Fossil

Check-in [92ea6183]
Login

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

Overview
Comment:Change the file_mkfolder() implementation to assume that the folder already exists and only go about creating it and its path if it does not previously exit.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256:92ea61837e987614f65a5b0da27c54c83534361e6c7806a6447db51e77ff76ca
User & Date: drh 2017-08-23 17:53:57
Context
2017-08-24
14:20
Typo fixes thanks to rosscanning, ref http://www.mail-archive.com/fossil-users@lists.fossil-scm.org/msg25775.html check-in: f98852a0 user: andygoth tags: trunk
2017-08-23
17:53
Change the file_mkfolder() implementation to assume that the folder already exists and only go about creating it and its path if it does not previously exit. check-in: 92ea6183 user: drh tags: trunk
17:38
Remove a redundant directory separator character from the temporary filenames generated on windows. check-in: b5f0d703 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/file.c.

630
631
632
633
634
635
636
637
638
639
640
641

642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
int file_mkfolder(const char *zFilename, int forceFlag, int errorReturn){
  int i, nName, rc = 0;
  char *zName;

  nName = strlen(zFilename);
  zName = mprintf("%s", zFilename);
  nName = file_simplify_name(zName, nName, 0);
  for(i=1; i<nName; i++){
    if( zName[i]=='/' ){
      zName[i] = 0;
#if defined(_WIN32) || defined(__CYGWIN__)
      /*

      ** On Windows, local path looks like: C:/develop/project/file.txt
      ** The if stops us from trying to create a directory of a drive letter
      ** C: in this example.
      */
      if( !(i==2 && zName[1]==':') ){
#endif
        if( file_mkdir(zName, forceFlag) && file_wd_isdir(zName)!=1 ){
          if (errorReturn <= 0) {
            fossil_fatal_recursive("unable to create directory %s", zName);
          }
          rc = errorReturn;
          break;
        }
#if defined(_WIN32) || defined(__CYGWIN__)
      }
#endif
      zName[i] = '/';
    }
  }
  free(zName);
  return rc;
}

/*







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

|



<

<

<
<







630
631
632
633
634
635
636
637
638
639
640

641
642





643
644
645
646
647

648

649


650
651
652
653
654
655
656
int file_mkfolder(const char *zFilename, int forceFlag, int errorReturn){
  int i, nName, rc = 0;
  char *zName;

  nName = strlen(zFilename);
  zName = mprintf("%s", zFilename);
  nName = file_simplify_name(zName, nName, 0);
  while( nName>0 && zName[nName-1]!='/' ){ nName--; }
  if( nName ){
    zName[nName-1] = 0;
    if( file_wd_isdir(zName)!=1 ){

      rc = file_mkfolder(zName, forceFlag, errorReturn);
      if( rc==0 ){





        if( file_mkdir(zName, forceFlag) && file_wd_isdir(zName)!=1 ){
          if( errorReturn <= 0 ){
            fossil_fatal_recursive("unable to create directory %s", zName);
          }
          rc = errorReturn;

        }

      }


    }
  }
  free(zName);
  return rc;
}

/*