Overview
SHA1 Hash: | 849b94c6317f855aed30ed371f75229c13cfe038 |
---|---|
Date: | 2008-07-17 01:49:16 |
User: | drh |
Comment: | Avoid the use of chdir() since this seems to cause problems on windows. |
Timelines: | ancestors | descendants | both | trunk |
Other Links: | files | ZIP archive | manifest |
Tags And Properties
- branch=trunk inherited from [a28c83647d]
- sym-trunk inherited from [a28c83647d]
Changes
[hide diffs]Modified src/checkin.c from [e9356000f0] to [213d5beae2].
@@ -155,15 +155,16 @@ ** the current checkout. See also the "clean" command. */ void extra_cmd(void){ Blob path; Stmt q; + int n; db_must_be_within_tree(); db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY)"); - chdir(g.zLocalRoot); - blob_zero(&path); - vfile_scan(0, &path); + n = strlen(g.zLocalRoot); + blob_init(&path, g.zLocalRoot, n-1); + vfile_scan(0, &path, blob_size(&path)); db_prepare(&q, "SELECT x FROM sfile" " WHERE x NOT IN ('manifest','manifest.uuid','_FOSSIL_')" " ORDER BY 1"); while( db_step(&q)==SQLITE_ROW ){ @@ -186,16 +187,17 @@ */ void clean_cmd(void){ int allFlag; Blob path; Stmt q; + int n; allFlag = find_option("all","a",0)!=0; db_must_be_within_tree(); db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY)"); - chdir(g.zLocalRoot); - blob_zero(&path); - vfile_scan(0, &path); + n = strlen(g.zLocalRoot); + blob_init(&path, g.zLocalRoot, n-1); + vfile_scan(0, &path, blob_size(&path)); db_prepare(&q, "SELECT %Q || x FROM sfile" " WHERE x NOT IN ('manifest','manifest.uuid','_FOSSIL_')" " ORDER BY 1", g.zLocalRoot); while( db_step(&q)==SQLITE_ROW ){
Modified src/vfile.c from [533b750082] to [a6f67aae7d].
@@ -240,41 +240,37 @@ db_finalize(&q); } /* ** Load into table SFILE the name of every ordinary file in -** the directory pPath. Subdirectories are scanned recursively. +** the directory pPath. Omit the first nPrefix characters of +** of pPath when inserting into the SFILE table. +** +** Subdirectories are scanned recursively. ** Omit files named in VFILE.vid */ -void vfile_scan(int vid, Blob *pPath){ +void vfile_scan(int vid, Blob *pPath, int nPrefix){ DIR *d; int origSize; const char *zDir; - const char *zFormat; struct dirent *pEntry; static const char *zSql = "SELECT 1 FROM vfile " - " WHERE pathname=%B AND NOT deleted"; + " WHERE pathname=%Q AND NOT deleted"; origSize = blob_size(pPath); zDir = blob_str(pPath); - if( zDir[0]==0 ){ - zDir = "."; - zFormat = "%s"; - }else{ - zFormat = "/%s"; - } d = opendir(zDir); if( d ){ while( (pEntry=readdir(d))!=0 ){ char *zPath; if( pEntry->d_name[0]=='.' ) continue; - blob_appendf(pPath, zFormat, pEntry->d_name); + blob_appendf(pPath, "/%s", pEntry->d_name); zPath = blob_str(pPath); if( file_isdir(zPath)==1 ){ - vfile_scan(vid, pPath); - }else if( file_isfile(zPath) && !db_exists(zSql,pPath) ){ - db_multi_exec("INSERT INTO sfile VALUES(%B)", pPath); + vfile_scan(vid, pPath, nPrefix); + }else if( file_isfile(zPath) && !db_exists(zSql, &zPath[nPrefix+1]) ){ + db_multi_exec("INSERT INTO sfile VALUES(%Q)", &zPath[nPrefix+1]); } blob_resize(pPath, origSize); } } closedir(d);