Fossil SCM

Add the --temp option to the "fossil extra" and "fossil clean" commands.

drh 2012-10-13 14:19 trunk
Commit 3206b6485a67d0284b078af83f71ef78631e0573
3 files changed +5 -4 +8 -5 +46 -6
+5 -4
--- src/add.c
+++ src/add.c
@@ -216,13 +216,14 @@
216216
int vid; /* Currently checked out version */
217217
int nRoot; /* Full path characters in g.zLocalRoot */
218218
const char *zIgnoreFlag; /* The --ignore option or ignore-glob setting */
219219
Glob *pIgnore; /* Ignore everything matching this glob pattern */
220220
int caseSensitive; /* True if filenames are case sensitive */
221
+ unsigned scanFlags = 0; /* Flags passed to vfile_scan() */
221222
222223
zIgnoreFlag = find_option("ignore",0,1);
223
- includeDotFiles = find_option("dotfiles",0,0)!=0;
224
+ if( find_option("dotfiles",0,0)!=0 ) scanFlags |= SCAN_ALL;
224225
capture_case_sensitive_option();
225226
db_must_be_within_tree();
226227
caseSensitive = filenames_are_case_sensitive();
227228
if( zIgnoreFlag==0 ){
228229
zIgnoreFlag = db_get("ignore-glob", 0);
@@ -250,11 +251,11 @@
250251
251252
file_canonical_name(g.argv[i], &fullName, 0);
252253
zName = blob_str(&fullName);
253254
isDir = file_wd_isdir(zName);
254255
if( isDir==1 ){
255
- vfile_scan(&fullName, nRoot-1, includeDotFiles, pIgnore);
256
+ vfile_scan(&fullName, nRoot-1, scanFlags, pIgnore);
256257
}else if( isDir==0 ){
257258
fossil_warning("not found: %s", zName);
258259
}else if( file_access(zName, R_OK) ){
259260
fossil_fatal("cannot open %s", zName);
260261
}else{
@@ -433,11 +434,11 @@
433434
** See also: add, rm
434435
*/
435436
void addremove_cmd(void){
436437
Blob path;
437438
const char *zIgnoreFlag = find_option("ignore",0,1);
438
- int allFlag = find_option("dotfiles",0,0)!=0;
439
+ unsigned scanFlags = find_option("dotfiles",0,0)!=0 ? SCAN_ALL : 0;
439440
int isTest = find_option("test",0,0)!=0;
440441
int caseSensitive;
441442
int n;
442443
Stmt q;
443444
int vid;
@@ -466,11 +467,11 @@
466467
db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY)");
467468
n = strlen(g.zLocalRoot);
468469
blob_init(&path, g.zLocalRoot, n-1);
469470
/* now we read the complete file structure into a temp table */
470471
pIgnore = glob_create(zIgnoreFlag);
471
- vfile_scan(&path, blob_size(&path), allFlag, pIgnore);
472
+ vfile_scan(&path, blob_size(&path), scanFlags, pIgnore);
472473
glob_free(pIgnore);
473474
nAdd = add_files_in_sfile(vid, caseSensitive);
474475
475476
/* step 2: search for missing files */
476477
db_prepare(&q,
477478
--- src/add.c
+++ src/add.c
@@ -216,13 +216,14 @@
216 int vid; /* Currently checked out version */
217 int nRoot; /* Full path characters in g.zLocalRoot */
218 const char *zIgnoreFlag; /* The --ignore option or ignore-glob setting */
219 Glob *pIgnore; /* Ignore everything matching this glob pattern */
220 int caseSensitive; /* True if filenames are case sensitive */
 
221
222 zIgnoreFlag = find_option("ignore",0,1);
223 includeDotFiles = find_option("dotfiles",0,0)!=0;
224 capture_case_sensitive_option();
225 db_must_be_within_tree();
226 caseSensitive = filenames_are_case_sensitive();
227 if( zIgnoreFlag==0 ){
228 zIgnoreFlag = db_get("ignore-glob", 0);
@@ -250,11 +251,11 @@
250
251 file_canonical_name(g.argv[i], &fullName, 0);
252 zName = blob_str(&fullName);
253 isDir = file_wd_isdir(zName);
254 if( isDir==1 ){
255 vfile_scan(&fullName, nRoot-1, includeDotFiles, pIgnore);
256 }else if( isDir==0 ){
257 fossil_warning("not found: %s", zName);
258 }else if( file_access(zName, R_OK) ){
259 fossil_fatal("cannot open %s", zName);
260 }else{
@@ -433,11 +434,11 @@
433 ** See also: add, rm
434 */
435 void addremove_cmd(void){
436 Blob path;
437 const char *zIgnoreFlag = find_option("ignore",0,1);
438 int allFlag = find_option("dotfiles",0,0)!=0;
439 int isTest = find_option("test",0,0)!=0;
440 int caseSensitive;
441 int n;
442 Stmt q;
443 int vid;
@@ -466,11 +467,11 @@
466 db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY)");
467 n = strlen(g.zLocalRoot);
468 blob_init(&path, g.zLocalRoot, n-1);
469 /* now we read the complete file structure into a temp table */
470 pIgnore = glob_create(zIgnoreFlag);
471 vfile_scan(&path, blob_size(&path), allFlag, pIgnore);
472 glob_free(pIgnore);
473 nAdd = add_files_in_sfile(vid, caseSensitive);
474
475 /* step 2: search for missing files */
476 db_prepare(&q,
477
--- src/add.c
+++ src/add.c
@@ -216,13 +216,14 @@
216 int vid; /* Currently checked out version */
217 int nRoot; /* Full path characters in g.zLocalRoot */
218 const char *zIgnoreFlag; /* The --ignore option or ignore-glob setting */
219 Glob *pIgnore; /* Ignore everything matching this glob pattern */
220 int caseSensitive; /* True if filenames are case sensitive */
221 unsigned scanFlags = 0; /* Flags passed to vfile_scan() */
222
223 zIgnoreFlag = find_option("ignore",0,1);
224 if( find_option("dotfiles",0,0)!=0 ) scanFlags |= SCAN_ALL;
225 capture_case_sensitive_option();
226 db_must_be_within_tree();
227 caseSensitive = filenames_are_case_sensitive();
228 if( zIgnoreFlag==0 ){
229 zIgnoreFlag = db_get("ignore-glob", 0);
@@ -250,11 +251,11 @@
251
252 file_canonical_name(g.argv[i], &fullName, 0);
253 zName = blob_str(&fullName);
254 isDir = file_wd_isdir(zName);
255 if( isDir==1 ){
256 vfile_scan(&fullName, nRoot-1, scanFlags, pIgnore);
257 }else if( isDir==0 ){
258 fossil_warning("not found: %s", zName);
259 }else if( file_access(zName, R_OK) ){
260 fossil_fatal("cannot open %s", zName);
261 }else{
@@ -433,11 +434,11 @@
434 ** See also: add, rm
435 */
436 void addremove_cmd(void){
437 Blob path;
438 const char *zIgnoreFlag = find_option("ignore",0,1);
439 unsigned scanFlags = find_option("dotfiles",0,0)!=0 ? SCAN_ALL : 0;
440 int isTest = find_option("test",0,0)!=0;
441 int caseSensitive;
442 int n;
443 Stmt q;
444 int vid;
@@ -466,11 +467,11 @@
467 db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY)");
468 n = strlen(g.zLocalRoot);
469 blob_init(&path, g.zLocalRoot, n-1);
470 /* now we read the complete file structure into a temp table */
471 pIgnore = glob_create(zIgnoreFlag);
472 vfile_scan(&path, blob_size(&path), scanFlags, pIgnore);
473 glob_free(pIgnore);
474 nAdd = add_files_in_sfile(vid, caseSensitive);
475
476 /* step 2: search for missing files */
477 db_prepare(&q,
478
+8 -5
--- src/checkin.c
+++ src/checkin.c
@@ -324,16 +324,17 @@
324324
Blob path;
325325
Blob repo;
326326
Stmt q;
327327
int n;
328328
const char *zIgnoreFlag = find_option("ignore",0,1);
329
- int allFlag = find_option("dotfiles",0,0)!=0;
329
+ unsigned scanFlags = find_option("dotfiles",0,0)!=0 ? SCAN_ALL : 0;
330330
int cwdRelative = 0;
331331
Glob *pIgnore;
332332
Blob rewrittenPathname;
333333
const char *zPathname, *zDisplayName;
334334
335
+ if( find_option("temp",0,0)!=0 ) scanFlags |= SCAN_TEMP;
335336
db_must_be_within_tree();
336337
cwdRelative = determine_cwd_relative_option();
337338
db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY %s)",
338339
filename_collation());
339340
n = strlen(g.zLocalRoot);
@@ -340,11 +341,11 @@
340341
blob_init(&path, g.zLocalRoot, n-1);
341342
if( zIgnoreFlag==0 ){
342343
zIgnoreFlag = db_get("ignore-glob", 0);
343344
}
344345
pIgnore = glob_create(zIgnoreFlag);
345
- vfile_scan(&path, blob_size(&path), allFlag, pIgnore);
346
+ vfile_scan(&path, blob_size(&path), scanFlags, pIgnore);
346347
glob_free(pIgnore);
347348
db_prepare(&q,
348349
"SELECT x FROM sfile"
349350
" WHERE x NOT IN (%s)"
350351
" ORDER BY 1",
@@ -395,34 +396,36 @@
395396
** Options:
396397
** --dotfiles include files beginning with a dot (".")
397398
** --force Remove files without prompting
398399
** --ignore <CSG> ignore files matching patterns from the
399400
** comma separated list of glob patterns.
401
+** --temp Remove only Fossil-generated temporary files
400402
**
401403
** See also: addremove, extra, status
402404
*/
403405
void clean_cmd(void){
404406
int allFlag;
405
- int dotfilesFlag;
407
+ unsigned scanFlags = 0;
406408
const char *zIgnoreFlag;
407409
Blob path, repo;
408410
Stmt q;
409411
int n;
410412
Glob *pIgnore;
411413
412414
allFlag = find_option("force","f",0)!=0;
413
- dotfilesFlag = find_option("dotfiles",0,0)!=0;
415
+ if( find_option("dotfiles",0,0)!=0 ) scanFlags |= SCAN_ALL;
416
+ if( find_option("temp",0,0)!=0 ) scanFlags |= SCAN_TEMP;
414417
zIgnoreFlag = find_option("ignore",0,1);
415418
db_must_be_within_tree();
416419
if( zIgnoreFlag==0 ){
417420
zIgnoreFlag = db_get("ignore-glob", 0);
418421
}
419422
db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY)");
420423
n = strlen(g.zLocalRoot);
421424
blob_init(&path, g.zLocalRoot, n-1);
422425
pIgnore = glob_create(zIgnoreFlag);
423
- vfile_scan(&path, blob_size(&path), dotfilesFlag, pIgnore);
426
+ vfile_scan(&path, blob_size(&path), scanFlags, pIgnore);
424427
glob_free(pIgnore);
425428
db_prepare(&q,
426429
"SELECT %Q || x FROM sfile"
427430
" WHERE x NOT IN (%s)"
428431
" ORDER BY 1",
429432
--- src/checkin.c
+++ src/checkin.c
@@ -324,16 +324,17 @@
324 Blob path;
325 Blob repo;
326 Stmt q;
327 int n;
328 const char *zIgnoreFlag = find_option("ignore",0,1);
329 int allFlag = find_option("dotfiles",0,0)!=0;
330 int cwdRelative = 0;
331 Glob *pIgnore;
332 Blob rewrittenPathname;
333 const char *zPathname, *zDisplayName;
334
 
335 db_must_be_within_tree();
336 cwdRelative = determine_cwd_relative_option();
337 db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY %s)",
338 filename_collation());
339 n = strlen(g.zLocalRoot);
@@ -340,11 +341,11 @@
340 blob_init(&path, g.zLocalRoot, n-1);
341 if( zIgnoreFlag==0 ){
342 zIgnoreFlag = db_get("ignore-glob", 0);
343 }
344 pIgnore = glob_create(zIgnoreFlag);
345 vfile_scan(&path, blob_size(&path), allFlag, pIgnore);
346 glob_free(pIgnore);
347 db_prepare(&q,
348 "SELECT x FROM sfile"
349 " WHERE x NOT IN (%s)"
350 " ORDER BY 1",
@@ -395,34 +396,36 @@
395 ** Options:
396 ** --dotfiles include files beginning with a dot (".")
397 ** --force Remove files without prompting
398 ** --ignore <CSG> ignore files matching patterns from the
399 ** comma separated list of glob patterns.
 
400 **
401 ** See also: addremove, extra, status
402 */
403 void clean_cmd(void){
404 int allFlag;
405 int dotfilesFlag;
406 const char *zIgnoreFlag;
407 Blob path, repo;
408 Stmt q;
409 int n;
410 Glob *pIgnore;
411
412 allFlag = find_option("force","f",0)!=0;
413 dotfilesFlag = find_option("dotfiles",0,0)!=0;
 
414 zIgnoreFlag = find_option("ignore",0,1);
415 db_must_be_within_tree();
416 if( zIgnoreFlag==0 ){
417 zIgnoreFlag = db_get("ignore-glob", 0);
418 }
419 db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY)");
420 n = strlen(g.zLocalRoot);
421 blob_init(&path, g.zLocalRoot, n-1);
422 pIgnore = glob_create(zIgnoreFlag);
423 vfile_scan(&path, blob_size(&path), dotfilesFlag, pIgnore);
424 glob_free(pIgnore);
425 db_prepare(&q,
426 "SELECT %Q || x FROM sfile"
427 " WHERE x NOT IN (%s)"
428 " ORDER BY 1",
429
--- src/checkin.c
+++ src/checkin.c
@@ -324,16 +324,17 @@
324 Blob path;
325 Blob repo;
326 Stmt q;
327 int n;
328 const char *zIgnoreFlag = find_option("ignore",0,1);
329 unsigned scanFlags = find_option("dotfiles",0,0)!=0 ? SCAN_ALL : 0;
330 int cwdRelative = 0;
331 Glob *pIgnore;
332 Blob rewrittenPathname;
333 const char *zPathname, *zDisplayName;
334
335 if( find_option("temp",0,0)!=0 ) scanFlags |= SCAN_TEMP;
336 db_must_be_within_tree();
337 cwdRelative = determine_cwd_relative_option();
338 db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY %s)",
339 filename_collation());
340 n = strlen(g.zLocalRoot);
@@ -340,11 +341,11 @@
341 blob_init(&path, g.zLocalRoot, n-1);
342 if( zIgnoreFlag==0 ){
343 zIgnoreFlag = db_get("ignore-glob", 0);
344 }
345 pIgnore = glob_create(zIgnoreFlag);
346 vfile_scan(&path, blob_size(&path), scanFlags, pIgnore);
347 glob_free(pIgnore);
348 db_prepare(&q,
349 "SELECT x FROM sfile"
350 " WHERE x NOT IN (%s)"
351 " ORDER BY 1",
@@ -395,34 +396,36 @@
396 ** Options:
397 ** --dotfiles include files beginning with a dot (".")
398 ** --force Remove files without prompting
399 ** --ignore <CSG> ignore files matching patterns from the
400 ** comma separated list of glob patterns.
401 ** --temp Remove only Fossil-generated temporary files
402 **
403 ** See also: addremove, extra, status
404 */
405 void clean_cmd(void){
406 int allFlag;
407 unsigned scanFlags = 0;
408 const char *zIgnoreFlag;
409 Blob path, repo;
410 Stmt q;
411 int n;
412 Glob *pIgnore;
413
414 allFlag = find_option("force","f",0)!=0;
415 if( find_option("dotfiles",0,0)!=0 ) scanFlags |= SCAN_ALL;
416 if( find_option("temp",0,0)!=0 ) scanFlags |= SCAN_TEMP;
417 zIgnoreFlag = find_option("ignore",0,1);
418 db_must_be_within_tree();
419 if( zIgnoreFlag==0 ){
420 zIgnoreFlag = db_get("ignore-glob", 0);
421 }
422 db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY)");
423 n = strlen(g.zLocalRoot);
424 blob_init(&path, g.zLocalRoot, n-1);
425 pIgnore = glob_create(zIgnoreFlag);
426 vfile_scan(&path, blob_size(&path), scanFlags, pIgnore);
427 glob_free(pIgnore);
428 db_prepare(&q,
429 "SELECT %Q || x FROM sfile"
430 " WHERE x NOT IN (%s)"
431 " ORDER BY 1",
432
+46 -6
--- src/vfile.c
+++ src/vfile.c
@@ -381,10 +381,48 @@
381381
fossil_free(zFile);
382382
}
383383
return fileFound;
384384
}
385385
386
+/*
387
+** Return TRUE if zFile is a temporary file. Return FALSE if not.
388
+*/
389
+static int is_temporary_file(const char *zName){
390
+ static const char *azTemp[] = {
391
+ "baseline",
392
+ "merge",
393
+ "original",
394
+ "output",
395
+ };
396
+ int i, j, n;
397
+
398
+ if( strglob("ci-comment-????????????.txt", zName) ) return 1;
399
+ for(; zName[0]!=0; zName++){
400
+ if( zName[0]=='/' && strglob("/ci-comment-????????????.txt", zName) ){
401
+ return 1;
402
+ }
403
+ if( zName[0]!='-' ) continue;
404
+ for(i=0; i<sizeof(azTemp)/sizeof(azTemp[0]); i++){
405
+ n = (int)strlen(azTemp[i]);
406
+ if( memcmp(azTemp[i], zName+1, n) ) continue;
407
+ if( zName[n+1]==0 ) return 1;
408
+ if( zName[n+1]=='-' ){
409
+ for(j=n+2; zName[j] && fossil_isdigit(zName[j]); j++){}
410
+ if( zName[j]==0 ) return 1;
411
+ }
412
+ }
413
+ }
414
+ return 0;
415
+}
416
+
417
+#if INTERFACE
418
+/*
419
+** Values for the scanFlags parameter to vfile_scan().
420
+*/
421
+#define SCAN_ALL 0x001 /* Includes files that begin with "." */
422
+#define SCAN_TEMP 0x002 /* Only Fossil-generated files like *-baseline */
423
+#endif /* INTERFACE */
386424
387425
/*
388426
** Load into table SFILE the name of every ordinary file in
389427
** the directory pPath. Omit the first nPrefix characters of
390428
** of pPath when inserting into the SFILE table.
@@ -396,11 +434,11 @@
396434
**
397435
** Any files or directories that match the glob pattern pIgnore are
398436
** excluded from the scan. Name matching occurs after the first
399437
** nPrefix characters are elided from the filename.
400438
*/
401
-void vfile_scan(Blob *pPath, int nPrefix, int allFlag, Glob *pIgnore){
439
+void vfile_scan(Blob *pPath, int nPrefix, unsigned scanFlags, Glob *pIgnore){
402440
DIR *d;
403441
int origSize;
404442
const char *zDir;
405443
struct dirent *pEntry;
406444
int skipAll = 0;
@@ -430,11 +468,11 @@
430468
if( d ){
431469
while( (pEntry=readdir(d))!=0 ){
432470
char *zPath;
433471
char *zUtf8;
434472
if( pEntry->d_name[0]=='.' ){
435
- if( !allFlag ) continue;
473
+ if( (scanFlags & SCAN_ALL)==0 ) continue;
436474
if( pEntry->d_name[1]==0 ) continue;
437475
if( pEntry->d_name[1]=='.' && pEntry->d_name[2]==0 ) continue;
438476
}
439477
zUtf8 = fossil_unicode_to_utf8(pEntry->d_name);
440478
blob_appendf(pPath, "/%s", zUtf8);
@@ -442,16 +480,18 @@
442480
zPath = blob_str(pPath);
443481
if( glob_match(pIgnore, &zPath[nPrefix+1]) ){
444482
/* do nothing */
445483
}else if( file_wd_isdir(zPath)==1 ){
446484
if( !vfile_top_of_checkout(zPath) ){
447
- vfile_scan(pPath, nPrefix, allFlag, pIgnore);
485
+ vfile_scan(pPath, nPrefix, scanFlags, pIgnore);
448486
}
449487
}else if( file_wd_isfile_or_link(zPath) ){
450
- db_bind_text(&ins, ":file", &zPath[nPrefix+1]);
451
- db_step(&ins);
452
- db_reset(&ins);
488
+ if( (scanFlags & SCAN_TEMP)==0 || is_temporary_file(pEntry->d_name) ){
489
+ db_bind_text(&ins, ":file", &zPath[nPrefix+1]);
490
+ db_step(&ins);
491
+ db_reset(&ins);
492
+ }
453493
}
454494
blob_resize(pPath, origSize);
455495
}
456496
closedir(d);
457497
}
458498
--- src/vfile.c
+++ src/vfile.c
@@ -381,10 +381,48 @@
381 fossil_free(zFile);
382 }
383 return fileFound;
384 }
385
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
386
387 /*
388 ** Load into table SFILE the name of every ordinary file in
389 ** the directory pPath. Omit the first nPrefix characters of
390 ** of pPath when inserting into the SFILE table.
@@ -396,11 +434,11 @@
396 **
397 ** Any files or directories that match the glob pattern pIgnore are
398 ** excluded from the scan. Name matching occurs after the first
399 ** nPrefix characters are elided from the filename.
400 */
401 void vfile_scan(Blob *pPath, int nPrefix, int allFlag, Glob *pIgnore){
402 DIR *d;
403 int origSize;
404 const char *zDir;
405 struct dirent *pEntry;
406 int skipAll = 0;
@@ -430,11 +468,11 @@
430 if( d ){
431 while( (pEntry=readdir(d))!=0 ){
432 char *zPath;
433 char *zUtf8;
434 if( pEntry->d_name[0]=='.' ){
435 if( !allFlag ) continue;
436 if( pEntry->d_name[1]==0 ) continue;
437 if( pEntry->d_name[1]=='.' && pEntry->d_name[2]==0 ) continue;
438 }
439 zUtf8 = fossil_unicode_to_utf8(pEntry->d_name);
440 blob_appendf(pPath, "/%s", zUtf8);
@@ -442,16 +480,18 @@
442 zPath = blob_str(pPath);
443 if( glob_match(pIgnore, &zPath[nPrefix+1]) ){
444 /* do nothing */
445 }else if( file_wd_isdir(zPath)==1 ){
446 if( !vfile_top_of_checkout(zPath) ){
447 vfile_scan(pPath, nPrefix, allFlag, pIgnore);
448 }
449 }else if( file_wd_isfile_or_link(zPath) ){
450 db_bind_text(&ins, ":file", &zPath[nPrefix+1]);
451 db_step(&ins);
452 db_reset(&ins);
 
 
453 }
454 blob_resize(pPath, origSize);
455 }
456 closedir(d);
457 }
458
--- src/vfile.c
+++ src/vfile.c
@@ -381,10 +381,48 @@
381 fossil_free(zFile);
382 }
383 return fileFound;
384 }
385
386 /*
387 ** Return TRUE if zFile is a temporary file. Return FALSE if not.
388 */
389 static int is_temporary_file(const char *zName){
390 static const char *azTemp[] = {
391 "baseline",
392 "merge",
393 "original",
394 "output",
395 };
396 int i, j, n;
397
398 if( strglob("ci-comment-????????????.txt", zName) ) return 1;
399 for(; zName[0]!=0; zName++){
400 if( zName[0]=='/' && strglob("/ci-comment-????????????.txt", zName) ){
401 return 1;
402 }
403 if( zName[0]!='-' ) continue;
404 for(i=0; i<sizeof(azTemp)/sizeof(azTemp[0]); i++){
405 n = (int)strlen(azTemp[i]);
406 if( memcmp(azTemp[i], zName+1, n) ) continue;
407 if( zName[n+1]==0 ) return 1;
408 if( zName[n+1]=='-' ){
409 for(j=n+2; zName[j] && fossil_isdigit(zName[j]); j++){}
410 if( zName[j]==0 ) return 1;
411 }
412 }
413 }
414 return 0;
415 }
416
417 #if INTERFACE
418 /*
419 ** Values for the scanFlags parameter to vfile_scan().
420 */
421 #define SCAN_ALL 0x001 /* Includes files that begin with "." */
422 #define SCAN_TEMP 0x002 /* Only Fossil-generated files like *-baseline */
423 #endif /* INTERFACE */
424
425 /*
426 ** Load into table SFILE the name of every ordinary file in
427 ** the directory pPath. Omit the first nPrefix characters of
428 ** of pPath when inserting into the SFILE table.
@@ -396,11 +434,11 @@
434 **
435 ** Any files or directories that match the glob pattern pIgnore are
436 ** excluded from the scan. Name matching occurs after the first
437 ** nPrefix characters are elided from the filename.
438 */
439 void vfile_scan(Blob *pPath, int nPrefix, unsigned scanFlags, Glob *pIgnore){
440 DIR *d;
441 int origSize;
442 const char *zDir;
443 struct dirent *pEntry;
444 int skipAll = 0;
@@ -430,11 +468,11 @@
468 if( d ){
469 while( (pEntry=readdir(d))!=0 ){
470 char *zPath;
471 char *zUtf8;
472 if( pEntry->d_name[0]=='.' ){
473 if( (scanFlags & SCAN_ALL)==0 ) continue;
474 if( pEntry->d_name[1]==0 ) continue;
475 if( pEntry->d_name[1]=='.' && pEntry->d_name[2]==0 ) continue;
476 }
477 zUtf8 = fossil_unicode_to_utf8(pEntry->d_name);
478 blob_appendf(pPath, "/%s", zUtf8);
@@ -442,16 +480,18 @@
480 zPath = blob_str(pPath);
481 if( glob_match(pIgnore, &zPath[nPrefix+1]) ){
482 /* do nothing */
483 }else if( file_wd_isdir(zPath)==1 ){
484 if( !vfile_top_of_checkout(zPath) ){
485 vfile_scan(pPath, nPrefix, scanFlags, pIgnore);
486 }
487 }else if( file_wd_isfile_or_link(zPath) ){
488 if( (scanFlags & SCAN_TEMP)==0 || is_temporary_file(pEntry->d_name) ){
489 db_bind_text(&ins, ":file", &zPath[nPrefix+1]);
490 db_step(&ins);
491 db_reset(&ins);
492 }
493 }
494 blob_resize(pPath, origSize);
495 }
496 closedir(d);
497 }
498

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button