Fossil

Check-in [529237a3]
Login

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

Overview
Comment:Tidy up and fix implementation of empty-dirs setting.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | versionable-settings
Files: files | file ages | folders
SHA1:529237a3c113d9946cc5d668304c07faa941d54e
User & Date: ben 2011-05-28 15:40:21
Context
2011-06-02
19:38
Merge versionable settings and empty-dirs setting from versionable-settings branch check-in: 30ebed19 user: ben tags: ben-testing
2011-05-28
15:40
Tidy up and fix implementation of empty-dirs setting. Closed-Leaf check-in: 529237a3 user: ben tags: versionable-settings
15:39
Add documentation for empty-dirs setting check-in: eb93d6ae user: ben tags: versionable-settings
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/update.c.

466
467
468
469
470
471
472
473
474
475
476
477





478
479
480
481


482









483
484

485









486
487
488
489
490
491
492
** Make sure empty directories are created
*/
void ensure_empty_dirs_created()
{
  /* Make empty directories? */
  char *zEmptyDirs = db_get_versionable_setting("empty-dirs", 0);
  if( zEmptyDirs!=0 ){
    Blob dirsList, line;
    blob_zero(&dirsList);
    blob_init(&dirsList, zEmptyDirs, strlen(zEmptyDirs));
    while( blob_line(&dirsList, &line) ){
      if( blob_buffer(&line)[0]=='#' ) continue;





      Blob dirName;
      int l = blob_token(&line, &dirName);
      if(l > 0) {
        /* Try and create the directory */


        if( file_mkdir(blob_str(&dirName), 0)!=0 ) {









          fossil_warning("couldn't create empty-dir %s", blob_str(&dirName));
        }

      }









    }
  }
}


/*
** Get the contents of a file within the checking "revision".  If







|


|
|
>
>
>
>
>
|
<
<
<
>
>
|
>
>
>
>
>
>
>
>
>
|
|
>
|
>
>
>
>
>
>
>
>
>







466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483



484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
** Make sure empty directories are created
*/
void ensure_empty_dirs_created()
{
  /* Make empty directories? */
  char *zEmptyDirs = db_get_versionable_setting("empty-dirs", 0);
  if( zEmptyDirs!=0 ){
    Blob dirsList;
    blob_zero(&dirsList);
    blob_init(&dirsList, zEmptyDirs, strlen(zEmptyDirs));
    /* Replace commas by spaces */
    char *bc = blob_str(&dirsList);
    while( (*bc)!='\0' ){
      if( (*bc)==',' ) { *bc = ' '; }
      ++bc;
    }
    /* Make directories */
    Blob dirName;



    blob_zero(&dirName);
    while( blob_token(&dirsList, &dirName) ){
      const char *zDir = blob_str(&dirName);
      /* Make full pathname of the directory */
      Blob path;
      blob_zero(&path);
      blob_appendf(&path, "%s/%s", g.zLocalRoot, zDir);
      const char *zPath = blob_str(&path);      
      /* Handle various cases of existence of the directory */
      switch( file_isdir(zPath) ){
        case 0: { /* doesn't exist */
          if( file_mkdir(zPath, 0)!=0 ) {
            fossil_warning("couldn't create directory %s as required by empty-dirs setting", zDir);
          }          
          break;
        }
        case 1: { /* exists, and is a directory */
          /* do nothing - required directory exists already */
          break;
        }
        case 2: { /* exists, but isn't a directory */
          fossil_warning("file %s found, but a directory is required by empty-dirs setting", zDir);          
        }
      }
      blob_reset(&path);
    }
  }
}


/*
** Get the contents of a file within the checking "revision".  If