Fossil

Check-in [3cb7d39e]
Login

Check-in [3cb7d39e]

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

Overview
Comment:file_directory_size() now unconditionally skips the magic "." and ".." entries. This does not affect current uses of the routine but a proposed patch provided in forum post 383838fbd0b6c881 would be awkwardly affected by them.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 3cb7d39e1247fbbbb08857ced403cc5609993c171c2fbe9696ae26ddc23d02fe
User & Date: stephan 2024-05-04 11:26:44
Context
2024-05-08
11:59
Import SQLite 3.46.0-beta-1 for testing. (check-in: c09fea32 user: drh tags: trunk)
2024-05-04
11:26
file_directory_size() now unconditionally skips the magic "." and ".." entries. This does not affect current uses of the routine but a proposed patch provided in forum post 383838fbd0b6c881 would be awkwardly affected by them. (check-in: 3cb7d39e user: stephan tags: trunk)
2024-05-02
17:22
Improvements to the tracing output in the find_filename_changes() routine. (check-in: 40086b74 user: drh tags: trunk)
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/file.c.

2407
2408
2409
2410
2411
2412
2413



2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426






2427
2428
2429
2430
2431
2432
2433
  return z;
}

/*
** Count the number of objects (files and subdirectories) in a given
** directory.  Return the count.  Return -1 if the object is not a
** directory.



*/
int file_directory_size(const char *zDir, const char *zGlob, int omitDotFiles){
  void *zNative;
  DIR *d;
  int n = -1;
  zNative = fossil_utf8_to_path(zDir,1);
  d = opendir(zNative);
  if( d ){
    struct dirent *pEntry;
    n = 0;
    while( (pEntry=readdir(d))!=0 ){
      if( pEntry->d_name[0]==0 ) continue;
      if( omitDotFiles && pEntry->d_name[0]=='.' ) continue;






      if( zGlob ){
        char *zUtf8 = fossil_path_to_utf8(pEntry->d_name);
        int rc = sqlite3_strglob(zGlob, zUtf8);
        fossil_path_free(zUtf8);
        if( rc ) continue;
      }
      n++;







>
>
>












|
>
>
>
>
>
>







2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
  return z;
}

/*
** Count the number of objects (files and subdirectories) in a given
** directory.  Return the count.  Return -1 if the object is not a
** directory.
**
** This routine never counts the two "." and ".." special directory
** entries, even if the provided glob would match them.
*/
int file_directory_size(const char *zDir, const char *zGlob, int omitDotFiles){
  void *zNative;
  DIR *d;
  int n = -1;
  zNative = fossil_utf8_to_path(zDir,1);
  d = opendir(zNative);
  if( d ){
    struct dirent *pEntry;
    n = 0;
    while( (pEntry=readdir(d))!=0 ){
      if( pEntry->d_name[0]==0 ) continue;
      if( pEntry->d_name[0]=='.' &&
          (omitDotFiles
           /* Skip the special "." and ".." entries. */
           || pEntry->d_name[1]==0
           || (pEntry->d_name[1]=='.' && pEntry->d_name[2]==0))){
        continue;
      }
      if( zGlob ){
        char *zUtf8 = fossil_path_to_utf8(pEntry->d_name);
        int rc = sqlite3_strglob(zGlob, zUtf8);
        fossil_path_free(zUtf8);
        if( rc ) continue;
      }
      n++;