Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | On Windows, deal with the reserved 12 characters (8.3) always needed for long directory names. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
9571b68a7aea9dc6561cf55c5bf8adf5 |
User & Date: | drh 2015-12-03 22:53:05.994 |
Context
2015-12-04
| ||
00:40 | Update the built-in SQLite to the latest 3.10.0 alpha. ... (check-in: 5032c50d user: drh tags: trunk) | |
2015-12-03
| ||
22:53 | On Windows, deal with the reserved 12 characters (8.3) always needed for long directory names. ... (check-in: 9571b68a user: drh tags: trunk) | |
15:41 | Improved cross-linking of clusters. ... (check-in: 24606598 user: drh tags: trunk) | |
2015-12-02
| ||
20:23 | Experimental changes to deal with the reserved 12 characters (e.g. 'FILENAME.EXT') always needed for long directory names on Windows. ... (Closed-Leaf check-in: 6ebef28f user: mistachkin tags: pending-review) | |
Changes
Changes to src/checkin.c.
︙ | ︙ | |||
924 925 926 927 928 929 930 | if( zEditor==0 ){ zEditor = fossil_getenv("EDITOR"); } #if defined(_WIN32) || defined(__CYGWIN__) if( zEditor==0 ){ zEditor = mprintf("%s\\notepad.exe", fossil_getenv("SYSTEMROOT")); #if defined(__CYGWIN__) | | | 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 | if( zEditor==0 ){ zEditor = fossil_getenv("EDITOR"); } #if defined(_WIN32) || defined(__CYGWIN__) if( zEditor==0 ){ zEditor = mprintf("%s\\notepad.exe", fossil_getenv("SYSTEMROOT")); #if defined(__CYGWIN__) zEditor = fossil_utf8_to_path(zEditor, 0); blob_add_cr(pPrompt); #endif } #endif if( zEditor==0 ){ blob_append(pPrompt, "#\n" |
︙ | ︙ |
Changes to src/file.c.
︙ | ︙ | |||
84 85 86 87 88 89 90 | /* ** Fill stat buf with information received from stat() or lstat(). ** lstat() is called on Unix if isWd is TRUE and allow-symlinks setting is on. ** */ static int fossil_stat(const char *zFilename, struct fossilStat *buf, int isWd){ int rc; | | | | 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | /* ** Fill stat buf with information received from stat() or lstat(). ** lstat() is called on Unix if isWd is TRUE and allow-symlinks setting is on. ** */ static int fossil_stat(const char *zFilename, struct fossilStat *buf, int isWd){ int rc; void *zMbcs = fossil_utf8_to_path(zFilename, 0); #if !defined(_WIN32) if( isWd && g.allowSymlinks ){ rc = lstat(zMbcs, buf); }else{ rc = stat(zMbcs, buf); } #else rc = win32_stat(zMbcs, buf, isWd); #endif fossil_path_free(zMbcs); return rc; } /* ** Fill in the fileStat variable for the file named zFilename. ** If zFilename==0, then use the previous value of fileStat if ** there is a previous value. |
︙ | ︙ | |||
312 313 314 315 316 317 318 | /* ** Wrapper around the access() system call. */ int file_access(const char *zFilename, int flags){ int rc; | | | | | | 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 | /* ** Wrapper around the access() system call. */ int file_access(const char *zFilename, int flags){ int rc; void *zMbcs = fossil_utf8_to_path(zFilename, 0); #ifdef _WIN32 rc = win32_access(zMbcs, flags); #else rc = access(zMbcs, flags); #endif fossil_path_free(zMbcs); return rc; } /* ** Wrapper around the chdir() system call. ** If bChroot=1, do a chroot to this dir as well ** (UNIX only) */ int file_chdir(const char *zChDir, int bChroot){ int rc; void *zPath = fossil_utf8_to_path(zChDir, 1); #ifdef _WIN32 rc = win32_chdir(zPath, bChroot); #else rc = chdir(zPath); if( !rc && bChroot ){ rc = chroot(zPath); if( !rc ) rc = chdir("/"); } #endif fossil_path_free(zPath); return rc; } /* ** Find an unused filename similar to zBase with zSuffix appended. ** ** Make the name relative to the working directory if relFlag is true. |
︙ | ︙ | |||
467 468 469 470 471 472 473 | void file_set_mtime(const char *zFilename, i64 newMTime){ #if !defined(_WIN32) char *zMbcs; struct timeval tv[2]; memset(tv, 0, sizeof(tv[0])*2); tv[0].tv_sec = newMTime; tv[1].tv_sec = newMTime; | | | | | 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 | void file_set_mtime(const char *zFilename, i64 newMTime){ #if !defined(_WIN32) char *zMbcs; struct timeval tv[2]; memset(tv, 0, sizeof(tv[0])*2); tv[0].tv_sec = newMTime; tv[1].tv_sec = newMTime; zMbcs = fossil_utf8_to_path(zFilename, 0); utimes(zMbcs, tv); #else struct _utimbuf tb; wchar_t *zMbcs = fossil_utf8_to_path(zFilename, 0); tb.actime = newMTime; tb.modtime = newMTime; _wutime(zMbcs, &tb); #endif fossil_path_free(zMbcs); } /* ** COMMAND: test-set-mtime ** ** Usage: %fossil test-set-mtime FILENAME DATE/TIME ** |
︙ | ︙ | |||
510 511 512 513 514 515 516 | ** Delete a file. ** ** Returns zero upon success. */ int file_delete(const char *zFilename){ int rc; #ifdef _WIN32 | | | | | | | | 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 | ** Delete a file. ** ** Returns zero upon success. */ int file_delete(const char *zFilename){ int rc; #ifdef _WIN32 wchar_t *z = fossil_utf8_to_path(zFilename, 0); rc = _wunlink(z); #else char *z = fossil_utf8_to_path(zFilename, 0); rc = unlink(zFilename); #endif fossil_path_free(z); return rc; } /* ** Create the directory named in the argument, if it does not already ** exist. If forceFlag is 1, delete any prior non-directory object ** with the same name. ** ** Return the number of errors. */ int file_mkdir(const char *zName, int forceFlag){ int rc = file_wd_isdir(zName); if( rc==2 ){ if( !forceFlag ) return 1; file_delete(zName); } if( rc!=1 ){ #if defined(_WIN32) wchar_t *zMbcs = fossil_utf8_to_path(zName, 1); rc = _wmkdir(zMbcs); #else char *zMbcs = fossil_utf8_to_path(zName, 1); rc = mkdir(zName, 0755); #endif fossil_path_free(zMbcs); return rc; } return 0; } /* ** Create the tree of directories in which zFilename belongs, if that sequence |
︙ | ︙ | |||
600 601 602 603 604 605 606 | ** Returns zero upon success. */ int file_rmdir(const char *zName){ int rc = file_wd_isdir(zName); if( rc==2 ) return 1; /* cannot remove normal file */ if( rc==1 ){ #if defined(_WIN32) | | | | | 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 | ** Returns zero upon success. */ int file_rmdir(const char *zName){ int rc = file_wd_isdir(zName); if( rc==2 ) return 1; /* cannot remove normal file */ if( rc==1 ){ #if defined(_WIN32) wchar_t *zMbcs = fossil_utf8_to_path(zName, 1); rc = _wrmdir(zMbcs); #else char *zMbcs = fossil_utf8_to_path(zName, 1); rc = rmdir(zName); #endif fossil_path_free(zMbcs); return rc; } return 0; } /* ** Return true if the filename given is a valid filename for |
︙ | ︙ | |||
1241 1242 1243 1244 1245 1246 1247 | const char *zDir = "."; int cnt = 0; #if defined(_WIN32) wchar_t zTmpPath[MAX_PATH]; if( GetTempPathW(MAX_PATH, zTmpPath) ){ | | | 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 | const char *zDir = "."; int cnt = 0; #if defined(_WIN32) wchar_t zTmpPath[MAX_PATH]; if( GetTempPathW(MAX_PATH, zTmpPath) ){ azDirs[0] = fossil_path_to_utf8(zTmpPath); } azDirs[1] = fossil_getenv("TEMP"); azDirs[2] = fossil_getenv("TMP"); #endif |
︙ | ︙ | |||
1275 1276 1277 1278 1279 1280 1281 | for(i=0; i<15; i++, j++){ zBuf[j] = (char)zChars[ ((unsigned char)zBuf[j])%(sizeof(zChars)-1) ]; } zBuf[j] = 0; }while( file_size(zBuf)>=0 ); #if defined(_WIN32) | | | | | 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 | for(i=0; i<15; i++, j++){ zBuf[j] = (char)zChars[ ((unsigned char)zBuf[j])%(sizeof(zChars)-1) ]; } zBuf[j] = 0; }while( file_size(zBuf)>=0 ); #if defined(_WIN32) fossil_path_free((char *)azDirs[0]); fossil_path_free((char *)azDirs[1]); fossil_path_free((char *)azDirs[2]); #endif } /* ** Return true if a file named zName exists and has identical content ** to the blob pContent. If zName does not exist or if the content is |
︙ | ︙ | |||
1307 1308 1309 1310 1311 1312 1313 | rc = blob_compare(&onDisk, pContent); blob_reset(&onDisk); return rc==0; } /* ** Return the value of an environment variable as UTF8. | | | | 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 | rc = blob_compare(&onDisk, pContent); blob_reset(&onDisk); return rc==0; } /* ** Return the value of an environment variable as UTF8. ** Use fossil_path_free() to release resources. */ char *fossil_getenv(const char *zName){ #ifdef _WIN32 wchar_t *uName = fossil_utf8_to_unicode(zName); void *zValue = _wgetenv(uName); fossil_unicode_free(uName); #else char *zValue = getenv(zName); #endif if( zValue ) zValue = fossil_path_to_utf8(zValue); return zValue; } /* ** Sets the value of an environment variable as UTF8. */ int fossil_setenv(const char *zName, const char *zValue){ |
︙ | ︙ | |||
1346 1347 1348 1349 1350 1351 1352 | /* ** Like fopen() but always takes a UTF8 argument. */ FILE *fossil_fopen(const char *zName, const char *zMode){ #ifdef _WIN32 wchar_t *uMode = fossil_utf8_to_unicode(zMode); | | | | 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 | /* ** Like fopen() but always takes a UTF8 argument. */ FILE *fossil_fopen(const char *zName, const char *zMode){ #ifdef _WIN32 wchar_t *uMode = fossil_utf8_to_unicode(zMode); wchar_t *uName = fossil_utf8_to_path(zName, 0); FILE *f = _wfopen(uName, uMode); fossil_path_free(uName); fossil_unicode_free(uMode); #else FILE *f = fopen(zName, zMode); #endif return f; } |
Changes to src/main.c.
︙ | ︙ | |||
418 419 420 421 422 423 424 | g.argc = argc; g.argv = argv; sqlite3_initialize(); #if defined(_WIN32) && defined(BROKEN_MINGW_CMDLINE) for(i=0; i<g.argc; i++) g.argv[i] = fossil_mbcs_to_utf8(g.argv[i]); #else | | | | 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 | g.argc = argc; g.argv = argv; sqlite3_initialize(); #if defined(_WIN32) && defined(BROKEN_MINGW_CMDLINE) for(i=0; i<g.argc; i++) g.argv[i] = fossil_mbcs_to_utf8(g.argv[i]); #else for(i=0; i<g.argc; i++) g.argv[i] = fossil_path_to_utf8(g.argv[i]); #endif #if defined(_WIN32) GetModuleFileNameW(NULL, buf, MAX_PATH); g.nameOfExe = fossil_path_to_utf8(buf); #else g.nameOfExe = g.argv[0]; #endif for(i=1; i<g.argc-1; i++){ z = g.argv[i]; if( z[0]!='-' ) continue; z++; |
︙ | ︙ | |||
2544 2545 2546 2547 2548 2549 2550 | ** ** Usage: %fossil test-echo [--hex] ARGS... ** ** Echo all command-line arguments (enclosed in [...]) to the screen so that ** wildcard expansion behavior of the host shell can be investigated. ** ** With the --hex option, show the output as hexadecimal. This can be used | | | 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 | ** ** Usage: %fossil test-echo [--hex] ARGS... ** ** Echo all command-line arguments (enclosed in [...]) to the screen so that ** wildcard expansion behavior of the host shell can be investigated. ** ** With the --hex option, show the output as hexadecimal. This can be used ** to verify the fossil_path_to_utf8() routine on Windows and Mac. */ void test_echo_cmd(void){ int i, j; if( find_option("hex",0,0)==0 ){ fossil_print("g.nameOfExe = [%s]\n", g.nameOfExe); for(i=0; i<g.argc; i++){ fossil_print("argv[%d] = [%s]\n", i, g.argv[i]); |
︙ | ︙ |
Changes to src/printf.c.
︙ | ︙ | |||
980 981 982 983 984 985 986 | vfprintf(out, zFormat, ap); fprintf(out, "\n"); va_end(ap); for(i=0; i<sizeof(azEnv)/sizeof(azEnv[0]); i++){ char *p; if( (p = fossil_getenv(azEnv[i]))!=0 ){ fprintf(out, "%s=%s\n", azEnv[i], p); | | | 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 | vfprintf(out, zFormat, ap); fprintf(out, "\n"); va_end(ap); for(i=0; i<sizeof(azEnv)/sizeof(azEnv[0]); i++){ char *p; if( (p = fossil_getenv(azEnv[i]))!=0 ){ fprintf(out, "%s=%s\n", azEnv[i], p); fossil_path_free(p); }else if( (z = P(azEnv[i]))!=0 ){ fprintf(out, "%s=%s\n", azEnv[i], z); } } fclose(out); } |
︙ | ︙ |
Changes to src/rebuild.c.
︙ | ︙ | |||
885 886 887 888 889 890 891 | DIR *d; struct dirent *pEntry; Blob aContent; /* content of the just read artifact */ static int nFileRead = 0; void *zUnicodePath; char *zUtf8Name; | | | | | 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 | DIR *d; struct dirent *pEntry; Blob aContent; /* content of the just read artifact */ static int nFileRead = 0; void *zUnicodePath; char *zUtf8Name; zUnicodePath = fossil_utf8_to_path(zPath, 1); d = opendir(zUnicodePath); if( d ){ while( (pEntry=readdir(d))!=0 ){ Blob path; char *zSubpath; if( pEntry->d_name[0]=='.' ){ continue; } zUtf8Name = fossil_path_to_utf8(pEntry->d_name); zSubpath = mprintf("%s/%s", zPath, zUtf8Name); fossil_path_free(zUtf8Name); #ifdef _DIRENT_HAVE_D_TYPE if( (pEntry->d_type==DT_UNKNOWN || pEntry->d_type==DT_LNK) ? (file_isdir(zSubpath)==1) : (pEntry->d_type==DT_DIR) ) #else if( file_isdir(zSubpath)==1 ) #endif { |
︙ | ︙ | |||
926 927 928 929 930 931 932 | free(zSubpath); } closedir(d); }else { fossil_fatal("encountered error %d while trying to open \"%s\".", errno, g.argv[3]); } | | | 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 | free(zSubpath); } closedir(d); }else { fossil_fatal("encountered error %d while trying to open \"%s\".", errno, g.argv[3]); } fossil_path_free(zUnicodePath); } /* ** COMMAND: reconstruct* ** ** Usage: %fossil reconstruct FILENAME DIRECTORY ** |
︙ | ︙ |
Changes to src/utf8.c.
︙ | ︙ | |||
99 100 101 102 103 104 105 | #if defined(__APPLE__) && !defined(WITHOUT_ICONV) # include <iconv.h> #endif /* ** Translate text from the filename character set into UTF-8. ** Return a pointer to the translated text. | | | | | | | | | | | > | 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 | #if defined(__APPLE__) && !defined(WITHOUT_ICONV) # include <iconv.h> #endif /* ** Translate text from the filename character set into UTF-8. ** Return a pointer to the translated text. ** Call fossil_path_free() to deallocate any memory used to store the ** returned pointer when done. ** ** This function must not convert '\' to '/' on windows/cygwin, as it is ** used in places where we are not sure it's really filenames we are handling, ** e.g. fossil_getenv() or handling the argv arguments from main(). ** ** On Windows, translate some characters in the in the range ** U+F001 - U+F07F (private use area) to ASCII. Cygwin sometimes ** generates such filenames. See: ** <http://cygwin.com/cygwin-ug-net/using-specialnames.html> */ char *fossil_path_to_utf8(const void *zPath){ #if defined(_WIN32) int nByte = WideCharToMultiByte(CP_UTF8, 0, zPath, -1, 0, 0, 0, 0); char *zUtf = sqlite3_malloc( nByte ); char *pUtf, *qUtf; if( zUtf==0 ){ return 0; } WideCharToMultiByte(CP_UTF8, 0, zPath, -1, zUtf, nByte, 0, 0); pUtf = qUtf = zUtf; while( *pUtf ) { if( *pUtf == (char)0xef ){ wchar_t c = ((pUtf[1]&0x3f)<<6)|(pUtf[2]&0x3f); /* Only really convert it when the resulting char is in range. */ if( c && ((c < ' ') || wcschr(L"\"*:<>?|", c)) ){ *qUtf++ = c; pUtf+=3; continue; } } *qUtf++ = *pUtf++; } *qUtf = 0; return zUtf; #elif defined(__CYGWIN__) char *zOut; zOut = fossil_strdup(zPath); return zOut; #elif defined(__APPLE__) && !defined(WITHOUT_ICONV) char *zIn = (char*)zPath; char *zOut; iconv_t cd; size_t n, x; for(n=0; zIn[n]>0 && zIn[n]<=0x7f; n++){} if( zIn[n]!=0 && (cd = iconv_open("UTF-8", "UTF-8-MAC"))!=(iconv_t)-1 ){ char *zOutx; char *zOrig = zIn; size_t nIn, nOutx; nIn = n = strlen(zIn); nOutx = nIn+100; zOutx = zOut = fossil_malloc( nOutx+1 ); x = iconv(cd, &zIn, &nIn, &zOutx, &nOutx); if( x==(size_t)-1 ){ fossil_free(zOut); zOut = fossil_strdup(zOrig); }else{ zOut[n+100-nOutx] = 0; } iconv_close(cd); }else{ zOut = fossil_strdup(zPath); } return zOut; #else return (char *)zPath; /* No-op on non-mac unix */ #endif } /* ** Translate text from UTF-8 to the filename character set. ** Return a pointer to the translated text. ** Call fossil_path_free() to deallocate any memory used to store the ** returned pointer when done. ** ** On Windows, characters in the range U+0001 to U+0031 and the ** characters '"', '*', ':', '<', '>', '?' and '|' are invalid ** to be used, except in the 'extended path' prefix ('?') and ** as drive specifier (':'). Therefore, translate those to characters ** in the range U+F001 - U+F07F (private use area), so those ** characters never arrive in any Windows API. The filenames might ** look strange in Windows explorer, but in the cygwin shell ** everything looks as expected. ** ** See: <http://cygwin.com/cygwin-ug-net/using-specialnames.html> ** */ void *fossil_utf8_to_path(const char *zUtf8, int isDir){ #ifdef _WIN32 int nReserved = isDir ? 12 : 0; /* For dir, need room for "FILENAME.EXT" */ int nChar = MultiByteToWideChar(CP_UTF8, 0, zUtf8, -1, 0, 0); /* Overallocate 6 chars, making some room for extended paths */ wchar_t *zUnicode = sqlite3_malloc( (nChar+6) * sizeof(wchar_t) ); wchar_t *wUnicode = zUnicode; if( zUnicode==0 ){ return 0; } |
︙ | ︙ | |||
214 215 216 217 218 219 220 | ** path prefix and the path is larger than MAX_PATH chars, ** no Win32 API function can handle that unless it is ** prefixed with the extended path prefix. See: ** <http://msdn.microsoft.com/en-us/library/aa365247(VS.85).aspx#maxpath> **/ if( fossil_isalpha(zUtf8[0]) && zUtf8[1]==':' && (zUtf8[2]=='\\' || zUtf8[2]=='/') ){ | | | | 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 | ** path prefix and the path is larger than MAX_PATH chars, ** no Win32 API function can handle that unless it is ** prefixed with the extended path prefix. See: ** <http://msdn.microsoft.com/en-us/library/aa365247(VS.85).aspx#maxpath> **/ if( fossil_isalpha(zUtf8[0]) && zUtf8[1]==':' && (zUtf8[2]=='\\' || zUtf8[2]=='/') ){ if( wUnicode==zUnicode && (nChar-nReserved)>MAX_PATH){ memmove(wUnicode+4, wUnicode, nChar*sizeof(wchar_t)); memcpy(wUnicode, L"\\\\?\\", 4*sizeof(wchar_t)); wUnicode += 4; } /* ** If (remainder of) path starts with "<drive>:/" or "<drive>:\", ** leave the ':' intact but translate the backslash to a slash. */ wUnicode[2] = '\\'; wUnicode += 3; }else if( wUnicode==zUnicode && (nChar-nReserved)>MAX_PATH && (zUtf8[0]=='\\' || zUtf8[0]=='/') && (zUtf8[1]=='\\' || zUtf8[1]=='/') && zUtf8[2]!='?'){ memmove(wUnicode+6, wUnicode, nChar*sizeof(wchar_t)); memcpy(wUnicode, L"\\\\?\\UNC", 7*sizeof(wchar_t)); wUnicode += 7; } /* |
︙ | ︙ | |||
284 285 286 287 288 289 290 | #else return (void *)zUtf8; /* No-op on unix */ #endif } /* ** Deallocate any memory that was previously allocated by | | | | 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 | #else return (void *)zUtf8; /* No-op on unix */ #endif } /* ** Deallocate any memory that was previously allocated by ** fossil_path_to_utf8() or fossil_utf8_to_path(). */ void fossil_path_free(void *pOld){ #if defined(_WIN32) sqlite3_free(pOld); #elif (defined(__APPLE__) && !defined(WITHOUT_ICONV)) || defined(__CYGWIN__) fossil_free(pOld); #else /* No-op on all other unix */ #endif |
︙ | ︙ |
Changes to src/vfile.c.
︙ | ︙ | |||
499 500 501 502 503 504 505 | "INSERT OR IGNORE INTO sfile(x) SELECT :file" " WHERE NOT EXISTS(SELECT 1 FROM vfile WHERE" " pathname=:file %s)", filename_collation() ); } depth++; | | | | 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 | "INSERT OR IGNORE INTO sfile(x) SELECT :file" " WHERE NOT EXISTS(SELECT 1 FROM vfile WHERE" " pathname=:file %s)", filename_collation() ); } depth++; zNative = fossil_utf8_to_path(blob_str(pPath), 1); d = opendir(zNative); if( d ){ while( (pEntry=readdir(d))!=0 ){ char *zPath; char *zUtf8; if( pEntry->d_name[0]=='.' ){ if( (scanFlags & SCAN_ALL)==0 ) continue; if( pEntry->d_name[1]==0 ) continue; if( pEntry->d_name[1]=='.' && pEntry->d_name[2]==0 ) continue; } zUtf8 = fossil_path_to_utf8(pEntry->d_name); blob_appendf(pPath, "/%s", zUtf8); zPath = blob_str(pPath); if( glob_match(pIgnore1, &zPath[nPrefix+1]) || glob_match(pIgnore2, &zPath[nPrefix+1]) ){ /* do nothing */ #ifdef _DIRENT_HAVE_D_TYPE }else if( (pEntry->d_type==DT_UNKNOWN || pEntry->d_type==DT_LNK) |
︙ | ︙ | |||
537 538 539 540 541 542 543 | #endif if( (scanFlags & SCAN_TEMP)==0 || is_temporary_file(zUtf8) ){ db_bind_text(&ins, ":file", &zPath[nPrefix+1]); db_step(&ins); db_reset(&ins); } } | | | | 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 | #endif if( (scanFlags & SCAN_TEMP)==0 || is_temporary_file(zUtf8) ){ db_bind_text(&ins, ":file", &zPath[nPrefix+1]); db_step(&ins); db_reset(&ins); } } fossil_path_free(zUtf8); blob_resize(pPath, origSize); } closedir(d); } fossil_path_free(zNative); depth--; if( depth==0 ){ db_finalize(&ins); } } |
︙ | ︙ | |||
611 612 613 614 615 616 617 | "UPDATE OR IGNORE dscan_temp SET y = coalesce(y, 0) + 1" " WHERE x=:file %s", filename_collation() ); } depth++; | | | | 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 | "UPDATE OR IGNORE dscan_temp SET y = coalesce(y, 0) + 1" " WHERE x=:file %s", filename_collation() ); } depth++; zNative = fossil_utf8_to_path(blob_str(pPath), 1); d = opendir(zNative); if( d ){ while( (pEntry=readdir(d))!=0 ){ char *zOrigPath; char *zPath; char *zUtf8; if( pEntry->d_name[0]=='.' ){ if( (scanFlags & SCAN_ALL)==0 ) continue; if( pEntry->d_name[1]==0 ) continue; if( pEntry->d_name[1]=='.' && pEntry->d_name[2]==0 ) continue; } zOrigPath = mprintf("%s", blob_str(pPath)); zUtf8 = fossil_path_to_utf8(pEntry->d_name); blob_appendf(pPath, "/%s", zUtf8); zPath = blob_str(pPath); if( glob_match(pIgnore1, &zPath[nPrefix+1]) || glob_match(pIgnore2, &zPath[nPrefix+1]) ){ /* do nothing */ #ifdef _DIRENT_HAVE_D_TYPE }else if( (pEntry->d_type==DT_UNKNOWN || pEntry->d_type==DT_LNK) |
︙ | ︙ | |||
658 659 660 661 662 663 664 | }else if( file_wd_isfile_or_link(zPath) ){ #endif db_bind_text(&upd, ":file", zOrigPath); db_step(&upd); db_reset(&upd); result++; /* found 1 normal file */ } | | | | 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 | }else if( file_wd_isfile_or_link(zPath) ){ #endif db_bind_text(&upd, ":file", zOrigPath); db_step(&upd); db_reset(&upd); result++; /* found 1 normal file */ } fossil_path_free(zUtf8); blob_resize(pPath, origSize); fossil_free(zOrigPath); } closedir(d); } fossil_path_free(zNative); depth--; if( depth==0 ){ db_finalize(&upd); db_finalize(&ins); } return result; |
︙ | ︙ |
Changes to src/winfile.c.
︙ | ︙ | |||
281 282 283 284 285 286 287 | void win32_getcwd(char *zBuf, int nBuf){ int i; char *zUtf8; wchar_t *zWide = fossil_malloc( sizeof(wchar_t)*nBuf ); if( GetCurrentDirectoryW(nBuf, zWide)==0 ){ fossil_fatal("cannot find current working directory."); } | | | | 281 282 283 284 285 286 287 288 289 290 291 292 293 294 | void win32_getcwd(char *zBuf, int nBuf){ int i; char *zUtf8; wchar_t *zWide = fossil_malloc( sizeof(wchar_t)*nBuf ); if( GetCurrentDirectoryW(nBuf, zWide)==0 ){ fossil_fatal("cannot find current working directory."); } zUtf8 = fossil_path_to_utf8(zWide); fossil_free(zWide); for(i=0; zUtf8[i]; i++) if( zUtf8[i]=='\\' ) zUtf8[i] = '/'; strncpy(zBuf, zUtf8, nBuf); fossil_path_free(zUtf8); } #endif /* _WIN32 -- This code is for win32 only */ |