Unnamed Fossil Project

Check-in [2cc2bfbd1b]
Login

Check-in [2cc2bfbd1b]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:updated
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 2cc2bfbd1b33e7cc3755c537b2878c16da1b9f10
User & Date: alexey@sudachen.name 2011-09-07 09:25:35.000
Context
2011-09-12
09:42
updated check-in: c92a6d63a0 user: alexey@sudachen.name tags: trunk
2011-09-07
09:25
updated check-in: 2cc2bfbd1b user: alexey@sudachen.name tags: trunk
2011-09-06
00:52
updated check-in: 1c9d4b953c user: alexey@sudachen.name tags: trunk
Changes
Side-by-Side Diff Ignore Whitespace Patch
Changes to core.hc.
1571
1572
1573
1574
1575
1576
1577


1578

1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597

1598
1599
1600
1601
1602
1603
1604
1571
1572
1573
1574
1575
1576
1577
1578
1579

1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607







+
+
-
+



















+







    char *msg = Error_Message();
    
  #ifndef _BACKTRACE
    if ( (code & YOYO_TRACED_ERROR_GROUP) || !Error_Info()->msg )
  #endif
      StdErr_Print_Nl(Yo_Error_Format_Btrace());
    
    if ( code == YOYO_ERROR_USER )
      StdErr_Print_Nl(Yo_Format(__yoTa("\n%s: %s",0),(pfx?pfx:__yoTa("error",0)),code,msg));
    if ( YOYO_ERROR_IS_USER_ERROR(code) )
    else if ( YOYO_ERROR_IS_USER_ERROR(code) )
      StdErr_Print_Nl(Yo_Format(__yoTa("\n%s(%d): %s",0),(pfx?pfx:__yoTa("error",0)),code,msg));
    else
      StdErr_Print_Nl(Yo_Format(__yoTa("\n%s(%08x): %s",0),(pfx?pfx:__yoTa("error",0)),code,msg));
    if ( code & YOYO_FATAL_ERROR_GROUP )
      abort();
    Yo_Unwind_Scope(0,-1);
    exit(code);
  }
#endif
  ;

#define __Pool(Ptr)                     Yo_Pool_Ptr(Ptr,0)
#define __Pool_Ptr(Ptr,Free)            Yo_Pool_Ptr(Ptr,Free)
#define __Release(Pooled)               Yo_Release(Pooled)
#define __Retain(Pooled)                Yo_Retain(Pooled)
#define __Purge(TholdPtr)               Yo_Pool_Purge(TholdPtr,YOYO_DEFAULT_PURGE_CAP)
#define __Refe(Ptr)                     Yo_Refe(Ptr)
#define __Unrefe(Ptr)                   Yo_Unrefe(Ptr)
#define __Raise(Err,Msg)                Yo_Raise(Err,Msg,__Yo_FILE__,__LINE__)
#define __Raise_User_Error(Msg)         Yo_Raise(YOYO_ERROR_USER,Msg,__Yo_FILE__,__LINE__)
#define __Raise_Format(Err,Fmt)         Yo_Raise(Err,(Yo_Format Fmt),__Yo_FILE__,__LINE__)
#define __Raise_If_Occured()            Yo_Raise_If_Occured()
#define __Fatal(Ctx)                    Yo_Fatal(YOYO_FATAL_ERROR,Ctx,__Yo_FILE__,__LINE__)
#define __Fatal_Format(x)               Yo_Fatal(YOYO_FATAL_ERROR,Yo_Format_Npl x,__Yo_FILE__,__LINE__)
#define __Format                        Yo_Format
#define __Format_Npl                    Yo_Format_Npl
#define __Format_Error()                Yo_Error_Format()
Changes to file.hc.
307
308
309
310
311
312
313
314

315
316
317
318
319
320
321
307
308
309
310
311
312
313

314
315
316
317
318
319
320
321







-
+







#else
  typedef struct stat _YOYO_stat;
#endif        

YOYO_FILE_STATS *File_Translate_Filestats(_YOYO_stat *fst,YOYO_FILE_STATS *st,int exists)
#ifdef _YOYO_FILE_BUILTIN
  {
    if ( !st ) st = Yo_Malloc(sizeof(YOYO_FILE_STATS));
    if ( !st ) st = __Malloc(sizeof(YOYO_FILE_STATS));
    memset(st,0,sizeof(*st));

    st->f.exists       = exists;
    st->f.is_regular   = (fst->st_mode&S_IFMT) == S_IFREG;
    st->f.is_directory = (fst->st_mode&S_IFMT) == S_IFDIR;
  #ifndef __windoze  
    st->f.is_symlink   = (fst->st_mode&S_IFMT) == S_IFLNK;    
346
347
348
349
350
351
352

353
354



355

356
357
358



359
360
361
362
363
364
365
346
347
348
349
350
351
352
353


354
355
356
357
358
359


360
361
362
363
364
365
366
367
368
369







+
-
-
+
+
+

+

-
-
+
+
+







      err = _wstat(uni_name,&fst);
    #endif
    Yo_Release(uni_name);
  #else
    err = stat(name,&fst);
  #endif
    if ( !err || ignorerr )
      {
      File_Translate_Filestats(&fst,st,!err);
    if ( err && !ignorerr )              
        st = File_Translate_Filestats(&fst,st,!err);
      }
    else if ( err && !ignorerr )              
      {
        int eno = errno;
        if ( st ) memset(st,0,sizeof(*st));
        if ( errno != ENOENT && errno != ENOTDIR )
          File_Check_Error("getting stats",0,name,1); 
        if ( eno == ENOENT || eno == ENOTDIR )
          __Raise_Format(YOYO_ERROR_DOESNT_EXIST,("file '%s' does not exist",name));
        File_Check_Error("getting stats",0,name,1); 
      }
    return st;
  }
#endif
  ;

YOYO_FILE_STATS *File_Get_Stats_Reuse(char *name, YOYO_FILE_STATS **stp)
443
444
445
446
447
448
449
450

451
452
453
454
455
456
457
447
448
449
450
451
452
453

454
455
456
457
458
459
460
461







-
+







enum _YOYO_DIRLIST_FLAGS
  {
    FILE_LIST_ALL = 0,
    FILE_LIST_DIRECTORIES = 1,
    FILE_LIST_FILES = 2,
  };

void *File_List_Directory(char *dirname, unsigned flags)
YOYO_ARRAY *File_List_Directory(char *dirname, unsigned flags)
#ifdef _YOYO_FILE_BUILTIN
  {
  #ifdef __windoze
    WIN32_FIND_DATAW fdtw;
    HANDLE hfnd;
  #else
    DIR *dir;
468
469
470
471
472
473
474

475



476
477
478
479
480
481
482
472
473
474
475
476
477
478
479

480
481
482
483
484
485
486
487
488
489







+
-
+
+
+







          {
            do
              if ( wcscmp(fdtw.cFileName,L".") && wcscmp(fdtw.cFileName,L"..") )
                {
                  int m = fdtw.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY ?
                    FILE_LIST_DIRECTORIES : FILE_LIST_FILES;
                  if ( m & flags )
                    {
                    Array_Push(L,Str_Unicode_To_Utf8_Npl(fdtw.cFileName));
                      char *name = Str_Unicode_To_Utf8_Npl(fdtw.cFileName);
                      Array_Push(L,name);
                    }
                }
            while( FindNextFileW(hfnd,&fdtw) );
            FindClose(hfnd);
          }
      #else
        dir = Yo_Pool_Ptr(opendir(dirname),closedir);
        if ( dir )
1060
1061
1062
1063
1064
1065
1066
1067
1068


1069
1070
1071

1072
1073
1074
1075
1076
1077
1078
1067
1068
1069
1070
1071
1072
1073


1074
1075
1076
1077

1078
1079
1080
1081
1082
1083
1084
1085







-
-
+
+


-
+







    YOYO_FILE_MODIFY      = YOYO_FILE_READWRITE|YOYO_FILE_OPENEXISTS, 
  };

void File_Check_Access_Is_Satisfied(char *path, uint_t access)
#ifdef _YOYO_FILE_BUILTIN
  {
    YOYO_FILE_STATS st = {0};
    File_Get_Stats(path,&st,0);

    File_Get_Stats(path,&st,1);
    
    if ( (access & YOYO_FILE_CREATE_PATH) && !st.f.exists )
      Create_Required_Dirs(path);
      
    
    if ( st.f.exists )
      if (st.f.is_directory )
        __Raise_Format(YOYO_ERROR_IO,("file '%s' is directory",path));
      else if ( (access & YOYO_FILE_CREATE_MASK) == YOYO_FILE_CREATENEW  )
        __Raise_Format(YOYO_ERROR_IO,("file '%s' already exists",path));
      else if ( (access & YOYO_FILE_CREATE_MASK) == YOYO_FILE_CREATEALWAYS )
        File_Unlink(path,0);
Changes to string.hc.
36
37
38
39
40
41
42

43
44
45
46
47
48
49
50















51
52
53
54
55
56
57
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73







+








+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







#ifdef _YOYO_STRING_BUILTIN
#define _YOYO_STRING_EXTERN
#else
#define _YOYO_STRING_EXTERN extern
#endif

/* caseinsensitive strcmp, returns 0 if equal */
#define Str_Ansi_Equal_Nocase(Cs,Ct) (!strcmp_I(Cs,Ct))
int strcmp_I(char *cs, char *ct)
#ifdef _YOYO_STRING_BUILTIN
  {
    int q = 0;
    do 
      {
        q = Toupper(*cs) - Toupper(*ct++);
      }
    while ( *cs++ && !q );
    return q;
  }
#endif
  ;

#define Str_Unicode_Compare_Nocase(Cs,Ct) wcscmp_I(Cs,Ct)
int wcscmp_I(wchar_t *cs, wchar_t *ct)
#ifdef _YOYO_STRING_BUILTIN
  {
    int q = 0;
    do 
      {
        q = towupper(*cs) - towupper(*ct++);
      }
    while ( *cs++ && !q );
    return q;
  }
#endif
  ;

/* caseinsensitive strncmp, returns 0 if equal */
65
66
67
68
69
70
71













72
73
74
75
76
77
78
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107







+
+
+
+
+
+
+
+
+
+
+
+
+







      }
    while ( *cs++ && !q && --l );
    return q;
  }    
#endif
  ;

int wcsncmp_I(wchar_t *cs, wchar_t *ct, int l)
#ifdef _YOYO_STRING_BUILTIN
  {
    int q = 0;
    if ( l ) do 
      {
        q = towupper(*cs) - towupper(*ct++);
      }
    while ( *cs++ && !q && --l );
    return q;
  }    
#endif
  ;

int Str_Length(char *S)
#ifdef _YOYO_STRING_BUILTIN
  {
    return S ? strlen(S) : 0;
  }
#endif