Fossil SCM
Refactor the symlink processing logic so that most of the file access routines take a new parameter indicating the conditions under which symlinks should and should not be followed.
Commit
1772357fc203311d885398b8f0c8a3bd260dc9c80944a4e644ea32b5416d9adf
Parent
28fd1c1bd4e438b…
54 files changed
+11
-11
+2
-2
+1
-1
+31
-9
+2
-2
+3
-3
+10
-19
+1
-1
+1
-1
+1
-1
+2
-2
+3
-3
+1
-1
+11
-10
+8
-8
+4
-4
+6
-14
+2
-2
+181
-167
+1
-1
+1
-1
+2
-2
+1
-1
+5
-2
+3
-2
+1
-1
+2
-2
+1
-1
+8
-8
+1
-1
+8
-8
+7
-7
+5
-5
+2
-2
+13
-3
+13
-9
+2
-2
+9
-22
+4
-4
+1
-1
+9
-3
+2
-2
+2
-2
+9
-17
+2
-2
+13
-11
+3
-3
+28
-32
+2
-2
+3
-3
+4
-3
+2
-2
+1
-1
+6
-2
~
src/add.c
~
src/allrepo.c
~
src/attach.c
~
src/blob.c
~
src/bundle.c
~
src/cache.c
~
src/checkin.c
~
src/checkout.c
~
src/clearsign.c
~
src/clone.c
~
src/comformat.c
~
src/configure.c
~
src/content.c
~
src/db.c
~
src/deltacmd.c
~
src/diff.c
~
src/diffcmd.c
~
src/doc.c
~
src/file.c
~
src/fusefs.c
~
src/gzip.c
~
src/hname.c
~
src/http_ssl.c
~
src/info.c
~
src/json.c
~
src/json_status.c
~
src/login.c
~
src/lookslike.c
~
src/main.c
~
src/manifest.c
~
src/merge.c
~
src/merge3.c
~
src/rebuild.c
~
src/search.c
~
src/sha1.c
~
src/sha3.c
~
src/skins.c
~
src/stash.c
~
src/stat.c
~
src/style.c
~
src/tar.c
~
src/th_main.c
~
src/th_tcl.c
~
src/undo.c
~
src/unversioned.c
~
src/update.c
~
src/url.c
~
src/vfile.c
~
src/wiki.c
~
src/wikiformat.c
~
src/winfile.c
~
src/winhttp.c
~
src/xfer.c
~
src/zip.c
+11
-11
| --- src/add.c | ||
| +++ src/add.c | ||
| @@ -23,20 +23,20 @@ | ||
| 23 | 23 | #include <assert.h> |
| 24 | 24 | #include <dirent.h> |
| 25 | 25 | #include "cygsup.h" |
| 26 | 26 | |
| 27 | 27 | /* |
| 28 | -** WARNING: For Fossil version 1.x this value was always zero. For Fossil | |
| 29 | -** 2.x, it will probably always be one. When this value is zero, | |
| 28 | +** WARNING: For Fossil version x.x this value was always zero. For Fossil-NG | |
| 29 | +** it will probably always be one. When this value is zero, | |
| 30 | 30 | ** files in the checkout will not be moved by the "mv" command and |
| 31 | 31 | ** files in the checkout will not be removed by the "rm" command. |
| 32 | 32 | ** |
| 33 | 33 | ** If the FOSSIL_ENABLE_LEGACY_MV_RM compile-time option is used, |
| 34 | 34 | ** the "mv-rm-files" setting will be consulted instead of using |
| 35 | 35 | ** this value. |
| 36 | 36 | ** |
| 37 | -** To retain the Fossil version 1.x behavior when using Fossil 2.x, | |
| 37 | +** To retain the Fossil version 2.x behavior when using Fossil-NG | |
| 38 | 38 | ** the FOSSIL_ENABLE_LEGACY_MV_RM compile-time option must be used |
| 39 | 39 | ** -AND- the "mv-rm-files" setting must be set to zero. |
| 40 | 40 | */ |
| 41 | 41 | #ifndef FOSSIL_MV_RM_FILE |
| 42 | 42 | #define FOSSIL_MV_RM_FILE (0) |
| @@ -185,15 +185,15 @@ | ||
| 185 | 185 | db_multi_exec("UPDATE vfile SET deleted=0" |
| 186 | 186 | " WHERE pathname=%Q %s AND deleted", |
| 187 | 187 | zPath, filename_collation()); |
| 188 | 188 | }else{ |
| 189 | 189 | char *zFullname = mprintf("%s%s", g.zLocalRoot, zPath); |
| 190 | - int isExe = file_wd_isexe(zFullname); | |
| 190 | + int isExe = file_isexe(zFullname, RepoFILE); | |
| 191 | 191 | db_multi_exec( |
| 192 | 192 | "INSERT INTO vfile(vid,deleted,rid,mrid,pathname,isexe,islink)" |
| 193 | 193 | "VALUES(%d,0,0,0,%Q,%d,%d)", |
| 194 | - vid, zPath, isExe, file_wd_islink(0)); | |
| 194 | + vid, zPath, isExe, file_islink(0)); | |
| 195 | 195 | fossil_free(zFullname); |
| 196 | 196 | } |
| 197 | 197 | if( db_changes() ){ |
| 198 | 198 | fossil_print("ADDED %s\n", zPath); |
| 199 | 199 | return 1; |
| @@ -326,11 +326,11 @@ | ||
| 326 | 326 | file_tree_name(g.argv[i], &fullName, 0, 1); |
| 327 | 327 | blob_reset(&fullName); |
| 328 | 328 | |
| 329 | 329 | file_canonical_name(g.argv[i], &fullName, 0); |
| 330 | 330 | zName = blob_str(&fullName); |
| 331 | - isDir = file_wd_isdir(zName); | |
| 331 | + isDir = file_isdir(zName, RepoFILE); | |
| 332 | 332 | if( isDir==1 ){ |
| 333 | 333 | vfile_scan(&fullName, nRoot-1, scanFlags, pClean, pIgnore); |
| 334 | 334 | }else if( isDir==0 ){ |
| 335 | 335 | fossil_warning("not found: %s", zName); |
| 336 | 336 | }else{ |
| @@ -695,11 +695,11 @@ | ||
| 695 | 695 | const char *zFile; |
| 696 | 696 | const char *zPath; |
| 697 | 697 | |
| 698 | 698 | zFile = db_column_text(&q, 0); |
| 699 | 699 | zPath = db_column_text(&q, 1); |
| 700 | - if( !file_wd_isfile_or_link(zPath) ){ | |
| 700 | + if( !file_isfile_or_link(zPath) ){ | |
| 701 | 701 | if( !dryRunFlag ){ |
| 702 | 702 | db_multi_exec("UPDATE vfile SET deleted=1 WHERE pathname=%Q", zFile); |
| 703 | 703 | } |
| 704 | 704 | fossil_print("DELETED %s\n", zFile); |
| 705 | 705 | nDelete++; |
| @@ -797,18 +797,18 @@ | ||
| 797 | 797 | db_prepare(&move, "SELECT x, y FROM fmove ORDER BY x;"); |
| 798 | 798 | while( db_step(&move)==SQLITE_ROW ){ |
| 799 | 799 | const char *zOldName = db_column_text(&move, 0); |
| 800 | 800 | const char *zNewName = db_column_text(&move, 1); |
| 801 | 801 | if( !dryRunFlag ){ |
| 802 | - int isOldDir = file_isdir(zOldName); | |
| 802 | + int isOldDir = file_isdir(zOldName, RepoFILE); | |
| 803 | 803 | if( isOldDir==1 ){ |
| 804 | - int isNewDir = file_isdir(zNewName); | |
| 804 | + int isNewDir = file_isdir(zNewName, RepoFILE); | |
| 805 | 805 | if( isNewDir==0 ){ |
| 806 | 806 | file_rename(zOldName, zNewName, isOldDir, isNewDir); |
| 807 | 807 | } |
| 808 | 808 | }else{ |
| 809 | - if( file_wd_islink(zOldName) ){ | |
| 809 | + if( file_islink(zOldName) ){ | |
| 810 | 810 | symlink_copy(zOldName, zNewName); |
| 811 | 811 | }else{ |
| 812 | 812 | file_copy(zOldName, zNewName); |
| 813 | 813 | } |
| 814 | 814 | file_delete(zOldName); |
| @@ -900,11 +900,11 @@ | ||
| 900 | 900 | "UPDATE vfile SET origname=pathname WHERE origname IS NULL;" |
| 901 | 901 | ); |
| 902 | 902 | db_multi_exec( |
| 903 | 903 | "CREATE TEMP TABLE mv(f TEXT UNIQUE ON CONFLICT IGNORE, t TEXT);" |
| 904 | 904 | ); |
| 905 | - if( file_wd_isdir(zDest)!=1 ){ | |
| 905 | + if( file_isdir(zDest, RepoFILE)!=1 ){ | |
| 906 | 906 | Blob orig; |
| 907 | 907 | if( g.argc!=4 ){ |
| 908 | 908 | usage("OLDNAME NEWNAME"); |
| 909 | 909 | } |
| 910 | 910 | file_tree_name(g.argv[2], &orig, 0, 1); |
| 911 | 911 |
| --- src/add.c | |
| +++ src/add.c | |
| @@ -23,20 +23,20 @@ | |
| 23 | #include <assert.h> |
| 24 | #include <dirent.h> |
| 25 | #include "cygsup.h" |
| 26 | |
| 27 | /* |
| 28 | ** WARNING: For Fossil version 1.x this value was always zero. For Fossil |
| 29 | ** 2.x, it will probably always be one. When this value is zero, |
| 30 | ** files in the checkout will not be moved by the "mv" command and |
| 31 | ** files in the checkout will not be removed by the "rm" command. |
| 32 | ** |
| 33 | ** If the FOSSIL_ENABLE_LEGACY_MV_RM compile-time option is used, |
| 34 | ** the "mv-rm-files" setting will be consulted instead of using |
| 35 | ** this value. |
| 36 | ** |
| 37 | ** To retain the Fossil version 1.x behavior when using Fossil 2.x, |
| 38 | ** the FOSSIL_ENABLE_LEGACY_MV_RM compile-time option must be used |
| 39 | ** -AND- the "mv-rm-files" setting must be set to zero. |
| 40 | */ |
| 41 | #ifndef FOSSIL_MV_RM_FILE |
| 42 | #define FOSSIL_MV_RM_FILE (0) |
| @@ -185,15 +185,15 @@ | |
| 185 | db_multi_exec("UPDATE vfile SET deleted=0" |
| 186 | " WHERE pathname=%Q %s AND deleted", |
| 187 | zPath, filename_collation()); |
| 188 | }else{ |
| 189 | char *zFullname = mprintf("%s%s", g.zLocalRoot, zPath); |
| 190 | int isExe = file_wd_isexe(zFullname); |
| 191 | db_multi_exec( |
| 192 | "INSERT INTO vfile(vid,deleted,rid,mrid,pathname,isexe,islink)" |
| 193 | "VALUES(%d,0,0,0,%Q,%d,%d)", |
| 194 | vid, zPath, isExe, file_wd_islink(0)); |
| 195 | fossil_free(zFullname); |
| 196 | } |
| 197 | if( db_changes() ){ |
| 198 | fossil_print("ADDED %s\n", zPath); |
| 199 | return 1; |
| @@ -326,11 +326,11 @@ | |
| 326 | file_tree_name(g.argv[i], &fullName, 0, 1); |
| 327 | blob_reset(&fullName); |
| 328 | |
| 329 | file_canonical_name(g.argv[i], &fullName, 0); |
| 330 | zName = blob_str(&fullName); |
| 331 | isDir = file_wd_isdir(zName); |
| 332 | if( isDir==1 ){ |
| 333 | vfile_scan(&fullName, nRoot-1, scanFlags, pClean, pIgnore); |
| 334 | }else if( isDir==0 ){ |
| 335 | fossil_warning("not found: %s", zName); |
| 336 | }else{ |
| @@ -695,11 +695,11 @@ | |
| 695 | const char *zFile; |
| 696 | const char *zPath; |
| 697 | |
| 698 | zFile = db_column_text(&q, 0); |
| 699 | zPath = db_column_text(&q, 1); |
| 700 | if( !file_wd_isfile_or_link(zPath) ){ |
| 701 | if( !dryRunFlag ){ |
| 702 | db_multi_exec("UPDATE vfile SET deleted=1 WHERE pathname=%Q", zFile); |
| 703 | } |
| 704 | fossil_print("DELETED %s\n", zFile); |
| 705 | nDelete++; |
| @@ -797,18 +797,18 @@ | |
| 797 | db_prepare(&move, "SELECT x, y FROM fmove ORDER BY x;"); |
| 798 | while( db_step(&move)==SQLITE_ROW ){ |
| 799 | const char *zOldName = db_column_text(&move, 0); |
| 800 | const char *zNewName = db_column_text(&move, 1); |
| 801 | if( !dryRunFlag ){ |
| 802 | int isOldDir = file_isdir(zOldName); |
| 803 | if( isOldDir==1 ){ |
| 804 | int isNewDir = file_isdir(zNewName); |
| 805 | if( isNewDir==0 ){ |
| 806 | file_rename(zOldName, zNewName, isOldDir, isNewDir); |
| 807 | } |
| 808 | }else{ |
| 809 | if( file_wd_islink(zOldName) ){ |
| 810 | symlink_copy(zOldName, zNewName); |
| 811 | }else{ |
| 812 | file_copy(zOldName, zNewName); |
| 813 | } |
| 814 | file_delete(zOldName); |
| @@ -900,11 +900,11 @@ | |
| 900 | "UPDATE vfile SET origname=pathname WHERE origname IS NULL;" |
| 901 | ); |
| 902 | db_multi_exec( |
| 903 | "CREATE TEMP TABLE mv(f TEXT UNIQUE ON CONFLICT IGNORE, t TEXT);" |
| 904 | ); |
| 905 | if( file_wd_isdir(zDest)!=1 ){ |
| 906 | Blob orig; |
| 907 | if( g.argc!=4 ){ |
| 908 | usage("OLDNAME NEWNAME"); |
| 909 | } |
| 910 | file_tree_name(g.argv[2], &orig, 0, 1); |
| 911 |
| --- src/add.c | |
| +++ src/add.c | |
| @@ -23,20 +23,20 @@ | |
| 23 | #include <assert.h> |
| 24 | #include <dirent.h> |
| 25 | #include "cygsup.h" |
| 26 | |
| 27 | /* |
| 28 | ** WARNING: For Fossil version x.x this value was always zero. For Fossil-NG |
| 29 | ** it will probably always be one. When this value is zero, |
| 30 | ** files in the checkout will not be moved by the "mv" command and |
| 31 | ** files in the checkout will not be removed by the "rm" command. |
| 32 | ** |
| 33 | ** If the FOSSIL_ENABLE_LEGACY_MV_RM compile-time option is used, |
| 34 | ** the "mv-rm-files" setting will be consulted instead of using |
| 35 | ** this value. |
| 36 | ** |
| 37 | ** To retain the Fossil version 2.x behavior when using Fossil-NG |
| 38 | ** the FOSSIL_ENABLE_LEGACY_MV_RM compile-time option must be used |
| 39 | ** -AND- the "mv-rm-files" setting must be set to zero. |
| 40 | */ |
| 41 | #ifndef FOSSIL_MV_RM_FILE |
| 42 | #define FOSSIL_MV_RM_FILE (0) |
| @@ -185,15 +185,15 @@ | |
| 185 | db_multi_exec("UPDATE vfile SET deleted=0" |
| 186 | " WHERE pathname=%Q %s AND deleted", |
| 187 | zPath, filename_collation()); |
| 188 | }else{ |
| 189 | char *zFullname = mprintf("%s%s", g.zLocalRoot, zPath); |
| 190 | int isExe = file_isexe(zFullname, RepoFILE); |
| 191 | db_multi_exec( |
| 192 | "INSERT INTO vfile(vid,deleted,rid,mrid,pathname,isexe,islink)" |
| 193 | "VALUES(%d,0,0,0,%Q,%d,%d)", |
| 194 | vid, zPath, isExe, file_islink(0)); |
| 195 | fossil_free(zFullname); |
| 196 | } |
| 197 | if( db_changes() ){ |
| 198 | fossil_print("ADDED %s\n", zPath); |
| 199 | return 1; |
| @@ -326,11 +326,11 @@ | |
| 326 | file_tree_name(g.argv[i], &fullName, 0, 1); |
| 327 | blob_reset(&fullName); |
| 328 | |
| 329 | file_canonical_name(g.argv[i], &fullName, 0); |
| 330 | zName = blob_str(&fullName); |
| 331 | isDir = file_isdir(zName, RepoFILE); |
| 332 | if( isDir==1 ){ |
| 333 | vfile_scan(&fullName, nRoot-1, scanFlags, pClean, pIgnore); |
| 334 | }else if( isDir==0 ){ |
| 335 | fossil_warning("not found: %s", zName); |
| 336 | }else{ |
| @@ -695,11 +695,11 @@ | |
| 695 | const char *zFile; |
| 696 | const char *zPath; |
| 697 | |
| 698 | zFile = db_column_text(&q, 0); |
| 699 | zPath = db_column_text(&q, 1); |
| 700 | if( !file_isfile_or_link(zPath) ){ |
| 701 | if( !dryRunFlag ){ |
| 702 | db_multi_exec("UPDATE vfile SET deleted=1 WHERE pathname=%Q", zFile); |
| 703 | } |
| 704 | fossil_print("DELETED %s\n", zFile); |
| 705 | nDelete++; |
| @@ -797,18 +797,18 @@ | |
| 797 | db_prepare(&move, "SELECT x, y FROM fmove ORDER BY x;"); |
| 798 | while( db_step(&move)==SQLITE_ROW ){ |
| 799 | const char *zOldName = db_column_text(&move, 0); |
| 800 | const char *zNewName = db_column_text(&move, 1); |
| 801 | if( !dryRunFlag ){ |
| 802 | int isOldDir = file_isdir(zOldName, RepoFILE); |
| 803 | if( isOldDir==1 ){ |
| 804 | int isNewDir = file_isdir(zNewName, RepoFILE); |
| 805 | if( isNewDir==0 ){ |
| 806 | file_rename(zOldName, zNewName, isOldDir, isNewDir); |
| 807 | } |
| 808 | }else{ |
| 809 | if( file_islink(zOldName) ){ |
| 810 | symlink_copy(zOldName, zNewName); |
| 811 | }else{ |
| 812 | file_copy(zOldName, zNewName); |
| 813 | } |
| 814 | file_delete(zOldName); |
| @@ -900,11 +900,11 @@ | |
| 900 | "UPDATE vfile SET origname=pathname WHERE origname IS NULL;" |
| 901 | ); |
| 902 | db_multi_exec( |
| 903 | "CREATE TEMP TABLE mv(f TEXT UNIQUE ON CONFLICT IGNORE, t TEXT);" |
| 904 | ); |
| 905 | if( file_isdir(zDest, RepoFILE)!=1 ){ |
| 906 | Blob orig; |
| 907 | if( g.argc!=4 ){ |
| 908 | usage("OLDNAME NEWNAME"); |
| 909 | } |
| 910 | file_tree_name(g.argv[2], &orig, 0, 1); |
| 911 |
+2
-2
| --- src/allrepo.c | ||
| +++ src/allrepo.c | ||
| @@ -331,11 +331,11 @@ | ||
| 331 | 331 | sqlite3 *db; |
| 332 | 332 | int rc; |
| 333 | 333 | const char *z; |
| 334 | 334 | file_canonical_name(g.argv[j], &fn, 0); |
| 335 | 335 | z = blob_str(&fn); |
| 336 | - if( !file_isfile(z) ) continue; | |
| 336 | + if( !file_isfile(z, ExtFILE) ) continue; | |
| 337 | 337 | g.dbIgnoreErrors++; |
| 338 | 338 | rc = sqlite3_open(z, &db); |
| 339 | 339 | if( rc!=SQLITE_OK ){ sqlite3_close(db); g.dbIgnoreErrors--; continue; } |
| 340 | 340 | rc = sqlite3_exec(db, "SELECT rcvid FROM blob, delta LIMIT 1", 0, 0, 0); |
| 341 | 341 | sqlite3_close(db); |
| @@ -397,11 +397,11 @@ | ||
| 397 | 397 | #if !USE_SEE |
| 398 | 398 | if( sqlite3_strglob("*.efossil", zFilename)==0 ) continue; |
| 399 | 399 | #endif |
| 400 | 400 | if( file_access(zFilename, F_OK) |
| 401 | 401 | || !file_is_canonical(zFilename) |
| 402 | - || (useCheckouts && file_isdir(zFilename)!=1) | |
| 402 | + || (useCheckouts && file_isdir(zFilename, ExtFILE)!=1) | |
| 403 | 403 | ){ |
| 404 | 404 | db_multi_exec("INSERT INTO toDel VALUES(%Q)", db_column_text(&q, 1)); |
| 405 | 405 | nToDel++; |
| 406 | 406 | continue; |
| 407 | 407 | } |
| 408 | 408 |
| --- src/allrepo.c | |
| +++ src/allrepo.c | |
| @@ -331,11 +331,11 @@ | |
| 331 | sqlite3 *db; |
| 332 | int rc; |
| 333 | const char *z; |
| 334 | file_canonical_name(g.argv[j], &fn, 0); |
| 335 | z = blob_str(&fn); |
| 336 | if( !file_isfile(z) ) continue; |
| 337 | g.dbIgnoreErrors++; |
| 338 | rc = sqlite3_open(z, &db); |
| 339 | if( rc!=SQLITE_OK ){ sqlite3_close(db); g.dbIgnoreErrors--; continue; } |
| 340 | rc = sqlite3_exec(db, "SELECT rcvid FROM blob, delta LIMIT 1", 0, 0, 0); |
| 341 | sqlite3_close(db); |
| @@ -397,11 +397,11 @@ | |
| 397 | #if !USE_SEE |
| 398 | if( sqlite3_strglob("*.efossil", zFilename)==0 ) continue; |
| 399 | #endif |
| 400 | if( file_access(zFilename, F_OK) |
| 401 | || !file_is_canonical(zFilename) |
| 402 | || (useCheckouts && file_isdir(zFilename)!=1) |
| 403 | ){ |
| 404 | db_multi_exec("INSERT INTO toDel VALUES(%Q)", db_column_text(&q, 1)); |
| 405 | nToDel++; |
| 406 | continue; |
| 407 | } |
| 408 |
| --- src/allrepo.c | |
| +++ src/allrepo.c | |
| @@ -331,11 +331,11 @@ | |
| 331 | sqlite3 *db; |
| 332 | int rc; |
| 333 | const char *z; |
| 334 | file_canonical_name(g.argv[j], &fn, 0); |
| 335 | z = blob_str(&fn); |
| 336 | if( !file_isfile(z, ExtFILE) ) continue; |
| 337 | g.dbIgnoreErrors++; |
| 338 | rc = sqlite3_open(z, &db); |
| 339 | if( rc!=SQLITE_OK ){ sqlite3_close(db); g.dbIgnoreErrors--; continue; } |
| 340 | rc = sqlite3_exec(db, "SELECT rcvid FROM blob, delta LIMIT 1", 0, 0, 0); |
| 341 | sqlite3_close(db); |
| @@ -397,11 +397,11 @@ | |
| 397 | #if !USE_SEE |
| 398 | if( sqlite3_strglob("*.efossil", zFilename)==0 ) continue; |
| 399 | #endif |
| 400 | if( file_access(zFilename, F_OK) |
| 401 | || !file_is_canonical(zFilename) |
| 402 | || (useCheckouts && file_isdir(zFilename, ExtFILE)!=1) |
| 403 | ){ |
| 404 | db_multi_exec("INSERT INTO toDel VALUES(%Q)", db_column_text(&q, 1)); |
| 405 | nToDel++; |
| 406 | continue; |
| 407 | } |
| 408 |
+1
-1
| --- src/attach.c | ||
| +++ src/attach.c | ||
| @@ -764,11 +764,11 @@ | ||
| 764 | 764 | "SELECT substr(tagname,7) FROM tag WHERE tagid=(SELECT tagid FROM event WHERE objid='%d')", |
| 765 | 765 | rid |
| 766 | 766 | ); |
| 767 | 767 | zFile = g.argv[3]; |
| 768 | 768 | } |
| 769 | - blob_read_from_file(&content, zFile); | |
| 769 | + blob_read_from_file(&content, zFile, ExtFILE); | |
| 770 | 770 | user_select(); |
| 771 | 771 | attach_commit( |
| 772 | 772 | zFile, /* The filename of the attachment */ |
| 773 | 773 | zTarget, /* The artifact uuid to attach to */ |
| 774 | 774 | blob_buffer(&content), /* The content of the attachment */ |
| 775 | 775 |
| --- src/attach.c | |
| +++ src/attach.c | |
| @@ -764,11 +764,11 @@ | |
| 764 | "SELECT substr(tagname,7) FROM tag WHERE tagid=(SELECT tagid FROM event WHERE objid='%d')", |
| 765 | rid |
| 766 | ); |
| 767 | zFile = g.argv[3]; |
| 768 | } |
| 769 | blob_read_from_file(&content, zFile); |
| 770 | user_select(); |
| 771 | attach_commit( |
| 772 | zFile, /* The filename of the attachment */ |
| 773 | zTarget, /* The artifact uuid to attach to */ |
| 774 | blob_buffer(&content), /* The content of the attachment */ |
| 775 |
| --- src/attach.c | |
| +++ src/attach.c | |
| @@ -764,11 +764,11 @@ | |
| 764 | "SELECT substr(tagname,7) FROM tag WHERE tagid=(SELECT tagid FROM event WHERE objid='%d')", |
| 765 | rid |
| 766 | ); |
| 767 | zFile = g.argv[3]; |
| 768 | } |
| 769 | blob_read_from_file(&content, zFile, ExtFILE); |
| 770 | user_select(); |
| 771 | attach_commit( |
| 772 | zFile, /* The filename of the attachment */ |
| 773 | zTarget, /* The artifact uuid to attach to */ |
| 774 | blob_buffer(&content), /* The content of the attachment */ |
| 775 |
+31
-9
| --- src/blob.c | ||
| +++ src/blob.c | ||
| @@ -783,24 +783,42 @@ | ||
| 783 | 783 | } |
| 784 | 784 | |
| 785 | 785 | /* |
| 786 | 786 | ** Initialize a blob to be the content of a file. If the filename |
| 787 | 787 | ** is blank or "-" then read from standard input. |
| 788 | +** | |
| 789 | +** If zFilename is a symbolic link, behavior depends on the eFType | |
| 790 | +** parameter: | |
| 791 | +** | |
| 792 | +** * If eFType is ExtFILE or allow-symlinks is OFF, then the | |
| 793 | +** pBlob is initialized to the *content* of the object to which | |
| 794 | +** the zFilename symlink points. | |
| 795 | +** | |
| 796 | +** * If eFType is RepoFILE and allow-symlinks is ON, then the | |
| 797 | +** pBlob is initialized to the *name* of the object to which | |
| 798 | +** the zFilename symlink points. | |
| 788 | 799 | ** |
| 789 | 800 | ** Any prior content of the blob is discarded, not freed. |
| 790 | 801 | ** |
| 791 | 802 | ** Return the number of bytes read. Calls fossil_fatal() on error (i.e. |
| 792 | 803 | ** it exit()s and does not return). |
| 793 | 804 | */ |
| 794 | -sqlite3_int64 blob_read_from_file(Blob *pBlob, const char *zFilename){ | |
| 805 | +sqlite3_int64 blob_read_from_file( | |
| 806 | + Blob *pBlob, /* The blob to be initialized */ | |
| 807 | + const char *zFilename, /* Extract content from this file */ | |
| 808 | + int eFType /* ExtFILE or RepoFILE - see above */ | |
| 809 | +){ | |
| 795 | 810 | sqlite3_int64 size, got; |
| 796 | 811 | FILE *in; |
| 797 | 812 | if( zFilename==0 || zFilename[0]==0 |
| 798 | 813 | || (zFilename[0]=='-' && zFilename[1]==0) ){ |
| 799 | 814 | return blob_read_from_channel(pBlob, stdin, -1); |
| 800 | 815 | } |
| 801 | - size = file_wd_size(zFilename); | |
| 816 | + if( file_islink(zFilename) ){ | |
| 817 | + return blob_read_link(pBlob, zFilename); | |
| 818 | + } | |
| 819 | + size = file_size(zFilename, eFType); | |
| 802 | 820 | blob_zero(pBlob); |
| 803 | 821 | if( size<0 ){ |
| 804 | 822 | fossil_fatal("no such file: %s", zFilename); |
| 805 | 823 | } |
| 806 | 824 | if( size==0 ){ |
| @@ -842,15 +860,19 @@ | ||
| 842 | 860 | blob_zero(pBlob); |
| 843 | 861 | return 0; |
| 844 | 862 | #endif |
| 845 | 863 | } |
| 846 | 864 | |
| 847 | - | |
| 848 | 865 | /* |
| 849 | 866 | ** Write the content of a blob into a file. |
| 850 | 867 | ** |
| 851 | 868 | ** If the filename is blank or "-" then write to standard output. |
| 869 | +** | |
| 870 | +** This routine always assumes ExtFILE. If zFilename is a symbolic link | |
| 871 | +** then the content is written into the object that symbolic link points | |
| 872 | +** to, not into the symbolic link itself. This is true regardless of | |
| 873 | +** the allow-symlinks setting. | |
| 852 | 874 | ** |
| 853 | 875 | ** Return the number of bytes written. |
| 854 | 876 | */ |
| 855 | 877 | int blob_write_to_file(Blob *pBlob, const char *zFilename){ |
| 856 | 878 | FILE *out; |
| @@ -868,11 +890,11 @@ | ||
| 868 | 890 | #if defined(_WIN32) |
| 869 | 891 | fflush(stdout); |
| 870 | 892 | _setmode(_fileno(stdout), _O_TEXT); |
| 871 | 893 | #endif |
| 872 | 894 | }else{ |
| 873 | - file_mkfolder(zFilename, 1, 0); | |
| 895 | + file_mkfolder(zFilename, ExtFILE, 1, 0); | |
| 874 | 896 | out = fossil_fopen(zFilename, "wb"); |
| 875 | 897 | if( out==0 ){ |
| 876 | 898 | #if _WIN32 |
| 877 | 899 | const char *zReserved = file_is_win_reserved(zFilename); |
| 878 | 900 | if( zReserved ){ |
| @@ -933,11 +955,11 @@ | ||
| 933 | 955 | ** This is used to test and debug the blob_compress() routine. |
| 934 | 956 | */ |
| 935 | 957 | void compress_cmd(void){ |
| 936 | 958 | Blob f; |
| 937 | 959 | if( g.argc!=4 ) usage("INPUTFILE OUTPUTFILE"); |
| 938 | - blob_read_from_file(&f, g.argv[2]); | |
| 960 | + blob_read_from_file(&f, g.argv[2], ExtFILE); | |
| 939 | 961 | blob_compress(&f, &f); |
| 940 | 962 | blob_write_to_file(&f, g.argv[3]); |
| 941 | 963 | } |
| 942 | 964 | |
| 943 | 965 | /* |
| @@ -992,12 +1014,12 @@ | ||
| 992 | 1014 | ** This is used to test and debug the blob_compress2() routine. |
| 993 | 1015 | */ |
| 994 | 1016 | void compress2_cmd(void){ |
| 995 | 1017 | Blob f1, f2; |
| 996 | 1018 | if( g.argc!=5 ) usage("INPUTFILE1 INPUTFILE2 OUTPUTFILE"); |
| 997 | - blob_read_from_file(&f1, g.argv[2]); | |
| 998 | - blob_read_from_file(&f2, g.argv[3]); | |
| 1019 | + blob_read_from_file(&f1, g.argv[2], ExtFILE); | |
| 1020 | + blob_read_from_file(&f2, g.argv[3], ExtFILE); | |
| 999 | 1021 | blob_compress2(&f1, &f2, &f1); |
| 1000 | 1022 | blob_write_to_file(&f1, g.argv[4]); |
| 1001 | 1023 | } |
| 1002 | 1024 | |
| 1003 | 1025 | /* |
| @@ -1044,11 +1066,11 @@ | ||
| 1044 | 1066 | ** blob_compress() function. |
| 1045 | 1067 | */ |
| 1046 | 1068 | void uncompress_cmd(void){ |
| 1047 | 1069 | Blob f; |
| 1048 | 1070 | if( g.argc!=4 ) usage("INPUTFILE OUTPUTFILE"); |
| 1049 | - blob_read_from_file(&f, g.argv[2]); | |
| 1071 | + blob_read_from_file(&f, g.argv[2], ExtFILE); | |
| 1050 | 1072 | blob_uncompress(&f, &f); |
| 1051 | 1073 | blob_write_to_file(&f, g.argv[3]); |
| 1052 | 1074 | } |
| 1053 | 1075 | |
| 1054 | 1076 | /* |
| @@ -1059,11 +1081,11 @@ | ||
| 1059 | 1081 | */ |
| 1060 | 1082 | void test_cycle_compress(void){ |
| 1061 | 1083 | int i; |
| 1062 | 1084 | Blob b1, b2, b3; |
| 1063 | 1085 | for(i=2; i<g.argc; i++){ |
| 1064 | - blob_read_from_file(&b1, g.argv[i]); | |
| 1086 | + blob_read_from_file(&b1, g.argv[i], ExtFILE); | |
| 1065 | 1087 | blob_compress(&b1, &b2); |
| 1066 | 1088 | blob_uncompress(&b2, &b3); |
| 1067 | 1089 | if( blob_compare(&b1, &b3) ){ |
| 1068 | 1090 | fossil_fatal("compress/uncompress cycle failed for %s", g.argv[i]); |
| 1069 | 1091 | } |
| 1070 | 1092 |
| --- src/blob.c | |
| +++ src/blob.c | |
| @@ -783,24 +783,42 @@ | |
| 783 | } |
| 784 | |
| 785 | /* |
| 786 | ** Initialize a blob to be the content of a file. If the filename |
| 787 | ** is blank or "-" then read from standard input. |
| 788 | ** |
| 789 | ** Any prior content of the blob is discarded, not freed. |
| 790 | ** |
| 791 | ** Return the number of bytes read. Calls fossil_fatal() on error (i.e. |
| 792 | ** it exit()s and does not return). |
| 793 | */ |
| 794 | sqlite3_int64 blob_read_from_file(Blob *pBlob, const char *zFilename){ |
| 795 | sqlite3_int64 size, got; |
| 796 | FILE *in; |
| 797 | if( zFilename==0 || zFilename[0]==0 |
| 798 | || (zFilename[0]=='-' && zFilename[1]==0) ){ |
| 799 | return blob_read_from_channel(pBlob, stdin, -1); |
| 800 | } |
| 801 | size = file_wd_size(zFilename); |
| 802 | blob_zero(pBlob); |
| 803 | if( size<0 ){ |
| 804 | fossil_fatal("no such file: %s", zFilename); |
| 805 | } |
| 806 | if( size==0 ){ |
| @@ -842,15 +860,19 @@ | |
| 842 | blob_zero(pBlob); |
| 843 | return 0; |
| 844 | #endif |
| 845 | } |
| 846 | |
| 847 | |
| 848 | /* |
| 849 | ** Write the content of a blob into a file. |
| 850 | ** |
| 851 | ** If the filename is blank or "-" then write to standard output. |
| 852 | ** |
| 853 | ** Return the number of bytes written. |
| 854 | */ |
| 855 | int blob_write_to_file(Blob *pBlob, const char *zFilename){ |
| 856 | FILE *out; |
| @@ -868,11 +890,11 @@ | |
| 868 | #if defined(_WIN32) |
| 869 | fflush(stdout); |
| 870 | _setmode(_fileno(stdout), _O_TEXT); |
| 871 | #endif |
| 872 | }else{ |
| 873 | file_mkfolder(zFilename, 1, 0); |
| 874 | out = fossil_fopen(zFilename, "wb"); |
| 875 | if( out==0 ){ |
| 876 | #if _WIN32 |
| 877 | const char *zReserved = file_is_win_reserved(zFilename); |
| 878 | if( zReserved ){ |
| @@ -933,11 +955,11 @@ | |
| 933 | ** This is used to test and debug the blob_compress() routine. |
| 934 | */ |
| 935 | void compress_cmd(void){ |
| 936 | Blob f; |
| 937 | if( g.argc!=4 ) usage("INPUTFILE OUTPUTFILE"); |
| 938 | blob_read_from_file(&f, g.argv[2]); |
| 939 | blob_compress(&f, &f); |
| 940 | blob_write_to_file(&f, g.argv[3]); |
| 941 | } |
| 942 | |
| 943 | /* |
| @@ -992,12 +1014,12 @@ | |
| 992 | ** This is used to test and debug the blob_compress2() routine. |
| 993 | */ |
| 994 | void compress2_cmd(void){ |
| 995 | Blob f1, f2; |
| 996 | if( g.argc!=5 ) usage("INPUTFILE1 INPUTFILE2 OUTPUTFILE"); |
| 997 | blob_read_from_file(&f1, g.argv[2]); |
| 998 | blob_read_from_file(&f2, g.argv[3]); |
| 999 | blob_compress2(&f1, &f2, &f1); |
| 1000 | blob_write_to_file(&f1, g.argv[4]); |
| 1001 | } |
| 1002 | |
| 1003 | /* |
| @@ -1044,11 +1066,11 @@ | |
| 1044 | ** blob_compress() function. |
| 1045 | */ |
| 1046 | void uncompress_cmd(void){ |
| 1047 | Blob f; |
| 1048 | if( g.argc!=4 ) usage("INPUTFILE OUTPUTFILE"); |
| 1049 | blob_read_from_file(&f, g.argv[2]); |
| 1050 | blob_uncompress(&f, &f); |
| 1051 | blob_write_to_file(&f, g.argv[3]); |
| 1052 | } |
| 1053 | |
| 1054 | /* |
| @@ -1059,11 +1081,11 @@ | |
| 1059 | */ |
| 1060 | void test_cycle_compress(void){ |
| 1061 | int i; |
| 1062 | Blob b1, b2, b3; |
| 1063 | for(i=2; i<g.argc; i++){ |
| 1064 | blob_read_from_file(&b1, g.argv[i]); |
| 1065 | blob_compress(&b1, &b2); |
| 1066 | blob_uncompress(&b2, &b3); |
| 1067 | if( blob_compare(&b1, &b3) ){ |
| 1068 | fossil_fatal("compress/uncompress cycle failed for %s", g.argv[i]); |
| 1069 | } |
| 1070 |
| --- src/blob.c | |
| +++ src/blob.c | |
| @@ -783,24 +783,42 @@ | |
| 783 | } |
| 784 | |
| 785 | /* |
| 786 | ** Initialize a blob to be the content of a file. If the filename |
| 787 | ** is blank or "-" then read from standard input. |
| 788 | ** |
| 789 | ** If zFilename is a symbolic link, behavior depends on the eFType |
| 790 | ** parameter: |
| 791 | ** |
| 792 | ** * If eFType is ExtFILE or allow-symlinks is OFF, then the |
| 793 | ** pBlob is initialized to the *content* of the object to which |
| 794 | ** the zFilename symlink points. |
| 795 | ** |
| 796 | ** * If eFType is RepoFILE and allow-symlinks is ON, then the |
| 797 | ** pBlob is initialized to the *name* of the object to which |
| 798 | ** the zFilename symlink points. |
| 799 | ** |
| 800 | ** Any prior content of the blob is discarded, not freed. |
| 801 | ** |
| 802 | ** Return the number of bytes read. Calls fossil_fatal() on error (i.e. |
| 803 | ** it exit()s and does not return). |
| 804 | */ |
| 805 | sqlite3_int64 blob_read_from_file( |
| 806 | Blob *pBlob, /* The blob to be initialized */ |
| 807 | const char *zFilename, /* Extract content from this file */ |
| 808 | int eFType /* ExtFILE or RepoFILE - see above */ |
| 809 | ){ |
| 810 | sqlite3_int64 size, got; |
| 811 | FILE *in; |
| 812 | if( zFilename==0 || zFilename[0]==0 |
| 813 | || (zFilename[0]=='-' && zFilename[1]==0) ){ |
| 814 | return blob_read_from_channel(pBlob, stdin, -1); |
| 815 | } |
| 816 | if( file_islink(zFilename) ){ |
| 817 | return blob_read_link(pBlob, zFilename); |
| 818 | } |
| 819 | size = file_size(zFilename, eFType); |
| 820 | blob_zero(pBlob); |
| 821 | if( size<0 ){ |
| 822 | fossil_fatal("no such file: %s", zFilename); |
| 823 | } |
| 824 | if( size==0 ){ |
| @@ -842,15 +860,19 @@ | |
| 860 | blob_zero(pBlob); |
| 861 | return 0; |
| 862 | #endif |
| 863 | } |
| 864 | |
| 865 | /* |
| 866 | ** Write the content of a blob into a file. |
| 867 | ** |
| 868 | ** If the filename is blank or "-" then write to standard output. |
| 869 | ** |
| 870 | ** This routine always assumes ExtFILE. If zFilename is a symbolic link |
| 871 | ** then the content is written into the object that symbolic link points |
| 872 | ** to, not into the symbolic link itself. This is true regardless of |
| 873 | ** the allow-symlinks setting. |
| 874 | ** |
| 875 | ** Return the number of bytes written. |
| 876 | */ |
| 877 | int blob_write_to_file(Blob *pBlob, const char *zFilename){ |
| 878 | FILE *out; |
| @@ -868,11 +890,11 @@ | |
| 890 | #if defined(_WIN32) |
| 891 | fflush(stdout); |
| 892 | _setmode(_fileno(stdout), _O_TEXT); |
| 893 | #endif |
| 894 | }else{ |
| 895 | file_mkfolder(zFilename, ExtFILE, 1, 0); |
| 896 | out = fossil_fopen(zFilename, "wb"); |
| 897 | if( out==0 ){ |
| 898 | #if _WIN32 |
| 899 | const char *zReserved = file_is_win_reserved(zFilename); |
| 900 | if( zReserved ){ |
| @@ -933,11 +955,11 @@ | |
| 955 | ** This is used to test and debug the blob_compress() routine. |
| 956 | */ |
| 957 | void compress_cmd(void){ |
| 958 | Blob f; |
| 959 | if( g.argc!=4 ) usage("INPUTFILE OUTPUTFILE"); |
| 960 | blob_read_from_file(&f, g.argv[2], ExtFILE); |
| 961 | blob_compress(&f, &f); |
| 962 | blob_write_to_file(&f, g.argv[3]); |
| 963 | } |
| 964 | |
| 965 | /* |
| @@ -992,12 +1014,12 @@ | |
| 1014 | ** This is used to test and debug the blob_compress2() routine. |
| 1015 | */ |
| 1016 | void compress2_cmd(void){ |
| 1017 | Blob f1, f2; |
| 1018 | if( g.argc!=5 ) usage("INPUTFILE1 INPUTFILE2 OUTPUTFILE"); |
| 1019 | blob_read_from_file(&f1, g.argv[2], ExtFILE); |
| 1020 | blob_read_from_file(&f2, g.argv[3], ExtFILE); |
| 1021 | blob_compress2(&f1, &f2, &f1); |
| 1022 | blob_write_to_file(&f1, g.argv[4]); |
| 1023 | } |
| 1024 | |
| 1025 | /* |
| @@ -1044,11 +1066,11 @@ | |
| 1066 | ** blob_compress() function. |
| 1067 | */ |
| 1068 | void uncompress_cmd(void){ |
| 1069 | Blob f; |
| 1070 | if( g.argc!=4 ) usage("INPUTFILE OUTPUTFILE"); |
| 1071 | blob_read_from_file(&f, g.argv[2], ExtFILE); |
| 1072 | blob_uncompress(&f, &f); |
| 1073 | blob_write_to_file(&f, g.argv[3]); |
| 1074 | } |
| 1075 | |
| 1076 | /* |
| @@ -1059,11 +1081,11 @@ | |
| 1081 | */ |
| 1082 | void test_cycle_compress(void){ |
| 1083 | int i; |
| 1084 | Blob b1, b2, b3; |
| 1085 | for(i=2; i<g.argc; i++){ |
| 1086 | blob_read_from_file(&b1, g.argv[i], ExtFILE); |
| 1087 | blob_compress(&b1, &b2); |
| 1088 | blob_uncompress(&b2, &b3); |
| 1089 | if( blob_compare(&b1, &b3) ){ |
| 1090 | fossil_fatal("compress/uncompress cycle failed for %s", g.argv[i]); |
| 1091 | } |
| 1092 |
+2
-2
| --- src/bundle.c | ||
| +++ src/bundle.c | ||
| @@ -55,11 +55,11 @@ | ||
| 55 | 55 | int doInit /* Initialize a new bundle, if true */ |
| 56 | 56 | ){ |
| 57 | 57 | int rc; |
| 58 | 58 | char *zErrMsg = 0; |
| 59 | 59 | char *zSql; |
| 60 | - if( !doInit && file_size(zFile)<0 ){ | |
| 60 | + if( !doInit && file_size(zFile, ExtFILE)<0 ){ | |
| 61 | 61 | fossil_fatal("no such file: %s", zFile); |
| 62 | 62 | } |
| 63 | 63 | assert( g.db ); |
| 64 | 64 | zSql = sqlite3_mprintf("ATTACH %Q AS %Q", zFile, zBName); |
| 65 | 65 | if( zSql==0 ) fossil_fatal("out of memory"); |
| @@ -161,11 +161,11 @@ | ||
| 161 | 161 | "INSERT INTO bblob(blobid, uuid, sz, delta, data, notes) " |
| 162 | 162 | "VALUES(NULL, $uuid, $sz, NULL, $data, $filename)"); |
| 163 | 163 | db_begin_transaction(); |
| 164 | 164 | for(i=4; i<g.argc; i++){ |
| 165 | 165 | int sz; |
| 166 | - blob_read_from_file(&content, g.argv[i]); | |
| 166 | + blob_read_from_file(&content, g.argv[i], ExtFILE); | |
| 167 | 167 | sz = blob_size(&content); |
| 168 | 168 | sha1sum_blob(&content, &hash); |
| 169 | 169 | blob_compress(&content, &content); |
| 170 | 170 | db_bind_text(&q, "$uuid", blob_str(&hash)); |
| 171 | 171 | db_bind_int(&q, "$sz", sz); |
| 172 | 172 |
| --- src/bundle.c | |
| +++ src/bundle.c | |
| @@ -55,11 +55,11 @@ | |
| 55 | int doInit /* Initialize a new bundle, if true */ |
| 56 | ){ |
| 57 | int rc; |
| 58 | char *zErrMsg = 0; |
| 59 | char *zSql; |
| 60 | if( !doInit && file_size(zFile)<0 ){ |
| 61 | fossil_fatal("no such file: %s", zFile); |
| 62 | } |
| 63 | assert( g.db ); |
| 64 | zSql = sqlite3_mprintf("ATTACH %Q AS %Q", zFile, zBName); |
| 65 | if( zSql==0 ) fossil_fatal("out of memory"); |
| @@ -161,11 +161,11 @@ | |
| 161 | "INSERT INTO bblob(blobid, uuid, sz, delta, data, notes) " |
| 162 | "VALUES(NULL, $uuid, $sz, NULL, $data, $filename)"); |
| 163 | db_begin_transaction(); |
| 164 | for(i=4; i<g.argc; i++){ |
| 165 | int sz; |
| 166 | blob_read_from_file(&content, g.argv[i]); |
| 167 | sz = blob_size(&content); |
| 168 | sha1sum_blob(&content, &hash); |
| 169 | blob_compress(&content, &content); |
| 170 | db_bind_text(&q, "$uuid", blob_str(&hash)); |
| 171 | db_bind_int(&q, "$sz", sz); |
| 172 |
| --- src/bundle.c | |
| +++ src/bundle.c | |
| @@ -55,11 +55,11 @@ | |
| 55 | int doInit /* Initialize a new bundle, if true */ |
| 56 | ){ |
| 57 | int rc; |
| 58 | char *zErrMsg = 0; |
| 59 | char *zSql; |
| 60 | if( !doInit && file_size(zFile, ExtFILE)<0 ){ |
| 61 | fossil_fatal("no such file: %s", zFile); |
| 62 | } |
| 63 | assert( g.db ); |
| 64 | zSql = sqlite3_mprintf("ATTACH %Q AS %Q", zFile, zBName); |
| 65 | if( zSql==0 ) fossil_fatal("out of memory"); |
| @@ -161,11 +161,11 @@ | |
| 161 | "INSERT INTO bblob(blobid, uuid, sz, delta, data, notes) " |
| 162 | "VALUES(NULL, $uuid, $sz, NULL, $data, $filename)"); |
| 163 | db_begin_transaction(); |
| 164 | for(i=4; i<g.argc; i++){ |
| 165 | int sz; |
| 166 | blob_read_from_file(&content, g.argv[i], ExtFILE); |
| 167 | sz = blob_size(&content); |
| 168 | sha1sum_blob(&content, &hash); |
| 169 | blob_compress(&content, &content); |
| 170 | db_bind_text(&q, "$uuid", blob_str(&hash)); |
| 171 | db_bind_int(&q, "$sz", sz); |
| 172 |
+3
-3
| --- src/cache.c | ||
| +++ src/cache.c | ||
| @@ -49,11 +49,11 @@ | ||
| 49 | 49 | i64 sz; |
| 50 | 50 | |
| 51 | 51 | zDbName = cacheName(); |
| 52 | 52 | if( zDbName==0 ) return 0; |
| 53 | 53 | if( bForce==0 ){ |
| 54 | - sz = file_size(zDbName); | |
| 54 | + sz = file_size(zDbName, ExtFILE); | |
| 55 | 55 | if( sz<=0 ){ |
| 56 | 56 | fossil_free(zDbName); |
| 57 | 57 | return 0; |
| 58 | 58 | } |
| 59 | 59 | } |
| @@ -317,11 +317,11 @@ | ||
| 317 | 317 | } |
| 318 | 318 | sqlite3_finalize(pStmt); |
| 319 | 319 | } |
| 320 | 320 | sqlite3_close(db); |
| 321 | 321 | fossil_print("Entries: %d Cache-file Size: %lld\n", |
| 322 | - nEntry, file_size(zDbName)); | |
| 322 | + nEntry, file_size(zDbName, ExtFILE)); | |
| 323 | 323 | fossil_free(zDbName); |
| 324 | 324 | } |
| 325 | 325 | }else if( strncmp(zCmd, "status", nCmd)==0 ){ |
| 326 | 326 | fossil_print("TBD...\n"); |
| 327 | 327 | }else{ |
| @@ -365,11 +365,11 @@ | ||
| 365 | 365 | } |
| 366 | 366 | sqlite3_finalize(pStmt); |
| 367 | 367 | @ </ol> |
| 368 | 368 | } |
| 369 | 369 | zDbName = cacheName(); |
| 370 | - bigSizeName(sizeof(zBuf), zBuf, file_size(zDbName)); | |
| 370 | + bigSizeName(sizeof(zBuf), zBuf, file_size(zDbName, ExtFILE)); | |
| 371 | 371 | @ <p>cache-file name: %h(zDbName)</p> |
| 372 | 372 | @ <p>cache-file size: %s(zBuf)</p> |
| 373 | 373 | fossil_free(zDbName); |
| 374 | 374 | sqlite3_close(db); |
| 375 | 375 | } |
| 376 | 376 |
| --- src/cache.c | |
| +++ src/cache.c | |
| @@ -49,11 +49,11 @@ | |
| 49 | i64 sz; |
| 50 | |
| 51 | zDbName = cacheName(); |
| 52 | if( zDbName==0 ) return 0; |
| 53 | if( bForce==0 ){ |
| 54 | sz = file_size(zDbName); |
| 55 | if( sz<=0 ){ |
| 56 | fossil_free(zDbName); |
| 57 | return 0; |
| 58 | } |
| 59 | } |
| @@ -317,11 +317,11 @@ | |
| 317 | } |
| 318 | sqlite3_finalize(pStmt); |
| 319 | } |
| 320 | sqlite3_close(db); |
| 321 | fossil_print("Entries: %d Cache-file Size: %lld\n", |
| 322 | nEntry, file_size(zDbName)); |
| 323 | fossil_free(zDbName); |
| 324 | } |
| 325 | }else if( strncmp(zCmd, "status", nCmd)==0 ){ |
| 326 | fossil_print("TBD...\n"); |
| 327 | }else{ |
| @@ -365,11 +365,11 @@ | |
| 365 | } |
| 366 | sqlite3_finalize(pStmt); |
| 367 | @ </ol> |
| 368 | } |
| 369 | zDbName = cacheName(); |
| 370 | bigSizeName(sizeof(zBuf), zBuf, file_size(zDbName)); |
| 371 | @ <p>cache-file name: %h(zDbName)</p> |
| 372 | @ <p>cache-file size: %s(zBuf)</p> |
| 373 | fossil_free(zDbName); |
| 374 | sqlite3_close(db); |
| 375 | } |
| 376 |
| --- src/cache.c | |
| +++ src/cache.c | |
| @@ -49,11 +49,11 @@ | |
| 49 | i64 sz; |
| 50 | |
| 51 | zDbName = cacheName(); |
| 52 | if( zDbName==0 ) return 0; |
| 53 | if( bForce==0 ){ |
| 54 | sz = file_size(zDbName, ExtFILE); |
| 55 | if( sz<=0 ){ |
| 56 | fossil_free(zDbName); |
| 57 | return 0; |
| 58 | } |
| 59 | } |
| @@ -317,11 +317,11 @@ | |
| 317 | } |
| 318 | sqlite3_finalize(pStmt); |
| 319 | } |
| 320 | sqlite3_close(db); |
| 321 | fossil_print("Entries: %d Cache-file Size: %lld\n", |
| 322 | nEntry, file_size(zDbName, ExtFILE)); |
| 323 | fossil_free(zDbName); |
| 324 | } |
| 325 | }else if( strncmp(zCmd, "status", nCmd)==0 ){ |
| 326 | fossil_print("TBD...\n"); |
| 327 | }else{ |
| @@ -365,11 +365,11 @@ | |
| 365 | } |
| 366 | sqlite3_finalize(pStmt); |
| 367 | @ </ol> |
| 368 | } |
| 369 | zDbName = cacheName(); |
| 370 | bigSizeName(sizeof(zBuf), zBuf, file_size(zDbName, ExtFILE)); |
| 371 | @ <p>cache-file name: %h(zDbName)</p> |
| 372 | @ <p>cache-file size: %s(zBuf)</p> |
| 373 | fossil_free(zDbName); |
| 374 | sqlite3_close(db); |
| 375 | } |
| 376 |
+10
-19
| --- src/checkin.c | ||
| +++ src/checkin.c | ||
| @@ -86,11 +86,11 @@ | ||
| 86 | 86 | blob_reset(&name); |
| 87 | 87 | }else{ |
| 88 | 88 | for(i=0; i<argc; i++){ |
| 89 | 89 | file_canonical_name(argv[i], &name, 0); |
| 90 | 90 | zName = blob_str(&name); |
| 91 | - isDir = file_wd_isdir(zName); | |
| 91 | + isDir = file_isdir(zName, RepoFILE); | |
| 92 | 92 | if( isDir==1 ){ |
| 93 | 93 | vfile_scan(&name, nRoot-1, scanFlags, pIgnore, 0); |
| 94 | 94 | }else if( isDir==0 ){ |
| 95 | 95 | fossil_warning("not found: %s", &zName[nRoot]); |
| 96 | 96 | }else if( file_access(zName, R_OK) ){ |
| @@ -209,11 +209,11 @@ | ||
| 209 | 209 | int isDeleted = db_column_int(&q, 3); |
| 210 | 210 | int isChnged = db_column_int(&q, 4); |
| 211 | 211 | int isNew = isManaged && !db_column_int(&q, 5); |
| 212 | 212 | int isRenamed = db_column_int(&q, 6); |
| 213 | 213 | char *zFullName = mprintf("%s%s", g.zLocalRoot, zPathname); |
| 214 | - int isMissing = !file_wd_isfile_or_link(zFullName); | |
| 214 | + int isMissing = !file_isfile_or_link(zFullName); | |
| 215 | 215 | |
| 216 | 216 | /* Determine the file change classification, if any. */ |
| 217 | 217 | if( isDeleted ){ |
| 218 | 218 | if( flags & C_DELETED ){ |
| 219 | 219 | zClass = "DELETED"; |
| @@ -254,11 +254,11 @@ | ||
| 254 | 254 | zClass = "SYMLINK"; |
| 255 | 255 | }else if( (flags & C_META) && isChnged==8 ){ |
| 256 | 256 | zClass = "UNEXEC"; |
| 257 | 257 | }else if( (flags & C_META) && isChnged==9 ){ |
| 258 | 258 | zClass = "UNLINK"; |
| 259 | - }else if( (flags & C_CONFLICT) && isChnged && !file_wd_islink(zFullName) | |
| 259 | + }else if( (flags & C_CONFLICT) && isChnged && !file_islink(zFullName) | |
| 260 | 260 | && file_contains_merge_marker(zFullName) ){ |
| 261 | 261 | zClass = "CONFLICT"; |
| 262 | 262 | }else if( (flags & (C_EDITED | C_CHANGED)) && isChnged |
| 263 | 263 | && (isChnged<2 || isChnged>9) ){ |
| 264 | 264 | zClass = "EDITED"; |
| @@ -764,11 +764,11 @@ | ||
| 764 | 764 | if( verboseFlag ){ |
| 765 | 765 | if( isNew ){ |
| 766 | 766 | type = "ADDED "; |
| 767 | 767 | }else if( isDeleted ){ |
| 768 | 768 | type = "DELETED "; |
| 769 | - }else if( !file_wd_isfile_or_link(zFullName) ){ | |
| 769 | + }else if( !file_isfile_or_link(zFullName) ){ | |
| 770 | 770 | if( file_access(zFullName, F_OK)==0 ){ |
| 771 | 771 | type = "NOT_A_FILE "; |
| 772 | 772 | }else{ |
| 773 | 773 | type = "MISSING "; |
| 774 | 774 | } |
| @@ -1221,11 +1221,11 @@ | ||
| 1221 | 1221 | fossil_print("%s\n", zCmd); |
| 1222 | 1222 | if( fossil_system(zCmd) ){ |
| 1223 | 1223 | fossil_fatal("editor aborted: \"%s\"", zCmd); |
| 1224 | 1224 | } |
| 1225 | 1225 | |
| 1226 | - blob_read_from_file(&reply, zFile); | |
| 1226 | + blob_read_from_file(&reply, zFile, ExtFILE); | |
| 1227 | 1227 | }else{ |
| 1228 | 1228 | char zIn[300]; |
| 1229 | 1229 | blob_zero(&reply); |
| 1230 | 1230 | while( fgets(zIn, sizeof(zIn), stdin)!=0 ){ |
| 1231 | 1231 | if( zIn[0]=='.' && (zIn[1]==0 || zIn[1]=='\r' || zIn[1]=='\n') ){ |
| @@ -1562,11 +1562,11 @@ | ||
| 1562 | 1562 | ** itself is actually selected to be part of this check-in. |
| 1563 | 1563 | */ |
| 1564 | 1564 | if( isSelected ){ |
| 1565 | 1565 | int mPerm; |
| 1566 | 1566 | |
| 1567 | - mPerm = file_wd_perm(blob_str(&filename)); | |
| 1567 | + mPerm = file_perm(blob_str(&filename), RepoFILE); | |
| 1568 | 1568 | isExe = ( mPerm==PERM_EXE ); |
| 1569 | 1569 | isLink = ( mPerm==PERM_LNK ); |
| 1570 | 1570 | } |
| 1571 | 1571 | #endif |
| 1572 | 1572 | if( isExe ){ |
| @@ -1908,15 +1908,11 @@ | ||
| 1908 | 1908 | zName = db_column_text(&q, 1); |
| 1909 | 1909 | crlfOk = db_column_int(&q, 2); |
| 1910 | 1910 | binOk = db_column_int(&q, 3); |
| 1911 | 1911 | encodingOk = db_column_int(&q, 4); |
| 1912 | 1912 | blob_zero(&content); |
| 1913 | - if( file_wd_islink(zFullname) ){ | |
| 1914 | - blob_read_link(&content, zFullname); | |
| 1915 | - }else{ | |
| 1916 | - blob_read_from_file(&content, zFullname); | |
| 1917 | - } | |
| 1913 | + blob_read_from_file(&content, zFullname, RepoFILE); | |
| 1918 | 1914 | blob_zero(&reason); |
| 1919 | 1915 | fileRc = commit_warning(&content, crlfOk, binOk, encodingOk, 2, |
| 1920 | 1916 | zFullname, &reason); |
| 1921 | 1917 | if( fileRc || verboseFlag ){ |
| 1922 | 1918 | fossil_print("%d\t%s\t%s\n", fileRc, zName, blob_str(&reason)); |
| @@ -2303,11 +2299,11 @@ | ||
| 2303 | 2299 | if( zComment ){ |
| 2304 | 2300 | blob_zero(&comment); |
| 2305 | 2301 | blob_append(&comment, zComment, -1); |
| 2306 | 2302 | }else if( zComFile ){ |
| 2307 | 2303 | blob_zero(&comment); |
| 2308 | - blob_read_from_file(&comment, zComFile); | |
| 2304 | + blob_read_from_file(&comment, zComFile, ExtFILE); | |
| 2309 | 2305 | blob_to_utf8_no_bom(&comment, 1); |
| 2310 | 2306 | }else if( dryRunFlag ){ |
| 2311 | 2307 | blob_zero(&comment); |
| 2312 | 2308 | }else if( !noPrompt ){ |
| 2313 | 2309 | char *zInit = db_text(0, "SELECT value FROM vvar WHERE name='ci-comment'"); |
| @@ -2374,16 +2370,11 @@ | ||
| 2374 | 2370 | crlfOk = db_column_int(&q, 3); |
| 2375 | 2371 | binOk = db_column_int(&q, 4); |
| 2376 | 2372 | encodingOk = db_column_int(&q, 5); |
| 2377 | 2373 | |
| 2378 | 2374 | blob_zero(&content); |
| 2379 | - if( file_wd_islink(zFullname) ){ | |
| 2380 | - /* Instead of file content, put link destination path */ | |
| 2381 | - blob_read_link(&content, zFullname); | |
| 2382 | - }else{ | |
| 2383 | - blob_read_from_file(&content, zFullname); | |
| 2384 | - } | |
| 2375 | + blob_read_from_file(&content, zFullname, RepoFILE); | |
| 2385 | 2376 | /* Do not emit any warnings when they are disabled. */ |
| 2386 | 2377 | if( !noWarningFlag ){ |
| 2387 | 2378 | abortCommit |= commit_warning(&content, crlfOk, binOk, |
| 2388 | 2379 | encodingOk, noPrompt, |
| 2389 | 2380 | zFullname, 0); |
| @@ -2491,11 +2482,11 @@ | ||
| 2491 | 2482 | } |
| 2492 | 2483 | if( outputManifest & MFESTFLG_RAW ){ |
| 2493 | 2484 | zManifestFile = mprintf("%smanifest", g.zLocalRoot); |
| 2494 | 2485 | blob_write_to_file(&manifest, zManifestFile); |
| 2495 | 2486 | blob_reset(&manifest); |
| 2496 | - blob_read_from_file(&manifest, zManifestFile); | |
| 2487 | + blob_read_from_file(&manifest, zManifestFile, ExtFILE); | |
| 2497 | 2488 | free(zManifestFile); |
| 2498 | 2489 | } |
| 2499 | 2490 | |
| 2500 | 2491 | nvid = content_put(&manifest); |
| 2501 | 2492 | if( nvid==0 ){ |
| 2502 | 2493 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -86,11 +86,11 @@ | |
| 86 | blob_reset(&name); |
| 87 | }else{ |
| 88 | for(i=0; i<argc; i++){ |
| 89 | file_canonical_name(argv[i], &name, 0); |
| 90 | zName = blob_str(&name); |
| 91 | isDir = file_wd_isdir(zName); |
| 92 | if( isDir==1 ){ |
| 93 | vfile_scan(&name, nRoot-1, scanFlags, pIgnore, 0); |
| 94 | }else if( isDir==0 ){ |
| 95 | fossil_warning("not found: %s", &zName[nRoot]); |
| 96 | }else if( file_access(zName, R_OK) ){ |
| @@ -209,11 +209,11 @@ | |
| 209 | int isDeleted = db_column_int(&q, 3); |
| 210 | int isChnged = db_column_int(&q, 4); |
| 211 | int isNew = isManaged && !db_column_int(&q, 5); |
| 212 | int isRenamed = db_column_int(&q, 6); |
| 213 | char *zFullName = mprintf("%s%s", g.zLocalRoot, zPathname); |
| 214 | int isMissing = !file_wd_isfile_or_link(zFullName); |
| 215 | |
| 216 | /* Determine the file change classification, if any. */ |
| 217 | if( isDeleted ){ |
| 218 | if( flags & C_DELETED ){ |
| 219 | zClass = "DELETED"; |
| @@ -254,11 +254,11 @@ | |
| 254 | zClass = "SYMLINK"; |
| 255 | }else if( (flags & C_META) && isChnged==8 ){ |
| 256 | zClass = "UNEXEC"; |
| 257 | }else if( (flags & C_META) && isChnged==9 ){ |
| 258 | zClass = "UNLINK"; |
| 259 | }else if( (flags & C_CONFLICT) && isChnged && !file_wd_islink(zFullName) |
| 260 | && file_contains_merge_marker(zFullName) ){ |
| 261 | zClass = "CONFLICT"; |
| 262 | }else if( (flags & (C_EDITED | C_CHANGED)) && isChnged |
| 263 | && (isChnged<2 || isChnged>9) ){ |
| 264 | zClass = "EDITED"; |
| @@ -764,11 +764,11 @@ | |
| 764 | if( verboseFlag ){ |
| 765 | if( isNew ){ |
| 766 | type = "ADDED "; |
| 767 | }else if( isDeleted ){ |
| 768 | type = "DELETED "; |
| 769 | }else if( !file_wd_isfile_or_link(zFullName) ){ |
| 770 | if( file_access(zFullName, F_OK)==0 ){ |
| 771 | type = "NOT_A_FILE "; |
| 772 | }else{ |
| 773 | type = "MISSING "; |
| 774 | } |
| @@ -1221,11 +1221,11 @@ | |
| 1221 | fossil_print("%s\n", zCmd); |
| 1222 | if( fossil_system(zCmd) ){ |
| 1223 | fossil_fatal("editor aborted: \"%s\"", zCmd); |
| 1224 | } |
| 1225 | |
| 1226 | blob_read_from_file(&reply, zFile); |
| 1227 | }else{ |
| 1228 | char zIn[300]; |
| 1229 | blob_zero(&reply); |
| 1230 | while( fgets(zIn, sizeof(zIn), stdin)!=0 ){ |
| 1231 | if( zIn[0]=='.' && (zIn[1]==0 || zIn[1]=='\r' || zIn[1]=='\n') ){ |
| @@ -1562,11 +1562,11 @@ | |
| 1562 | ** itself is actually selected to be part of this check-in. |
| 1563 | */ |
| 1564 | if( isSelected ){ |
| 1565 | int mPerm; |
| 1566 | |
| 1567 | mPerm = file_wd_perm(blob_str(&filename)); |
| 1568 | isExe = ( mPerm==PERM_EXE ); |
| 1569 | isLink = ( mPerm==PERM_LNK ); |
| 1570 | } |
| 1571 | #endif |
| 1572 | if( isExe ){ |
| @@ -1908,15 +1908,11 @@ | |
| 1908 | zName = db_column_text(&q, 1); |
| 1909 | crlfOk = db_column_int(&q, 2); |
| 1910 | binOk = db_column_int(&q, 3); |
| 1911 | encodingOk = db_column_int(&q, 4); |
| 1912 | blob_zero(&content); |
| 1913 | if( file_wd_islink(zFullname) ){ |
| 1914 | blob_read_link(&content, zFullname); |
| 1915 | }else{ |
| 1916 | blob_read_from_file(&content, zFullname); |
| 1917 | } |
| 1918 | blob_zero(&reason); |
| 1919 | fileRc = commit_warning(&content, crlfOk, binOk, encodingOk, 2, |
| 1920 | zFullname, &reason); |
| 1921 | if( fileRc || verboseFlag ){ |
| 1922 | fossil_print("%d\t%s\t%s\n", fileRc, zName, blob_str(&reason)); |
| @@ -2303,11 +2299,11 @@ | |
| 2303 | if( zComment ){ |
| 2304 | blob_zero(&comment); |
| 2305 | blob_append(&comment, zComment, -1); |
| 2306 | }else if( zComFile ){ |
| 2307 | blob_zero(&comment); |
| 2308 | blob_read_from_file(&comment, zComFile); |
| 2309 | blob_to_utf8_no_bom(&comment, 1); |
| 2310 | }else if( dryRunFlag ){ |
| 2311 | blob_zero(&comment); |
| 2312 | }else if( !noPrompt ){ |
| 2313 | char *zInit = db_text(0, "SELECT value FROM vvar WHERE name='ci-comment'"); |
| @@ -2374,16 +2370,11 @@ | |
| 2374 | crlfOk = db_column_int(&q, 3); |
| 2375 | binOk = db_column_int(&q, 4); |
| 2376 | encodingOk = db_column_int(&q, 5); |
| 2377 | |
| 2378 | blob_zero(&content); |
| 2379 | if( file_wd_islink(zFullname) ){ |
| 2380 | /* Instead of file content, put link destination path */ |
| 2381 | blob_read_link(&content, zFullname); |
| 2382 | }else{ |
| 2383 | blob_read_from_file(&content, zFullname); |
| 2384 | } |
| 2385 | /* Do not emit any warnings when they are disabled. */ |
| 2386 | if( !noWarningFlag ){ |
| 2387 | abortCommit |= commit_warning(&content, crlfOk, binOk, |
| 2388 | encodingOk, noPrompt, |
| 2389 | zFullname, 0); |
| @@ -2491,11 +2482,11 @@ | |
| 2491 | } |
| 2492 | if( outputManifest & MFESTFLG_RAW ){ |
| 2493 | zManifestFile = mprintf("%smanifest", g.zLocalRoot); |
| 2494 | blob_write_to_file(&manifest, zManifestFile); |
| 2495 | blob_reset(&manifest); |
| 2496 | blob_read_from_file(&manifest, zManifestFile); |
| 2497 | free(zManifestFile); |
| 2498 | } |
| 2499 | |
| 2500 | nvid = content_put(&manifest); |
| 2501 | if( nvid==0 ){ |
| 2502 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -86,11 +86,11 @@ | |
| 86 | blob_reset(&name); |
| 87 | }else{ |
| 88 | for(i=0; i<argc; i++){ |
| 89 | file_canonical_name(argv[i], &name, 0); |
| 90 | zName = blob_str(&name); |
| 91 | isDir = file_isdir(zName, RepoFILE); |
| 92 | if( isDir==1 ){ |
| 93 | vfile_scan(&name, nRoot-1, scanFlags, pIgnore, 0); |
| 94 | }else if( isDir==0 ){ |
| 95 | fossil_warning("not found: %s", &zName[nRoot]); |
| 96 | }else if( file_access(zName, R_OK) ){ |
| @@ -209,11 +209,11 @@ | |
| 209 | int isDeleted = db_column_int(&q, 3); |
| 210 | int isChnged = db_column_int(&q, 4); |
| 211 | int isNew = isManaged && !db_column_int(&q, 5); |
| 212 | int isRenamed = db_column_int(&q, 6); |
| 213 | char *zFullName = mprintf("%s%s", g.zLocalRoot, zPathname); |
| 214 | int isMissing = !file_isfile_or_link(zFullName); |
| 215 | |
| 216 | /* Determine the file change classification, if any. */ |
| 217 | if( isDeleted ){ |
| 218 | if( flags & C_DELETED ){ |
| 219 | zClass = "DELETED"; |
| @@ -254,11 +254,11 @@ | |
| 254 | zClass = "SYMLINK"; |
| 255 | }else if( (flags & C_META) && isChnged==8 ){ |
| 256 | zClass = "UNEXEC"; |
| 257 | }else if( (flags & C_META) && isChnged==9 ){ |
| 258 | zClass = "UNLINK"; |
| 259 | }else if( (flags & C_CONFLICT) && isChnged && !file_islink(zFullName) |
| 260 | && file_contains_merge_marker(zFullName) ){ |
| 261 | zClass = "CONFLICT"; |
| 262 | }else if( (flags & (C_EDITED | C_CHANGED)) && isChnged |
| 263 | && (isChnged<2 || isChnged>9) ){ |
| 264 | zClass = "EDITED"; |
| @@ -764,11 +764,11 @@ | |
| 764 | if( verboseFlag ){ |
| 765 | if( isNew ){ |
| 766 | type = "ADDED "; |
| 767 | }else if( isDeleted ){ |
| 768 | type = "DELETED "; |
| 769 | }else if( !file_isfile_or_link(zFullName) ){ |
| 770 | if( file_access(zFullName, F_OK)==0 ){ |
| 771 | type = "NOT_A_FILE "; |
| 772 | }else{ |
| 773 | type = "MISSING "; |
| 774 | } |
| @@ -1221,11 +1221,11 @@ | |
| 1221 | fossil_print("%s\n", zCmd); |
| 1222 | if( fossil_system(zCmd) ){ |
| 1223 | fossil_fatal("editor aborted: \"%s\"", zCmd); |
| 1224 | } |
| 1225 | |
| 1226 | blob_read_from_file(&reply, zFile, ExtFILE); |
| 1227 | }else{ |
| 1228 | char zIn[300]; |
| 1229 | blob_zero(&reply); |
| 1230 | while( fgets(zIn, sizeof(zIn), stdin)!=0 ){ |
| 1231 | if( zIn[0]=='.' && (zIn[1]==0 || zIn[1]=='\r' || zIn[1]=='\n') ){ |
| @@ -1562,11 +1562,11 @@ | |
| 1562 | ** itself is actually selected to be part of this check-in. |
| 1563 | */ |
| 1564 | if( isSelected ){ |
| 1565 | int mPerm; |
| 1566 | |
| 1567 | mPerm = file_perm(blob_str(&filename), RepoFILE); |
| 1568 | isExe = ( mPerm==PERM_EXE ); |
| 1569 | isLink = ( mPerm==PERM_LNK ); |
| 1570 | } |
| 1571 | #endif |
| 1572 | if( isExe ){ |
| @@ -1908,15 +1908,11 @@ | |
| 1908 | zName = db_column_text(&q, 1); |
| 1909 | crlfOk = db_column_int(&q, 2); |
| 1910 | binOk = db_column_int(&q, 3); |
| 1911 | encodingOk = db_column_int(&q, 4); |
| 1912 | blob_zero(&content); |
| 1913 | blob_read_from_file(&content, zFullname, RepoFILE); |
| 1914 | blob_zero(&reason); |
| 1915 | fileRc = commit_warning(&content, crlfOk, binOk, encodingOk, 2, |
| 1916 | zFullname, &reason); |
| 1917 | if( fileRc || verboseFlag ){ |
| 1918 | fossil_print("%d\t%s\t%s\n", fileRc, zName, blob_str(&reason)); |
| @@ -2303,11 +2299,11 @@ | |
| 2299 | if( zComment ){ |
| 2300 | blob_zero(&comment); |
| 2301 | blob_append(&comment, zComment, -1); |
| 2302 | }else if( zComFile ){ |
| 2303 | blob_zero(&comment); |
| 2304 | blob_read_from_file(&comment, zComFile, ExtFILE); |
| 2305 | blob_to_utf8_no_bom(&comment, 1); |
| 2306 | }else if( dryRunFlag ){ |
| 2307 | blob_zero(&comment); |
| 2308 | }else if( !noPrompt ){ |
| 2309 | char *zInit = db_text(0, "SELECT value FROM vvar WHERE name='ci-comment'"); |
| @@ -2374,16 +2370,11 @@ | |
| 2370 | crlfOk = db_column_int(&q, 3); |
| 2371 | binOk = db_column_int(&q, 4); |
| 2372 | encodingOk = db_column_int(&q, 5); |
| 2373 | |
| 2374 | blob_zero(&content); |
| 2375 | blob_read_from_file(&content, zFullname, RepoFILE); |
| 2376 | /* Do not emit any warnings when they are disabled. */ |
| 2377 | if( !noWarningFlag ){ |
| 2378 | abortCommit |= commit_warning(&content, crlfOk, binOk, |
| 2379 | encodingOk, noPrompt, |
| 2380 | zFullname, 0); |
| @@ -2491,11 +2482,11 @@ | |
| 2482 | } |
| 2483 | if( outputManifest & MFESTFLG_RAW ){ |
| 2484 | zManifestFile = mprintf("%smanifest", g.zLocalRoot); |
| 2485 | blob_write_to_file(&manifest, zManifestFile); |
| 2486 | blob_reset(&manifest); |
| 2487 | blob_read_from_file(&manifest, zManifestFile, ExtFILE); |
| 2488 | free(zManifestFile); |
| 2489 | } |
| 2490 | |
| 2491 | nvid = content_put(&manifest); |
| 2492 | if( nvid==0 ){ |
| 2493 |
+1
-1
| --- src/checkout.c | ||
| +++ src/checkout.c | ||
| @@ -114,11 +114,11 @@ | ||
| 114 | 114 | manifest_file_rewind(pManifest); |
| 115 | 115 | while( (pFile = manifest_file_next(pManifest, 0))!=0 ){ |
| 116 | 116 | int isExe; |
| 117 | 117 | blob_append(&filename, pFile->zName, -1); |
| 118 | 118 | isExe = pFile->zPerm && strstr(pFile->zPerm, "x"); |
| 119 | - file_wd_setexe(blob_str(&filename), isExe); | |
| 119 | + file_setexe(blob_str(&filename), isExe); | |
| 120 | 120 | set_or_clear_isexe(pFile->zName, vid, isExe); |
| 121 | 121 | blob_resize(&filename, baseLen); |
| 122 | 122 | } |
| 123 | 123 | blob_reset(&filename); |
| 124 | 124 | manifest_destroy(pManifest); |
| 125 | 125 |
| --- src/checkout.c | |
| +++ src/checkout.c | |
| @@ -114,11 +114,11 @@ | |
| 114 | manifest_file_rewind(pManifest); |
| 115 | while( (pFile = manifest_file_next(pManifest, 0))!=0 ){ |
| 116 | int isExe; |
| 117 | blob_append(&filename, pFile->zName, -1); |
| 118 | isExe = pFile->zPerm && strstr(pFile->zPerm, "x"); |
| 119 | file_wd_setexe(blob_str(&filename), isExe); |
| 120 | set_or_clear_isexe(pFile->zName, vid, isExe); |
| 121 | blob_resize(&filename, baseLen); |
| 122 | } |
| 123 | blob_reset(&filename); |
| 124 | manifest_destroy(pManifest); |
| 125 |
| --- src/checkout.c | |
| +++ src/checkout.c | |
| @@ -114,11 +114,11 @@ | |
| 114 | manifest_file_rewind(pManifest); |
| 115 | while( (pFile = manifest_file_next(pManifest, 0))!=0 ){ |
| 116 | int isExe; |
| 117 | blob_append(&filename, pFile->zName, -1); |
| 118 | isExe = pFile->zPerm && strstr(pFile->zPerm, "x"); |
| 119 | file_setexe(blob_str(&filename), isExe); |
| 120 | set_or_clear_isexe(pFile->zName, vid, isExe); |
| 121 | blob_resize(&filename, baseLen); |
| 122 | } |
| 123 | blob_reset(&filename); |
| 124 | manifest_destroy(pManifest); |
| 125 |
+1
-1
| --- src/clearsign.c | ||
| +++ src/clearsign.c | ||
| @@ -46,11 +46,11 @@ | ||
| 46 | 46 | if( rc==0 ){ |
| 47 | 47 | if( pOut==pIn ){ |
| 48 | 48 | blob_reset(pIn); |
| 49 | 49 | } |
| 50 | 50 | blob_zero(pOut); |
| 51 | - blob_read_from_file(pOut, zIn); | |
| 51 | + blob_read_from_file(pOut, zIn, ExtFILE); | |
| 52 | 52 | }else{ |
| 53 | 53 | if( pOut!=pIn ){ |
| 54 | 54 | blob_copy(pOut, pIn); |
| 55 | 55 | } |
| 56 | 56 | } |
| 57 | 57 |
| --- src/clearsign.c | |
| +++ src/clearsign.c | |
| @@ -46,11 +46,11 @@ | |
| 46 | if( rc==0 ){ |
| 47 | if( pOut==pIn ){ |
| 48 | blob_reset(pIn); |
| 49 | } |
| 50 | blob_zero(pOut); |
| 51 | blob_read_from_file(pOut, zIn); |
| 52 | }else{ |
| 53 | if( pOut!=pIn ){ |
| 54 | blob_copy(pOut, pIn); |
| 55 | } |
| 56 | } |
| 57 |
| --- src/clearsign.c | |
| +++ src/clearsign.c | |
| @@ -46,11 +46,11 @@ | |
| 46 | if( rc==0 ){ |
| 47 | if( pOut==pIn ){ |
| 48 | blob_reset(pIn); |
| 49 | } |
| 50 | blob_zero(pOut); |
| 51 | blob_read_from_file(pOut, zIn, ExtFILE); |
| 52 | }else{ |
| 53 | if( pOut!=pIn ){ |
| 54 | blob_copy(pOut, pIn); |
| 55 | } |
| 56 | } |
| 57 |
+1
-1
| --- src/clone.c | ||
| +++ src/clone.c | ||
| @@ -144,11 +144,11 @@ | ||
| 144 | 144 | |
| 145 | 145 | if( g.argc < 4 ){ |
| 146 | 146 | usage("?OPTIONS? FILE-OR-URL NEW-REPOSITORY"); |
| 147 | 147 | } |
| 148 | 148 | db_open_config(0, 0); |
| 149 | - if( -1 != file_size(g.argv[3]) ){ | |
| 149 | + if( -1 != file_size(g.argv[3], ExtFILE) ){ | |
| 150 | 150 | fossil_fatal("file already exists: %s", g.argv[3]); |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | url_parse(g.argv[2], urlFlags); |
| 154 | 154 | if( zDefaultUser==0 && g.url.user!=0 ) zDefaultUser = g.url.user; |
| 155 | 155 |
| --- src/clone.c | |
| +++ src/clone.c | |
| @@ -144,11 +144,11 @@ | |
| 144 | |
| 145 | if( g.argc < 4 ){ |
| 146 | usage("?OPTIONS? FILE-OR-URL NEW-REPOSITORY"); |
| 147 | } |
| 148 | db_open_config(0, 0); |
| 149 | if( -1 != file_size(g.argv[3]) ){ |
| 150 | fossil_fatal("file already exists: %s", g.argv[3]); |
| 151 | } |
| 152 | |
| 153 | url_parse(g.argv[2], urlFlags); |
| 154 | if( zDefaultUser==0 && g.url.user!=0 ) zDefaultUser = g.url.user; |
| 155 |
| --- src/clone.c | |
| +++ src/clone.c | |
| @@ -144,11 +144,11 @@ | |
| 144 | |
| 145 | if( g.argc < 4 ){ |
| 146 | usage("?OPTIONS? FILE-OR-URL NEW-REPOSITORY"); |
| 147 | } |
| 148 | db_open_config(0, 0); |
| 149 | if( -1 != file_size(g.argv[3], ExtFILE) ){ |
| 150 | fossil_fatal("file already exists: %s", g.argv[3]); |
| 151 | } |
| 152 | |
| 153 | url_parse(g.argv[2], urlFlags); |
| 154 | if( zDefaultUser==0 && g.url.user!=0 ) zDefaultUser = g.url.user; |
| 155 |
+2
-2
| --- src/comformat.c | ||
| +++ src/comformat.c | ||
| @@ -484,15 +484,15 @@ | ||
| 484 | 484 | }else{ |
| 485 | 485 | zOrigText = 0; |
| 486 | 486 | } |
| 487 | 487 | if( fromFile ){ |
| 488 | 488 | Blob fileData; |
| 489 | - blob_read_from_file(&fileData, zText); | |
| 489 | + blob_read_from_file(&fileData, zText, ExtFILE); | |
| 490 | 490 | zText = mprintf("%s", blob_str(&fileData)); |
| 491 | 491 | blob_reset(&fileData); |
| 492 | 492 | if( zOrigText ){ |
| 493 | - blob_read_from_file(&fileData, zOrigText); | |
| 493 | + blob_read_from_file(&fileData, zOrigText, ExtFILE); | |
| 494 | 494 | zOrigText = mprintf("%s", blob_str(&fileData)); |
| 495 | 495 | blob_reset(&fileData); |
| 496 | 496 | } |
| 497 | 497 | } |
| 498 | 498 | if( decode ){ |
| 499 | 499 |
| --- src/comformat.c | |
| +++ src/comformat.c | |
| @@ -484,15 +484,15 @@ | |
| 484 | }else{ |
| 485 | zOrigText = 0; |
| 486 | } |
| 487 | if( fromFile ){ |
| 488 | Blob fileData; |
| 489 | blob_read_from_file(&fileData, zText); |
| 490 | zText = mprintf("%s", blob_str(&fileData)); |
| 491 | blob_reset(&fileData); |
| 492 | if( zOrigText ){ |
| 493 | blob_read_from_file(&fileData, zOrigText); |
| 494 | zOrigText = mprintf("%s", blob_str(&fileData)); |
| 495 | blob_reset(&fileData); |
| 496 | } |
| 497 | } |
| 498 | if( decode ){ |
| 499 |
| --- src/comformat.c | |
| +++ src/comformat.c | |
| @@ -484,15 +484,15 @@ | |
| 484 | }else{ |
| 485 | zOrigText = 0; |
| 486 | } |
| 487 | if( fromFile ){ |
| 488 | Blob fileData; |
| 489 | blob_read_from_file(&fileData, zText, ExtFILE); |
| 490 | zText = mprintf("%s", blob_str(&fileData)); |
| 491 | blob_reset(&fileData); |
| 492 | if( zOrigText ){ |
| 493 | blob_read_from_file(&fileData, zOrigText, ExtFILE); |
| 494 | zOrigText = mprintf("%s", blob_str(&fileData)); |
| 495 | blob_reset(&fileData); |
| 496 | } |
| 497 | } |
| 498 | if( decode ){ |
| 499 |
+3
-3
| --- src/configure.c | ||
| +++ src/configure.c | ||
| @@ -729,11 +729,11 @@ | ||
| 729 | 729 | if( strncmp(zMethod, "import", n)==0 |
| 730 | 730 | || strncmp(zMethod, "merge", n)==0 ){ |
| 731 | 731 | Blob in; |
| 732 | 732 | int groupMask; |
| 733 | 733 | if( g.argc!=4 ) usage(mprintf("%s FILENAME",zMethod)); |
| 734 | - blob_read_from_file(&in, g.argv[3]); | |
| 734 | + blob_read_from_file(&in, g.argv[3], ExtFILE); | |
| 735 | 735 | db_begin_transaction(); |
| 736 | 736 | if( zMethod[0]=='i' ){ |
| 737 | 737 | groupMask = CONFIGSET_ALL | CONFIGSET_OVERWRITE; |
| 738 | 738 | }else{ |
| 739 | 739 | groupMask = CONFIGSET_ALL; |
| @@ -983,13 +983,13 @@ | ||
| 983 | 983 | usage("VAR ?VALUE? ?--file FILE?"); |
| 984 | 984 | } |
| 985 | 985 | zVar = g.argv[2]; |
| 986 | 986 | if( zFile ){ |
| 987 | 987 | if( zBlob ) fossil_fatal("cannot do both --file or --blob"); |
| 988 | - blob_read_from_file(&x, zFile); | |
| 988 | + blob_read_from_file(&x, zFile, ExtFILE); | |
| 989 | 989 | }else if( zBlob ){ |
| 990 | - blob_read_from_file(&x, zBlob); | |
| 990 | + blob_read_from_file(&x, zBlob, ExtFILE); | |
| 991 | 991 | }else{ |
| 992 | 992 | blob_init(&x,g.argv[3],-1); |
| 993 | 993 | } |
| 994 | 994 | db_prepare(&ins, |
| 995 | 995 | "REPLACE INTO config(name,value,mtime)" |
| 996 | 996 |
| --- src/configure.c | |
| +++ src/configure.c | |
| @@ -729,11 +729,11 @@ | |
| 729 | if( strncmp(zMethod, "import", n)==0 |
| 730 | || strncmp(zMethod, "merge", n)==0 ){ |
| 731 | Blob in; |
| 732 | int groupMask; |
| 733 | if( g.argc!=4 ) usage(mprintf("%s FILENAME",zMethod)); |
| 734 | blob_read_from_file(&in, g.argv[3]); |
| 735 | db_begin_transaction(); |
| 736 | if( zMethod[0]=='i' ){ |
| 737 | groupMask = CONFIGSET_ALL | CONFIGSET_OVERWRITE; |
| 738 | }else{ |
| 739 | groupMask = CONFIGSET_ALL; |
| @@ -983,13 +983,13 @@ | |
| 983 | usage("VAR ?VALUE? ?--file FILE?"); |
| 984 | } |
| 985 | zVar = g.argv[2]; |
| 986 | if( zFile ){ |
| 987 | if( zBlob ) fossil_fatal("cannot do both --file or --blob"); |
| 988 | blob_read_from_file(&x, zFile); |
| 989 | }else if( zBlob ){ |
| 990 | blob_read_from_file(&x, zBlob); |
| 991 | }else{ |
| 992 | blob_init(&x,g.argv[3],-1); |
| 993 | } |
| 994 | db_prepare(&ins, |
| 995 | "REPLACE INTO config(name,value,mtime)" |
| 996 |
| --- src/configure.c | |
| +++ src/configure.c | |
| @@ -729,11 +729,11 @@ | |
| 729 | if( strncmp(zMethod, "import", n)==0 |
| 730 | || strncmp(zMethod, "merge", n)==0 ){ |
| 731 | Blob in; |
| 732 | int groupMask; |
| 733 | if( g.argc!=4 ) usage(mprintf("%s FILENAME",zMethod)); |
| 734 | blob_read_from_file(&in, g.argv[3], ExtFILE); |
| 735 | db_begin_transaction(); |
| 736 | if( zMethod[0]=='i' ){ |
| 737 | groupMask = CONFIGSET_ALL | CONFIGSET_OVERWRITE; |
| 738 | }else{ |
| 739 | groupMask = CONFIGSET_ALL; |
| @@ -983,13 +983,13 @@ | |
| 983 | usage("VAR ?VALUE? ?--file FILE?"); |
| 984 | } |
| 985 | zVar = g.argv[2]; |
| 986 | if( zFile ){ |
| 987 | if( zBlob ) fossil_fatal("cannot do both --file or --blob"); |
| 988 | blob_read_from_file(&x, zFile, ExtFILE); |
| 989 | }else if( zBlob ){ |
| 990 | blob_read_from_file(&x, zBlob, ExtFILE); |
| 991 | }else{ |
| 992 | blob_init(&x,g.argv[3],-1); |
| 993 | } |
| 994 | db_prepare(&ins, |
| 995 | "REPLACE INTO config(name,value,mtime)" |
| 996 |
+1
-1
| --- src/content.c | ||
| +++ src/content.c | ||
| @@ -705,11 +705,11 @@ | ||
| 705 | 705 | int rid; |
| 706 | 706 | Blob content; |
| 707 | 707 | if( g.argc!=3 ) usage("FILENAME"); |
| 708 | 708 | db_must_be_within_tree(); |
| 709 | 709 | user_select(); |
| 710 | - blob_read_from_file(&content, g.argv[2]); | |
| 710 | + blob_read_from_file(&content, g.argv[2], ExtFILE); | |
| 711 | 711 | rid = content_put(&content); |
| 712 | 712 | fossil_print("inserted as record %d\n", rid); |
| 713 | 713 | } |
| 714 | 714 | |
| 715 | 715 | /* |
| 716 | 716 |
| --- src/content.c | |
| +++ src/content.c | |
| @@ -705,11 +705,11 @@ | |
| 705 | int rid; |
| 706 | Blob content; |
| 707 | if( g.argc!=3 ) usage("FILENAME"); |
| 708 | db_must_be_within_tree(); |
| 709 | user_select(); |
| 710 | blob_read_from_file(&content, g.argv[2]); |
| 711 | rid = content_put(&content); |
| 712 | fossil_print("inserted as record %d\n", rid); |
| 713 | } |
| 714 | |
| 715 | /* |
| 716 |
| --- src/content.c | |
| +++ src/content.c | |
| @@ -705,11 +705,11 @@ | |
| 705 | int rid; |
| 706 | Blob content; |
| 707 | if( g.argc!=3 ) usage("FILENAME"); |
| 708 | db_must_be_within_tree(); |
| 709 | user_select(); |
| 710 | blob_read_from_file(&content, g.argv[2], ExtFILE); |
| 711 | rid = content_put(&content); |
| 712 | fossil_print("inserted as record %d\n", rid); |
| 713 | } |
| 714 | |
| 715 | /* |
| 716 |
M
src/db.c
+11
-10
| --- src/db.c | ||
| +++ src/db.c | ||
| @@ -1274,21 +1274,21 @@ | ||
| 1274 | 1274 | if( isOptional ) return 0; |
| 1275 | 1275 | fossil_fatal("cannot locate home directory - please set the " |
| 1276 | 1276 | "FOSSIL_HOME or HOME environment variables"); |
| 1277 | 1277 | } |
| 1278 | 1278 | #endif |
| 1279 | - if( file_isdir(zHome)!=1 ){ | |
| 1279 | + if( file_isdir(zHome, ExtFILE)!=1 ){ | |
| 1280 | 1280 | if( isOptional ) return 0; |
| 1281 | 1281 | fossil_fatal("invalid home directory: %s", zHome); |
| 1282 | 1282 | } |
| 1283 | 1283 | #if defined(_WIN32) || defined(__CYGWIN__) |
| 1284 | 1284 | /* . filenames give some window systems problems and many apps problems */ |
| 1285 | 1285 | zDbName = mprintf("%//_fossil", zHome); |
| 1286 | 1286 | #else |
| 1287 | 1287 | zDbName = mprintf("%s/.fossil", zHome); |
| 1288 | 1288 | #endif |
| 1289 | - if( file_size(zDbName)<1024*3 ){ | |
| 1289 | + if( file_size(zDbName, ExtFILE)<1024*3 ){ | |
| 1290 | 1290 | if( file_access(zHome, W_OK) ){ |
| 1291 | 1291 | if( isOptional ) return 0; |
| 1292 | 1292 | fossil_fatal("home directory %s must be writeable", zHome); |
| 1293 | 1293 | } |
| 1294 | 1294 | db_init_database(zDbName, zConfigSchema, (char*)0); |
| @@ -1352,11 +1352,11 @@ | ||
| 1352 | 1352 | static int isValidLocalDb(const char *zDbName){ |
| 1353 | 1353 | i64 lsize; |
| 1354 | 1354 | char *zVFileDef; |
| 1355 | 1355 | |
| 1356 | 1356 | if( file_access(zDbName, F_OK) ) return 0; |
| 1357 | - lsize = file_size(zDbName); | |
| 1357 | + lsize = file_size(zDbName, ExtFILE); | |
| 1358 | 1358 | if( lsize%1024!=0 || lsize<4096 ) return 0; |
| 1359 | 1359 | db_open_or_attach(zDbName, "localdb"); |
| 1360 | 1360 | zVFileDef = db_text(0, "SELECT sql FROM localdb.sqlite_master" |
| 1361 | 1361 | " WHERE name=='vfile'"); |
| 1362 | 1362 | if( zVFileDef==0 ) return 0; |
| @@ -1493,11 +1493,11 @@ | ||
| 1493 | 1493 | } |
| 1494 | 1494 | if( zDbName==0 ){ |
| 1495 | 1495 | db_err("unable to find the name of a repository database"); |
| 1496 | 1496 | } |
| 1497 | 1497 | } |
| 1498 | - if( file_access(zDbName, R_OK) || file_size(zDbName)<1024 ){ | |
| 1498 | + if( file_access(zDbName, R_OK) || file_size(zDbName, ExtFILE)<1024 ){ | |
| 1499 | 1499 | if( file_access(zDbName, F_OK) ){ |
| 1500 | 1500 | #ifdef FOSSIL_ENABLE_JSON |
| 1501 | 1501 | g.json.resultCode = FSL_JSON_E_DB_NOT_FOUND; |
| 1502 | 1502 | #endif |
| 1503 | 1503 | fossil_panic("repository does not exist or" |
| @@ -1548,11 +1548,11 @@ | ||
| 1548 | 1548 | ** |
| 1549 | 1549 | ** Error out if the repository cannot be opened. |
| 1550 | 1550 | */ |
| 1551 | 1551 | void db_find_and_open_repository(int bFlags, int nArgUsed){ |
| 1552 | 1552 | const char *zRep = find_repository_option(); |
| 1553 | - if( zRep && file_isdir(zRep)==1 ){ | |
| 1553 | + if( zRep && file_isdir(zRep, ExtFILE)==1 ){ | |
| 1554 | 1554 | goto rep_not_found; |
| 1555 | 1555 | } |
| 1556 | 1556 | if( zRep==0 && nArgUsed && g.argc==nArgUsed+1 ){ |
| 1557 | 1557 | zRep = g.argv[nArgUsed]; |
| 1558 | 1558 | } |
| @@ -1983,11 +1983,11 @@ | ||
| 1983 | 1983 | |
| 1984 | 1984 | if( g.argc!=3 ){ |
| 1985 | 1985 | usage("REPOSITORY-NAME"); |
| 1986 | 1986 | } |
| 1987 | 1987 | |
| 1988 | - if( -1 != file_size(g.argv[2]) ){ | |
| 1988 | + if( -1 != file_size(g.argv[2], ExtFILE) ){ | |
| 1989 | 1989 | fossil_fatal("file already exists: %s", g.argv[2]); |
| 1990 | 1990 | } |
| 1991 | 1991 | |
| 1992 | 1992 | db_create_repository(g.argv[2]); |
| 1993 | 1993 | db_open_repository(g.argv[2]); |
| @@ -2280,19 +2280,20 @@ | ||
| 2280 | 2280 | if( historical_blob(g.zOpenRevision, blob_str(&versionedPathname), |
| 2281 | 2281 | &noWarnFile, 0) ){ |
| 2282 | 2282 | noWarn = 1; |
| 2283 | 2283 | } |
| 2284 | 2284 | blob_reset(&noWarnFile); |
| 2285 | - }else if( file_size(blob_str(&versionedPathname))>=0 ){ | |
| 2285 | + }else if( file_size(blob_str(&versionedPathname), ExtFILE)>=0 ){ | |
| 2286 | 2286 | /* File exists, and contains the value for this setting. Load from |
| 2287 | 2287 | ** the file. */ |
| 2288 | - if( blob_read_from_file(&setting, blob_str(&versionedPathname))>=0 ){ | |
| 2288 | + const char *zFile = blob_str(&versionedPathname); | |
| 2289 | + if( blob_read_from_file(&setting, zFile, ExtFILE)>=0 ){ | |
| 2289 | 2290 | found = 1; |
| 2290 | 2291 | } |
| 2291 | 2292 | /* See if there's a no-warn flag */ |
| 2292 | 2293 | blob_append(&versionedPathname, ".no-warn", -1); |
| 2293 | - if( file_size(blob_str(&versionedPathname))>=0 ){ | |
| 2294 | + if( file_size(blob_str(&versionedPathname), ExtFILE)>=0 ){ | |
| 2294 | 2295 | noWarn = 1; |
| 2295 | 2296 | } |
| 2296 | 2297 | } |
| 2297 | 2298 | blob_reset(&versionedPathname); |
| 2298 | 2299 | if( found ){ |
| @@ -2729,11 +2730,11 @@ | ||
| 2729 | 2730 | /* Check to see if this is overridden by a versionable settings file */ |
| 2730 | 2731 | Blob versionedPathname; |
| 2731 | 2732 | blob_zero(&versionedPathname); |
| 2732 | 2733 | blob_appendf(&versionedPathname, "%s.fossil-settings/%s", |
| 2733 | 2734 | g.zLocalRoot, pSetting->name); |
| 2734 | - if( file_size(blob_str(&versionedPathname))>=0 ){ | |
| 2735 | + if( file_size(blob_str(&versionedPathname), ExtFILE)>=0 ){ | |
| 2735 | 2736 | fossil_print(" (overridden by contents of file .fossil-settings/%s)\n", |
| 2736 | 2737 | pSetting->name); |
| 2737 | 2738 | } |
| 2738 | 2739 | } |
| 2739 | 2740 | db_finalize(&q); |
| 2740 | 2741 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -1274,21 +1274,21 @@ | |
| 1274 | if( isOptional ) return 0; |
| 1275 | fossil_fatal("cannot locate home directory - please set the " |
| 1276 | "FOSSIL_HOME or HOME environment variables"); |
| 1277 | } |
| 1278 | #endif |
| 1279 | if( file_isdir(zHome)!=1 ){ |
| 1280 | if( isOptional ) return 0; |
| 1281 | fossil_fatal("invalid home directory: %s", zHome); |
| 1282 | } |
| 1283 | #if defined(_WIN32) || defined(__CYGWIN__) |
| 1284 | /* . filenames give some window systems problems and many apps problems */ |
| 1285 | zDbName = mprintf("%//_fossil", zHome); |
| 1286 | #else |
| 1287 | zDbName = mprintf("%s/.fossil", zHome); |
| 1288 | #endif |
| 1289 | if( file_size(zDbName)<1024*3 ){ |
| 1290 | if( file_access(zHome, W_OK) ){ |
| 1291 | if( isOptional ) return 0; |
| 1292 | fossil_fatal("home directory %s must be writeable", zHome); |
| 1293 | } |
| 1294 | db_init_database(zDbName, zConfigSchema, (char*)0); |
| @@ -1352,11 +1352,11 @@ | |
| 1352 | static int isValidLocalDb(const char *zDbName){ |
| 1353 | i64 lsize; |
| 1354 | char *zVFileDef; |
| 1355 | |
| 1356 | if( file_access(zDbName, F_OK) ) return 0; |
| 1357 | lsize = file_size(zDbName); |
| 1358 | if( lsize%1024!=0 || lsize<4096 ) return 0; |
| 1359 | db_open_or_attach(zDbName, "localdb"); |
| 1360 | zVFileDef = db_text(0, "SELECT sql FROM localdb.sqlite_master" |
| 1361 | " WHERE name=='vfile'"); |
| 1362 | if( zVFileDef==0 ) return 0; |
| @@ -1493,11 +1493,11 @@ | |
| 1493 | } |
| 1494 | if( zDbName==0 ){ |
| 1495 | db_err("unable to find the name of a repository database"); |
| 1496 | } |
| 1497 | } |
| 1498 | if( file_access(zDbName, R_OK) || file_size(zDbName)<1024 ){ |
| 1499 | if( file_access(zDbName, F_OK) ){ |
| 1500 | #ifdef FOSSIL_ENABLE_JSON |
| 1501 | g.json.resultCode = FSL_JSON_E_DB_NOT_FOUND; |
| 1502 | #endif |
| 1503 | fossil_panic("repository does not exist or" |
| @@ -1548,11 +1548,11 @@ | |
| 1548 | ** |
| 1549 | ** Error out if the repository cannot be opened. |
| 1550 | */ |
| 1551 | void db_find_and_open_repository(int bFlags, int nArgUsed){ |
| 1552 | const char *zRep = find_repository_option(); |
| 1553 | if( zRep && file_isdir(zRep)==1 ){ |
| 1554 | goto rep_not_found; |
| 1555 | } |
| 1556 | if( zRep==0 && nArgUsed && g.argc==nArgUsed+1 ){ |
| 1557 | zRep = g.argv[nArgUsed]; |
| 1558 | } |
| @@ -1983,11 +1983,11 @@ | |
| 1983 | |
| 1984 | if( g.argc!=3 ){ |
| 1985 | usage("REPOSITORY-NAME"); |
| 1986 | } |
| 1987 | |
| 1988 | if( -1 != file_size(g.argv[2]) ){ |
| 1989 | fossil_fatal("file already exists: %s", g.argv[2]); |
| 1990 | } |
| 1991 | |
| 1992 | db_create_repository(g.argv[2]); |
| 1993 | db_open_repository(g.argv[2]); |
| @@ -2280,19 +2280,20 @@ | |
| 2280 | if( historical_blob(g.zOpenRevision, blob_str(&versionedPathname), |
| 2281 | &noWarnFile, 0) ){ |
| 2282 | noWarn = 1; |
| 2283 | } |
| 2284 | blob_reset(&noWarnFile); |
| 2285 | }else if( file_size(blob_str(&versionedPathname))>=0 ){ |
| 2286 | /* File exists, and contains the value for this setting. Load from |
| 2287 | ** the file. */ |
| 2288 | if( blob_read_from_file(&setting, blob_str(&versionedPathname))>=0 ){ |
| 2289 | found = 1; |
| 2290 | } |
| 2291 | /* See if there's a no-warn flag */ |
| 2292 | blob_append(&versionedPathname, ".no-warn", -1); |
| 2293 | if( file_size(blob_str(&versionedPathname))>=0 ){ |
| 2294 | noWarn = 1; |
| 2295 | } |
| 2296 | } |
| 2297 | blob_reset(&versionedPathname); |
| 2298 | if( found ){ |
| @@ -2729,11 +2730,11 @@ | |
| 2729 | /* Check to see if this is overridden by a versionable settings file */ |
| 2730 | Blob versionedPathname; |
| 2731 | blob_zero(&versionedPathname); |
| 2732 | blob_appendf(&versionedPathname, "%s.fossil-settings/%s", |
| 2733 | g.zLocalRoot, pSetting->name); |
| 2734 | if( file_size(blob_str(&versionedPathname))>=0 ){ |
| 2735 | fossil_print(" (overridden by contents of file .fossil-settings/%s)\n", |
| 2736 | pSetting->name); |
| 2737 | } |
| 2738 | } |
| 2739 | db_finalize(&q); |
| 2740 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -1274,21 +1274,21 @@ | |
| 1274 | if( isOptional ) return 0; |
| 1275 | fossil_fatal("cannot locate home directory - please set the " |
| 1276 | "FOSSIL_HOME or HOME environment variables"); |
| 1277 | } |
| 1278 | #endif |
| 1279 | if( file_isdir(zHome, ExtFILE)!=1 ){ |
| 1280 | if( isOptional ) return 0; |
| 1281 | fossil_fatal("invalid home directory: %s", zHome); |
| 1282 | } |
| 1283 | #if defined(_WIN32) || defined(__CYGWIN__) |
| 1284 | /* . filenames give some window systems problems and many apps problems */ |
| 1285 | zDbName = mprintf("%//_fossil", zHome); |
| 1286 | #else |
| 1287 | zDbName = mprintf("%s/.fossil", zHome); |
| 1288 | #endif |
| 1289 | if( file_size(zDbName, ExtFILE)<1024*3 ){ |
| 1290 | if( file_access(zHome, W_OK) ){ |
| 1291 | if( isOptional ) return 0; |
| 1292 | fossil_fatal("home directory %s must be writeable", zHome); |
| 1293 | } |
| 1294 | db_init_database(zDbName, zConfigSchema, (char*)0); |
| @@ -1352,11 +1352,11 @@ | |
| 1352 | static int isValidLocalDb(const char *zDbName){ |
| 1353 | i64 lsize; |
| 1354 | char *zVFileDef; |
| 1355 | |
| 1356 | if( file_access(zDbName, F_OK) ) return 0; |
| 1357 | lsize = file_size(zDbName, ExtFILE); |
| 1358 | if( lsize%1024!=0 || lsize<4096 ) return 0; |
| 1359 | db_open_or_attach(zDbName, "localdb"); |
| 1360 | zVFileDef = db_text(0, "SELECT sql FROM localdb.sqlite_master" |
| 1361 | " WHERE name=='vfile'"); |
| 1362 | if( zVFileDef==0 ) return 0; |
| @@ -1493,11 +1493,11 @@ | |
| 1493 | } |
| 1494 | if( zDbName==0 ){ |
| 1495 | db_err("unable to find the name of a repository database"); |
| 1496 | } |
| 1497 | } |
| 1498 | if( file_access(zDbName, R_OK) || file_size(zDbName, ExtFILE)<1024 ){ |
| 1499 | if( file_access(zDbName, F_OK) ){ |
| 1500 | #ifdef FOSSIL_ENABLE_JSON |
| 1501 | g.json.resultCode = FSL_JSON_E_DB_NOT_FOUND; |
| 1502 | #endif |
| 1503 | fossil_panic("repository does not exist or" |
| @@ -1548,11 +1548,11 @@ | |
| 1548 | ** |
| 1549 | ** Error out if the repository cannot be opened. |
| 1550 | */ |
| 1551 | void db_find_and_open_repository(int bFlags, int nArgUsed){ |
| 1552 | const char *zRep = find_repository_option(); |
| 1553 | if( zRep && file_isdir(zRep, ExtFILE)==1 ){ |
| 1554 | goto rep_not_found; |
| 1555 | } |
| 1556 | if( zRep==0 && nArgUsed && g.argc==nArgUsed+1 ){ |
| 1557 | zRep = g.argv[nArgUsed]; |
| 1558 | } |
| @@ -1983,11 +1983,11 @@ | |
| 1983 | |
| 1984 | if( g.argc!=3 ){ |
| 1985 | usage("REPOSITORY-NAME"); |
| 1986 | } |
| 1987 | |
| 1988 | if( -1 != file_size(g.argv[2], ExtFILE) ){ |
| 1989 | fossil_fatal("file already exists: %s", g.argv[2]); |
| 1990 | } |
| 1991 | |
| 1992 | db_create_repository(g.argv[2]); |
| 1993 | db_open_repository(g.argv[2]); |
| @@ -2280,19 +2280,20 @@ | |
| 2280 | if( historical_blob(g.zOpenRevision, blob_str(&versionedPathname), |
| 2281 | &noWarnFile, 0) ){ |
| 2282 | noWarn = 1; |
| 2283 | } |
| 2284 | blob_reset(&noWarnFile); |
| 2285 | }else if( file_size(blob_str(&versionedPathname), ExtFILE)>=0 ){ |
| 2286 | /* File exists, and contains the value for this setting. Load from |
| 2287 | ** the file. */ |
| 2288 | const char *zFile = blob_str(&versionedPathname); |
| 2289 | if( blob_read_from_file(&setting, zFile, ExtFILE)>=0 ){ |
| 2290 | found = 1; |
| 2291 | } |
| 2292 | /* See if there's a no-warn flag */ |
| 2293 | blob_append(&versionedPathname, ".no-warn", -1); |
| 2294 | if( file_size(blob_str(&versionedPathname), ExtFILE)>=0 ){ |
| 2295 | noWarn = 1; |
| 2296 | } |
| 2297 | } |
| 2298 | blob_reset(&versionedPathname); |
| 2299 | if( found ){ |
| @@ -2729,11 +2730,11 @@ | |
| 2730 | /* Check to see if this is overridden by a versionable settings file */ |
| 2731 | Blob versionedPathname; |
| 2732 | blob_zero(&versionedPathname); |
| 2733 | blob_appendf(&versionedPathname, "%s.fossil-settings/%s", |
| 2734 | g.zLocalRoot, pSetting->name); |
| 2735 | if( file_size(blob_str(&versionedPathname), ExtFILE)>=0 ){ |
| 2736 | fossil_print(" (overridden by contents of file .fossil-settings/%s)\n", |
| 2737 | pSetting->name); |
| 2738 | } |
| 2739 | } |
| 2740 | db_finalize(&q); |
| 2741 |
+8
-8
| --- src/deltacmd.c | ||
| +++ src/deltacmd.c | ||
| @@ -53,14 +53,14 @@ | ||
| 53 | 53 | void delta_create_cmd(void){ |
| 54 | 54 | Blob orig, target, delta; |
| 55 | 55 | if( g.argc!=5 ){ |
| 56 | 56 | usage("ORIGIN TARGET DELTA"); |
| 57 | 57 | } |
| 58 | - if( blob_read_from_file(&orig, g.argv[2])<0 ){ | |
| 58 | + if( blob_read_from_file(&orig, g.argv[2], ExtFILE)<0 ){ | |
| 59 | 59 | fossil_fatal("cannot read %s", g.argv[2]); |
| 60 | 60 | } |
| 61 | - if( blob_read_from_file(&target, g.argv[3])<0 ){ | |
| 61 | + if( blob_read_from_file(&target, g.argv[3], ExtFILE)<0 ){ | |
| 62 | 62 | fossil_fatal("cannot read %s", g.argv[3]); |
| 63 | 63 | } |
| 64 | 64 | blob_delta_create(&orig, &target, &delta); |
| 65 | 65 | if( blob_write_to_file(&delta, g.argv[4])<blob_size(&delta) ){ |
| 66 | 66 | fossil_fatal("cannot write %s", g.argv[4]); |
| @@ -84,14 +84,14 @@ | ||
| 84 | 84 | int nInsert = 0; |
| 85 | 85 | int sz1, sz2, sz3; |
| 86 | 86 | if( g.argc!=4 ){ |
| 87 | 87 | usage("ORIGIN TARGET"); |
| 88 | 88 | } |
| 89 | - if( blob_read_from_file(&orig, g.argv[2])<0 ){ | |
| 89 | + if( blob_read_from_file(&orig, g.argv[2], ExtFILE)<0 ){ | |
| 90 | 90 | fossil_fatal("cannot read %s", g.argv[2]); |
| 91 | 91 | } |
| 92 | - if( blob_read_from_file(&target, g.argv[3])<0 ){ | |
| 92 | + if( blob_read_from_file(&target, g.argv[3], ExtFILE)<0 ){ | |
| 93 | 93 | fossil_fatal("cannot read %s", g.argv[3]); |
| 94 | 94 | } |
| 95 | 95 | blob_delta_create(&orig, &target, &delta); |
| 96 | 96 | delta_analyze(blob_buffer(&delta), blob_size(&delta), &nCopy, &nInsert); |
| 97 | 97 | sz1 = blob_size(&orig); |
| @@ -152,14 +152,14 @@ | ||
| 152 | 152 | void delta_apply_cmd(void){ |
| 153 | 153 | Blob orig, target, delta; |
| 154 | 154 | if( g.argc!=5 ){ |
| 155 | 155 | usage("ORIGIN DELTA TARGET"); |
| 156 | 156 | } |
| 157 | - if( blob_read_from_file(&orig, g.argv[2])<0 ){ | |
| 157 | + if( blob_read_from_file(&orig, g.argv[2], ExtFILE)<0 ){ | |
| 158 | 158 | fossil_fatal("cannot read %s", g.argv[2]); |
| 159 | 159 | } |
| 160 | - if( blob_read_from_file(&delta, g.argv[3])<0 ){ | |
| 160 | + if( blob_read_from_file(&delta, g.argv[3], ExtFILE)<0 ){ | |
| 161 | 161 | fossil_fatal("cannot read %s", g.argv[3]); |
| 162 | 162 | } |
| 163 | 163 | blob_delta_apply(&orig, &delta, &target); |
| 164 | 164 | if( blob_write_to_file(&target, g.argv[4])<blob_size(&target) ){ |
| 165 | 165 | fossil_fatal("cannot write %s", g.argv[4]); |
| @@ -182,16 +182,16 @@ | ||
| 182 | 182 | void cmd_test_delta(void){ |
| 183 | 183 | Blob f1, f2; /* Original file content */ |
| 184 | 184 | Blob d12, d21; /* Deltas from f1->f2 and f2->f1 */ |
| 185 | 185 | Blob a1, a2; /* Recovered file content */ |
| 186 | 186 | if( g.argc!=4 ) usage("FILE1 FILE2"); |
| 187 | - blob_read_from_file(&f1, g.argv[2]); | |
| 188 | - blob_read_from_file(&f2, g.argv[3]); | |
| 187 | + blob_read_from_file(&f1, g.argv[2], ExtFILE); | |
| 188 | + blob_read_from_file(&f2, g.argv[3], ExtFILE); | |
| 189 | 189 | blob_delta_create(&f1, &f2, &d12); |
| 190 | 190 | blob_delta_create(&f2, &f1, &d21); |
| 191 | 191 | blob_delta_apply(&f1, &d12, &a2); |
| 192 | 192 | blob_delta_apply(&f2, &d21, &a1); |
| 193 | 193 | if( blob_compare(&f1,&a1) || blob_compare(&f2, &a2) ){ |
| 194 | 194 | fossil_fatal("delta test failed"); |
| 195 | 195 | } |
| 196 | 196 | fossil_print("ok\n"); |
| 197 | 197 | } |
| 198 | 198 |
| --- src/deltacmd.c | |
| +++ src/deltacmd.c | |
| @@ -53,14 +53,14 @@ | |
| 53 | void delta_create_cmd(void){ |
| 54 | Blob orig, target, delta; |
| 55 | if( g.argc!=5 ){ |
| 56 | usage("ORIGIN TARGET DELTA"); |
| 57 | } |
| 58 | if( blob_read_from_file(&orig, g.argv[2])<0 ){ |
| 59 | fossil_fatal("cannot read %s", g.argv[2]); |
| 60 | } |
| 61 | if( blob_read_from_file(&target, g.argv[3])<0 ){ |
| 62 | fossil_fatal("cannot read %s", g.argv[3]); |
| 63 | } |
| 64 | blob_delta_create(&orig, &target, &delta); |
| 65 | if( blob_write_to_file(&delta, g.argv[4])<blob_size(&delta) ){ |
| 66 | fossil_fatal("cannot write %s", g.argv[4]); |
| @@ -84,14 +84,14 @@ | |
| 84 | int nInsert = 0; |
| 85 | int sz1, sz2, sz3; |
| 86 | if( g.argc!=4 ){ |
| 87 | usage("ORIGIN TARGET"); |
| 88 | } |
| 89 | if( blob_read_from_file(&orig, g.argv[2])<0 ){ |
| 90 | fossil_fatal("cannot read %s", g.argv[2]); |
| 91 | } |
| 92 | if( blob_read_from_file(&target, g.argv[3])<0 ){ |
| 93 | fossil_fatal("cannot read %s", g.argv[3]); |
| 94 | } |
| 95 | blob_delta_create(&orig, &target, &delta); |
| 96 | delta_analyze(blob_buffer(&delta), blob_size(&delta), &nCopy, &nInsert); |
| 97 | sz1 = blob_size(&orig); |
| @@ -152,14 +152,14 @@ | |
| 152 | void delta_apply_cmd(void){ |
| 153 | Blob orig, target, delta; |
| 154 | if( g.argc!=5 ){ |
| 155 | usage("ORIGIN DELTA TARGET"); |
| 156 | } |
| 157 | if( blob_read_from_file(&orig, g.argv[2])<0 ){ |
| 158 | fossil_fatal("cannot read %s", g.argv[2]); |
| 159 | } |
| 160 | if( blob_read_from_file(&delta, g.argv[3])<0 ){ |
| 161 | fossil_fatal("cannot read %s", g.argv[3]); |
| 162 | } |
| 163 | blob_delta_apply(&orig, &delta, &target); |
| 164 | if( blob_write_to_file(&target, g.argv[4])<blob_size(&target) ){ |
| 165 | fossil_fatal("cannot write %s", g.argv[4]); |
| @@ -182,16 +182,16 @@ | |
| 182 | void cmd_test_delta(void){ |
| 183 | Blob f1, f2; /* Original file content */ |
| 184 | Blob d12, d21; /* Deltas from f1->f2 and f2->f1 */ |
| 185 | Blob a1, a2; /* Recovered file content */ |
| 186 | if( g.argc!=4 ) usage("FILE1 FILE2"); |
| 187 | blob_read_from_file(&f1, g.argv[2]); |
| 188 | blob_read_from_file(&f2, g.argv[3]); |
| 189 | blob_delta_create(&f1, &f2, &d12); |
| 190 | blob_delta_create(&f2, &f1, &d21); |
| 191 | blob_delta_apply(&f1, &d12, &a2); |
| 192 | blob_delta_apply(&f2, &d21, &a1); |
| 193 | if( blob_compare(&f1,&a1) || blob_compare(&f2, &a2) ){ |
| 194 | fossil_fatal("delta test failed"); |
| 195 | } |
| 196 | fossil_print("ok\n"); |
| 197 | } |
| 198 |
| --- src/deltacmd.c | |
| +++ src/deltacmd.c | |
| @@ -53,14 +53,14 @@ | |
| 53 | void delta_create_cmd(void){ |
| 54 | Blob orig, target, delta; |
| 55 | if( g.argc!=5 ){ |
| 56 | usage("ORIGIN TARGET DELTA"); |
| 57 | } |
| 58 | if( blob_read_from_file(&orig, g.argv[2], ExtFILE)<0 ){ |
| 59 | fossil_fatal("cannot read %s", g.argv[2]); |
| 60 | } |
| 61 | if( blob_read_from_file(&target, g.argv[3], ExtFILE)<0 ){ |
| 62 | fossil_fatal("cannot read %s", g.argv[3]); |
| 63 | } |
| 64 | blob_delta_create(&orig, &target, &delta); |
| 65 | if( blob_write_to_file(&delta, g.argv[4])<blob_size(&delta) ){ |
| 66 | fossil_fatal("cannot write %s", g.argv[4]); |
| @@ -84,14 +84,14 @@ | |
| 84 | int nInsert = 0; |
| 85 | int sz1, sz2, sz3; |
| 86 | if( g.argc!=4 ){ |
| 87 | usage("ORIGIN TARGET"); |
| 88 | } |
| 89 | if( blob_read_from_file(&orig, g.argv[2], ExtFILE)<0 ){ |
| 90 | fossil_fatal("cannot read %s", g.argv[2]); |
| 91 | } |
| 92 | if( blob_read_from_file(&target, g.argv[3], ExtFILE)<0 ){ |
| 93 | fossil_fatal("cannot read %s", g.argv[3]); |
| 94 | } |
| 95 | blob_delta_create(&orig, &target, &delta); |
| 96 | delta_analyze(blob_buffer(&delta), blob_size(&delta), &nCopy, &nInsert); |
| 97 | sz1 = blob_size(&orig); |
| @@ -152,14 +152,14 @@ | |
| 152 | void delta_apply_cmd(void){ |
| 153 | Blob orig, target, delta; |
| 154 | if( g.argc!=5 ){ |
| 155 | usage("ORIGIN DELTA TARGET"); |
| 156 | } |
| 157 | if( blob_read_from_file(&orig, g.argv[2], ExtFILE)<0 ){ |
| 158 | fossil_fatal("cannot read %s", g.argv[2]); |
| 159 | } |
| 160 | if( blob_read_from_file(&delta, g.argv[3], ExtFILE)<0 ){ |
| 161 | fossil_fatal("cannot read %s", g.argv[3]); |
| 162 | } |
| 163 | blob_delta_apply(&orig, &delta, &target); |
| 164 | if( blob_write_to_file(&target, g.argv[4])<blob_size(&target) ){ |
| 165 | fossil_fatal("cannot write %s", g.argv[4]); |
| @@ -182,16 +182,16 @@ | |
| 182 | void cmd_test_delta(void){ |
| 183 | Blob f1, f2; /* Original file content */ |
| 184 | Blob d12, d21; /* Deltas from f1->f2 and f2->f1 */ |
| 185 | Blob a1, a2; /* Recovered file content */ |
| 186 | if( g.argc!=4 ) usage("FILE1 FILE2"); |
| 187 | blob_read_from_file(&f1, g.argv[2], ExtFILE); |
| 188 | blob_read_from_file(&f2, g.argv[3], ExtFILE); |
| 189 | blob_delta_create(&f1, &f2, &d12); |
| 190 | blob_delta_create(&f2, &f1, &d21); |
| 191 | blob_delta_apply(&f1, &d12, &a2); |
| 192 | blob_delta_apply(&f2, &d21, &a1); |
| 193 | if( blob_compare(&f1,&a1) || blob_compare(&f2, &a2) ){ |
| 194 | fossil_fatal("delta test failed"); |
| 195 | } |
| 196 | fossil_print("ok\n"); |
| 197 | } |
| 198 |
+4
-4
| --- src/diff.c | ||
| +++ src/diff.c | ||
| @@ -2015,14 +2015,14 @@ | ||
| 2015 | 2015 | int r; |
| 2016 | 2016 | int i; |
| 2017 | 2017 | int *R; |
| 2018 | 2018 | u64 diffFlags = diff_options(); |
| 2019 | 2019 | if( g.argc<4 ) usage("FILE1 FILE2 ..."); |
| 2020 | - blob_read_from_file(&a, g.argv[2]); | |
| 2020 | + blob_read_from_file(&a, g.argv[2], ExtFILE); | |
| 2021 | 2021 | for(i=3; i<g.argc; i++){ |
| 2022 | 2022 | if( i>3 ) fossil_print("-------------------------------\n"); |
| 2023 | - blob_read_from_file(&b, g.argv[i]); | |
| 2023 | + blob_read_from_file(&b, g.argv[i], ExtFILE); | |
| 2024 | 2024 | R = text_diff(&a, &b, 0, 0, diffFlags); |
| 2025 | 2025 | for(r=0; R[r] || R[r+1] || R[r+2]; r += 3){ |
| 2026 | 2026 | fossil_print(" copy %4d delete %4d insert %4d\n", R[r], R[r+1], R[r+2]); |
| 2027 | 2027 | } |
| 2028 | 2028 | /* free(R); */ |
| @@ -2056,12 +2056,12 @@ | ||
| 2056 | 2056 | } |
| 2057 | 2057 | diffFlag = diff_options(); |
| 2058 | 2058 | verify_all_options(); |
| 2059 | 2059 | if( g.argc!=4 ) usage("FILE1 FILE2"); |
| 2060 | 2060 | diff_print_filenames(g.argv[2], g.argv[3], diffFlag); |
| 2061 | - blob_read_from_file(&a, g.argv[2]); | |
| 2062 | - blob_read_from_file(&b, g.argv[3]); | |
| 2061 | + blob_read_from_file(&a, g.argv[2], ExtFILE); | |
| 2062 | + blob_read_from_file(&b, g.argv[3], ExtFILE); | |
| 2063 | 2063 | blob_zero(&out); |
| 2064 | 2064 | text_diff(&a, &b, &out, pRe, diffFlag); |
| 2065 | 2065 | blob_write_to_file(&out, "-"); |
| 2066 | 2066 | re_free(pRe); |
| 2067 | 2067 | } |
| 2068 | 2068 |
| --- src/diff.c | |
| +++ src/diff.c | |
| @@ -2015,14 +2015,14 @@ | |
| 2015 | int r; |
| 2016 | int i; |
| 2017 | int *R; |
| 2018 | u64 diffFlags = diff_options(); |
| 2019 | if( g.argc<4 ) usage("FILE1 FILE2 ..."); |
| 2020 | blob_read_from_file(&a, g.argv[2]); |
| 2021 | for(i=3; i<g.argc; i++){ |
| 2022 | if( i>3 ) fossil_print("-------------------------------\n"); |
| 2023 | blob_read_from_file(&b, g.argv[i]); |
| 2024 | R = text_diff(&a, &b, 0, 0, diffFlags); |
| 2025 | for(r=0; R[r] || R[r+1] || R[r+2]; r += 3){ |
| 2026 | fossil_print(" copy %4d delete %4d insert %4d\n", R[r], R[r+1], R[r+2]); |
| 2027 | } |
| 2028 | /* free(R); */ |
| @@ -2056,12 +2056,12 @@ | |
| 2056 | } |
| 2057 | diffFlag = diff_options(); |
| 2058 | verify_all_options(); |
| 2059 | if( g.argc!=4 ) usage("FILE1 FILE2"); |
| 2060 | diff_print_filenames(g.argv[2], g.argv[3], diffFlag); |
| 2061 | blob_read_from_file(&a, g.argv[2]); |
| 2062 | blob_read_from_file(&b, g.argv[3]); |
| 2063 | blob_zero(&out); |
| 2064 | text_diff(&a, &b, &out, pRe, diffFlag); |
| 2065 | blob_write_to_file(&out, "-"); |
| 2066 | re_free(pRe); |
| 2067 | } |
| 2068 |
| --- src/diff.c | |
| +++ src/diff.c | |
| @@ -2015,14 +2015,14 @@ | |
| 2015 | int r; |
| 2016 | int i; |
| 2017 | int *R; |
| 2018 | u64 diffFlags = diff_options(); |
| 2019 | if( g.argc<4 ) usage("FILE1 FILE2 ..."); |
| 2020 | blob_read_from_file(&a, g.argv[2], ExtFILE); |
| 2021 | for(i=3; i<g.argc; i++){ |
| 2022 | if( i>3 ) fossil_print("-------------------------------\n"); |
| 2023 | blob_read_from_file(&b, g.argv[i], ExtFILE); |
| 2024 | R = text_diff(&a, &b, 0, 0, diffFlags); |
| 2025 | for(r=0; R[r] || R[r+1] || R[r+2]; r += 3){ |
| 2026 | fossil_print(" copy %4d delete %4d insert %4d\n", R[r], R[r+1], R[r+2]); |
| 2027 | } |
| 2028 | /* free(R); */ |
| @@ -2056,12 +2056,12 @@ | |
| 2056 | } |
| 2057 | diffFlag = diff_options(); |
| 2058 | verify_all_options(); |
| 2059 | if( g.argc!=4 ) usage("FILE1 FILE2"); |
| 2060 | diff_print_filenames(g.argv[2], g.argv[3], diffFlag); |
| 2061 | blob_read_from_file(&a, g.argv[2], ExtFILE); |
| 2062 | blob_read_from_file(&b, g.argv[3], ExtFILE); |
| 2063 | blob_zero(&out); |
| 2064 | text_diff(&a, &b, &out, pRe, diffFlag); |
| 2065 | blob_write_to_file(&out, "-"); |
| 2066 | re_free(pRe); |
| 2067 | } |
| 2068 |
+6
-14
| --- src/diffcmd.c | ||
| +++ src/diffcmd.c | ||
| @@ -180,18 +180,14 @@ | ||
| 180 | 180 | Blob file2; /* Content of zFile2 */ |
| 181 | 181 | const char *zName2; /* Name of zFile2 for display */ |
| 182 | 182 | |
| 183 | 183 | /* Read content of zFile2 into memory */ |
| 184 | 184 | blob_zero(&file2); |
| 185 | - if( file_wd_size(zFile2)<0 ){ | |
| 185 | + if( file_size(zFile2, ExtFILE)<0 ){ | |
| 186 | 186 | zName2 = NULL_DEVICE; |
| 187 | 187 | }else{ |
| 188 | - if( file_wd_islink(0) ){ | |
| 189 | - blob_read_link(&file2, zFile2); | |
| 190 | - }else{ | |
| 191 | - blob_read_from_file(&file2, zFile2); | |
| 192 | - } | |
| 188 | + blob_read_from_file(&file2, zFile2, ExtFILE); | |
| 193 | 189 | zName2 = zName; |
| 194 | 190 | } |
| 195 | 191 | |
| 196 | 192 | /* Compute and output the differences */ |
| 197 | 193 | if( diffFlags & DIFF_BRIEF ){ |
| @@ -237,16 +233,12 @@ | ||
| 237 | 233 | return; |
| 238 | 234 | } |
| 239 | 235 | glob_free(pBinary); |
| 240 | 236 | } |
| 241 | 237 | blob_zero(&file2); |
| 242 | - if( file_wd_size(zFile2)>=0 ){ | |
| 243 | - if( file_wd_islink(0) ){ | |
| 244 | - blob_read_link(&file2, zFile2); | |
| 245 | - }else{ | |
| 246 | - blob_read_from_file(&file2, zFile2); | |
| 247 | - } | |
| 238 | + if( file_size(zFile2, ExtFILE)>=0 ){ | |
| 239 | + blob_read_from_file(&file2, zFile2, ExtFILE); | |
| 248 | 240 | } |
| 249 | 241 | if( looks_like_binary(&file2) ){ |
| 250 | 242 | fossil_print("%s",DIFF_CANNOT_COMPUTE_BINARY); |
| 251 | 243 | blob_reset(&file2); |
| 252 | 244 | return; |
| @@ -489,11 +481,11 @@ | ||
| 489 | 481 | if( !asNewFile ){ showDiff = 0; } |
| 490 | 482 | } |
| 491 | 483 | if( showDiff ){ |
| 492 | 484 | Blob content; |
| 493 | 485 | int isBin; |
| 494 | - if( !isLink != !file_wd_islink(zFullName) ){ | |
| 486 | + if( !isLink != !file_islink(zFullName) ){ | |
| 495 | 487 | diff_print_index(zPathname, diffFlags); |
| 496 | 488 | diff_print_filenames(zPathname, zPathname, diffFlags); |
| 497 | 489 | fossil_print("%s",DIFF_CANNOT_COMPUTE_SYMLINK); |
| 498 | 490 | continue; |
| 499 | 491 | } |
| @@ -965,11 +957,11 @@ | ||
| 965 | 957 | if( pFileDir ){ |
| 966 | 958 | int i; |
| 967 | 959 | for(i=0; pFileDir[i].zName; i++){ |
| 968 | 960 | if( pFileDir[i].nUsed==0 |
| 969 | 961 | && strcmp(pFileDir[0].zName,".")!=0 |
| 970 | - && !file_wd_isdir(g.argv[i+2]) | |
| 962 | + && !file_isdir(g.argv[i+2], ExtFILE) | |
| 971 | 963 | ){ |
| 972 | 964 | fossil_fatal("not found: '%s'", g.argv[i+2]); |
| 973 | 965 | } |
| 974 | 966 | fossil_free(pFileDir[i].zName); |
| 975 | 967 | } |
| 976 | 968 |
| --- src/diffcmd.c | |
| +++ src/diffcmd.c | |
| @@ -180,18 +180,14 @@ | |
| 180 | Blob file2; /* Content of zFile2 */ |
| 181 | const char *zName2; /* Name of zFile2 for display */ |
| 182 | |
| 183 | /* Read content of zFile2 into memory */ |
| 184 | blob_zero(&file2); |
| 185 | if( file_wd_size(zFile2)<0 ){ |
| 186 | zName2 = NULL_DEVICE; |
| 187 | }else{ |
| 188 | if( file_wd_islink(0) ){ |
| 189 | blob_read_link(&file2, zFile2); |
| 190 | }else{ |
| 191 | blob_read_from_file(&file2, zFile2); |
| 192 | } |
| 193 | zName2 = zName; |
| 194 | } |
| 195 | |
| 196 | /* Compute and output the differences */ |
| 197 | if( diffFlags & DIFF_BRIEF ){ |
| @@ -237,16 +233,12 @@ | |
| 237 | return; |
| 238 | } |
| 239 | glob_free(pBinary); |
| 240 | } |
| 241 | blob_zero(&file2); |
| 242 | if( file_wd_size(zFile2)>=0 ){ |
| 243 | if( file_wd_islink(0) ){ |
| 244 | blob_read_link(&file2, zFile2); |
| 245 | }else{ |
| 246 | blob_read_from_file(&file2, zFile2); |
| 247 | } |
| 248 | } |
| 249 | if( looks_like_binary(&file2) ){ |
| 250 | fossil_print("%s",DIFF_CANNOT_COMPUTE_BINARY); |
| 251 | blob_reset(&file2); |
| 252 | return; |
| @@ -489,11 +481,11 @@ | |
| 489 | if( !asNewFile ){ showDiff = 0; } |
| 490 | } |
| 491 | if( showDiff ){ |
| 492 | Blob content; |
| 493 | int isBin; |
| 494 | if( !isLink != !file_wd_islink(zFullName) ){ |
| 495 | diff_print_index(zPathname, diffFlags); |
| 496 | diff_print_filenames(zPathname, zPathname, diffFlags); |
| 497 | fossil_print("%s",DIFF_CANNOT_COMPUTE_SYMLINK); |
| 498 | continue; |
| 499 | } |
| @@ -965,11 +957,11 @@ | |
| 965 | if( pFileDir ){ |
| 966 | int i; |
| 967 | for(i=0; pFileDir[i].zName; i++){ |
| 968 | if( pFileDir[i].nUsed==0 |
| 969 | && strcmp(pFileDir[0].zName,".")!=0 |
| 970 | && !file_wd_isdir(g.argv[i+2]) |
| 971 | ){ |
| 972 | fossil_fatal("not found: '%s'", g.argv[i+2]); |
| 973 | } |
| 974 | fossil_free(pFileDir[i].zName); |
| 975 | } |
| 976 |
| --- src/diffcmd.c | |
| +++ src/diffcmd.c | |
| @@ -180,18 +180,14 @@ | |
| 180 | Blob file2; /* Content of zFile2 */ |
| 181 | const char *zName2; /* Name of zFile2 for display */ |
| 182 | |
| 183 | /* Read content of zFile2 into memory */ |
| 184 | blob_zero(&file2); |
| 185 | if( file_size(zFile2, ExtFILE)<0 ){ |
| 186 | zName2 = NULL_DEVICE; |
| 187 | }else{ |
| 188 | blob_read_from_file(&file2, zFile2, ExtFILE); |
| 189 | zName2 = zName; |
| 190 | } |
| 191 | |
| 192 | /* Compute and output the differences */ |
| 193 | if( diffFlags & DIFF_BRIEF ){ |
| @@ -237,16 +233,12 @@ | |
| 233 | return; |
| 234 | } |
| 235 | glob_free(pBinary); |
| 236 | } |
| 237 | blob_zero(&file2); |
| 238 | if( file_size(zFile2, ExtFILE)>=0 ){ |
| 239 | blob_read_from_file(&file2, zFile2, ExtFILE); |
| 240 | } |
| 241 | if( looks_like_binary(&file2) ){ |
| 242 | fossil_print("%s",DIFF_CANNOT_COMPUTE_BINARY); |
| 243 | blob_reset(&file2); |
| 244 | return; |
| @@ -489,11 +481,11 @@ | |
| 481 | if( !asNewFile ){ showDiff = 0; } |
| 482 | } |
| 483 | if( showDiff ){ |
| 484 | Blob content; |
| 485 | int isBin; |
| 486 | if( !isLink != !file_islink(zFullName) ){ |
| 487 | diff_print_index(zPathname, diffFlags); |
| 488 | diff_print_filenames(zPathname, zPathname, diffFlags); |
| 489 | fossil_print("%s",DIFF_CANNOT_COMPUTE_SYMLINK); |
| 490 | continue; |
| 491 | } |
| @@ -965,11 +957,11 @@ | |
| 957 | if( pFileDir ){ |
| 958 | int i; |
| 959 | for(i=0; pFileDir[i].zName; i++){ |
| 960 | if( pFileDir[i].nUsed==0 |
| 961 | && strcmp(pFileDir[0].zName,".")!=0 |
| 962 | && !file_isdir(g.argv[i+2], ExtFILE) |
| 963 | ){ |
| 964 | fossil_fatal("not found: '%s'", g.argv[i+2]); |
| 965 | } |
| 966 | fossil_free(pFileDir[i].zName); |
| 967 | } |
| 968 |
+2
-2
| --- src/doc.c | ||
| +++ src/doc.c | ||
| @@ -649,12 +649,12 @@ | ||
| 649 | 649 | }else if( fossil_strcmp(zCheckin,"ckout")==0 ){ |
| 650 | 650 | /* Read from the local checkout */ |
| 651 | 651 | char *zFullpath; |
| 652 | 652 | db_must_be_within_tree(); |
| 653 | 653 | zFullpath = mprintf("%s/%s", g.zLocalRoot, zName); |
| 654 | - if( file_isfile(zFullpath) | |
| 655 | - && blob_read_from_file(&filebody, zFullpath)>0 ){ | |
| 654 | + if( file_isfile(zFullpath, RepoFILE) | |
| 655 | + && blob_read_from_file(&filebody, zFullpath, RepoFILE)>0 ){ | |
| 656 | 656 | rid = 1; /* Fake RID just to get the loop to end */ |
| 657 | 657 | } |
| 658 | 658 | fossil_free(zFullpath); |
| 659 | 659 | }else{ |
| 660 | 660 | vid = name_to_typed_rid(zCheckin, "ci"); |
| 661 | 661 |
| --- src/doc.c | |
| +++ src/doc.c | |
| @@ -649,12 +649,12 @@ | |
| 649 | }else if( fossil_strcmp(zCheckin,"ckout")==0 ){ |
| 650 | /* Read from the local checkout */ |
| 651 | char *zFullpath; |
| 652 | db_must_be_within_tree(); |
| 653 | zFullpath = mprintf("%s/%s", g.zLocalRoot, zName); |
| 654 | if( file_isfile(zFullpath) |
| 655 | && blob_read_from_file(&filebody, zFullpath)>0 ){ |
| 656 | rid = 1; /* Fake RID just to get the loop to end */ |
| 657 | } |
| 658 | fossil_free(zFullpath); |
| 659 | }else{ |
| 660 | vid = name_to_typed_rid(zCheckin, "ci"); |
| 661 |
| --- src/doc.c | |
| +++ src/doc.c | |
| @@ -649,12 +649,12 @@ | |
| 649 | }else if( fossil_strcmp(zCheckin,"ckout")==0 ){ |
| 650 | /* Read from the local checkout */ |
| 651 | char *zFullpath; |
| 652 | db_must_be_within_tree(); |
| 653 | zFullpath = mprintf("%s/%s", g.zLocalRoot, zName); |
| 654 | if( file_isfile(zFullpath, RepoFILE) |
| 655 | && blob_read_from_file(&filebody, zFullpath, RepoFILE)>0 ){ |
| 656 | rid = 1; /* Fake RID just to get the loop to end */ |
| 657 | } |
| 658 | fossil_free(zFullpath); |
| 659 | }else{ |
| 660 | vid = name_to_typed_rid(zCheckin, "ci"); |
| 661 |
+181
-167
| --- src/file.c | ||
| +++ src/file.c | ||
| @@ -2,11 +2,11 @@ | ||
| 2 | 2 | ** Copyright (c) 2006 D. Richard Hipp |
| 3 | 3 | ** |
| 4 | 4 | ** This program is free software; you can redistribute it and/or |
| 5 | 5 | ** modify it under the terms of the Simplified BSD License (also |
| 6 | 6 | ** known as the "2-Clause License" or "FreeBSD License".) |
| 7 | - | |
| 7 | +** | |
| 8 | 8 | ** This program is distributed in the hope that it will be useful, |
| 9 | 9 | ** but without any warranty; without even the implied warranty of |
| 10 | 10 | ** merchantability or fitness for a particular purpose. |
| 11 | 11 | ** |
| 12 | 12 | ** Author contact information: |
| @@ -14,15 +14,10 @@ | ||
| 14 | 14 | ** http://www.hwaci.com/drh/ |
| 15 | 15 | ** |
| 16 | 16 | ******************************************************************************* |
| 17 | 17 | ** |
| 18 | 18 | ** File utilities. |
| 19 | -** | |
| 20 | -** Functions named file_* are generic functions that always follow symlinks. | |
| 21 | -** | |
| 22 | -** Functions named file_wd_* are to be used for files inside working | |
| 23 | -** directories. They follow symlinks depending on 'allow-symlinks' setting. | |
| 24 | 19 | */ |
| 25 | 20 | #include "config.h" |
| 26 | 21 | #include <sys/types.h> |
| 27 | 22 | #include <sys/stat.h> |
| 28 | 23 | #include <unistd.h> |
| @@ -42,10 +37,36 @@ | ||
| 42 | 37 | # include <sys/time.h> |
| 43 | 38 | #endif |
| 44 | 39 | |
| 45 | 40 | #if INTERFACE |
| 46 | 41 | |
| 42 | +/* Many APIs take a eFType argument which must be one of ExtFILE, RepoFILE, | |
| 43 | +** or SymFILE. | |
| 44 | +** | |
| 45 | +** The difference is in the handling of symbolic links. RepoFILE should be | |
| 46 | +** used for files that are under management by a Fossil repository. ExtFILE | |
| 47 | +** should be used for files that are not under management. SymFILE is for | |
| 48 | +** a few special cases such as the "fossil test-tarball" command when we never | |
| 49 | +** want to follow symlinks. | |
| 50 | +** | |
| 51 | +** If RepoFILE is used and if the allow-symlinks setting is true and if | |
| 52 | +** the object is a symbolic link, then the object is treated like an ordinary | |
| 53 | +** file whose content is name of the object to which the symbolic link | |
| 54 | +** points. | |
| 55 | +** | |
| 56 | +** If ExtFILE is used or allow-symlinks is false, then operations on a | |
| 57 | +** symbolic link are the same as operations on the object to which the | |
| 58 | +** symbolic link points. | |
| 59 | +** | |
| 60 | +** SymFILE is like RepoFILE except that it always uses the target filename of | |
| 61 | +** a symbolic link as the content, instead of the content of the object | |
| 62 | +** that the symlink points to. SymFILE acts as if allow-symlinks is always ON. | |
| 63 | +*/ | |
| 64 | +#define ExtFILE 0 /* Always follow symlinks */ | |
| 65 | +#define RepoFILE 1 /* Follow symlinks iff allow-symlinks is OFF */ | |
| 66 | +#define SymFILE 2 /* Never follow symlinks */ | |
| 67 | + | |
| 47 | 68 | #include <dirent.h> |
| 48 | 69 | #if defined(_WIN32) |
| 49 | 70 | # define DIR _WDIR |
| 50 | 71 | # define dirent _wdirent |
| 51 | 72 | # define opendir _wopendir |
| @@ -52,10 +73,13 @@ | ||
| 52 | 73 | # define readdir _wreaddir |
| 53 | 74 | # define closedir _wclosedir |
| 54 | 75 | #endif /* _WIN32 */ |
| 55 | 76 | |
| 56 | 77 | #if defined(_WIN32) && (defined(__MSVCRT__) || defined(_MSC_VER)) |
| 78 | +/* | |
| 79 | +** File status information for windows systems. | |
| 80 | +*/ | |
| 57 | 81 | struct fossilStat { |
| 58 | 82 | i64 st_size; |
| 59 | 83 | i64 st_mtime; |
| 60 | 84 | int st_mode; |
| 61 | 85 | }; |
| @@ -68,73 +92,88 @@ | ||
| 68 | 92 | #endif |
| 69 | 93 | |
| 70 | 94 | #endif /* INTERFACE */ |
| 71 | 95 | |
| 72 | 96 | #if !defined(_WIN32) || !(defined(__MSVCRT__) || defined(_MSC_VER)) |
| 97 | +/* | |
| 98 | +** File status information for unix systems | |
| 99 | +*/ | |
| 73 | 100 | # define fossilStat stat |
| 74 | 101 | #endif |
| 75 | 102 | |
| 76 | 103 | /* |
| 77 | 104 | ** On Windows S_ISLNK always returns FALSE. |
| 78 | 105 | */ |
| 79 | 106 | #if !defined(S_ISLNK) |
| 80 | 107 | # define S_ISLNK(x) (0) |
| 81 | 108 | #endif |
| 82 | -static int fileStatValid = 0; | |
| 83 | -static struct fossilStat fileStat; | |
| 109 | + | |
| 110 | +/* | |
| 111 | +** Local state information for the file status routines | |
| 112 | +*/ | |
| 113 | +static struct { | |
| 114 | + struct fossilStat fileStat; /* File status from last fossil_stat() */ | |
| 115 | + int fileStatValid; /* True if fileStat is valid */ | |
| 116 | +} fx; | |
| 84 | 117 | |
| 85 | 118 | /* |
| 86 | -** Fill stat buf with information received from stat() or lstat(). | |
| 87 | -** lstat() is called on Unix if isWd is TRUE and allow-symlinks setting is on. | |
| 119 | +** Fill *buf with information about zFilename. | |
| 120 | +** | |
| 121 | +** If zFilename refers to a symbolic link: | |
| 122 | +** | |
| 123 | +** (A) If allow-symlinks is on and eFType is RepoFILE, then fill | |
| 124 | +** *buf with information about the symbolic link itself. | |
| 125 | +** | |
| 126 | +** (B) If allow-symlinks is off or eFType is ExtFILE, then fill | |
| 127 | +** *buf with information about the object that the symbolic link | |
| 128 | +** points to. | |
| 88 | 129 | */ |
| 89 | 130 | static int fossil_stat( |
| 90 | 131 | const char *zFilename, /* name of file or directory to inspect. */ |
| 91 | 132 | struct fossilStat *buf, /* pointer to buffer where info should go. */ |
| 92 | - int isWd /* non-zero to consider look at symlink itself. */ | |
| 133 | + int eFType /* Look at symlink itself if RepoFILE and enabled. */ | |
| 93 | 134 | ){ |
| 94 | 135 | int rc; |
| 95 | 136 | void *zMbcs = fossil_utf8_to_path(zFilename, 0); |
| 96 | 137 | #if !defined(_WIN32) |
| 97 | - if( isWd && db_allow_symlinks() ){ | |
| 138 | + if( eFType>=RepoFILE && (eFType==SymFILE || db_allow_symlinks()) ){ | |
| 98 | 139 | rc = lstat(zMbcs, buf); |
| 99 | 140 | }else{ |
| 100 | 141 | rc = stat(zMbcs, buf); |
| 101 | 142 | } |
| 102 | 143 | #else |
| 103 | - rc = win32_stat(zMbcs, buf, isWd); | |
| 144 | + rc = win32_stat(zMbcs, buf, eFType); | |
| 104 | 145 | #endif |
| 105 | 146 | fossil_path_free(zMbcs); |
| 106 | 147 | return rc; |
| 107 | 148 | } |
| 108 | 149 | |
| 109 | 150 | /* |
| 110 | -** Clears the fileStat variable and its associated validity flag. | |
| 151 | +** Clears the fx.fileStat variable and its associated validity flag. | |
| 111 | 152 | */ |
| 112 | 153 | static void resetStat(){ |
| 113 | - fileStatValid = 0; | |
| 114 | - memset(&fileStat, 0, sizeof(struct fossilStat)); | |
| 154 | + fx.fileStatValid = 0; | |
| 155 | + memset(&fx.fileStat, 0, sizeof(struct fossilStat)); | |
| 115 | 156 | } |
| 116 | 157 | |
| 117 | 158 | /* |
| 118 | -** Fill in the fileStat variable for the file named zFilename. | |
| 119 | -** If zFilename==0, then use the previous value of fileStat if | |
| 159 | +** Fill in the fx.fileStat variable for the file named zFilename. | |
| 160 | +** If zFilename==0, then use the previous value of fx.fileStat if | |
| 120 | 161 | ** there is a previous value. |
| 121 | 162 | ** |
| 122 | -** If isWd is TRUE, do lstat() instead of stat() if allow-symlinks is on. | |
| 123 | -** | |
| 124 | 163 | ** Return the number of errors. No error messages are generated. |
| 125 | 164 | */ |
| 126 | -static int getStat(const char *zFilename, int isWd){ | |
| 165 | +static int getStat(const char *zFilename, int eFType){ | |
| 127 | 166 | int rc = 0; |
| 128 | 167 | if( zFilename==0 ){ |
| 129 | - if( fileStatValid==0 ) rc = 1; | |
| 168 | + if( fx.fileStatValid==0 ) rc = 1; | |
| 130 | 169 | }else{ |
| 131 | - if( fossil_stat(zFilename, &fileStat, isWd)!=0 ){ | |
| 132 | - fileStatValid = 0; | |
| 170 | + if( fossil_stat(zFilename, &fx.fileStat, eFType)!=0 ){ | |
| 171 | + fx.fileStatValid = 0; | |
| 133 | 172 | rc = 1; |
| 134 | 173 | }else{ |
| 135 | - fileStatValid = 1; | |
| 174 | + fx.fileStatValid = 1; | |
| 136 | 175 | rc = 0; |
| 137 | 176 | } |
| 138 | 177 | } |
| 139 | 178 | return rc; |
| 140 | 179 | } |
| @@ -142,83 +181,60 @@ | ||
| 142 | 181 | /* |
| 143 | 182 | ** Return the size of a file in bytes. Return -1 if the file does not |
| 144 | 183 | ** exist. If zFilename is NULL, return the size of the most recently |
| 145 | 184 | ** stat-ed file. |
| 146 | 185 | */ |
| 147 | -i64 file_size(const char *zFilename){ | |
| 148 | - return getStat(zFilename, 0) ? -1 : fileStat.st_size; | |
| 149 | -} | |
| 150 | - | |
| 151 | -/* | |
| 152 | -** Same as file_size(), but takes into account symlinks. | |
| 153 | -*/ | |
| 154 | -i64 file_wd_size(const char *zFilename){ | |
| 155 | - return getStat(zFilename, 1) ? -1 : fileStat.st_size; | |
| 186 | +i64 file_size(const char *zFilename, int eFType){ | |
| 187 | + return getStat(zFilename, eFType) ? -1 : fx.fileStat.st_size; | |
| 156 | 188 | } |
| 157 | 189 | |
| 158 | 190 | /* |
| 159 | 191 | ** Return the modification time for a file. Return -1 if the file |
| 160 | 192 | ** does not exist. If zFilename is NULL return the size of the most |
| 161 | 193 | ** recently stat-ed file. |
| 162 | 194 | */ |
| 163 | -i64 file_mtime(const char *zFilename){ | |
| 164 | - return getStat(zFilename, 0) ? -1 : fileStat.st_mtime; | |
| 165 | -} | |
| 166 | - | |
| 167 | -/* | |
| 168 | -** Same as file_mtime(), but takes into account symlinks. | |
| 169 | -*/ | |
| 170 | -i64 file_wd_mtime(const char *zFilename){ | |
| 171 | - return getStat(zFilename, 1) ? -1 : fileStat.st_mtime; | |
| 195 | +i64 file_mtime(const char *zFilename, int eFType){ | |
| 196 | + return getStat(zFilename, eFType) ? -1 : fx.fileStat.st_mtime; | |
| 172 | 197 | } |
| 173 | 198 | |
| 174 | 199 | /* |
| 175 | 200 | ** Return the mode bits for a file. Return -1 if the file does not |
| 176 | 201 | ** exist. If zFilename is NULL return the size of the most recently |
| 177 | 202 | ** stat-ed file. |
| 178 | 203 | */ |
| 179 | -int file_mode(const char *zFilename){ | |
| 180 | - return getStat(zFilename, 0) ? -1 : fileStat.st_mode; | |
| 204 | +int file_mode(const char *zFilename, int eFType){ | |
| 205 | + return getStat(zFilename, eFType) ? -1 : fx.fileStat.st_mode; | |
| 181 | 206 | } |
| 182 | 207 | |
| 183 | 208 | /* |
| 184 | -** Same as file_mode(), but takes into account symlinks. | |
| 185 | -*/ | |
| 186 | -int file_wd_mode(const char *zFilename){ | |
| 187 | - return getStat(zFilename, 1) ? -1 : fileStat.st_mode; | |
| 188 | -} | |
| 189 | - | |
| 190 | -/* | |
| 191 | -** Return TRUE if the named file is an ordinary file or symlink | |
| 192 | -** and symlinks are allowed. | |
| 193 | -** Return false for directories, devices, fifos, etc. | |
| 194 | -*/ | |
| 195 | -int file_wd_isfile_or_link(const char *zFilename){ | |
| 196 | - return getStat(zFilename, 1) ? 0 : S_ISREG(fileStat.st_mode) || | |
| 197 | - S_ISLNK(fileStat.st_mode); | |
| 209 | +** Return TRUE if either of the following are true: | |
| 210 | +** | |
| 211 | +** (1) zFilename is an ordinary file | |
| 212 | +** | |
| 213 | +** (2) allow_symlinks is on and zFilename is a symbolic link to | |
| 214 | +** a file, directory, or other object | |
| 215 | +*/ | |
| 216 | +int file_isfile_or_link(const char *zFilename){ | |
| 217 | + if( getStat(zFilename, RepoFILE) ){ | |
| 218 | + return 0; /* stat() failed. Return false. */ | |
| 219 | + } | |
| 220 | + return S_ISREG(fx.fileStat.st_mode) || S_ISLNK(fx.fileStat.st_mode); | |
| 198 | 221 | } |
| 199 | 222 | |
| 200 | 223 | /* |
| 201 | 224 | ** Return TRUE if the named file is an ordinary file. Return false |
| 202 | 225 | ** for directories, devices, fifos, symlinks, etc. |
| 203 | 226 | */ |
| 204 | -int file_isfile(const char *zFilename){ | |
| 205 | - return getStat(zFilename, 0) ? 0 : S_ISREG(fileStat.st_mode); | |
| 227 | +int file_isfile(const char *zFilename, int eFType){ | |
| 228 | + return getStat(zFilename, eFType) ? 0 : S_ISREG(fx.fileStat.st_mode); | |
| 206 | 229 | } |
| 207 | 230 | |
| 208 | 231 | /* |
| 209 | -** Same as file_isfile(), but takes into account symlinks. | |
| 210 | -*/ | |
| 211 | -int file_wd_isfile(const char *zFilename){ | |
| 212 | - return getStat(zFilename, 1) ? 0 : S_ISREG(fileStat.st_mode); | |
| 213 | -} | |
| 214 | - | |
| 215 | -/* | |
| 216 | -** Create symlink to file on Unix, or plain-text file with | |
| 217 | -** symlink target if "allow-symlinks" is off or we're on Windows. | |
| 232 | +** Create a symbolic link named zLinkFile that points to zTargetFile. | |
| 218 | 233 | ** |
| 219 | -** Arguments: target file (symlink will point to it), link file | |
| 234 | +** If allow-symlinks is off, create an ordinary file named zLinkFile | |
| 235 | +** with the name of zTargetFile as its content. | |
| 220 | 236 | **/ |
| 221 | 237 | void symlink_create(const char *zTargetFile, const char *zLinkFile){ |
| 222 | 238 | #if !defined(_WIN32) |
| 223 | 239 | if( db_allow_symlinks() ){ |
| 224 | 240 | int i, nName; |
| @@ -233,14 +249,14 @@ | ||
| 233 | 249 | } |
| 234 | 250 | nName = file_simplify_name(zName, nName, 0); |
| 235 | 251 | for(i=1; i<nName; i++){ |
| 236 | 252 | if( zName[i]=='/' ){ |
| 237 | 253 | zName[i] = 0; |
| 238 | - if( file_mkdir(zName, 1) ){ | |
| 239 | - fossil_fatal_recursive("unable to create directory %s", zName); | |
| 240 | - return; | |
| 241 | - } | |
| 254 | + if( file_mkdir(zName, ExtFILE, 1) ){ | |
| 255 | + fossil_fatal_recursive("unable to create directory %s", zName); | |
| 256 | + return; | |
| 257 | + } | |
| 242 | 258 | zName[i] = '/'; |
| 243 | 259 | } |
| 244 | 260 | } |
| 245 | 261 | if( symlink(zTargetFile, zName)!=0 ){ |
| 246 | 262 | fossil_fatal_recursive("unable to create symlink \"%s\"", zName); |
| @@ -269,17 +285,22 @@ | ||
| 269 | 285 | /* |
| 270 | 286 | ** Return file permissions (normal, executable, or symlink): |
| 271 | 287 | ** - PERM_EXE on Unix if file is executable; |
| 272 | 288 | ** - PERM_LNK on Unix if file is symlink and allow-symlinks option is on; |
| 273 | 289 | ** - PERM_REG for all other cases (regular file, directory, fifo, etc). |
| 290 | +** | |
| 291 | +** If eFType is ExtFile then symbolic links are followed and so this | |
| 292 | +** routine can only return PERM_EXE and PERM_REG. | |
| 293 | +** | |
| 294 | +** On windows, this routine returns only PERM_REG. | |
| 274 | 295 | */ |
| 275 | -int file_wd_perm(const char *zFilename){ | |
| 296 | +int file_perm(const char *zFilename, int eFType){ | |
| 276 | 297 | #if !defined(_WIN32) |
| 277 | - if( !getStat(zFilename, 1) ){ | |
| 278 | - if( S_ISREG(fileStat.st_mode) && ((S_IXUSR)&fileStat.st_mode)!=0 ) | |
| 298 | + if( !getStat(zFilename, RepoFILE) ){ | |
| 299 | + if( S_ISREG(fx.fileStat.st_mode) && ((S_IXUSR)&fx.fileStat.st_mode)!=0 ) | |
| 279 | 300 | return PERM_EXE; |
| 280 | - else if( db_allow_symlinks() && S_ISLNK(fileStat.st_mode) ) | |
| 301 | + else if( db_allow_symlinks() && S_ISLNK(fx.fileStat.st_mode) ) | |
| 281 | 302 | return PERM_LNK; |
| 282 | 303 | } |
| 283 | 304 | #endif |
| 284 | 305 | return PERM_REG; |
| 285 | 306 | } |
| @@ -286,65 +307,42 @@ | ||
| 286 | 307 | |
| 287 | 308 | /* |
| 288 | 309 | ** Return TRUE if the named file is an executable. Return false |
| 289 | 310 | ** for directories, devices, fifos, symlinks, etc. |
| 290 | 311 | */ |
| 291 | -int file_wd_isexe(const char *zFilename){ | |
| 292 | - return file_wd_perm(zFilename)==PERM_EXE; | |
| 312 | +int file_isexe(const char *zFilename, int eFType){ | |
| 313 | + return file_perm(zFilename, eFType)==PERM_EXE; | |
| 293 | 314 | } |
| 294 | 315 | |
| 295 | 316 | /* |
| 296 | 317 | ** Return TRUE if the named file is a symlink and symlinks are allowed. |
| 297 | 318 | ** Return false for all other cases. |
| 298 | 319 | ** |
| 320 | +** This routines RepoFILE - that zFilename is always a file under management. | |
| 321 | +** | |
| 299 | 322 | ** On Windows, always return False. |
| 300 | 323 | */ |
| 301 | -int file_wd_islink(const char *zFilename){ | |
| 302 | - return file_wd_perm(zFilename)==PERM_LNK; | |
| 324 | +int file_islink(const char *zFilename){ | |
| 325 | + return file_perm(zFilename, RepoFILE)==PERM_LNK; | |
| 303 | 326 | } |
| 304 | 327 | |
| 305 | 328 | /* |
| 306 | 329 | ** Return 1 if zFilename is a directory. Return 0 if zFilename |
| 307 | 330 | ** does not exist. Return 2 if zFilename exists but is something |
| 308 | 331 | ** other than a directory. |
| 309 | 332 | */ |
| 310 | -int file_isdir(const char *zFilename){ | |
| 311 | - int rc; | |
| 312 | - | |
| 313 | - if( zFilename ){ | |
| 314 | - char *zFN = mprintf("%s", zFilename); | |
| 315 | - file_simplify_name(zFN, -1, 0); | |
| 316 | - rc = getStat(zFN, 0); | |
| 317 | - free(zFN); | |
| 318 | - }else{ | |
| 319 | - rc = getStat(0, 0); | |
| 320 | - } | |
| 321 | - return rc ? 0 : (S_ISDIR(fileStat.st_mode) ? 1 : 2); | |
| 322 | -} | |
| 323 | - | |
| 324 | -/* | |
| 325 | -** Same as file_isdir(), but takes into account symlinks. Return 1 if | |
| 326 | -** zFilename is a directory -OR- a symlink that points to a directory. | |
| 327 | -** Return 0 if zFilename does not exist. Return 2 if zFilename exists | |
| 328 | -** but is something other than a directory. | |
| 329 | -*/ | |
| 330 | -int file_wd_isdir(const char *zFilename){ | |
| 333 | +int file_isdir(const char *zFilename, int eFType){ | |
| 331 | 334 | int rc; |
| 332 | 335 | char *zFN; |
| 333 | 336 | |
| 334 | 337 | zFN = mprintf("%s", zFilename); |
| 335 | 338 | file_simplify_name(zFN, -1, 0); |
| 336 | - rc = getStat(zFN, 1); | |
| 339 | + rc = getStat(zFN, eFType); | |
| 337 | 340 | if( rc ){ |
| 338 | 341 | rc = 0; /* It does not exist at all. */ |
| 339 | - }else if( S_ISDIR(fileStat.st_mode) ){ | |
| 342 | + }else if( S_ISDIR(fx.fileStat.st_mode) ){ | |
| 340 | 343 | rc = 1; /* It exists and is a real directory. */ |
| 341 | - }else if( S_ISLNK(fileStat.st_mode) ){ | |
| 342 | - Blob content; | |
| 343 | - blob_read_link(&content, zFN); /* It exists and is a link. */ | |
| 344 | - rc = file_wd_isdir(blob_str(&content)); /* Points to directory? */ | |
| 345 | - blob_reset(&content); | |
| 346 | 344 | }else{ |
| 347 | 345 | rc = 2; /* It exists and is something else. */ |
| 348 | 346 | } |
| 349 | 347 | free(zFN); |
| 350 | 348 | return rc; |
| @@ -397,11 +395,11 @@ | ||
| 397 | 395 | */ |
| 398 | 396 | char *file_newname(const char *zBase, const char *zSuffix, int relFlag){ |
| 399 | 397 | char *z = 0; |
| 400 | 398 | int cnt = 0; |
| 401 | 399 | z = mprintf("%s-%s", zBase, zSuffix); |
| 402 | - while( file_size(z)>=0 ){ | |
| 400 | + while( file_size(z, ExtFILE)>=0 ){ | |
| 403 | 401 | fossil_free(z); |
| 404 | 402 | z = mprintf("%s-%s-%d", zBase, zSuffix, cnt++); |
| 405 | 403 | } |
| 406 | 404 | if( relFlag ){ |
| 407 | 405 | Blob x; |
| @@ -473,11 +471,11 @@ | ||
| 473 | 471 | FILE *in, *out; |
| 474 | 472 | int got; |
| 475 | 473 | char zBuf[8192]; |
| 476 | 474 | in = fossil_fopen(zFrom, "rb"); |
| 477 | 475 | if( in==0 ) fossil_fatal("cannot open \"%s\" for reading", zFrom); |
| 478 | - file_mkfolder(zTo, 0, 0); | |
| 476 | + file_mkfolder(zTo, ExtFILE, 0, 0); | |
| 479 | 477 | out = fossil_fopen(zTo, "wb"); |
| 480 | 478 | if( out==0 ) fossil_fatal("cannot open \"%s\" for writing", zTo); |
| 481 | 479 | while( (got=fread(zBuf, 1, sizeof(zBuf), in))>0 ){ |
| 482 | 480 | fwrite(zBuf, 1, got, out); |
| 483 | 481 | } |
| @@ -502,16 +500,22 @@ | ||
| 502 | 500 | } |
| 503 | 501 | |
| 504 | 502 | /* |
| 505 | 503 | ** Set or clear the execute bit on a file. Return true if a change |
| 506 | 504 | ** occurred and false if this routine is a no-op. |
| 505 | +** | |
| 506 | +** This routine assumes RepoFILE as the eFType. In other words, if | |
| 507 | +** zFilename is a symbolic link, it is the object that zFilename points | |
| 508 | +** to that is modified. | |
| 507 | 509 | */ |
| 508 | -int file_wd_setexe(const char *zFilename, int onoff){ | |
| 510 | +int file_setexe(const char *zFilename, int onoff){ | |
| 509 | 511 | int rc = 0; |
| 510 | 512 | #if !defined(_WIN32) |
| 511 | 513 | struct stat buf; |
| 512 | - if( fossil_stat(zFilename, &buf, 1)!=0 || S_ISLNK(buf.st_mode) ) return 0; | |
| 514 | + if( fossil_stat(zFilename, &buf, RepoFILE)!=0 || S_ISLNK(buf.st_mode) ){ | |
| 515 | + return 0; | |
| 516 | + } | |
| 513 | 517 | if( onoff ){ |
| 514 | 518 | int targetMode = (buf.st_mode & 0444)>>2; |
| 515 | 519 | if( (buf.st_mode & 0100)==0 ){ |
| 516 | 520 | chmod(zFilename, buf.st_mode | targetMode); |
| 517 | 521 | rc = 1; |
| @@ -564,17 +568,20 @@ | ||
| 564 | 568 | } |
| 565 | 569 | db_open_or_attach(":memory:", "mem"); |
| 566 | 570 | iMTime = db_int64(0, "SELECT strftime('%%s',%Q)", g.argv[3]); |
| 567 | 571 | zFile = g.argv[2]; |
| 568 | 572 | file_set_mtime(zFile, iMTime); |
| 569 | - iMTime = file_wd_mtime(zFile); | |
| 573 | + iMTime = file_mtime(zFile, RepoFILE); | |
| 570 | 574 | zDate = db_text(0, "SELECT datetime(%lld, 'unixepoch')", iMTime); |
| 571 | 575 | fossil_print("Set mtime of \"%s\" to %s (%lld)\n", zFile, zDate, iMTime); |
| 572 | 576 | } |
| 573 | 577 | |
| 574 | 578 | /* |
| 575 | 579 | ** Delete a file. |
| 580 | +** | |
| 581 | +** If zFilename is a symbolic link, then it is the link itself that is | |
| 582 | +** removed, not the object that zFilename points to. | |
| 576 | 583 | ** |
| 577 | 584 | ** Returns zero upon success. |
| 578 | 585 | */ |
| 579 | 586 | int file_delete(const char *zFilename){ |
| 580 | 587 | int rc; |
| @@ -588,18 +595,18 @@ | ||
| 588 | 595 | fossil_path_free(z); |
| 589 | 596 | return rc; |
| 590 | 597 | } |
| 591 | 598 | |
| 592 | 599 | /* |
| 593 | -** Create the directory named in the argument, if it does not already | |
| 594 | -** exist. If forceFlag is 1, delete any prior non-directory object | |
| 600 | +** Create a directory called zName, if it does not already exist. | |
| 601 | +** If forceFlag is 1, delete any prior non-directory object | |
| 595 | 602 | ** with the same name. |
| 596 | 603 | ** |
| 597 | 604 | ** Return the number of errors. |
| 598 | 605 | */ |
| 599 | -int file_mkdir(const char *zName, int forceFlag){ | |
| 600 | - int rc = file_wd_isdir(zName); | |
| 606 | +int file_mkdir(const char *zName, int eFType, int forceFlag){ | |
| 607 | + int rc = file_isdir(zName, eFType); | |
| 601 | 608 | if( rc==2 ){ |
| 602 | 609 | if( !forceFlag ) return 1; |
| 603 | 610 | file_delete(zName); |
| 604 | 611 | } |
| 605 | 612 | if( rc!=1 ){ |
| @@ -621,24 +628,31 @@ | ||
| 621 | 628 | ** of directories does not already exist. |
| 622 | 629 | ** |
| 623 | 630 | ** On success, return zero. On error, return errorReturn if positive, otherwise |
| 624 | 631 | ** print an error message and abort. |
| 625 | 632 | */ |
| 626 | -int file_mkfolder(const char *zFilename, int forceFlag, int errorReturn){ | |
| 633 | +int file_mkfolder( | |
| 634 | + const char *zFilename, /* Pathname showing directories to be created */ | |
| 635 | + int eFType, /* Follow symlinks if ExtFILE */ | |
| 636 | + int forceFlag, /* Delete non-directory objects in the way */ | |
| 637 | + int errorReturn /* What to do when an error is seen */ | |
| 638 | +){ | |
| 627 | 639 | int nName, rc = 0; |
| 628 | 640 | char *zName; |
| 629 | 641 | |
| 630 | 642 | nName = strlen(zFilename); |
| 631 | 643 | zName = mprintf("%s", zFilename); |
| 632 | 644 | nName = file_simplify_name(zName, nName, 0); |
| 633 | 645 | while( nName>0 && zName[nName-1]!='/' ){ nName--; } |
| 634 | 646 | if( nName ){ |
| 635 | 647 | zName[nName-1] = 0; |
| 636 | - if( file_wd_isdir(zName)!=1 ){ | |
| 637 | - rc = file_mkfolder(zName, forceFlag, errorReturn); | |
| 648 | + if( file_isdir(zName, eFType)!=1 ){ | |
| 649 | + rc = file_mkfolder(zName, eFType, forceFlag, errorReturn); | |
| 638 | 650 | if( rc==0 ){ |
| 639 | - if( file_mkdir(zName, forceFlag) && file_wd_isdir(zName)!=1 ){ | |
| 651 | + if( file_mkdir(zName, eFType, forceFlag) | |
| 652 | + && file_isdir(zName, eFType)!=1 | |
| 653 | + ){ | |
| 640 | 654 | if( errorReturn <= 0 ){ |
| 641 | 655 | fossil_fatal_recursive("unable to create directory %s", zName); |
| 642 | 656 | } |
| 643 | 657 | rc = errorReturn; |
| 644 | 658 | } |
| @@ -654,11 +668,11 @@ | ||
| 654 | 668 | ** must be empty and cannot be the current directory or the root directory. |
| 655 | 669 | ** |
| 656 | 670 | ** Returns zero upon success. |
| 657 | 671 | */ |
| 658 | 672 | int file_rmdir(const char *zName){ |
| 659 | - int rc = file_wd_isdir(zName); | |
| 673 | + int rc = file_isdir(zName, RepoFILE); | |
| 660 | 674 | if( rc==2 ) return 1; /* cannot remove normal file */ |
| 661 | 675 | if( rc==1 ){ |
| 662 | 676 | #if defined(_WIN32) |
| 663 | 677 | wchar_t *zMbcs = fossil_utf8_to_path(zName, 1); |
| 664 | 678 | rc = _wrmdir(zMbcs); |
| @@ -994,35 +1008,34 @@ | ||
| 994 | 1008 | sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld (%s)", testFileStat.st_mtime, z); |
| 995 | 1009 | fossil_free(z); |
| 996 | 1010 | fossil_print(" l_stat_mtime = %s\n", zBuf); |
| 997 | 1011 | fossil_print(" l_stat_mode = 0%o\n", testFileStat.st_mode); |
| 998 | 1012 | if( reset ) resetStat(); |
| 999 | - sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", file_size(zPath)); | |
| 1000 | - fossil_print(" file_size = %s\n", zBuf); | |
| 1001 | - iMtime = file_mtime(zPath); | |
| 1002 | - z = db_text(0, "SELECT datetime(%lld, 'unixepoch')", iMtime); | |
| 1003 | - sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld (%s)", iMtime, z); | |
| 1004 | - fossil_free(z); | |
| 1005 | - fossil_print(" file_mtime = %s\n", zBuf); | |
| 1006 | - fossil_print(" file_mode = 0%o\n", file_mode(zPath)); | |
| 1007 | - fossil_print(" file_isfile = %d\n", file_isfile(zPath)); | |
| 1008 | - fossil_print(" file_isdir = %d\n", file_isdir(zPath)); | |
| 1009 | - if( reset ) resetStat(); | |
| 1010 | - sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", file_wd_size(zPath)); | |
| 1011 | - fossil_print(" file_wd_size = %s\n", zBuf); | |
| 1012 | - iMtime = file_wd_mtime(zPath); | |
| 1013 | - z = db_text(0, "SELECT datetime(%lld, 'unixepoch')", iMtime); | |
| 1014 | - sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld (%s)", iMtime, z); | |
| 1015 | - fossil_free(z); | |
| 1016 | - fossil_print(" file_wd_mtime = %s\n", zBuf); | |
| 1017 | - fossil_print(" file_wd_mode = 0%o\n", file_wd_mode(zPath)); | |
| 1018 | - fossil_print(" file_wd_isfile = %d\n", file_wd_isfile(zPath)); | |
| 1019 | - fossil_print(" file_wd_isfile_or_link = %d\n", | |
| 1020 | - file_wd_isfile_or_link(zPath)); | |
| 1021 | - fossil_print(" file_wd_islink = %d\n", file_wd_islink(zPath)); | |
| 1022 | - fossil_print(" file_wd_isexe = %d\n", file_wd_isexe(zPath)); | |
| 1023 | - fossil_print(" file_wd_isdir = %d\n", file_wd_isdir(zPath)); | |
| 1013 | + sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", file_size(zPath,ExtFILE)); | |
| 1014 | + fossil_print(" file_size(ExtFILE) = %s\n", zBuf); | |
| 1015 | + iMtime = file_mtime(zPath, ExtFILE); | |
| 1016 | + z = db_text(0, "SELECT datetime(%lld, 'unixepoch')", iMtime); | |
| 1017 | + sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld (%s)", iMtime, z); | |
| 1018 | + fossil_free(z); | |
| 1019 | + fossil_print(" file_mtime(ExtFILE) = %s\n", zBuf); | |
| 1020 | + fossil_print(" file_mode(ExtFILE) = 0%o\n", file_mode(zPath,ExtFILE)); | |
| 1021 | + fossil_print(" file_isfile(ExtFILE) = %d\n", file_isfile(zPath,ExtFILE)); | |
| 1022 | + fossil_print(" file_isdir(ExtFILE) = %d\n", file_isdir(zPath,ExtFILE)); | |
| 1023 | + if( reset ) resetStat(); | |
| 1024 | + sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", file_size(zPath,RepoFILE)); | |
| 1025 | + fossil_print(" file_size(RepoFILE) = %s\n", zBuf); | |
| 1026 | + iMtime = file_mtime(zPath,RepoFILE); | |
| 1027 | + z = db_text(0, "SELECT datetime(%lld, 'unixepoch')", iMtime); | |
| 1028 | + sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld (%s)", iMtime, z); | |
| 1029 | + fossil_free(z); | |
| 1030 | + fossil_print(" file_mtime(RepoFILE) = %s\n", zBuf); | |
| 1031 | + fossil_print(" file_mode(RepoFILE) = 0%o\n", file_mode(zPath,RepoFILE)); | |
| 1032 | + fossil_print(" file_isfile(RepoFILE) = %d\n", file_isfile(zPath,RepoFILE)); | |
| 1033 | + fossil_print(" file_isfile_or_link = %d\n", file_isfile_or_link(zPath)); | |
| 1034 | + fossil_print(" file_islink = %d\n", file_islink(zPath)); | |
| 1035 | + fossil_print(" file_isexe(RepoFILE) = %d\n", file_isexe(zPath,RepoFILE)); | |
| 1036 | + fossil_print(" file_isdir(RepoFILE) = %d\n", file_isdir(zPath,RepoFILE)); | |
| 1024 | 1037 | if( reset ) resetStat(); |
| 1025 | 1038 | } |
| 1026 | 1039 | |
| 1027 | 1040 | /* |
| 1028 | 1041 | ** COMMAND: test-file-environment |
| @@ -1078,19 +1091,19 @@ | ||
| 1078 | 1091 | char zBuf[100]; |
| 1079 | 1092 | const char *zName = g.argv[i]; |
| 1080 | 1093 | file_canonical_name(zName, &x, slashFlag); |
| 1081 | 1094 | fossil_print("[%s] -> [%s]\n", zName, blob_buffer(&x)); |
| 1082 | 1095 | blob_reset(&x); |
| 1083 | - sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", file_wd_size(zName)); | |
| 1084 | - fossil_print(" file_size = %s\n", zBuf); | |
| 1085 | - sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", file_wd_mtime(zName)); | |
| 1086 | - fossil_print(" file_mtime = %s\n", zBuf); | |
| 1087 | - fossil_print(" file_isfile = %d\n", file_wd_isfile(zName)); | |
| 1088 | - fossil_print(" file_isfile_or_link = %d\n",file_wd_isfile_or_link(zName)); | |
| 1089 | - fossil_print(" file_islink = %d\n", file_wd_islink(zName)); | |
| 1090 | - fossil_print(" file_isexe = %d\n", file_wd_isexe(zName)); | |
| 1091 | - fossil_print(" file_isdir = %d\n", file_wd_isdir(zName)); | |
| 1096 | + sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", file_size(zName,RepoFILE)); | |
| 1097 | + fossil_print(" file_size = %s\n", zBuf); | |
| 1098 | + sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", file_mtime(zName,RepoFILE)); | |
| 1099 | + fossil_print(" file_mtime = %s\n", zBuf); | |
| 1100 | + fossil_print(" file_isfile = %d\n", file_isfile(zName,RepoFILE)); | |
| 1101 | + fossil_print(" file_isfile_or_link = %d\n", file_isfile_or_link(zName)); | |
| 1102 | + fossil_print(" file_islink = %d\n", file_islink(zName)); | |
| 1103 | + fossil_print(" file_isexe = %d\n", file_isexe(zName,RepoFILE)); | |
| 1104 | + fossil_print(" file_isdir = %d\n", file_isdir(zName,RepoFILE)); | |
| 1092 | 1105 | } |
| 1093 | 1106 | } |
| 1094 | 1107 | |
| 1095 | 1108 | /* |
| 1096 | 1109 | ** Return TRUE if the given filename is canonical. |
| @@ -1426,11 +1439,11 @@ | ||
| 1426 | 1439 | azDirs[0] = fossil_getenv("TMPDIR"); |
| 1427 | 1440 | #endif |
| 1428 | 1441 | |
| 1429 | 1442 | for(i=0; i<count(azDirs); i++){ |
| 1430 | 1443 | if( azDirs[i]==0 ) continue; |
| 1431 | - if( !file_isdir(azDirs[i]) ) continue; | |
| 1444 | + if( !file_isdir(azDirs[i], ExtFILE) ) continue; | |
| 1432 | 1445 | zDir = azDirs[i]; |
| 1433 | 1446 | break; |
| 1434 | 1447 | } |
| 1435 | 1448 | |
| 1436 | 1449 | do{ |
| @@ -1440,11 +1453,11 @@ | ||
| 1440 | 1453 | for(i=0; i<15; i++){ |
| 1441 | 1454 | zRand[i] = (char)zChars[ ((unsigned char)zRand[i])%(sizeof(zChars)-1) ]; |
| 1442 | 1455 | } |
| 1443 | 1456 | zRand[15] = 0; |
| 1444 | 1457 | blob_appendf(pBuf, "%s/%s-%s.txt", zDir, zPrefix ? zPrefix : "", zRand); |
| 1445 | - }while( file_size(blob_str(pBuf))>=0 ); | |
| 1458 | + }while( file_size(blob_str(pBuf), ExtFILE)>=0 ); | |
| 1446 | 1459 | |
| 1447 | 1460 | #if defined(_WIN32) |
| 1448 | 1461 | fossil_path_free((char *)azDirs[0]); |
| 1449 | 1462 | fossil_path_free((char *)azDirs[1]); |
| 1450 | 1463 | fossil_path_free((char *)azDirs[2]); |
| @@ -1477,24 +1490,22 @@ | ||
| 1477 | 1490 | |
| 1478 | 1491 | /* |
| 1479 | 1492 | ** Return true if a file named zName exists and has identical content |
| 1480 | 1493 | ** to the blob pContent. If zName does not exist or if the content is |
| 1481 | 1494 | ** different in any way, then return false. |
| 1495 | +** | |
| 1496 | +** This routine assumes RepoFILE | |
| 1482 | 1497 | */ |
| 1483 | 1498 | int file_is_the_same(Blob *pContent, const char *zName){ |
| 1484 | 1499 | i64 iSize; |
| 1485 | 1500 | int rc; |
| 1486 | 1501 | Blob onDisk; |
| 1487 | 1502 | |
| 1488 | - iSize = file_wd_size(zName); | |
| 1503 | + iSize = file_size(zName, RepoFILE); | |
| 1489 | 1504 | if( iSize<0 ) return 0; |
| 1490 | 1505 | if( iSize!=blob_size(pContent) ) return 0; |
| 1491 | - if( file_wd_islink(zName) ){ | |
| 1492 | - blob_read_link(&onDisk, zName); | |
| 1493 | - }else{ | |
| 1494 | - blob_read_from_file(&onDisk, zName); | |
| 1495 | - } | |
| 1506 | + blob_read_from_file(&onDisk, zName, RepoFILE); | |
| 1496 | 1507 | rc = blob_compare(&onDisk, pContent); |
| 1497 | 1508 | blob_reset(&onDisk); |
| 1498 | 1509 | return rc==0; |
| 1499 | 1510 | } |
| 1500 | 1511 | |
| @@ -1533,10 +1544,13 @@ | ||
| 1533 | 1544 | return rc; |
| 1534 | 1545 | } |
| 1535 | 1546 | |
| 1536 | 1547 | /* |
| 1537 | 1548 | ** Like fopen() but always takes a UTF8 argument. |
| 1549 | +** | |
| 1550 | +** This function assumes ExtFILE. In other words, symbolic links | |
| 1551 | +** are always followed. | |
| 1538 | 1552 | */ |
| 1539 | 1553 | FILE *fossil_fopen(const char *zName, const char *zMode){ |
| 1540 | 1554 | #ifdef _WIN32 |
| 1541 | 1555 | wchar_t *uMode = fossil_utf8_to_unicode(zMode); |
| 1542 | 1556 | wchar_t *uName = fossil_utf8_to_path(zName, 0); |
| 1543 | 1557 |
| --- src/file.c | |
| +++ src/file.c | |
| @@ -2,11 +2,11 @@ | |
| 2 | ** Copyright (c) 2006 D. Richard Hipp |
| 3 | ** |
| 4 | ** This program is free software; you can redistribute it and/or |
| 5 | ** modify it under the terms of the Simplified BSD License (also |
| 6 | ** known as the "2-Clause License" or "FreeBSD License".) |
| 7 | |
| 8 | ** This program is distributed in the hope that it will be useful, |
| 9 | ** but without any warranty; without even the implied warranty of |
| 10 | ** merchantability or fitness for a particular purpose. |
| 11 | ** |
| 12 | ** Author contact information: |
| @@ -14,15 +14,10 @@ | |
| 14 | ** http://www.hwaci.com/drh/ |
| 15 | ** |
| 16 | ******************************************************************************* |
| 17 | ** |
| 18 | ** File utilities. |
| 19 | ** |
| 20 | ** Functions named file_* are generic functions that always follow symlinks. |
| 21 | ** |
| 22 | ** Functions named file_wd_* are to be used for files inside working |
| 23 | ** directories. They follow symlinks depending on 'allow-symlinks' setting. |
| 24 | */ |
| 25 | #include "config.h" |
| 26 | #include <sys/types.h> |
| 27 | #include <sys/stat.h> |
| 28 | #include <unistd.h> |
| @@ -42,10 +37,36 @@ | |
| 42 | # include <sys/time.h> |
| 43 | #endif |
| 44 | |
| 45 | #if INTERFACE |
| 46 | |
| 47 | #include <dirent.h> |
| 48 | #if defined(_WIN32) |
| 49 | # define DIR _WDIR |
| 50 | # define dirent _wdirent |
| 51 | # define opendir _wopendir |
| @@ -52,10 +73,13 @@ | |
| 52 | # define readdir _wreaddir |
| 53 | # define closedir _wclosedir |
| 54 | #endif /* _WIN32 */ |
| 55 | |
| 56 | #if defined(_WIN32) && (defined(__MSVCRT__) || defined(_MSC_VER)) |
| 57 | struct fossilStat { |
| 58 | i64 st_size; |
| 59 | i64 st_mtime; |
| 60 | int st_mode; |
| 61 | }; |
| @@ -68,73 +92,88 @@ | |
| 68 | #endif |
| 69 | |
| 70 | #endif /* INTERFACE */ |
| 71 | |
| 72 | #if !defined(_WIN32) || !(defined(__MSVCRT__) || defined(_MSC_VER)) |
| 73 | # define fossilStat stat |
| 74 | #endif |
| 75 | |
| 76 | /* |
| 77 | ** On Windows S_ISLNK always returns FALSE. |
| 78 | */ |
| 79 | #if !defined(S_ISLNK) |
| 80 | # define S_ISLNK(x) (0) |
| 81 | #endif |
| 82 | static int fileStatValid = 0; |
| 83 | static struct fossilStat fileStat; |
| 84 | |
| 85 | /* |
| 86 | ** Fill stat buf with information received from stat() or lstat(). |
| 87 | ** lstat() is called on Unix if isWd is TRUE and allow-symlinks setting is on. |
| 88 | */ |
| 89 | static int fossil_stat( |
| 90 | const char *zFilename, /* name of file or directory to inspect. */ |
| 91 | struct fossilStat *buf, /* pointer to buffer where info should go. */ |
| 92 | int isWd /* non-zero to consider look at symlink itself. */ |
| 93 | ){ |
| 94 | int rc; |
| 95 | void *zMbcs = fossil_utf8_to_path(zFilename, 0); |
| 96 | #if !defined(_WIN32) |
| 97 | if( isWd && db_allow_symlinks() ){ |
| 98 | rc = lstat(zMbcs, buf); |
| 99 | }else{ |
| 100 | rc = stat(zMbcs, buf); |
| 101 | } |
| 102 | #else |
| 103 | rc = win32_stat(zMbcs, buf, isWd); |
| 104 | #endif |
| 105 | fossil_path_free(zMbcs); |
| 106 | return rc; |
| 107 | } |
| 108 | |
| 109 | /* |
| 110 | ** Clears the fileStat variable and its associated validity flag. |
| 111 | */ |
| 112 | static void resetStat(){ |
| 113 | fileStatValid = 0; |
| 114 | memset(&fileStat, 0, sizeof(struct fossilStat)); |
| 115 | } |
| 116 | |
| 117 | /* |
| 118 | ** Fill in the fileStat variable for the file named zFilename. |
| 119 | ** If zFilename==0, then use the previous value of fileStat if |
| 120 | ** there is a previous value. |
| 121 | ** |
| 122 | ** If isWd is TRUE, do lstat() instead of stat() if allow-symlinks is on. |
| 123 | ** |
| 124 | ** Return the number of errors. No error messages are generated. |
| 125 | */ |
| 126 | static int getStat(const char *zFilename, int isWd){ |
| 127 | int rc = 0; |
| 128 | if( zFilename==0 ){ |
| 129 | if( fileStatValid==0 ) rc = 1; |
| 130 | }else{ |
| 131 | if( fossil_stat(zFilename, &fileStat, isWd)!=0 ){ |
| 132 | fileStatValid = 0; |
| 133 | rc = 1; |
| 134 | }else{ |
| 135 | fileStatValid = 1; |
| 136 | rc = 0; |
| 137 | } |
| 138 | } |
| 139 | return rc; |
| 140 | } |
| @@ -142,83 +181,60 @@ | |
| 142 | /* |
| 143 | ** Return the size of a file in bytes. Return -1 if the file does not |
| 144 | ** exist. If zFilename is NULL, return the size of the most recently |
| 145 | ** stat-ed file. |
| 146 | */ |
| 147 | i64 file_size(const char *zFilename){ |
| 148 | return getStat(zFilename, 0) ? -1 : fileStat.st_size; |
| 149 | } |
| 150 | |
| 151 | /* |
| 152 | ** Same as file_size(), but takes into account symlinks. |
| 153 | */ |
| 154 | i64 file_wd_size(const char *zFilename){ |
| 155 | return getStat(zFilename, 1) ? -1 : fileStat.st_size; |
| 156 | } |
| 157 | |
| 158 | /* |
| 159 | ** Return the modification time for a file. Return -1 if the file |
| 160 | ** does not exist. If zFilename is NULL return the size of the most |
| 161 | ** recently stat-ed file. |
| 162 | */ |
| 163 | i64 file_mtime(const char *zFilename){ |
| 164 | return getStat(zFilename, 0) ? -1 : fileStat.st_mtime; |
| 165 | } |
| 166 | |
| 167 | /* |
| 168 | ** Same as file_mtime(), but takes into account symlinks. |
| 169 | */ |
| 170 | i64 file_wd_mtime(const char *zFilename){ |
| 171 | return getStat(zFilename, 1) ? -1 : fileStat.st_mtime; |
| 172 | } |
| 173 | |
| 174 | /* |
| 175 | ** Return the mode bits for a file. Return -1 if the file does not |
| 176 | ** exist. If zFilename is NULL return the size of the most recently |
| 177 | ** stat-ed file. |
| 178 | */ |
| 179 | int file_mode(const char *zFilename){ |
| 180 | return getStat(zFilename, 0) ? -1 : fileStat.st_mode; |
| 181 | } |
| 182 | |
| 183 | /* |
| 184 | ** Same as file_mode(), but takes into account symlinks. |
| 185 | */ |
| 186 | int file_wd_mode(const char *zFilename){ |
| 187 | return getStat(zFilename, 1) ? -1 : fileStat.st_mode; |
| 188 | } |
| 189 | |
| 190 | /* |
| 191 | ** Return TRUE if the named file is an ordinary file or symlink |
| 192 | ** and symlinks are allowed. |
| 193 | ** Return false for directories, devices, fifos, etc. |
| 194 | */ |
| 195 | int file_wd_isfile_or_link(const char *zFilename){ |
| 196 | return getStat(zFilename, 1) ? 0 : S_ISREG(fileStat.st_mode) || |
| 197 | S_ISLNK(fileStat.st_mode); |
| 198 | } |
| 199 | |
| 200 | /* |
| 201 | ** Return TRUE if the named file is an ordinary file. Return false |
| 202 | ** for directories, devices, fifos, symlinks, etc. |
| 203 | */ |
| 204 | int file_isfile(const char *zFilename){ |
| 205 | return getStat(zFilename, 0) ? 0 : S_ISREG(fileStat.st_mode); |
| 206 | } |
| 207 | |
| 208 | /* |
| 209 | ** Same as file_isfile(), but takes into account symlinks. |
| 210 | */ |
| 211 | int file_wd_isfile(const char *zFilename){ |
| 212 | return getStat(zFilename, 1) ? 0 : S_ISREG(fileStat.st_mode); |
| 213 | } |
| 214 | |
| 215 | /* |
| 216 | ** Create symlink to file on Unix, or plain-text file with |
| 217 | ** symlink target if "allow-symlinks" is off or we're on Windows. |
| 218 | ** |
| 219 | ** Arguments: target file (symlink will point to it), link file |
| 220 | **/ |
| 221 | void symlink_create(const char *zTargetFile, const char *zLinkFile){ |
| 222 | #if !defined(_WIN32) |
| 223 | if( db_allow_symlinks() ){ |
| 224 | int i, nName; |
| @@ -233,14 +249,14 @@ | |
| 233 | } |
| 234 | nName = file_simplify_name(zName, nName, 0); |
| 235 | for(i=1; i<nName; i++){ |
| 236 | if( zName[i]=='/' ){ |
| 237 | zName[i] = 0; |
| 238 | if( file_mkdir(zName, 1) ){ |
| 239 | fossil_fatal_recursive("unable to create directory %s", zName); |
| 240 | return; |
| 241 | } |
| 242 | zName[i] = '/'; |
| 243 | } |
| 244 | } |
| 245 | if( symlink(zTargetFile, zName)!=0 ){ |
| 246 | fossil_fatal_recursive("unable to create symlink \"%s\"", zName); |
| @@ -269,17 +285,22 @@ | |
| 269 | /* |
| 270 | ** Return file permissions (normal, executable, or symlink): |
| 271 | ** - PERM_EXE on Unix if file is executable; |
| 272 | ** - PERM_LNK on Unix if file is symlink and allow-symlinks option is on; |
| 273 | ** - PERM_REG for all other cases (regular file, directory, fifo, etc). |
| 274 | */ |
| 275 | int file_wd_perm(const char *zFilename){ |
| 276 | #if !defined(_WIN32) |
| 277 | if( !getStat(zFilename, 1) ){ |
| 278 | if( S_ISREG(fileStat.st_mode) && ((S_IXUSR)&fileStat.st_mode)!=0 ) |
| 279 | return PERM_EXE; |
| 280 | else if( db_allow_symlinks() && S_ISLNK(fileStat.st_mode) ) |
| 281 | return PERM_LNK; |
| 282 | } |
| 283 | #endif |
| 284 | return PERM_REG; |
| 285 | } |
| @@ -286,65 +307,42 @@ | |
| 286 | |
| 287 | /* |
| 288 | ** Return TRUE if the named file is an executable. Return false |
| 289 | ** for directories, devices, fifos, symlinks, etc. |
| 290 | */ |
| 291 | int file_wd_isexe(const char *zFilename){ |
| 292 | return file_wd_perm(zFilename)==PERM_EXE; |
| 293 | } |
| 294 | |
| 295 | /* |
| 296 | ** Return TRUE if the named file is a symlink and symlinks are allowed. |
| 297 | ** Return false for all other cases. |
| 298 | ** |
| 299 | ** On Windows, always return False. |
| 300 | */ |
| 301 | int file_wd_islink(const char *zFilename){ |
| 302 | return file_wd_perm(zFilename)==PERM_LNK; |
| 303 | } |
| 304 | |
| 305 | /* |
| 306 | ** Return 1 if zFilename is a directory. Return 0 if zFilename |
| 307 | ** does not exist. Return 2 if zFilename exists but is something |
| 308 | ** other than a directory. |
| 309 | */ |
| 310 | int file_isdir(const char *zFilename){ |
| 311 | int rc; |
| 312 | |
| 313 | if( zFilename ){ |
| 314 | char *zFN = mprintf("%s", zFilename); |
| 315 | file_simplify_name(zFN, -1, 0); |
| 316 | rc = getStat(zFN, 0); |
| 317 | free(zFN); |
| 318 | }else{ |
| 319 | rc = getStat(0, 0); |
| 320 | } |
| 321 | return rc ? 0 : (S_ISDIR(fileStat.st_mode) ? 1 : 2); |
| 322 | } |
| 323 | |
| 324 | /* |
| 325 | ** Same as file_isdir(), but takes into account symlinks. Return 1 if |
| 326 | ** zFilename is a directory -OR- a symlink that points to a directory. |
| 327 | ** Return 0 if zFilename does not exist. Return 2 if zFilename exists |
| 328 | ** but is something other than a directory. |
| 329 | */ |
| 330 | int file_wd_isdir(const char *zFilename){ |
| 331 | int rc; |
| 332 | char *zFN; |
| 333 | |
| 334 | zFN = mprintf("%s", zFilename); |
| 335 | file_simplify_name(zFN, -1, 0); |
| 336 | rc = getStat(zFN, 1); |
| 337 | if( rc ){ |
| 338 | rc = 0; /* It does not exist at all. */ |
| 339 | }else if( S_ISDIR(fileStat.st_mode) ){ |
| 340 | rc = 1; /* It exists and is a real directory. */ |
| 341 | }else if( S_ISLNK(fileStat.st_mode) ){ |
| 342 | Blob content; |
| 343 | blob_read_link(&content, zFN); /* It exists and is a link. */ |
| 344 | rc = file_wd_isdir(blob_str(&content)); /* Points to directory? */ |
| 345 | blob_reset(&content); |
| 346 | }else{ |
| 347 | rc = 2; /* It exists and is something else. */ |
| 348 | } |
| 349 | free(zFN); |
| 350 | return rc; |
| @@ -397,11 +395,11 @@ | |
| 397 | */ |
| 398 | char *file_newname(const char *zBase, const char *zSuffix, int relFlag){ |
| 399 | char *z = 0; |
| 400 | int cnt = 0; |
| 401 | z = mprintf("%s-%s", zBase, zSuffix); |
| 402 | while( file_size(z)>=0 ){ |
| 403 | fossil_free(z); |
| 404 | z = mprintf("%s-%s-%d", zBase, zSuffix, cnt++); |
| 405 | } |
| 406 | if( relFlag ){ |
| 407 | Blob x; |
| @@ -473,11 +471,11 @@ | |
| 473 | FILE *in, *out; |
| 474 | int got; |
| 475 | char zBuf[8192]; |
| 476 | in = fossil_fopen(zFrom, "rb"); |
| 477 | if( in==0 ) fossil_fatal("cannot open \"%s\" for reading", zFrom); |
| 478 | file_mkfolder(zTo, 0, 0); |
| 479 | out = fossil_fopen(zTo, "wb"); |
| 480 | if( out==0 ) fossil_fatal("cannot open \"%s\" for writing", zTo); |
| 481 | while( (got=fread(zBuf, 1, sizeof(zBuf), in))>0 ){ |
| 482 | fwrite(zBuf, 1, got, out); |
| 483 | } |
| @@ -502,16 +500,22 @@ | |
| 502 | } |
| 503 | |
| 504 | /* |
| 505 | ** Set or clear the execute bit on a file. Return true if a change |
| 506 | ** occurred and false if this routine is a no-op. |
| 507 | */ |
| 508 | int file_wd_setexe(const char *zFilename, int onoff){ |
| 509 | int rc = 0; |
| 510 | #if !defined(_WIN32) |
| 511 | struct stat buf; |
| 512 | if( fossil_stat(zFilename, &buf, 1)!=0 || S_ISLNK(buf.st_mode) ) return 0; |
| 513 | if( onoff ){ |
| 514 | int targetMode = (buf.st_mode & 0444)>>2; |
| 515 | if( (buf.st_mode & 0100)==0 ){ |
| 516 | chmod(zFilename, buf.st_mode | targetMode); |
| 517 | rc = 1; |
| @@ -564,17 +568,20 @@ | |
| 564 | } |
| 565 | db_open_or_attach(":memory:", "mem"); |
| 566 | iMTime = db_int64(0, "SELECT strftime('%%s',%Q)", g.argv[3]); |
| 567 | zFile = g.argv[2]; |
| 568 | file_set_mtime(zFile, iMTime); |
| 569 | iMTime = file_wd_mtime(zFile); |
| 570 | zDate = db_text(0, "SELECT datetime(%lld, 'unixepoch')", iMTime); |
| 571 | fossil_print("Set mtime of \"%s\" to %s (%lld)\n", zFile, zDate, iMTime); |
| 572 | } |
| 573 | |
| 574 | /* |
| 575 | ** Delete a file. |
| 576 | ** |
| 577 | ** Returns zero upon success. |
| 578 | */ |
| 579 | int file_delete(const char *zFilename){ |
| 580 | int rc; |
| @@ -588,18 +595,18 @@ | |
| 588 | fossil_path_free(z); |
| 589 | return rc; |
| 590 | } |
| 591 | |
| 592 | /* |
| 593 | ** Create the directory named in the argument, if it does not already |
| 594 | ** exist. If forceFlag is 1, delete any prior non-directory object |
| 595 | ** with the same name. |
| 596 | ** |
| 597 | ** Return the number of errors. |
| 598 | */ |
| 599 | int file_mkdir(const char *zName, int forceFlag){ |
| 600 | int rc = file_wd_isdir(zName); |
| 601 | if( rc==2 ){ |
| 602 | if( !forceFlag ) return 1; |
| 603 | file_delete(zName); |
| 604 | } |
| 605 | if( rc!=1 ){ |
| @@ -621,24 +628,31 @@ | |
| 621 | ** of directories does not already exist. |
| 622 | ** |
| 623 | ** On success, return zero. On error, return errorReturn if positive, otherwise |
| 624 | ** print an error message and abort. |
| 625 | */ |
| 626 | int file_mkfolder(const char *zFilename, int forceFlag, int errorReturn){ |
| 627 | int nName, rc = 0; |
| 628 | char *zName; |
| 629 | |
| 630 | nName = strlen(zFilename); |
| 631 | zName = mprintf("%s", zFilename); |
| 632 | nName = file_simplify_name(zName, nName, 0); |
| 633 | while( nName>0 && zName[nName-1]!='/' ){ nName--; } |
| 634 | if( nName ){ |
| 635 | zName[nName-1] = 0; |
| 636 | if( file_wd_isdir(zName)!=1 ){ |
| 637 | rc = file_mkfolder(zName, forceFlag, errorReturn); |
| 638 | if( rc==0 ){ |
| 639 | if( file_mkdir(zName, forceFlag) && file_wd_isdir(zName)!=1 ){ |
| 640 | if( errorReturn <= 0 ){ |
| 641 | fossil_fatal_recursive("unable to create directory %s", zName); |
| 642 | } |
| 643 | rc = errorReturn; |
| 644 | } |
| @@ -654,11 +668,11 @@ | |
| 654 | ** must be empty and cannot be the current directory or the root directory. |
| 655 | ** |
| 656 | ** Returns zero upon success. |
| 657 | */ |
| 658 | int file_rmdir(const char *zName){ |
| 659 | int rc = file_wd_isdir(zName); |
| 660 | if( rc==2 ) return 1; /* cannot remove normal file */ |
| 661 | if( rc==1 ){ |
| 662 | #if defined(_WIN32) |
| 663 | wchar_t *zMbcs = fossil_utf8_to_path(zName, 1); |
| 664 | rc = _wrmdir(zMbcs); |
| @@ -994,35 +1008,34 @@ | |
| 994 | sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld (%s)", testFileStat.st_mtime, z); |
| 995 | fossil_free(z); |
| 996 | fossil_print(" l_stat_mtime = %s\n", zBuf); |
| 997 | fossil_print(" l_stat_mode = 0%o\n", testFileStat.st_mode); |
| 998 | if( reset ) resetStat(); |
| 999 | sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", file_size(zPath)); |
| 1000 | fossil_print(" file_size = %s\n", zBuf); |
| 1001 | iMtime = file_mtime(zPath); |
| 1002 | z = db_text(0, "SELECT datetime(%lld, 'unixepoch')", iMtime); |
| 1003 | sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld (%s)", iMtime, z); |
| 1004 | fossil_free(z); |
| 1005 | fossil_print(" file_mtime = %s\n", zBuf); |
| 1006 | fossil_print(" file_mode = 0%o\n", file_mode(zPath)); |
| 1007 | fossil_print(" file_isfile = %d\n", file_isfile(zPath)); |
| 1008 | fossil_print(" file_isdir = %d\n", file_isdir(zPath)); |
| 1009 | if( reset ) resetStat(); |
| 1010 | sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", file_wd_size(zPath)); |
| 1011 | fossil_print(" file_wd_size = %s\n", zBuf); |
| 1012 | iMtime = file_wd_mtime(zPath); |
| 1013 | z = db_text(0, "SELECT datetime(%lld, 'unixepoch')", iMtime); |
| 1014 | sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld (%s)", iMtime, z); |
| 1015 | fossil_free(z); |
| 1016 | fossil_print(" file_wd_mtime = %s\n", zBuf); |
| 1017 | fossil_print(" file_wd_mode = 0%o\n", file_wd_mode(zPath)); |
| 1018 | fossil_print(" file_wd_isfile = %d\n", file_wd_isfile(zPath)); |
| 1019 | fossil_print(" file_wd_isfile_or_link = %d\n", |
| 1020 | file_wd_isfile_or_link(zPath)); |
| 1021 | fossil_print(" file_wd_islink = %d\n", file_wd_islink(zPath)); |
| 1022 | fossil_print(" file_wd_isexe = %d\n", file_wd_isexe(zPath)); |
| 1023 | fossil_print(" file_wd_isdir = %d\n", file_wd_isdir(zPath)); |
| 1024 | if( reset ) resetStat(); |
| 1025 | } |
| 1026 | |
| 1027 | /* |
| 1028 | ** COMMAND: test-file-environment |
| @@ -1078,19 +1091,19 @@ | |
| 1078 | char zBuf[100]; |
| 1079 | const char *zName = g.argv[i]; |
| 1080 | file_canonical_name(zName, &x, slashFlag); |
| 1081 | fossil_print("[%s] -> [%s]\n", zName, blob_buffer(&x)); |
| 1082 | blob_reset(&x); |
| 1083 | sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", file_wd_size(zName)); |
| 1084 | fossil_print(" file_size = %s\n", zBuf); |
| 1085 | sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", file_wd_mtime(zName)); |
| 1086 | fossil_print(" file_mtime = %s\n", zBuf); |
| 1087 | fossil_print(" file_isfile = %d\n", file_wd_isfile(zName)); |
| 1088 | fossil_print(" file_isfile_or_link = %d\n",file_wd_isfile_or_link(zName)); |
| 1089 | fossil_print(" file_islink = %d\n", file_wd_islink(zName)); |
| 1090 | fossil_print(" file_isexe = %d\n", file_wd_isexe(zName)); |
| 1091 | fossil_print(" file_isdir = %d\n", file_wd_isdir(zName)); |
| 1092 | } |
| 1093 | } |
| 1094 | |
| 1095 | /* |
| 1096 | ** Return TRUE if the given filename is canonical. |
| @@ -1426,11 +1439,11 @@ | |
| 1426 | azDirs[0] = fossil_getenv("TMPDIR"); |
| 1427 | #endif |
| 1428 | |
| 1429 | for(i=0; i<count(azDirs); i++){ |
| 1430 | if( azDirs[i]==0 ) continue; |
| 1431 | if( !file_isdir(azDirs[i]) ) continue; |
| 1432 | zDir = azDirs[i]; |
| 1433 | break; |
| 1434 | } |
| 1435 | |
| 1436 | do{ |
| @@ -1440,11 +1453,11 @@ | |
| 1440 | for(i=0; i<15; i++){ |
| 1441 | zRand[i] = (char)zChars[ ((unsigned char)zRand[i])%(sizeof(zChars)-1) ]; |
| 1442 | } |
| 1443 | zRand[15] = 0; |
| 1444 | blob_appendf(pBuf, "%s/%s-%s.txt", zDir, zPrefix ? zPrefix : "", zRand); |
| 1445 | }while( file_size(blob_str(pBuf))>=0 ); |
| 1446 | |
| 1447 | #if defined(_WIN32) |
| 1448 | fossil_path_free((char *)azDirs[0]); |
| 1449 | fossil_path_free((char *)azDirs[1]); |
| 1450 | fossil_path_free((char *)azDirs[2]); |
| @@ -1477,24 +1490,22 @@ | |
| 1477 | |
| 1478 | /* |
| 1479 | ** Return true if a file named zName exists and has identical content |
| 1480 | ** to the blob pContent. If zName does not exist or if the content is |
| 1481 | ** different in any way, then return false. |
| 1482 | */ |
| 1483 | int file_is_the_same(Blob *pContent, const char *zName){ |
| 1484 | i64 iSize; |
| 1485 | int rc; |
| 1486 | Blob onDisk; |
| 1487 | |
| 1488 | iSize = file_wd_size(zName); |
| 1489 | if( iSize<0 ) return 0; |
| 1490 | if( iSize!=blob_size(pContent) ) return 0; |
| 1491 | if( file_wd_islink(zName) ){ |
| 1492 | blob_read_link(&onDisk, zName); |
| 1493 | }else{ |
| 1494 | blob_read_from_file(&onDisk, zName); |
| 1495 | } |
| 1496 | rc = blob_compare(&onDisk, pContent); |
| 1497 | blob_reset(&onDisk); |
| 1498 | return rc==0; |
| 1499 | } |
| 1500 | |
| @@ -1533,10 +1544,13 @@ | |
| 1533 | return rc; |
| 1534 | } |
| 1535 | |
| 1536 | /* |
| 1537 | ** Like fopen() but always takes a UTF8 argument. |
| 1538 | */ |
| 1539 | FILE *fossil_fopen(const char *zName, const char *zMode){ |
| 1540 | #ifdef _WIN32 |
| 1541 | wchar_t *uMode = fossil_utf8_to_unicode(zMode); |
| 1542 | wchar_t *uName = fossil_utf8_to_path(zName, 0); |
| 1543 |
| --- src/file.c | |
| +++ src/file.c | |
| @@ -2,11 +2,11 @@ | |
| 2 | ** Copyright (c) 2006 D. Richard Hipp |
| 3 | ** |
| 4 | ** This program is free software; you can redistribute it and/or |
| 5 | ** modify it under the terms of the Simplified BSD License (also |
| 6 | ** known as the "2-Clause License" or "FreeBSD License".) |
| 7 | ** |
| 8 | ** This program is distributed in the hope that it will be useful, |
| 9 | ** but without any warranty; without even the implied warranty of |
| 10 | ** merchantability or fitness for a particular purpose. |
| 11 | ** |
| 12 | ** Author contact information: |
| @@ -14,15 +14,10 @@ | |
| 14 | ** http://www.hwaci.com/drh/ |
| 15 | ** |
| 16 | ******************************************************************************* |
| 17 | ** |
| 18 | ** File utilities. |
| 19 | */ |
| 20 | #include "config.h" |
| 21 | #include <sys/types.h> |
| 22 | #include <sys/stat.h> |
| 23 | #include <unistd.h> |
| @@ -42,10 +37,36 @@ | |
| 37 | # include <sys/time.h> |
| 38 | #endif |
| 39 | |
| 40 | #if INTERFACE |
| 41 | |
| 42 | /* Many APIs take a eFType argument which must be one of ExtFILE, RepoFILE, |
| 43 | ** or SymFILE. |
| 44 | ** |
| 45 | ** The difference is in the handling of symbolic links. RepoFILE should be |
| 46 | ** used for files that are under management by a Fossil repository. ExtFILE |
| 47 | ** should be used for files that are not under management. SymFILE is for |
| 48 | ** a few special cases such as the "fossil test-tarball" command when we never |
| 49 | ** want to follow symlinks. |
| 50 | ** |
| 51 | ** If RepoFILE is used and if the allow-symlinks setting is true and if |
| 52 | ** the object is a symbolic link, then the object is treated like an ordinary |
| 53 | ** file whose content is name of the object to which the symbolic link |
| 54 | ** points. |
| 55 | ** |
| 56 | ** If ExtFILE is used or allow-symlinks is false, then operations on a |
| 57 | ** symbolic link are the same as operations on the object to which the |
| 58 | ** symbolic link points. |
| 59 | ** |
| 60 | ** SymFILE is like RepoFILE except that it always uses the target filename of |
| 61 | ** a symbolic link as the content, instead of the content of the object |
| 62 | ** that the symlink points to. SymFILE acts as if allow-symlinks is always ON. |
| 63 | */ |
| 64 | #define ExtFILE 0 /* Always follow symlinks */ |
| 65 | #define RepoFILE 1 /* Follow symlinks iff allow-symlinks is OFF */ |
| 66 | #define SymFILE 2 /* Never follow symlinks */ |
| 67 | |
| 68 | #include <dirent.h> |
| 69 | #if defined(_WIN32) |
| 70 | # define DIR _WDIR |
| 71 | # define dirent _wdirent |
| 72 | # define opendir _wopendir |
| @@ -52,10 +73,13 @@ | |
| 73 | # define readdir _wreaddir |
| 74 | # define closedir _wclosedir |
| 75 | #endif /* _WIN32 */ |
| 76 | |
| 77 | #if defined(_WIN32) && (defined(__MSVCRT__) || defined(_MSC_VER)) |
| 78 | /* |
| 79 | ** File status information for windows systems. |
| 80 | */ |
| 81 | struct fossilStat { |
| 82 | i64 st_size; |
| 83 | i64 st_mtime; |
| 84 | int st_mode; |
| 85 | }; |
| @@ -68,73 +92,88 @@ | |
| 92 | #endif |
| 93 | |
| 94 | #endif /* INTERFACE */ |
| 95 | |
| 96 | #if !defined(_WIN32) || !(defined(__MSVCRT__) || defined(_MSC_VER)) |
| 97 | /* |
| 98 | ** File status information for unix systems |
| 99 | */ |
| 100 | # define fossilStat stat |
| 101 | #endif |
| 102 | |
| 103 | /* |
| 104 | ** On Windows S_ISLNK always returns FALSE. |
| 105 | */ |
| 106 | #if !defined(S_ISLNK) |
| 107 | # define S_ISLNK(x) (0) |
| 108 | #endif |
| 109 | |
| 110 | /* |
| 111 | ** Local state information for the file status routines |
| 112 | */ |
| 113 | static struct { |
| 114 | struct fossilStat fileStat; /* File status from last fossil_stat() */ |
| 115 | int fileStatValid; /* True if fileStat is valid */ |
| 116 | } fx; |
| 117 | |
| 118 | /* |
| 119 | ** Fill *buf with information about zFilename. |
| 120 | ** |
| 121 | ** If zFilename refers to a symbolic link: |
| 122 | ** |
| 123 | ** (A) If allow-symlinks is on and eFType is RepoFILE, then fill |
| 124 | ** *buf with information about the symbolic link itself. |
| 125 | ** |
| 126 | ** (B) If allow-symlinks is off or eFType is ExtFILE, then fill |
| 127 | ** *buf with information about the object that the symbolic link |
| 128 | ** points to. |
| 129 | */ |
| 130 | static int fossil_stat( |
| 131 | const char *zFilename, /* name of file or directory to inspect. */ |
| 132 | struct fossilStat *buf, /* pointer to buffer where info should go. */ |
| 133 | int eFType /* Look at symlink itself if RepoFILE and enabled. */ |
| 134 | ){ |
| 135 | int rc; |
| 136 | void *zMbcs = fossil_utf8_to_path(zFilename, 0); |
| 137 | #if !defined(_WIN32) |
| 138 | if( eFType>=RepoFILE && (eFType==SymFILE || db_allow_symlinks()) ){ |
| 139 | rc = lstat(zMbcs, buf); |
| 140 | }else{ |
| 141 | rc = stat(zMbcs, buf); |
| 142 | } |
| 143 | #else |
| 144 | rc = win32_stat(zMbcs, buf, eFType); |
| 145 | #endif |
| 146 | fossil_path_free(zMbcs); |
| 147 | return rc; |
| 148 | } |
| 149 | |
| 150 | /* |
| 151 | ** Clears the fx.fileStat variable and its associated validity flag. |
| 152 | */ |
| 153 | static void resetStat(){ |
| 154 | fx.fileStatValid = 0; |
| 155 | memset(&fx.fileStat, 0, sizeof(struct fossilStat)); |
| 156 | } |
| 157 | |
| 158 | /* |
| 159 | ** Fill in the fx.fileStat variable for the file named zFilename. |
| 160 | ** If zFilename==0, then use the previous value of fx.fileStat if |
| 161 | ** there is a previous value. |
| 162 | ** |
| 163 | ** Return the number of errors. No error messages are generated. |
| 164 | */ |
| 165 | static int getStat(const char *zFilename, int eFType){ |
| 166 | int rc = 0; |
| 167 | if( zFilename==0 ){ |
| 168 | if( fx.fileStatValid==0 ) rc = 1; |
| 169 | }else{ |
| 170 | if( fossil_stat(zFilename, &fx.fileStat, eFType)!=0 ){ |
| 171 | fx.fileStatValid = 0; |
| 172 | rc = 1; |
| 173 | }else{ |
| 174 | fx.fileStatValid = 1; |
| 175 | rc = 0; |
| 176 | } |
| 177 | } |
| 178 | return rc; |
| 179 | } |
| @@ -142,83 +181,60 @@ | |
| 181 | /* |
| 182 | ** Return the size of a file in bytes. Return -1 if the file does not |
| 183 | ** exist. If zFilename is NULL, return the size of the most recently |
| 184 | ** stat-ed file. |
| 185 | */ |
| 186 | i64 file_size(const char *zFilename, int eFType){ |
| 187 | return getStat(zFilename, eFType) ? -1 : fx.fileStat.st_size; |
| 188 | } |
| 189 | |
| 190 | /* |
| 191 | ** Return the modification time for a file. Return -1 if the file |
| 192 | ** does not exist. If zFilename is NULL return the size of the most |
| 193 | ** recently stat-ed file. |
| 194 | */ |
| 195 | i64 file_mtime(const char *zFilename, int eFType){ |
| 196 | return getStat(zFilename, eFType) ? -1 : fx.fileStat.st_mtime; |
| 197 | } |
| 198 | |
| 199 | /* |
| 200 | ** Return the mode bits for a file. Return -1 if the file does not |
| 201 | ** exist. If zFilename is NULL return the size of the most recently |
| 202 | ** stat-ed file. |
| 203 | */ |
| 204 | int file_mode(const char *zFilename, int eFType){ |
| 205 | return getStat(zFilename, eFType) ? -1 : fx.fileStat.st_mode; |
| 206 | } |
| 207 | |
| 208 | /* |
| 209 | ** Return TRUE if either of the following are true: |
| 210 | ** |
| 211 | ** (1) zFilename is an ordinary file |
| 212 | ** |
| 213 | ** (2) allow_symlinks is on and zFilename is a symbolic link to |
| 214 | ** a file, directory, or other object |
| 215 | */ |
| 216 | int file_isfile_or_link(const char *zFilename){ |
| 217 | if( getStat(zFilename, RepoFILE) ){ |
| 218 | return 0; /* stat() failed. Return false. */ |
| 219 | } |
| 220 | return S_ISREG(fx.fileStat.st_mode) || S_ISLNK(fx.fileStat.st_mode); |
| 221 | } |
| 222 | |
| 223 | /* |
| 224 | ** Return TRUE if the named file is an ordinary file. Return false |
| 225 | ** for directories, devices, fifos, symlinks, etc. |
| 226 | */ |
| 227 | int file_isfile(const char *zFilename, int eFType){ |
| 228 | return getStat(zFilename, eFType) ? 0 : S_ISREG(fx.fileStat.st_mode); |
| 229 | } |
| 230 | |
| 231 | /* |
| 232 | ** Create a symbolic link named zLinkFile that points to zTargetFile. |
| 233 | ** |
| 234 | ** If allow-symlinks is off, create an ordinary file named zLinkFile |
| 235 | ** with the name of zTargetFile as its content. |
| 236 | **/ |
| 237 | void symlink_create(const char *zTargetFile, const char *zLinkFile){ |
| 238 | #if !defined(_WIN32) |
| 239 | if( db_allow_symlinks() ){ |
| 240 | int i, nName; |
| @@ -233,14 +249,14 @@ | |
| 249 | } |
| 250 | nName = file_simplify_name(zName, nName, 0); |
| 251 | for(i=1; i<nName; i++){ |
| 252 | if( zName[i]=='/' ){ |
| 253 | zName[i] = 0; |
| 254 | if( file_mkdir(zName, ExtFILE, 1) ){ |
| 255 | fossil_fatal_recursive("unable to create directory %s", zName); |
| 256 | return; |
| 257 | } |
| 258 | zName[i] = '/'; |
| 259 | } |
| 260 | } |
| 261 | if( symlink(zTargetFile, zName)!=0 ){ |
| 262 | fossil_fatal_recursive("unable to create symlink \"%s\"", zName); |
| @@ -269,17 +285,22 @@ | |
| 285 | /* |
| 286 | ** Return file permissions (normal, executable, or symlink): |
| 287 | ** - PERM_EXE on Unix if file is executable; |
| 288 | ** - PERM_LNK on Unix if file is symlink and allow-symlinks option is on; |
| 289 | ** - PERM_REG for all other cases (regular file, directory, fifo, etc). |
| 290 | ** |
| 291 | ** If eFType is ExtFile then symbolic links are followed and so this |
| 292 | ** routine can only return PERM_EXE and PERM_REG. |
| 293 | ** |
| 294 | ** On windows, this routine returns only PERM_REG. |
| 295 | */ |
| 296 | int file_perm(const char *zFilename, int eFType){ |
| 297 | #if !defined(_WIN32) |
| 298 | if( !getStat(zFilename, RepoFILE) ){ |
| 299 | if( S_ISREG(fx.fileStat.st_mode) && ((S_IXUSR)&fx.fileStat.st_mode)!=0 ) |
| 300 | return PERM_EXE; |
| 301 | else if( db_allow_symlinks() && S_ISLNK(fx.fileStat.st_mode) ) |
| 302 | return PERM_LNK; |
| 303 | } |
| 304 | #endif |
| 305 | return PERM_REG; |
| 306 | } |
| @@ -286,65 +307,42 @@ | |
| 307 | |
| 308 | /* |
| 309 | ** Return TRUE if the named file is an executable. Return false |
| 310 | ** for directories, devices, fifos, symlinks, etc. |
| 311 | */ |
| 312 | int file_isexe(const char *zFilename, int eFType){ |
| 313 | return file_perm(zFilename, eFType)==PERM_EXE; |
| 314 | } |
| 315 | |
| 316 | /* |
| 317 | ** Return TRUE if the named file is a symlink and symlinks are allowed. |
| 318 | ** Return false for all other cases. |
| 319 | ** |
| 320 | ** This routines RepoFILE - that zFilename is always a file under management. |
| 321 | ** |
| 322 | ** On Windows, always return False. |
| 323 | */ |
| 324 | int file_islink(const char *zFilename){ |
| 325 | return file_perm(zFilename, RepoFILE)==PERM_LNK; |
| 326 | } |
| 327 | |
| 328 | /* |
| 329 | ** Return 1 if zFilename is a directory. Return 0 if zFilename |
| 330 | ** does not exist. Return 2 if zFilename exists but is something |
| 331 | ** other than a directory. |
| 332 | */ |
| 333 | int file_isdir(const char *zFilename, int eFType){ |
| 334 | int rc; |
| 335 | char *zFN; |
| 336 | |
| 337 | zFN = mprintf("%s", zFilename); |
| 338 | file_simplify_name(zFN, -1, 0); |
| 339 | rc = getStat(zFN, eFType); |
| 340 | if( rc ){ |
| 341 | rc = 0; /* It does not exist at all. */ |
| 342 | }else if( S_ISDIR(fx.fileStat.st_mode) ){ |
| 343 | rc = 1; /* It exists and is a real directory. */ |
| 344 | }else{ |
| 345 | rc = 2; /* It exists and is something else. */ |
| 346 | } |
| 347 | free(zFN); |
| 348 | return rc; |
| @@ -397,11 +395,11 @@ | |
| 395 | */ |
| 396 | char *file_newname(const char *zBase, const char *zSuffix, int relFlag){ |
| 397 | char *z = 0; |
| 398 | int cnt = 0; |
| 399 | z = mprintf("%s-%s", zBase, zSuffix); |
| 400 | while( file_size(z, ExtFILE)>=0 ){ |
| 401 | fossil_free(z); |
| 402 | z = mprintf("%s-%s-%d", zBase, zSuffix, cnt++); |
| 403 | } |
| 404 | if( relFlag ){ |
| 405 | Blob x; |
| @@ -473,11 +471,11 @@ | |
| 471 | FILE *in, *out; |
| 472 | int got; |
| 473 | char zBuf[8192]; |
| 474 | in = fossil_fopen(zFrom, "rb"); |
| 475 | if( in==0 ) fossil_fatal("cannot open \"%s\" for reading", zFrom); |
| 476 | file_mkfolder(zTo, ExtFILE, 0, 0); |
| 477 | out = fossil_fopen(zTo, "wb"); |
| 478 | if( out==0 ) fossil_fatal("cannot open \"%s\" for writing", zTo); |
| 479 | while( (got=fread(zBuf, 1, sizeof(zBuf), in))>0 ){ |
| 480 | fwrite(zBuf, 1, got, out); |
| 481 | } |
| @@ -502,16 +500,22 @@ | |
| 500 | } |
| 501 | |
| 502 | /* |
| 503 | ** Set or clear the execute bit on a file. Return true if a change |
| 504 | ** occurred and false if this routine is a no-op. |
| 505 | ** |
| 506 | ** This routine assumes RepoFILE as the eFType. In other words, if |
| 507 | ** zFilename is a symbolic link, it is the object that zFilename points |
| 508 | ** to that is modified. |
| 509 | */ |
| 510 | int file_setexe(const char *zFilename, int onoff){ |
| 511 | int rc = 0; |
| 512 | #if !defined(_WIN32) |
| 513 | struct stat buf; |
| 514 | if( fossil_stat(zFilename, &buf, RepoFILE)!=0 || S_ISLNK(buf.st_mode) ){ |
| 515 | return 0; |
| 516 | } |
| 517 | if( onoff ){ |
| 518 | int targetMode = (buf.st_mode & 0444)>>2; |
| 519 | if( (buf.st_mode & 0100)==0 ){ |
| 520 | chmod(zFilename, buf.st_mode | targetMode); |
| 521 | rc = 1; |
| @@ -564,17 +568,20 @@ | |
| 568 | } |
| 569 | db_open_or_attach(":memory:", "mem"); |
| 570 | iMTime = db_int64(0, "SELECT strftime('%%s',%Q)", g.argv[3]); |
| 571 | zFile = g.argv[2]; |
| 572 | file_set_mtime(zFile, iMTime); |
| 573 | iMTime = file_mtime(zFile, RepoFILE); |
| 574 | zDate = db_text(0, "SELECT datetime(%lld, 'unixepoch')", iMTime); |
| 575 | fossil_print("Set mtime of \"%s\" to %s (%lld)\n", zFile, zDate, iMTime); |
| 576 | } |
| 577 | |
| 578 | /* |
| 579 | ** Delete a file. |
| 580 | ** |
| 581 | ** If zFilename is a symbolic link, then it is the link itself that is |
| 582 | ** removed, not the object that zFilename points to. |
| 583 | ** |
| 584 | ** Returns zero upon success. |
| 585 | */ |
| 586 | int file_delete(const char *zFilename){ |
| 587 | int rc; |
| @@ -588,18 +595,18 @@ | |
| 595 | fossil_path_free(z); |
| 596 | return rc; |
| 597 | } |
| 598 | |
| 599 | /* |
| 600 | ** Create a directory called zName, if it does not already exist. |
| 601 | ** If forceFlag is 1, delete any prior non-directory object |
| 602 | ** with the same name. |
| 603 | ** |
| 604 | ** Return the number of errors. |
| 605 | */ |
| 606 | int file_mkdir(const char *zName, int eFType, int forceFlag){ |
| 607 | int rc = file_isdir(zName, eFType); |
| 608 | if( rc==2 ){ |
| 609 | if( !forceFlag ) return 1; |
| 610 | file_delete(zName); |
| 611 | } |
| 612 | if( rc!=1 ){ |
| @@ -621,24 +628,31 @@ | |
| 628 | ** of directories does not already exist. |
| 629 | ** |
| 630 | ** On success, return zero. On error, return errorReturn if positive, otherwise |
| 631 | ** print an error message and abort. |
| 632 | */ |
| 633 | int file_mkfolder( |
| 634 | const char *zFilename, /* Pathname showing directories to be created */ |
| 635 | int eFType, /* Follow symlinks if ExtFILE */ |
| 636 | int forceFlag, /* Delete non-directory objects in the way */ |
| 637 | int errorReturn /* What to do when an error is seen */ |
| 638 | ){ |
| 639 | int nName, rc = 0; |
| 640 | char *zName; |
| 641 | |
| 642 | nName = strlen(zFilename); |
| 643 | zName = mprintf("%s", zFilename); |
| 644 | nName = file_simplify_name(zName, nName, 0); |
| 645 | while( nName>0 && zName[nName-1]!='/' ){ nName--; } |
| 646 | if( nName ){ |
| 647 | zName[nName-1] = 0; |
| 648 | if( file_isdir(zName, eFType)!=1 ){ |
| 649 | rc = file_mkfolder(zName, eFType, forceFlag, errorReturn); |
| 650 | if( rc==0 ){ |
| 651 | if( file_mkdir(zName, eFType, forceFlag) |
| 652 | && file_isdir(zName, eFType)!=1 |
| 653 | ){ |
| 654 | if( errorReturn <= 0 ){ |
| 655 | fossil_fatal_recursive("unable to create directory %s", zName); |
| 656 | } |
| 657 | rc = errorReturn; |
| 658 | } |
| @@ -654,11 +668,11 @@ | |
| 668 | ** must be empty and cannot be the current directory or the root directory. |
| 669 | ** |
| 670 | ** Returns zero upon success. |
| 671 | */ |
| 672 | int file_rmdir(const char *zName){ |
| 673 | int rc = file_isdir(zName, RepoFILE); |
| 674 | if( rc==2 ) return 1; /* cannot remove normal file */ |
| 675 | if( rc==1 ){ |
| 676 | #if defined(_WIN32) |
| 677 | wchar_t *zMbcs = fossil_utf8_to_path(zName, 1); |
| 678 | rc = _wrmdir(zMbcs); |
| @@ -994,35 +1008,34 @@ | |
| 1008 | sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld (%s)", testFileStat.st_mtime, z); |
| 1009 | fossil_free(z); |
| 1010 | fossil_print(" l_stat_mtime = %s\n", zBuf); |
| 1011 | fossil_print(" l_stat_mode = 0%o\n", testFileStat.st_mode); |
| 1012 | if( reset ) resetStat(); |
| 1013 | sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", file_size(zPath,ExtFILE)); |
| 1014 | fossil_print(" file_size(ExtFILE) = %s\n", zBuf); |
| 1015 | iMtime = file_mtime(zPath, ExtFILE); |
| 1016 | z = db_text(0, "SELECT datetime(%lld, 'unixepoch')", iMtime); |
| 1017 | sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld (%s)", iMtime, z); |
| 1018 | fossil_free(z); |
| 1019 | fossil_print(" file_mtime(ExtFILE) = %s\n", zBuf); |
| 1020 | fossil_print(" file_mode(ExtFILE) = 0%o\n", file_mode(zPath,ExtFILE)); |
| 1021 | fossil_print(" file_isfile(ExtFILE) = %d\n", file_isfile(zPath,ExtFILE)); |
| 1022 | fossil_print(" file_isdir(ExtFILE) = %d\n", file_isdir(zPath,ExtFILE)); |
| 1023 | if( reset ) resetStat(); |
| 1024 | sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", file_size(zPath,RepoFILE)); |
| 1025 | fossil_print(" file_size(RepoFILE) = %s\n", zBuf); |
| 1026 | iMtime = file_mtime(zPath,RepoFILE); |
| 1027 | z = db_text(0, "SELECT datetime(%lld, 'unixepoch')", iMtime); |
| 1028 | sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld (%s)", iMtime, z); |
| 1029 | fossil_free(z); |
| 1030 | fossil_print(" file_mtime(RepoFILE) = %s\n", zBuf); |
| 1031 | fossil_print(" file_mode(RepoFILE) = 0%o\n", file_mode(zPath,RepoFILE)); |
| 1032 | fossil_print(" file_isfile(RepoFILE) = %d\n", file_isfile(zPath,RepoFILE)); |
| 1033 | fossil_print(" file_isfile_or_link = %d\n", file_isfile_or_link(zPath)); |
| 1034 | fossil_print(" file_islink = %d\n", file_islink(zPath)); |
| 1035 | fossil_print(" file_isexe(RepoFILE) = %d\n", file_isexe(zPath,RepoFILE)); |
| 1036 | fossil_print(" file_isdir(RepoFILE) = %d\n", file_isdir(zPath,RepoFILE)); |
| 1037 | if( reset ) resetStat(); |
| 1038 | } |
| 1039 | |
| 1040 | /* |
| 1041 | ** COMMAND: test-file-environment |
| @@ -1078,19 +1091,19 @@ | |
| 1091 | char zBuf[100]; |
| 1092 | const char *zName = g.argv[i]; |
| 1093 | file_canonical_name(zName, &x, slashFlag); |
| 1094 | fossil_print("[%s] -> [%s]\n", zName, blob_buffer(&x)); |
| 1095 | blob_reset(&x); |
| 1096 | sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", file_size(zName,RepoFILE)); |
| 1097 | fossil_print(" file_size = %s\n", zBuf); |
| 1098 | sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", file_mtime(zName,RepoFILE)); |
| 1099 | fossil_print(" file_mtime = %s\n", zBuf); |
| 1100 | fossil_print(" file_isfile = %d\n", file_isfile(zName,RepoFILE)); |
| 1101 | fossil_print(" file_isfile_or_link = %d\n", file_isfile_or_link(zName)); |
| 1102 | fossil_print(" file_islink = %d\n", file_islink(zName)); |
| 1103 | fossil_print(" file_isexe = %d\n", file_isexe(zName,RepoFILE)); |
| 1104 | fossil_print(" file_isdir = %d\n", file_isdir(zName,RepoFILE)); |
| 1105 | } |
| 1106 | } |
| 1107 | |
| 1108 | /* |
| 1109 | ** Return TRUE if the given filename is canonical. |
| @@ -1426,11 +1439,11 @@ | |
| 1439 | azDirs[0] = fossil_getenv("TMPDIR"); |
| 1440 | #endif |
| 1441 | |
| 1442 | for(i=0; i<count(azDirs); i++){ |
| 1443 | if( azDirs[i]==0 ) continue; |
| 1444 | if( !file_isdir(azDirs[i], ExtFILE) ) continue; |
| 1445 | zDir = azDirs[i]; |
| 1446 | break; |
| 1447 | } |
| 1448 | |
| 1449 | do{ |
| @@ -1440,11 +1453,11 @@ | |
| 1453 | for(i=0; i<15; i++){ |
| 1454 | zRand[i] = (char)zChars[ ((unsigned char)zRand[i])%(sizeof(zChars)-1) ]; |
| 1455 | } |
| 1456 | zRand[15] = 0; |
| 1457 | blob_appendf(pBuf, "%s/%s-%s.txt", zDir, zPrefix ? zPrefix : "", zRand); |
| 1458 | }while( file_size(blob_str(pBuf), ExtFILE)>=0 ); |
| 1459 | |
| 1460 | #if defined(_WIN32) |
| 1461 | fossil_path_free((char *)azDirs[0]); |
| 1462 | fossil_path_free((char *)azDirs[1]); |
| 1463 | fossil_path_free((char *)azDirs[2]); |
| @@ -1477,24 +1490,22 @@ | |
| 1490 | |
| 1491 | /* |
| 1492 | ** Return true if a file named zName exists and has identical content |
| 1493 | ** to the blob pContent. If zName does not exist or if the content is |
| 1494 | ** different in any way, then return false. |
| 1495 | ** |
| 1496 | ** This routine assumes RepoFILE |
| 1497 | */ |
| 1498 | int file_is_the_same(Blob *pContent, const char *zName){ |
| 1499 | i64 iSize; |
| 1500 | int rc; |
| 1501 | Blob onDisk; |
| 1502 | |
| 1503 | iSize = file_size(zName, RepoFILE); |
| 1504 | if( iSize<0 ) return 0; |
| 1505 | if( iSize!=blob_size(pContent) ) return 0; |
| 1506 | blob_read_from_file(&onDisk, zName, RepoFILE); |
| 1507 | rc = blob_compare(&onDisk, pContent); |
| 1508 | blob_reset(&onDisk); |
| 1509 | return rc==0; |
| 1510 | } |
| 1511 | |
| @@ -1533,10 +1544,13 @@ | |
| 1544 | return rc; |
| 1545 | } |
| 1546 | |
| 1547 | /* |
| 1548 | ** Like fopen() but always takes a UTF8 argument. |
| 1549 | ** |
| 1550 | ** This function assumes ExtFILE. In other words, symbolic links |
| 1551 | ** are always followed. |
| 1552 | */ |
| 1553 | FILE *fossil_fopen(const char *zName, const char *zMode){ |
| 1554 | #ifdef _WIN32 |
| 1555 | wchar_t *uMode = fossil_utf8_to_unicode(zMode); |
| 1556 | wchar_t *uName = fossil_utf8_to_path(zName, 0); |
| 1557 |
+1
-1
| --- src/fusefs.c | ||
| +++ src/fusefs.c | ||
| @@ -323,11 +323,11 @@ | ||
| 323 | 323 | db_find_and_open_repository(0,0); |
| 324 | 324 | verify_all_options(); |
| 325 | 325 | blob_init(&fusefs.content, 0, 0); |
| 326 | 326 | if( g.argc!=3 ) usage("DIRECTORY"); |
| 327 | 327 | zMountPoint = g.argv[2]; |
| 328 | - if( file_mkdir(zMountPoint, 0) ){ | |
| 328 | + if( file_mkdir(zMountPoint, ExtFILE, 0) ){ | |
| 329 | 329 | fossil_fatal("cannot make directory [%s]", zMountPoint); |
| 330 | 330 | } |
| 331 | 331 | azNewArgv[0] = g.argv[0]; |
| 332 | 332 | azNewArgv[1] = doDebug ? "-d" : "-f"; |
| 333 | 333 | azNewArgv[2] = "-s"; |
| 334 | 334 |
| --- src/fusefs.c | |
| +++ src/fusefs.c | |
| @@ -323,11 +323,11 @@ | |
| 323 | db_find_and_open_repository(0,0); |
| 324 | verify_all_options(); |
| 325 | blob_init(&fusefs.content, 0, 0); |
| 326 | if( g.argc!=3 ) usage("DIRECTORY"); |
| 327 | zMountPoint = g.argv[2]; |
| 328 | if( file_mkdir(zMountPoint, 0) ){ |
| 329 | fossil_fatal("cannot make directory [%s]", zMountPoint); |
| 330 | } |
| 331 | azNewArgv[0] = g.argv[0]; |
| 332 | azNewArgv[1] = doDebug ? "-d" : "-f"; |
| 333 | azNewArgv[2] = "-s"; |
| 334 |
| --- src/fusefs.c | |
| +++ src/fusefs.c | |
| @@ -323,11 +323,11 @@ | |
| 323 | db_find_and_open_repository(0,0); |
| 324 | verify_all_options(); |
| 325 | blob_init(&fusefs.content, 0, 0); |
| 326 | if( g.argc!=3 ) usage("DIRECTORY"); |
| 327 | zMountPoint = g.argv[2]; |
| 328 | if( file_mkdir(zMountPoint, ExtFILE, 0) ){ |
| 329 | fossil_fatal("cannot make directory [%s]", zMountPoint); |
| 330 | } |
| 331 | azNewArgv[0] = g.argv[0]; |
| 332 | azNewArgv[1] = doDebug ? "-d" : "-f"; |
| 333 | azNewArgv[2] = "-s"; |
| 334 |
+1
-1
| --- src/gzip.c | ||
| +++ src/gzip.c | ||
| @@ -132,11 +132,11 @@ | ||
| 132 | 132 | Blob b; |
| 133 | 133 | char *zOut; |
| 134 | 134 | if( g.argc!=3 ) usage("FILENAME"); |
| 135 | 135 | sqlite3_open(":memory:", &g.db); |
| 136 | 136 | gzip_begin(-1); |
| 137 | - blob_read_from_file(&b, g.argv[2]); | |
| 137 | + blob_read_from_file(&b, g.argv[2], ExtFILE); | |
| 138 | 138 | zOut = mprintf("%s.gz", g.argv[2]); |
| 139 | 139 | gzip_step(blob_buffer(&b), blob_size(&b)); |
| 140 | 140 | blob_reset(&b); |
| 141 | 141 | gzip_finish(&b); |
| 142 | 142 | blob_write_to_file(&b, zOut); |
| 143 | 143 |
| --- src/gzip.c | |
| +++ src/gzip.c | |
| @@ -132,11 +132,11 @@ | |
| 132 | Blob b; |
| 133 | char *zOut; |
| 134 | if( g.argc!=3 ) usage("FILENAME"); |
| 135 | sqlite3_open(":memory:", &g.db); |
| 136 | gzip_begin(-1); |
| 137 | blob_read_from_file(&b, g.argv[2]); |
| 138 | zOut = mprintf("%s.gz", g.argv[2]); |
| 139 | gzip_step(blob_buffer(&b), blob_size(&b)); |
| 140 | blob_reset(&b); |
| 141 | gzip_finish(&b); |
| 142 | blob_write_to_file(&b, zOut); |
| 143 |
| --- src/gzip.c | |
| +++ src/gzip.c | |
| @@ -132,11 +132,11 @@ | |
| 132 | Blob b; |
| 133 | char *zOut; |
| 134 | if( g.argc!=3 ) usage("FILENAME"); |
| 135 | sqlite3_open(":memory:", &g.db); |
| 136 | gzip_begin(-1); |
| 137 | blob_read_from_file(&b, g.argv[2], ExtFILE); |
| 138 | zOut = mprintf("%s.gz", g.argv[2]); |
| 139 | gzip_step(blob_buffer(&b), blob_size(&b)); |
| 140 | blob_reset(&b); |
| 141 | gzip_finish(&b); |
| 142 | blob_write_to_file(&b, zOut); |
| 143 |
+2
-2
| --- src/hname.c | ||
| +++ src/hname.c | ||
| @@ -133,18 +133,18 @@ | ||
| 133 | 133 | int hname_verify_file_hash(const char *zFile, const char *zHash, int nHash){ |
| 134 | 134 | int id = HNAME_ERROR; |
| 135 | 135 | switch( nHash ){ |
| 136 | 136 | case HNAME_LEN_SHA1: { |
| 137 | 137 | Blob hash; |
| 138 | - if( sha1sum_file(zFile, &hash) ) break; | |
| 138 | + if( sha1sum_file(zFile, RepoFILE, &hash) ) break; | |
| 139 | 139 | if( memcmp(blob_buffer(&hash),zHash,HNAME_LEN_SHA1)==0 ) id = HNAME_SHA1; |
| 140 | 140 | blob_reset(&hash); |
| 141 | 141 | break; |
| 142 | 142 | } |
| 143 | 143 | case HNAME_LEN_K256: { |
| 144 | 144 | Blob hash; |
| 145 | - if( sha3sum_file(zFile, 256, &hash) ) break; | |
| 145 | + if( sha3sum_file(zFile, RepoFILE, 256, &hash) ) break; | |
| 146 | 146 | if( memcmp(blob_buffer(&hash),zHash,64)==0 ) id = HNAME_LEN_K256; |
| 147 | 147 | blob_reset(&hash); |
| 148 | 148 | break; |
| 149 | 149 | } |
| 150 | 150 | } |
| 151 | 151 |
| --- src/hname.c | |
| +++ src/hname.c | |
| @@ -133,18 +133,18 @@ | |
| 133 | int hname_verify_file_hash(const char *zFile, const char *zHash, int nHash){ |
| 134 | int id = HNAME_ERROR; |
| 135 | switch( nHash ){ |
| 136 | case HNAME_LEN_SHA1: { |
| 137 | Blob hash; |
| 138 | if( sha1sum_file(zFile, &hash) ) break; |
| 139 | if( memcmp(blob_buffer(&hash),zHash,HNAME_LEN_SHA1)==0 ) id = HNAME_SHA1; |
| 140 | blob_reset(&hash); |
| 141 | break; |
| 142 | } |
| 143 | case HNAME_LEN_K256: { |
| 144 | Blob hash; |
| 145 | if( sha3sum_file(zFile, 256, &hash) ) break; |
| 146 | if( memcmp(blob_buffer(&hash),zHash,64)==0 ) id = HNAME_LEN_K256; |
| 147 | blob_reset(&hash); |
| 148 | break; |
| 149 | } |
| 150 | } |
| 151 |
| --- src/hname.c | |
| +++ src/hname.c | |
| @@ -133,18 +133,18 @@ | |
| 133 | int hname_verify_file_hash(const char *zFile, const char *zHash, int nHash){ |
| 134 | int id = HNAME_ERROR; |
| 135 | switch( nHash ){ |
| 136 | case HNAME_LEN_SHA1: { |
| 137 | Blob hash; |
| 138 | if( sha1sum_file(zFile, RepoFILE, &hash) ) break; |
| 139 | if( memcmp(blob_buffer(&hash),zHash,HNAME_LEN_SHA1)==0 ) id = HNAME_SHA1; |
| 140 | blob_reset(&hash); |
| 141 | break; |
| 142 | } |
| 143 | case HNAME_LEN_K256: { |
| 144 | Blob hash; |
| 145 | if( sha3sum_file(zFile, RepoFILE, 256, &hash) ) break; |
| 146 | if( memcmp(blob_buffer(&hash),zHash,64)==0 ) id = HNAME_LEN_K256; |
| 147 | blob_reset(&hash); |
| 148 | break; |
| 149 | } |
| 150 | } |
| 151 |
+1
-1
| --- src/http_ssl.c | ||
| +++ src/http_ssl.c | ||
| @@ -109,11 +109,11 @@ | ||
| 109 | 109 | if( zCaSetting==0 || zCaSetting[0]=='\0' ){ |
| 110 | 110 | /* CA location not specified, use platform's default certificate store */ |
| 111 | 111 | X509_STORE_set_default_paths(SSL_CTX_get_cert_store(sslCtx)); |
| 112 | 112 | }else{ |
| 113 | 113 | /* User has specified a CA location, make sure it exists and use it */ |
| 114 | - switch( file_isdir(zCaSetting) ){ | |
| 114 | + switch( file_isdir(zCaSetting, ExtFILE) ){ | |
| 115 | 115 | case 0: { /* doesn't exist */ |
| 116 | 116 | fossil_fatal("ssl-ca-location is set to '%s', " |
| 117 | 117 | "but is not a file or directory", zCaSetting); |
| 118 | 118 | break; |
| 119 | 119 | } |
| 120 | 120 |
| --- src/http_ssl.c | |
| +++ src/http_ssl.c | |
| @@ -109,11 +109,11 @@ | |
| 109 | if( zCaSetting==0 || zCaSetting[0]=='\0' ){ |
| 110 | /* CA location not specified, use platform's default certificate store */ |
| 111 | X509_STORE_set_default_paths(SSL_CTX_get_cert_store(sslCtx)); |
| 112 | }else{ |
| 113 | /* User has specified a CA location, make sure it exists and use it */ |
| 114 | switch( file_isdir(zCaSetting) ){ |
| 115 | case 0: { /* doesn't exist */ |
| 116 | fossil_fatal("ssl-ca-location is set to '%s', " |
| 117 | "but is not a file or directory", zCaSetting); |
| 118 | break; |
| 119 | } |
| 120 |
| --- src/http_ssl.c | |
| +++ src/http_ssl.c | |
| @@ -109,11 +109,11 @@ | |
| 109 | if( zCaSetting==0 || zCaSetting[0]=='\0' ){ |
| 110 | /* CA location not specified, use platform's default certificate store */ |
| 111 | X509_STORE_set_default_paths(SSL_CTX_get_cert_store(sslCtx)); |
| 112 | }else{ |
| 113 | /* User has specified a CA location, make sure it exists and use it */ |
| 114 | switch( file_isdir(zCaSetting, ExtFILE) ){ |
| 115 | case 0: { /* doesn't exist */ |
| 116 | fossil_fatal("ssl-ca-location is set to '%s', " |
| 117 | "but is not a file or directory", zCaSetting); |
| 118 | break; |
| 119 | } |
| 120 |
+5
-2
| --- src/info.c | ||
| +++ src/info.c | ||
| @@ -201,11 +201,14 @@ | ||
| 201 | 201 | int verboseFlag = find_option("verbose","v",0)!=0; |
| 202 | 202 | if( !verboseFlag ){ |
| 203 | 203 | verboseFlag = find_option("detail","l",0)!=0; /* deprecated */ |
| 204 | 204 | } |
| 205 | 205 | |
| 206 | - if( g.argc==3 && (fsize = file_size(g.argv[2]))>0 && (fsize&0x1ff)==0 ){ | |
| 206 | + if( g.argc==3 | |
| 207 | + && (fsize = file_size(g.argv[2], ExtFILE))>0 | |
| 208 | + && (fsize&0x1ff)==0 | |
| 209 | + ){ | |
| 207 | 210 | db_open_config(0, 0); |
| 208 | 211 | db_open_repository(g.argv[2]); |
| 209 | 212 | db_record_repository_filename(g.argv[2]); |
| 210 | 213 | fossil_print("project-name: %s\n", db_get("project-name", "<unnamed>")); |
| 211 | 214 | fossil_print("project-code: %s\n", db_get("project-code", "<none>")); |
| @@ -3117,11 +3120,11 @@ | ||
| 3117 | 3120 | if( fEditComment ){ |
| 3118 | 3121 | prepare_amend_comment(&comment, zComment, zUuid); |
| 3119 | 3122 | zNewComment = blob_str(&comment); |
| 3120 | 3123 | }else if( zComFile ){ |
| 3121 | 3124 | blob_zero(&comment); |
| 3122 | - blob_read_from_file(&comment, zComFile); | |
| 3125 | + blob_read_from_file(&comment, zComFile, ExtFILE); | |
| 3123 | 3126 | blob_to_utf8_no_bom(&comment, 1); |
| 3124 | 3127 | zNewComment = blob_str(&comment); |
| 3125 | 3128 | } |
| 3126 | 3129 | if( zNewComment && zNewComment[0] |
| 3127 | 3130 | && comment_compare(zComment,zNewComment)==0 ) add_comment(zNewComment); |
| 3128 | 3131 |
| --- src/info.c | |
| +++ src/info.c | |
| @@ -201,11 +201,14 @@ | |
| 201 | int verboseFlag = find_option("verbose","v",0)!=0; |
| 202 | if( !verboseFlag ){ |
| 203 | verboseFlag = find_option("detail","l",0)!=0; /* deprecated */ |
| 204 | } |
| 205 | |
| 206 | if( g.argc==3 && (fsize = file_size(g.argv[2]))>0 && (fsize&0x1ff)==0 ){ |
| 207 | db_open_config(0, 0); |
| 208 | db_open_repository(g.argv[2]); |
| 209 | db_record_repository_filename(g.argv[2]); |
| 210 | fossil_print("project-name: %s\n", db_get("project-name", "<unnamed>")); |
| 211 | fossil_print("project-code: %s\n", db_get("project-code", "<none>")); |
| @@ -3117,11 +3120,11 @@ | |
| 3117 | if( fEditComment ){ |
| 3118 | prepare_amend_comment(&comment, zComment, zUuid); |
| 3119 | zNewComment = blob_str(&comment); |
| 3120 | }else if( zComFile ){ |
| 3121 | blob_zero(&comment); |
| 3122 | blob_read_from_file(&comment, zComFile); |
| 3123 | blob_to_utf8_no_bom(&comment, 1); |
| 3124 | zNewComment = blob_str(&comment); |
| 3125 | } |
| 3126 | if( zNewComment && zNewComment[0] |
| 3127 | && comment_compare(zComment,zNewComment)==0 ) add_comment(zNewComment); |
| 3128 |
| --- src/info.c | |
| +++ src/info.c | |
| @@ -201,11 +201,14 @@ | |
| 201 | int verboseFlag = find_option("verbose","v",0)!=0; |
| 202 | if( !verboseFlag ){ |
| 203 | verboseFlag = find_option("detail","l",0)!=0; /* deprecated */ |
| 204 | } |
| 205 | |
| 206 | if( g.argc==3 |
| 207 | && (fsize = file_size(g.argv[2], ExtFILE))>0 |
| 208 | && (fsize&0x1ff)==0 |
| 209 | ){ |
| 210 | db_open_config(0, 0); |
| 211 | db_open_repository(g.argv[2]); |
| 212 | db_record_repository_filename(g.argv[2]); |
| 213 | fossil_print("project-name: %s\n", db_get("project-name", "<unnamed>")); |
| 214 | fossil_print("project-code: %s\n", db_get("project-code", "<none>")); |
| @@ -3117,11 +3120,11 @@ | |
| 3120 | if( fEditComment ){ |
| 3121 | prepare_amend_comment(&comment, zComment, zUuid); |
| 3122 | zNewComment = blob_str(&comment); |
| 3123 | }else if( zComFile ){ |
| 3124 | blob_zero(&comment); |
| 3125 | blob_read_from_file(&comment, zComFile, ExtFILE); |
| 3126 | blob_to_utf8_no_bom(&comment, 1); |
| 3127 | zNewComment = blob_str(&comment); |
| 3128 | } |
| 3129 | if( zNewComment && zNewComment[0] |
| 3130 | && comment_compare(zComment,zNewComment)==0 ) add_comment(zNewComment); |
| 3131 |
+3
-2
| --- src/json.c | ||
| +++ src/json.c | ||
| @@ -1928,12 +1928,13 @@ | ||
| 1928 | 1928 | free(zTmp); |
| 1929 | 1929 | zTmp = db_get("project-description",NULL); |
| 1930 | 1930 | cson_object_set(jo, "projectDescription", json_new_string(zTmp)); |
| 1931 | 1931 | free(zTmp); |
| 1932 | 1932 | zTmp = NULL; |
| 1933 | - fsize = file_size(g.zRepositoryName); | |
| 1934 | - cson_object_set(jo, "repositorySize", cson_value_new_integer((cson_int_t)fsize)); | |
| 1933 | + fsize = file_size(g.zRepositoryName, ExtFILE); | |
| 1934 | + cson_object_set(jo, "repositorySize", | |
| 1935 | + cson_value_new_integer((cson_int_t)fsize)); | |
| 1935 | 1936 | |
| 1936 | 1937 | if(full){ |
| 1937 | 1938 | n = db_int(0, "SELECT count(*) FROM blob"); |
| 1938 | 1939 | m = db_int(0, "SELECT count(*) FROM delta"); |
| 1939 | 1940 | cson_object_set(jo, "blobCount", cson_value_new_integer((cson_int_t)n)); |
| 1940 | 1941 |
| --- src/json.c | |
| +++ src/json.c | |
| @@ -1928,12 +1928,13 @@ | |
| 1928 | free(zTmp); |
| 1929 | zTmp = db_get("project-description",NULL); |
| 1930 | cson_object_set(jo, "projectDescription", json_new_string(zTmp)); |
| 1931 | free(zTmp); |
| 1932 | zTmp = NULL; |
| 1933 | fsize = file_size(g.zRepositoryName); |
| 1934 | cson_object_set(jo, "repositorySize", cson_value_new_integer((cson_int_t)fsize)); |
| 1935 | |
| 1936 | if(full){ |
| 1937 | n = db_int(0, "SELECT count(*) FROM blob"); |
| 1938 | m = db_int(0, "SELECT count(*) FROM delta"); |
| 1939 | cson_object_set(jo, "blobCount", cson_value_new_integer((cson_int_t)n)); |
| 1940 |
| --- src/json.c | |
| +++ src/json.c | |
| @@ -1928,12 +1928,13 @@ | |
| 1928 | free(zTmp); |
| 1929 | zTmp = db_get("project-description",NULL); |
| 1930 | cson_object_set(jo, "projectDescription", json_new_string(zTmp)); |
| 1931 | free(zTmp); |
| 1932 | zTmp = NULL; |
| 1933 | fsize = file_size(g.zRepositoryName, ExtFILE); |
| 1934 | cson_object_set(jo, "repositorySize", |
| 1935 | cson_value_new_integer((cson_int_t)fsize)); |
| 1936 | |
| 1937 | if(full){ |
| 1938 | n = db_int(0, "SELECT count(*) FROM blob"); |
| 1939 | m = db_int(0, "SELECT count(*) FROM delta"); |
| 1940 | cson_object_set(jo, "blobCount", cson_value_new_integer((cson_int_t)n)); |
| 1941 |
+1
-1
| --- src/json_status.c | ||
| +++ src/json_status.c | ||
| @@ -114,11 +114,11 @@ | ||
| 114 | 114 | }else if( isNew ){ |
| 115 | 115 | zStatus = "new" /* maintenance reminder: MUST come |
| 116 | 116 | BEFORE the isChnged checks. */; |
| 117 | 117 | }else if( isRenamed ){ |
| 118 | 118 | zStatus = "renamed"; |
| 119 | - }else if( !file_wd_isfile_or_link(zFullName) ){ | |
| 119 | + }else if( !file_isfile_or_link(zFullName) ){ | |
| 120 | 120 | if( file_access(zFullName, F_OK)==0 ){ |
| 121 | 121 | zStatus = "notAFile"; |
| 122 | 122 | ++nErr; |
| 123 | 123 | }else{ |
| 124 | 124 | zStatus = "missing"; |
| 125 | 125 |
| --- src/json_status.c | |
| +++ src/json_status.c | |
| @@ -114,11 +114,11 @@ | |
| 114 | }else if( isNew ){ |
| 115 | zStatus = "new" /* maintenance reminder: MUST come |
| 116 | BEFORE the isChnged checks. */; |
| 117 | }else if( isRenamed ){ |
| 118 | zStatus = "renamed"; |
| 119 | }else if( !file_wd_isfile_or_link(zFullName) ){ |
| 120 | if( file_access(zFullName, F_OK)==0 ){ |
| 121 | zStatus = "notAFile"; |
| 122 | ++nErr; |
| 123 | }else{ |
| 124 | zStatus = "missing"; |
| 125 |
| --- src/json_status.c | |
| +++ src/json_status.c | |
| @@ -114,11 +114,11 @@ | |
| 114 | }else if( isNew ){ |
| 115 | zStatus = "new" /* maintenance reminder: MUST come |
| 116 | BEFORE the isChnged checks. */; |
| 117 | }else if( isRenamed ){ |
| 118 | zStatus = "renamed"; |
| 119 | }else if( !file_isfile_or_link(zFullName) ){ |
| 120 | if( file_access(zFullName, F_OK)==0 ){ |
| 121 | zStatus = "notAFile"; |
| 122 | ++nErr; |
| 123 | }else{ |
| 124 | zStatus = "missing"; |
| 125 |
+2
-2
| --- src/login.c | ||
| +++ src/login.c | ||
| @@ -1565,11 +1565,11 @@ | ||
| 1565 | 1565 | " ORDER BY +value", |
| 1566 | 1566 | zSelfCode |
| 1567 | 1567 | ); |
| 1568 | 1568 | while( db_step(&q)==SQLITE_ROW ){ |
| 1569 | 1569 | const char *zRepoName = db_column_text(&q, 1); |
| 1570 | - if( file_size(zRepoName)<0 ){ | |
| 1570 | + if( file_size(zRepoName, ExtFILE)<0 ){ | |
| 1571 | 1571 | /* Silently remove non-existent repositories from the login group. */ |
| 1572 | 1572 | const char *zLabel = db_column_text(&q, 0); |
| 1573 | 1573 | db_multi_exec( |
| 1574 | 1574 | "DELETE FROM config WHERE name GLOB 'peer-*-%q'", |
| 1575 | 1575 | &zLabel[10] |
| @@ -1661,11 +1661,11 @@ | ||
| 1661 | 1661 | *pzErrMsg = mprintf("The \"other\" repository is the same as this one."); |
| 1662 | 1662 | return; |
| 1663 | 1663 | } |
| 1664 | 1664 | |
| 1665 | 1665 | /* Make sure the other repository is a valid Fossil database */ |
| 1666 | - if( file_size(zRepo)<0 ){ | |
| 1666 | + if( file_size(zRepo, ExtFILE)<0 ){ | |
| 1667 | 1667 | *pzErrMsg = mprintf("repository file \"%s\" does not exist", zRepo); |
| 1668 | 1668 | return; |
| 1669 | 1669 | } |
| 1670 | 1670 | rc = sqlite3_open_v2( |
| 1671 | 1671 | zRepo, &pOther, |
| 1672 | 1672 |
| --- src/login.c | |
| +++ src/login.c | |
| @@ -1565,11 +1565,11 @@ | |
| 1565 | " ORDER BY +value", |
| 1566 | zSelfCode |
| 1567 | ); |
| 1568 | while( db_step(&q)==SQLITE_ROW ){ |
| 1569 | const char *zRepoName = db_column_text(&q, 1); |
| 1570 | if( file_size(zRepoName)<0 ){ |
| 1571 | /* Silently remove non-existent repositories from the login group. */ |
| 1572 | const char *zLabel = db_column_text(&q, 0); |
| 1573 | db_multi_exec( |
| 1574 | "DELETE FROM config WHERE name GLOB 'peer-*-%q'", |
| 1575 | &zLabel[10] |
| @@ -1661,11 +1661,11 @@ | |
| 1661 | *pzErrMsg = mprintf("The \"other\" repository is the same as this one."); |
| 1662 | return; |
| 1663 | } |
| 1664 | |
| 1665 | /* Make sure the other repository is a valid Fossil database */ |
| 1666 | if( file_size(zRepo)<0 ){ |
| 1667 | *pzErrMsg = mprintf("repository file \"%s\" does not exist", zRepo); |
| 1668 | return; |
| 1669 | } |
| 1670 | rc = sqlite3_open_v2( |
| 1671 | zRepo, &pOther, |
| 1672 |
| --- src/login.c | |
| +++ src/login.c | |
| @@ -1565,11 +1565,11 @@ | |
| 1565 | " ORDER BY +value", |
| 1566 | zSelfCode |
| 1567 | ); |
| 1568 | while( db_step(&q)==SQLITE_ROW ){ |
| 1569 | const char *zRepoName = db_column_text(&q, 1); |
| 1570 | if( file_size(zRepoName, ExtFILE)<0 ){ |
| 1571 | /* Silently remove non-existent repositories from the login group. */ |
| 1572 | const char *zLabel = db_column_text(&q, 0); |
| 1573 | db_multi_exec( |
| 1574 | "DELETE FROM config WHERE name GLOB 'peer-*-%q'", |
| 1575 | &zLabel[10] |
| @@ -1661,11 +1661,11 @@ | |
| 1661 | *pzErrMsg = mprintf("The \"other\" repository is the same as this one."); |
| 1662 | return; |
| 1663 | } |
| 1664 | |
| 1665 | /* Make sure the other repository is a valid Fossil database */ |
| 1666 | if( file_size(zRepo, ExtFILE)<0 ){ |
| 1667 | *pzErrMsg = mprintf("repository file \"%s\" does not exist", zRepo); |
| 1668 | return; |
| 1669 | } |
| 1670 | rc = sqlite3_open_v2( |
| 1671 | zRepo, &pOther, |
| 1672 |
+1
-1
| --- src/lookslike.c | ||
| +++ src/lookslike.c | ||
| @@ -422,11 +422,11 @@ | ||
| 422 | 422 | |
| 423 | 423 | if( g.argc!=3 ) usage("FILENAME"); |
| 424 | 424 | if( zCount ){ |
| 425 | 425 | nRepeat = atoi(zCount); |
| 426 | 426 | } |
| 427 | - blob_read_from_file(&blob, g.argv[2]); | |
| 427 | + blob_read_from_file(&blob, g.argv[2], ExtFILE); | |
| 428 | 428 | while( --nRepeat >= 0 ){ |
| 429 | 429 | fUtf8 = starts_with_utf8_bom(&blob, 0); |
| 430 | 430 | fUtf16 = starts_with_utf16_bom(&blob, 0, &bRevUtf16); |
| 431 | 431 | if( fForceUtf8 ){ |
| 432 | 432 | fUnicode = 0; |
| 433 | 433 |
| --- src/lookslike.c | |
| +++ src/lookslike.c | |
| @@ -422,11 +422,11 @@ | |
| 422 | |
| 423 | if( g.argc!=3 ) usage("FILENAME"); |
| 424 | if( zCount ){ |
| 425 | nRepeat = atoi(zCount); |
| 426 | } |
| 427 | blob_read_from_file(&blob, g.argv[2]); |
| 428 | while( --nRepeat >= 0 ){ |
| 429 | fUtf8 = starts_with_utf8_bom(&blob, 0); |
| 430 | fUtf16 = starts_with_utf16_bom(&blob, 0, &bRevUtf16); |
| 431 | if( fForceUtf8 ){ |
| 432 | fUnicode = 0; |
| 433 |
| --- src/lookslike.c | |
| +++ src/lookslike.c | |
| @@ -422,11 +422,11 @@ | |
| 422 | |
| 423 | if( g.argc!=3 ) usage("FILENAME"); |
| 424 | if( zCount ){ |
| 425 | nRepeat = atoi(zCount); |
| 426 | } |
| 427 | blob_read_from_file(&blob, g.argv[2], ExtFILE); |
| 428 | while( --nRepeat >= 0 ){ |
| 429 | fUtf8 = starts_with_utf8_bom(&blob, 0); |
| 430 | fUtf16 = starts_with_utf16_bom(&blob, 0, &bRevUtf16); |
| 431 | if( fForceUtf8 ){ |
| 432 | fUnicode = 0; |
| 433 |
+8
-8
| --- src/main.c | ||
| +++ src/main.c | ||
| @@ -1181,11 +1181,11 @@ | ||
| 1181 | 1181 | } |
| 1182 | 1182 | |
| 1183 | 1183 | file_canonical_name(zRepo, &dir, 0); |
| 1184 | 1184 | zDir = blob_str(&dir); |
| 1185 | 1185 | if( !noJail ){ |
| 1186 | - if( file_isdir(zDir)==1 ){ | |
| 1186 | + if( file_isdir(zDir, ExtFILE)==1 ){ | |
| 1187 | 1187 | if( file_chdir(zDir, 1) ){ |
| 1188 | 1188 | fossil_fatal("unable to chroot into %s", zDir); |
| 1189 | 1189 | } |
| 1190 | 1190 | g.fJail = 1; |
| 1191 | 1191 | zRepo = "/"; |
| @@ -1208,11 +1208,11 @@ | ||
| 1208 | 1208 | i = setgid(sStat.st_gid); |
| 1209 | 1209 | i = i || setuid(sStat.st_uid); |
| 1210 | 1210 | if(i){ |
| 1211 | 1211 | fossil_fatal("setgid/uid() failed with errno %d", errno); |
| 1212 | 1212 | } |
| 1213 | - if( g.db==0 && file_isfile(zRepo) ){ | |
| 1213 | + if( g.db==0 && file_isfile(zRepo, ExtFILE) ){ | |
| 1214 | 1214 | db_open_repository(zRepo); |
| 1215 | 1215 | } |
| 1216 | 1216 | } |
| 1217 | 1217 | #endif |
| 1218 | 1218 | return zRepo; |
| @@ -1427,11 +1427,11 @@ | ||
| 1427 | 1427 | ** Special case: Assume any file with a basename of ".fossil" does |
| 1428 | 1428 | ** not exist. |
| 1429 | 1429 | */ |
| 1430 | 1430 | zCleanRepo = file_cleanup_fullpath(zRepo); |
| 1431 | 1431 | if( szFile==0 && sqlite3_strglob("*/.fossil",zRepo)!=0 ){ |
| 1432 | - szFile = file_size(zCleanRepo); | |
| 1432 | + szFile = file_size(zCleanRepo, ExtFILE); | |
| 1433 | 1433 | if( g.fHttpTrace ){ |
| 1434 | 1434 | char zBuf[24]; |
| 1435 | 1435 | sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", szFile); |
| 1436 | 1436 | @ <!-- file_size(%h(zCleanRepo)) is %s(zBuf) --> |
| 1437 | 1437 | fprintf(stderr, "# file_size(%s) = %s\n", zCleanRepo, zBuf); |
| @@ -1447,11 +1447,11 @@ | ||
| 1447 | 1447 | assert( fossil_strcmp(&zRepo[j], ".fossil")==0 ); |
| 1448 | 1448 | zRepo[j] = 0; /* Remove the ".fossil" suffix */ |
| 1449 | 1449 | |
| 1450 | 1450 | /* The PATH_INFO prefix seen so far is a valid directory. |
| 1451 | 1451 | ** Continue the loop with the next element of the PATH_INFO */ |
| 1452 | - if( zPathInfo[i]=='/' && file_isdir(zCleanRepo)==1 ){ | |
| 1452 | + if( zPathInfo[i]=='/' && file_isdir(zCleanRepo, ExtFILE)==1 ){ | |
| 1453 | 1453 | fossil_free(zToFree); |
| 1454 | 1454 | i++; |
| 1455 | 1455 | continue; |
| 1456 | 1456 | } |
| 1457 | 1457 | |
| @@ -1465,18 +1465,18 @@ | ||
| 1465 | 1465 | ** general-purpose web server. The "--file GLOB" mechanism is |
| 1466 | 1466 | ** designed to allow the delivery of a few static images or HTML |
| 1467 | 1467 | ** pages. |
| 1468 | 1468 | */ |
| 1469 | 1469 | if( pFileGlob!=0 |
| 1470 | - && file_isfile(zCleanRepo) | |
| 1470 | + && file_isfile(zCleanRepo, ExtFILE) | |
| 1471 | 1471 | && glob_match(pFileGlob, file_cleanup_fullpath(zRepo)) |
| 1472 | 1472 | && sqlite3_strglob("*.fossil*",zRepo)!=0 |
| 1473 | 1473 | && (zMimetype = mimetype_from_name(zRepo))!=0 |
| 1474 | 1474 | && strcmp(zMimetype, "application/x-fossil-artifact")!=0 |
| 1475 | 1475 | ){ |
| 1476 | 1476 | Blob content; |
| 1477 | - blob_read_from_file(&content, file_cleanup_fullpath(zRepo)); | |
| 1477 | + blob_read_from_file(&content, file_cleanup_fullpath(zRepo), ExtFILE); | |
| 1478 | 1478 | cgi_set_content_type(zMimetype); |
| 1479 | 1479 | cgi_set_content(&content); |
| 1480 | 1480 | cgi_reply(); |
| 1481 | 1481 | return; |
| 1482 | 1482 | } |
| @@ -1844,11 +1844,11 @@ | ||
| 1844 | 1844 | g.httpOut = stdout; |
| 1845 | 1845 | g.httpIn = stdin; |
| 1846 | 1846 | fossil_binary_mode(g.httpOut); |
| 1847 | 1847 | fossil_binary_mode(g.httpIn); |
| 1848 | 1848 | g.cgiOutput = 1; |
| 1849 | - blob_read_from_file(&config, zFile); | |
| 1849 | + blob_read_from_file(&config, zFile, ExtFILE); | |
| 1850 | 1850 | while( blob_line(&config, &line) ){ |
| 1851 | 1851 | if( !blob_token(&line, &key) ) continue; |
| 1852 | 1852 | if( blob_buffer(&key)[0]=='#' ) continue; |
| 1853 | 1853 | if( blob_eq(&key, "repository:") && blob_tail(&line, &value) ){ |
| 1854 | 1854 | /* repository: FILENAME |
| @@ -2018,11 +2018,11 @@ | ||
| 2018 | 2018 | static void find_server_repository(int arg, int fCreate){ |
| 2019 | 2019 | if( g.argc<=arg ){ |
| 2020 | 2020 | db_must_be_within_tree(); |
| 2021 | 2021 | }else{ |
| 2022 | 2022 | const char *zRepo = g.argv[arg]; |
| 2023 | - int isDir = file_isdir(zRepo); | |
| 2023 | + int isDir = file_isdir(zRepo, ExtFILE); | |
| 2024 | 2024 | if( isDir==1 ){ |
| 2025 | 2025 | g.zRepositoryName = mprintf("%s", zRepo); |
| 2026 | 2026 | file_simplify_name(g.zRepositoryName, -1, 0); |
| 2027 | 2027 | }else{ |
| 2028 | 2028 | if( isDir==0 && fCreate ){ |
| 2029 | 2029 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -1181,11 +1181,11 @@ | |
| 1181 | } |
| 1182 | |
| 1183 | file_canonical_name(zRepo, &dir, 0); |
| 1184 | zDir = blob_str(&dir); |
| 1185 | if( !noJail ){ |
| 1186 | if( file_isdir(zDir)==1 ){ |
| 1187 | if( file_chdir(zDir, 1) ){ |
| 1188 | fossil_fatal("unable to chroot into %s", zDir); |
| 1189 | } |
| 1190 | g.fJail = 1; |
| 1191 | zRepo = "/"; |
| @@ -1208,11 +1208,11 @@ | |
| 1208 | i = setgid(sStat.st_gid); |
| 1209 | i = i || setuid(sStat.st_uid); |
| 1210 | if(i){ |
| 1211 | fossil_fatal("setgid/uid() failed with errno %d", errno); |
| 1212 | } |
| 1213 | if( g.db==0 && file_isfile(zRepo) ){ |
| 1214 | db_open_repository(zRepo); |
| 1215 | } |
| 1216 | } |
| 1217 | #endif |
| 1218 | return zRepo; |
| @@ -1427,11 +1427,11 @@ | |
| 1427 | ** Special case: Assume any file with a basename of ".fossil" does |
| 1428 | ** not exist. |
| 1429 | */ |
| 1430 | zCleanRepo = file_cleanup_fullpath(zRepo); |
| 1431 | if( szFile==0 && sqlite3_strglob("*/.fossil",zRepo)!=0 ){ |
| 1432 | szFile = file_size(zCleanRepo); |
| 1433 | if( g.fHttpTrace ){ |
| 1434 | char zBuf[24]; |
| 1435 | sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", szFile); |
| 1436 | @ <!-- file_size(%h(zCleanRepo)) is %s(zBuf) --> |
| 1437 | fprintf(stderr, "# file_size(%s) = %s\n", zCleanRepo, zBuf); |
| @@ -1447,11 +1447,11 @@ | |
| 1447 | assert( fossil_strcmp(&zRepo[j], ".fossil")==0 ); |
| 1448 | zRepo[j] = 0; /* Remove the ".fossil" suffix */ |
| 1449 | |
| 1450 | /* The PATH_INFO prefix seen so far is a valid directory. |
| 1451 | ** Continue the loop with the next element of the PATH_INFO */ |
| 1452 | if( zPathInfo[i]=='/' && file_isdir(zCleanRepo)==1 ){ |
| 1453 | fossil_free(zToFree); |
| 1454 | i++; |
| 1455 | continue; |
| 1456 | } |
| 1457 | |
| @@ -1465,18 +1465,18 @@ | |
| 1465 | ** general-purpose web server. The "--file GLOB" mechanism is |
| 1466 | ** designed to allow the delivery of a few static images or HTML |
| 1467 | ** pages. |
| 1468 | */ |
| 1469 | if( pFileGlob!=0 |
| 1470 | && file_isfile(zCleanRepo) |
| 1471 | && glob_match(pFileGlob, file_cleanup_fullpath(zRepo)) |
| 1472 | && sqlite3_strglob("*.fossil*",zRepo)!=0 |
| 1473 | && (zMimetype = mimetype_from_name(zRepo))!=0 |
| 1474 | && strcmp(zMimetype, "application/x-fossil-artifact")!=0 |
| 1475 | ){ |
| 1476 | Blob content; |
| 1477 | blob_read_from_file(&content, file_cleanup_fullpath(zRepo)); |
| 1478 | cgi_set_content_type(zMimetype); |
| 1479 | cgi_set_content(&content); |
| 1480 | cgi_reply(); |
| 1481 | return; |
| 1482 | } |
| @@ -1844,11 +1844,11 @@ | |
| 1844 | g.httpOut = stdout; |
| 1845 | g.httpIn = stdin; |
| 1846 | fossil_binary_mode(g.httpOut); |
| 1847 | fossil_binary_mode(g.httpIn); |
| 1848 | g.cgiOutput = 1; |
| 1849 | blob_read_from_file(&config, zFile); |
| 1850 | while( blob_line(&config, &line) ){ |
| 1851 | if( !blob_token(&line, &key) ) continue; |
| 1852 | if( blob_buffer(&key)[0]=='#' ) continue; |
| 1853 | if( blob_eq(&key, "repository:") && blob_tail(&line, &value) ){ |
| 1854 | /* repository: FILENAME |
| @@ -2018,11 +2018,11 @@ | |
| 2018 | static void find_server_repository(int arg, int fCreate){ |
| 2019 | if( g.argc<=arg ){ |
| 2020 | db_must_be_within_tree(); |
| 2021 | }else{ |
| 2022 | const char *zRepo = g.argv[arg]; |
| 2023 | int isDir = file_isdir(zRepo); |
| 2024 | if( isDir==1 ){ |
| 2025 | g.zRepositoryName = mprintf("%s", zRepo); |
| 2026 | file_simplify_name(g.zRepositoryName, -1, 0); |
| 2027 | }else{ |
| 2028 | if( isDir==0 && fCreate ){ |
| 2029 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -1181,11 +1181,11 @@ | |
| 1181 | } |
| 1182 | |
| 1183 | file_canonical_name(zRepo, &dir, 0); |
| 1184 | zDir = blob_str(&dir); |
| 1185 | if( !noJail ){ |
| 1186 | if( file_isdir(zDir, ExtFILE)==1 ){ |
| 1187 | if( file_chdir(zDir, 1) ){ |
| 1188 | fossil_fatal("unable to chroot into %s", zDir); |
| 1189 | } |
| 1190 | g.fJail = 1; |
| 1191 | zRepo = "/"; |
| @@ -1208,11 +1208,11 @@ | |
| 1208 | i = setgid(sStat.st_gid); |
| 1209 | i = i || setuid(sStat.st_uid); |
| 1210 | if(i){ |
| 1211 | fossil_fatal("setgid/uid() failed with errno %d", errno); |
| 1212 | } |
| 1213 | if( g.db==0 && file_isfile(zRepo, ExtFILE) ){ |
| 1214 | db_open_repository(zRepo); |
| 1215 | } |
| 1216 | } |
| 1217 | #endif |
| 1218 | return zRepo; |
| @@ -1427,11 +1427,11 @@ | |
| 1427 | ** Special case: Assume any file with a basename of ".fossil" does |
| 1428 | ** not exist. |
| 1429 | */ |
| 1430 | zCleanRepo = file_cleanup_fullpath(zRepo); |
| 1431 | if( szFile==0 && sqlite3_strglob("*/.fossil",zRepo)!=0 ){ |
| 1432 | szFile = file_size(zCleanRepo, ExtFILE); |
| 1433 | if( g.fHttpTrace ){ |
| 1434 | char zBuf[24]; |
| 1435 | sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", szFile); |
| 1436 | @ <!-- file_size(%h(zCleanRepo)) is %s(zBuf) --> |
| 1437 | fprintf(stderr, "# file_size(%s) = %s\n", zCleanRepo, zBuf); |
| @@ -1447,11 +1447,11 @@ | |
| 1447 | assert( fossil_strcmp(&zRepo[j], ".fossil")==0 ); |
| 1448 | zRepo[j] = 0; /* Remove the ".fossil" suffix */ |
| 1449 | |
| 1450 | /* The PATH_INFO prefix seen so far is a valid directory. |
| 1451 | ** Continue the loop with the next element of the PATH_INFO */ |
| 1452 | if( zPathInfo[i]=='/' && file_isdir(zCleanRepo, ExtFILE)==1 ){ |
| 1453 | fossil_free(zToFree); |
| 1454 | i++; |
| 1455 | continue; |
| 1456 | } |
| 1457 | |
| @@ -1465,18 +1465,18 @@ | |
| 1465 | ** general-purpose web server. The "--file GLOB" mechanism is |
| 1466 | ** designed to allow the delivery of a few static images or HTML |
| 1467 | ** pages. |
| 1468 | */ |
| 1469 | if( pFileGlob!=0 |
| 1470 | && file_isfile(zCleanRepo, ExtFILE) |
| 1471 | && glob_match(pFileGlob, file_cleanup_fullpath(zRepo)) |
| 1472 | && sqlite3_strglob("*.fossil*",zRepo)!=0 |
| 1473 | && (zMimetype = mimetype_from_name(zRepo))!=0 |
| 1474 | && strcmp(zMimetype, "application/x-fossil-artifact")!=0 |
| 1475 | ){ |
| 1476 | Blob content; |
| 1477 | blob_read_from_file(&content, file_cleanup_fullpath(zRepo), ExtFILE); |
| 1478 | cgi_set_content_type(zMimetype); |
| 1479 | cgi_set_content(&content); |
| 1480 | cgi_reply(); |
| 1481 | return; |
| 1482 | } |
| @@ -1844,11 +1844,11 @@ | |
| 1844 | g.httpOut = stdout; |
| 1845 | g.httpIn = stdin; |
| 1846 | fossil_binary_mode(g.httpOut); |
| 1847 | fossil_binary_mode(g.httpIn); |
| 1848 | g.cgiOutput = 1; |
| 1849 | blob_read_from_file(&config, zFile, ExtFILE); |
| 1850 | while( blob_line(&config, &line) ){ |
| 1851 | if( !blob_token(&line, &key) ) continue; |
| 1852 | if( blob_buffer(&key)[0]=='#' ) continue; |
| 1853 | if( blob_eq(&key, "repository:") && blob_tail(&line, &value) ){ |
| 1854 | /* repository: FILENAME |
| @@ -2018,11 +2018,11 @@ | |
| 2018 | static void find_server_repository(int arg, int fCreate){ |
| 2019 | if( g.argc<=arg ){ |
| 2020 | db_must_be_within_tree(); |
| 2021 | }else{ |
| 2022 | const char *zRepo = g.argv[arg]; |
| 2023 | int isDir = file_isdir(zRepo, ExtFILE); |
| 2024 | if( isDir==1 ){ |
| 2025 | g.zRepositoryName = mprintf("%s", zRepo); |
| 2026 | file_simplify_name(g.zRepositoryName, -1, 0); |
| 2027 | }else{ |
| 2028 | if( isDir==0 && fCreate ){ |
| 2029 |
+1
-1
| --- src/manifest.c | ||
| +++ src/manifest.c | ||
| @@ -1026,11 +1026,11 @@ | ||
| 1026 | 1026 | int n = 1; |
| 1027 | 1027 | sqlite3_open(":memory:", &g.db); |
| 1028 | 1028 | if( g.argc!=3 && g.argc!=4 ){ |
| 1029 | 1029 | usage("FILENAME"); |
| 1030 | 1030 | } |
| 1031 | - blob_read_from_file(&b, g.argv[2]); | |
| 1031 | + blob_read_from_file(&b, g.argv[2], ExtFILE); | |
| 1032 | 1032 | if( g.argc>3 ) n = atoi(g.argv[3]); |
| 1033 | 1033 | for(i=0; i<n; i++){ |
| 1034 | 1034 | Blob b2; |
| 1035 | 1035 | Blob err; |
| 1036 | 1036 | blob_copy(&b2, &b); |
| 1037 | 1037 |
| --- src/manifest.c | |
| +++ src/manifest.c | |
| @@ -1026,11 +1026,11 @@ | |
| 1026 | int n = 1; |
| 1027 | sqlite3_open(":memory:", &g.db); |
| 1028 | if( g.argc!=3 && g.argc!=4 ){ |
| 1029 | usage("FILENAME"); |
| 1030 | } |
| 1031 | blob_read_from_file(&b, g.argv[2]); |
| 1032 | if( g.argc>3 ) n = atoi(g.argv[3]); |
| 1033 | for(i=0; i<n; i++){ |
| 1034 | Blob b2; |
| 1035 | Blob err; |
| 1036 | blob_copy(&b2, &b); |
| 1037 |
| --- src/manifest.c | |
| +++ src/manifest.c | |
| @@ -1026,11 +1026,11 @@ | |
| 1026 | int n = 1; |
| 1027 | sqlite3_open(":memory:", &g.db); |
| 1028 | if( g.argc!=3 && g.argc!=4 ){ |
| 1029 | usage("FILENAME"); |
| 1030 | } |
| 1031 | blob_read_from_file(&b, g.argv[2], ExtFILE); |
| 1032 | if( g.argc>3 ) n = atoi(g.argv[3]); |
| 1033 | for(i=0; i<n; i++){ |
| 1034 | Blob b2; |
| 1035 | Blob err; |
| 1036 | blob_copy(&b2, &b); |
| 1037 |
+8
-8
| --- src/merge.c | ||
| +++ src/merge.c | ||
| @@ -548,11 +548,11 @@ | ||
| 548 | 548 | const char *zName = db_column_text(&q, 1); |
| 549 | 549 | int isExe = db_column_int(&q, 2); |
| 550 | 550 | fossil_print("%s %s\n", isExe ? "EXECUTABLE" : "UNEXEC", zName); |
| 551 | 551 | if( !dryRunFlag ){ |
| 552 | 552 | char *zFullPath = mprintf("%s/%s", g.zLocalRoot, zName); |
| 553 | - file_wd_setexe(zFullPath, isExe); | |
| 553 | + file_setexe(zFullPath, isExe); | |
| 554 | 554 | free(zFullPath); |
| 555 | 555 | db_multi_exec("UPDATE vfile SET isexe=%d WHERE id=%d", isExe, idv); |
| 556 | 556 | } |
| 557 | 557 | } |
| 558 | 558 | db_finalize(&q); |
| @@ -628,11 +628,11 @@ | ||
| 628 | 628 | fossil_print("MERGE %s (pivot=%d v1=%d v2=%d)\n", |
| 629 | 629 | zName, ridp, ridm, ridv); |
| 630 | 630 | }else{ |
| 631 | 631 | fossil_print("MERGE %s\n", zName); |
| 632 | 632 | } |
| 633 | - if( islinkv || islinkm /* || file_wd_islink(zFullPath) */ ){ | |
| 633 | + if( islinkv || islinkm ){ | |
| 634 | 634 | fossil_print("***** Cannot merge symlink %s\n", zName); |
| 635 | 635 | nConflict++; |
| 636 | 636 | }else{ |
| 637 | 637 | if( !dryRunFlag ) undo_save(zName); |
| 638 | 638 | zFullPath = mprintf("%s/%s", g.zLocalRoot, zName); |
| @@ -646,11 +646,11 @@ | ||
| 646 | 646 | rc = merge_3way(&p, zFullPath, &m, &r, mergeFlags); |
| 647 | 647 | } |
| 648 | 648 | if( rc>=0 ){ |
| 649 | 649 | if( !dryRunFlag ){ |
| 650 | 650 | blob_write_to_file(&r, zFullPath); |
| 651 | - file_wd_setexe(zFullPath, isExe); | |
| 651 | + file_setexe(zFullPath, isExe); | |
| 652 | 652 | } |
| 653 | 653 | db_multi_exec("UPDATE vfile SET mtime=0 WHERE id=%d", idv); |
| 654 | 654 | if( rc>0 ){ |
| 655 | 655 | fossil_print("***** %d merge conflicts in %s\n", rc, zName); |
| 656 | 656 | nConflict++; |
| @@ -736,28 +736,28 @@ | ||
| 736 | 736 | zFullOldPath = db_text(0,"SELECT tmpfn FROM tmprn WHERE fn=%Q", zOldName); |
| 737 | 737 | if( !zFullOldPath ){ |
| 738 | 738 | zFullOldPath = mprintf("%s%s", g.zLocalRoot, zOldName); |
| 739 | 739 | } |
| 740 | 740 | zFullNewPath = mprintf("%s%s", g.zLocalRoot, zNewName); |
| 741 | - if( file_wd_size(zFullNewPath)>=0 ){ | |
| 741 | + if( file_size(zFullNewPath, RepoFILE)>=0 ){ | |
| 742 | 742 | Blob tmpPath; |
| 743 | 743 | file_tempname(&tmpPath, ""); |
| 744 | 744 | db_multi_exec("INSERT INTO tmprn(fn,tmpfn) VALUES(%Q,%Q)", |
| 745 | 745 | zNewName, blob_str(&tmpPath)); |
| 746 | - if( file_wd_islink(zFullNewPath) ){ | |
| 746 | + if( file_islink(zFullNewPath) ){ | |
| 747 | 747 | symlink_copy(zFullNewPath, blob_str(&tmpPath)); |
| 748 | 748 | }else{ |
| 749 | 749 | file_copy(zFullNewPath, blob_str(&tmpPath)); |
| 750 | 750 | } |
| 751 | 751 | blob_reset(&tmpPath); |
| 752 | 752 | } |
| 753 | - if( file_wd_islink(zFullOldPath) ){ | |
| 753 | + if( file_islink(zFullOldPath) ){ | |
| 754 | 754 | symlink_copy(zFullOldPath, zFullNewPath); |
| 755 | 755 | }else{ |
| 756 | 756 | file_copy(zFullOldPath, zFullNewPath); |
| 757 | 757 | } |
| 758 | - file_wd_setexe(zFullNewPath, isExe); | |
| 758 | + file_setexe(zFullNewPath, isExe); | |
| 759 | 759 | file_delete(zFullOldPath); |
| 760 | 760 | free(zFullNewPath); |
| 761 | 761 | free(zFullOldPath); |
| 762 | 762 | } |
| 763 | 763 | } |
| @@ -789,11 +789,11 @@ | ||
| 789 | 789 | " SELECT %d,%d,0,rid,mrid,isexe,islink,pathname FROM vfile WHERE id=%d", |
| 790 | 790 | vid, integrateFlag?5:3, idm |
| 791 | 791 | ); |
| 792 | 792 | zName = db_column_text(&q, 1); |
| 793 | 793 | zFullName = mprintf("%s%s", g.zLocalRoot, zName); |
| 794 | - if( file_wd_isfile_or_link(zFullName) | |
| 794 | + if( file_isfile_or_link(zFullName) | |
| 795 | 795 | && !db_exists("SELECT 1 FROM fv WHERE fn=%Q", zName) ){ |
| 796 | 796 | fossil_print("ADDED %s (overwrites an unmanaged file)\n", zName); |
| 797 | 797 | nOverwrite++; |
| 798 | 798 | }else{ |
| 799 | 799 | fossil_print("ADDED %s\n", zName); |
| 800 | 800 |
| --- src/merge.c | |
| +++ src/merge.c | |
| @@ -548,11 +548,11 @@ | |
| 548 | const char *zName = db_column_text(&q, 1); |
| 549 | int isExe = db_column_int(&q, 2); |
| 550 | fossil_print("%s %s\n", isExe ? "EXECUTABLE" : "UNEXEC", zName); |
| 551 | if( !dryRunFlag ){ |
| 552 | char *zFullPath = mprintf("%s/%s", g.zLocalRoot, zName); |
| 553 | file_wd_setexe(zFullPath, isExe); |
| 554 | free(zFullPath); |
| 555 | db_multi_exec("UPDATE vfile SET isexe=%d WHERE id=%d", isExe, idv); |
| 556 | } |
| 557 | } |
| 558 | db_finalize(&q); |
| @@ -628,11 +628,11 @@ | |
| 628 | fossil_print("MERGE %s (pivot=%d v1=%d v2=%d)\n", |
| 629 | zName, ridp, ridm, ridv); |
| 630 | }else{ |
| 631 | fossil_print("MERGE %s\n", zName); |
| 632 | } |
| 633 | if( islinkv || islinkm /* || file_wd_islink(zFullPath) */ ){ |
| 634 | fossil_print("***** Cannot merge symlink %s\n", zName); |
| 635 | nConflict++; |
| 636 | }else{ |
| 637 | if( !dryRunFlag ) undo_save(zName); |
| 638 | zFullPath = mprintf("%s/%s", g.zLocalRoot, zName); |
| @@ -646,11 +646,11 @@ | |
| 646 | rc = merge_3way(&p, zFullPath, &m, &r, mergeFlags); |
| 647 | } |
| 648 | if( rc>=0 ){ |
| 649 | if( !dryRunFlag ){ |
| 650 | blob_write_to_file(&r, zFullPath); |
| 651 | file_wd_setexe(zFullPath, isExe); |
| 652 | } |
| 653 | db_multi_exec("UPDATE vfile SET mtime=0 WHERE id=%d", idv); |
| 654 | if( rc>0 ){ |
| 655 | fossil_print("***** %d merge conflicts in %s\n", rc, zName); |
| 656 | nConflict++; |
| @@ -736,28 +736,28 @@ | |
| 736 | zFullOldPath = db_text(0,"SELECT tmpfn FROM tmprn WHERE fn=%Q", zOldName); |
| 737 | if( !zFullOldPath ){ |
| 738 | zFullOldPath = mprintf("%s%s", g.zLocalRoot, zOldName); |
| 739 | } |
| 740 | zFullNewPath = mprintf("%s%s", g.zLocalRoot, zNewName); |
| 741 | if( file_wd_size(zFullNewPath)>=0 ){ |
| 742 | Blob tmpPath; |
| 743 | file_tempname(&tmpPath, ""); |
| 744 | db_multi_exec("INSERT INTO tmprn(fn,tmpfn) VALUES(%Q,%Q)", |
| 745 | zNewName, blob_str(&tmpPath)); |
| 746 | if( file_wd_islink(zFullNewPath) ){ |
| 747 | symlink_copy(zFullNewPath, blob_str(&tmpPath)); |
| 748 | }else{ |
| 749 | file_copy(zFullNewPath, blob_str(&tmpPath)); |
| 750 | } |
| 751 | blob_reset(&tmpPath); |
| 752 | } |
| 753 | if( file_wd_islink(zFullOldPath) ){ |
| 754 | symlink_copy(zFullOldPath, zFullNewPath); |
| 755 | }else{ |
| 756 | file_copy(zFullOldPath, zFullNewPath); |
| 757 | } |
| 758 | file_wd_setexe(zFullNewPath, isExe); |
| 759 | file_delete(zFullOldPath); |
| 760 | free(zFullNewPath); |
| 761 | free(zFullOldPath); |
| 762 | } |
| 763 | } |
| @@ -789,11 +789,11 @@ | |
| 789 | " SELECT %d,%d,0,rid,mrid,isexe,islink,pathname FROM vfile WHERE id=%d", |
| 790 | vid, integrateFlag?5:3, idm |
| 791 | ); |
| 792 | zName = db_column_text(&q, 1); |
| 793 | zFullName = mprintf("%s%s", g.zLocalRoot, zName); |
| 794 | if( file_wd_isfile_or_link(zFullName) |
| 795 | && !db_exists("SELECT 1 FROM fv WHERE fn=%Q", zName) ){ |
| 796 | fossil_print("ADDED %s (overwrites an unmanaged file)\n", zName); |
| 797 | nOverwrite++; |
| 798 | }else{ |
| 799 | fossil_print("ADDED %s\n", zName); |
| 800 |
| --- src/merge.c | |
| +++ src/merge.c | |
| @@ -548,11 +548,11 @@ | |
| 548 | const char *zName = db_column_text(&q, 1); |
| 549 | int isExe = db_column_int(&q, 2); |
| 550 | fossil_print("%s %s\n", isExe ? "EXECUTABLE" : "UNEXEC", zName); |
| 551 | if( !dryRunFlag ){ |
| 552 | char *zFullPath = mprintf("%s/%s", g.zLocalRoot, zName); |
| 553 | file_setexe(zFullPath, isExe); |
| 554 | free(zFullPath); |
| 555 | db_multi_exec("UPDATE vfile SET isexe=%d WHERE id=%d", isExe, idv); |
| 556 | } |
| 557 | } |
| 558 | db_finalize(&q); |
| @@ -628,11 +628,11 @@ | |
| 628 | fossil_print("MERGE %s (pivot=%d v1=%d v2=%d)\n", |
| 629 | zName, ridp, ridm, ridv); |
| 630 | }else{ |
| 631 | fossil_print("MERGE %s\n", zName); |
| 632 | } |
| 633 | if( islinkv || islinkm ){ |
| 634 | fossil_print("***** Cannot merge symlink %s\n", zName); |
| 635 | nConflict++; |
| 636 | }else{ |
| 637 | if( !dryRunFlag ) undo_save(zName); |
| 638 | zFullPath = mprintf("%s/%s", g.zLocalRoot, zName); |
| @@ -646,11 +646,11 @@ | |
| 646 | rc = merge_3way(&p, zFullPath, &m, &r, mergeFlags); |
| 647 | } |
| 648 | if( rc>=0 ){ |
| 649 | if( !dryRunFlag ){ |
| 650 | blob_write_to_file(&r, zFullPath); |
| 651 | file_setexe(zFullPath, isExe); |
| 652 | } |
| 653 | db_multi_exec("UPDATE vfile SET mtime=0 WHERE id=%d", idv); |
| 654 | if( rc>0 ){ |
| 655 | fossil_print("***** %d merge conflicts in %s\n", rc, zName); |
| 656 | nConflict++; |
| @@ -736,28 +736,28 @@ | |
| 736 | zFullOldPath = db_text(0,"SELECT tmpfn FROM tmprn WHERE fn=%Q", zOldName); |
| 737 | if( !zFullOldPath ){ |
| 738 | zFullOldPath = mprintf("%s%s", g.zLocalRoot, zOldName); |
| 739 | } |
| 740 | zFullNewPath = mprintf("%s%s", g.zLocalRoot, zNewName); |
| 741 | if( file_size(zFullNewPath, RepoFILE)>=0 ){ |
| 742 | Blob tmpPath; |
| 743 | file_tempname(&tmpPath, ""); |
| 744 | db_multi_exec("INSERT INTO tmprn(fn,tmpfn) VALUES(%Q,%Q)", |
| 745 | zNewName, blob_str(&tmpPath)); |
| 746 | if( file_islink(zFullNewPath) ){ |
| 747 | symlink_copy(zFullNewPath, blob_str(&tmpPath)); |
| 748 | }else{ |
| 749 | file_copy(zFullNewPath, blob_str(&tmpPath)); |
| 750 | } |
| 751 | blob_reset(&tmpPath); |
| 752 | } |
| 753 | if( file_islink(zFullOldPath) ){ |
| 754 | symlink_copy(zFullOldPath, zFullNewPath); |
| 755 | }else{ |
| 756 | file_copy(zFullOldPath, zFullNewPath); |
| 757 | } |
| 758 | file_setexe(zFullNewPath, isExe); |
| 759 | file_delete(zFullOldPath); |
| 760 | free(zFullNewPath); |
| 761 | free(zFullOldPath); |
| 762 | } |
| 763 | } |
| @@ -789,11 +789,11 @@ | |
| 789 | " SELECT %d,%d,0,rid,mrid,isexe,islink,pathname FROM vfile WHERE id=%d", |
| 790 | vid, integrateFlag?5:3, idm |
| 791 | ); |
| 792 | zName = db_column_text(&q, 1); |
| 793 | zFullName = mprintf("%s%s", g.zLocalRoot, zName); |
| 794 | if( file_isfile_or_link(zFullName) |
| 795 | && !db_exists("SELECT 1 FROM fv WHERE fn=%Q", zName) ){ |
| 796 | fossil_print("ADDED %s (overwrites an unmanaged file)\n", zName); |
| 797 | nOverwrite++; |
| 798 | }else{ |
| 799 | fossil_print("ADDED %s\n", zName); |
| 800 |
+7
-7
| --- src/merge3.c | ||
| +++ src/merge3.c | ||
| @@ -333,11 +333,11 @@ | ||
| 333 | 333 | ** Return true if the named file contains an unresolved merge marker line. |
| 334 | 334 | */ |
| 335 | 335 | int file_contains_merge_marker(const char *zFullpath){ |
| 336 | 336 | Blob file; |
| 337 | 337 | int rc; |
| 338 | - blob_read_from_file(&file, zFullpath); | |
| 338 | + blob_read_from_file(&file, zFullpath, ExtFILE); | |
| 339 | 339 | rc = contains_merge_marker(&file); |
| 340 | 340 | blob_reset(&file); |
| 341 | 341 | return rc; |
| 342 | 342 | } |
| 343 | 343 | |
| @@ -376,17 +376,17 @@ | ||
| 376 | 376 | verify_all_options(); |
| 377 | 377 | |
| 378 | 378 | if( g.argc!=6 ){ |
| 379 | 379 | usage("PIVOT V1 V2 MERGED"); |
| 380 | 380 | } |
| 381 | - if( blob_read_from_file(&pivot, g.argv[2])<0 ){ | |
| 381 | + if( blob_read_from_file(&pivot, g.argv[2], ExtFILE)<0 ){ | |
| 382 | 382 | fossil_fatal("cannot read %s", g.argv[2]); |
| 383 | 383 | } |
| 384 | - if( blob_read_from_file(&v1, g.argv[3])<0 ){ | |
| 384 | + if( blob_read_from_file(&v1, g.argv[3], ExtFILE)<0 ){ | |
| 385 | 385 | fossil_fatal("cannot read %s", g.argv[3]); |
| 386 | 386 | } |
| 387 | - if( blob_read_from_file(&v2, g.argv[4])<0 ){ | |
| 387 | + if( blob_read_from_file(&v2, g.argv[4], ExtFILE)<0 ){ | |
| 388 | 388 | fossil_fatal("cannot read %s", g.argv[4]); |
| 389 | 389 | } |
| 390 | 390 | nConflict = blob_merge(&pivot, &v1, &v2, &merged); |
| 391 | 391 | if( blob_write_to_file(&merged, g.argv[5])<blob_size(&merged) ){ |
| 392 | 392 | fossil_fatal("cannot write %s", g.argv[4]); |
| @@ -466,11 +466,11 @@ | ||
| 466 | 466 | unsigned mergeFlags /* Flags that control operation */ |
| 467 | 467 | ){ |
| 468 | 468 | Blob v1; /* Content of zV1 */ |
| 469 | 469 | int rc; /* Return code of subroutines and this routine */ |
| 470 | 470 | |
| 471 | - blob_read_from_file(&v1, zV1); | |
| 471 | + blob_read_from_file(&v1, zV1, ExtFILE); | |
| 472 | 472 | rc = blob_merge(pPivot, &v1, pV2, pOut); |
| 473 | 473 | if( rc!=0 && (mergeFlags & MERGE_DRYRUN)==0 ){ |
| 474 | 474 | char *zPivot; /* Name of the pivot file */ |
| 475 | 475 | char *zOrig; /* Name of the original content file */ |
| 476 | 476 | char *zOther; /* Name of the merge file */ |
| @@ -496,12 +496,12 @@ | ||
| 496 | 496 | azSubst[4] = "%merge"; azSubst[5] = zOther; |
| 497 | 497 | azSubst[6] = "%output"; azSubst[7] = zOut; |
| 498 | 498 | zCmd = string_subst(zGMerge, 8, azSubst); |
| 499 | 499 | printf("%s\n", zCmd); fflush(stdout); |
| 500 | 500 | fossil_system(zCmd); |
| 501 | - if( file_wd_size(zOut)>=0 ){ | |
| 502 | - blob_read_from_file(pOut, zOut); | |
| 501 | + if( file_size(zOut, RepoFILE)>=0 ){ | |
| 502 | + blob_read_from_file(pOut, zOut, ExtFILE); | |
| 503 | 503 | file_delete(zPivot); |
| 504 | 504 | file_delete(zOrig); |
| 505 | 505 | file_delete(zOther); |
| 506 | 506 | file_delete(zOut); |
| 507 | 507 | } |
| 508 | 508 |
| --- src/merge3.c | |
| +++ src/merge3.c | |
| @@ -333,11 +333,11 @@ | |
| 333 | ** Return true if the named file contains an unresolved merge marker line. |
| 334 | */ |
| 335 | int file_contains_merge_marker(const char *zFullpath){ |
| 336 | Blob file; |
| 337 | int rc; |
| 338 | blob_read_from_file(&file, zFullpath); |
| 339 | rc = contains_merge_marker(&file); |
| 340 | blob_reset(&file); |
| 341 | return rc; |
| 342 | } |
| 343 | |
| @@ -376,17 +376,17 @@ | |
| 376 | verify_all_options(); |
| 377 | |
| 378 | if( g.argc!=6 ){ |
| 379 | usage("PIVOT V1 V2 MERGED"); |
| 380 | } |
| 381 | if( blob_read_from_file(&pivot, g.argv[2])<0 ){ |
| 382 | fossil_fatal("cannot read %s", g.argv[2]); |
| 383 | } |
| 384 | if( blob_read_from_file(&v1, g.argv[3])<0 ){ |
| 385 | fossil_fatal("cannot read %s", g.argv[3]); |
| 386 | } |
| 387 | if( blob_read_from_file(&v2, g.argv[4])<0 ){ |
| 388 | fossil_fatal("cannot read %s", g.argv[4]); |
| 389 | } |
| 390 | nConflict = blob_merge(&pivot, &v1, &v2, &merged); |
| 391 | if( blob_write_to_file(&merged, g.argv[5])<blob_size(&merged) ){ |
| 392 | fossil_fatal("cannot write %s", g.argv[4]); |
| @@ -466,11 +466,11 @@ | |
| 466 | unsigned mergeFlags /* Flags that control operation */ |
| 467 | ){ |
| 468 | Blob v1; /* Content of zV1 */ |
| 469 | int rc; /* Return code of subroutines and this routine */ |
| 470 | |
| 471 | blob_read_from_file(&v1, zV1); |
| 472 | rc = blob_merge(pPivot, &v1, pV2, pOut); |
| 473 | if( rc!=0 && (mergeFlags & MERGE_DRYRUN)==0 ){ |
| 474 | char *zPivot; /* Name of the pivot file */ |
| 475 | char *zOrig; /* Name of the original content file */ |
| 476 | char *zOther; /* Name of the merge file */ |
| @@ -496,12 +496,12 @@ | |
| 496 | azSubst[4] = "%merge"; azSubst[5] = zOther; |
| 497 | azSubst[6] = "%output"; azSubst[7] = zOut; |
| 498 | zCmd = string_subst(zGMerge, 8, azSubst); |
| 499 | printf("%s\n", zCmd); fflush(stdout); |
| 500 | fossil_system(zCmd); |
| 501 | if( file_wd_size(zOut)>=0 ){ |
| 502 | blob_read_from_file(pOut, zOut); |
| 503 | file_delete(zPivot); |
| 504 | file_delete(zOrig); |
| 505 | file_delete(zOther); |
| 506 | file_delete(zOut); |
| 507 | } |
| 508 |
| --- src/merge3.c | |
| +++ src/merge3.c | |
| @@ -333,11 +333,11 @@ | |
| 333 | ** Return true if the named file contains an unresolved merge marker line. |
| 334 | */ |
| 335 | int file_contains_merge_marker(const char *zFullpath){ |
| 336 | Blob file; |
| 337 | int rc; |
| 338 | blob_read_from_file(&file, zFullpath, ExtFILE); |
| 339 | rc = contains_merge_marker(&file); |
| 340 | blob_reset(&file); |
| 341 | return rc; |
| 342 | } |
| 343 | |
| @@ -376,17 +376,17 @@ | |
| 376 | verify_all_options(); |
| 377 | |
| 378 | if( g.argc!=6 ){ |
| 379 | usage("PIVOT V1 V2 MERGED"); |
| 380 | } |
| 381 | if( blob_read_from_file(&pivot, g.argv[2], ExtFILE)<0 ){ |
| 382 | fossil_fatal("cannot read %s", g.argv[2]); |
| 383 | } |
| 384 | if( blob_read_from_file(&v1, g.argv[3], ExtFILE)<0 ){ |
| 385 | fossil_fatal("cannot read %s", g.argv[3]); |
| 386 | } |
| 387 | if( blob_read_from_file(&v2, g.argv[4], ExtFILE)<0 ){ |
| 388 | fossil_fatal("cannot read %s", g.argv[4]); |
| 389 | } |
| 390 | nConflict = blob_merge(&pivot, &v1, &v2, &merged); |
| 391 | if( blob_write_to_file(&merged, g.argv[5])<blob_size(&merged) ){ |
| 392 | fossil_fatal("cannot write %s", g.argv[4]); |
| @@ -466,11 +466,11 @@ | |
| 466 | unsigned mergeFlags /* Flags that control operation */ |
| 467 | ){ |
| 468 | Blob v1; /* Content of zV1 */ |
| 469 | int rc; /* Return code of subroutines and this routine */ |
| 470 | |
| 471 | blob_read_from_file(&v1, zV1, ExtFILE); |
| 472 | rc = blob_merge(pPivot, &v1, pV2, pOut); |
| 473 | if( rc!=0 && (mergeFlags & MERGE_DRYRUN)==0 ){ |
| 474 | char *zPivot; /* Name of the pivot file */ |
| 475 | char *zOrig; /* Name of the original content file */ |
| 476 | char *zOther; /* Name of the merge file */ |
| @@ -496,12 +496,12 @@ | |
| 496 | azSubst[4] = "%merge"; azSubst[5] = zOther; |
| 497 | azSubst[6] = "%output"; azSubst[7] = zOut; |
| 498 | zCmd = string_subst(zGMerge, 8, azSubst); |
| 499 | printf("%s\n", zCmd); fflush(stdout); |
| 500 | fossil_system(zCmd); |
| 501 | if( file_size(zOut, RepoFILE)>=0 ){ |
| 502 | blob_read_from_file(pOut, zOut, ExtFILE); |
| 503 | file_delete(zPivot); |
| 504 | file_delete(zOrig); |
| 505 | file_delete(zOther); |
| 506 | file_delete(zOut); |
| 507 | } |
| 508 |
+5
-5
| --- src/rebuild.c | ||
| +++ src/rebuild.c | ||
| @@ -943,20 +943,20 @@ | ||
| 943 | 943 | zUtf8Name = fossil_path_to_utf8(pEntry->d_name); |
| 944 | 944 | zSubpath = mprintf("%s/%s", zPath, zUtf8Name); |
| 945 | 945 | fossil_path_free(zUtf8Name); |
| 946 | 946 | #ifdef _DIRENT_HAVE_D_TYPE |
| 947 | 947 | if( (pEntry->d_type==DT_UNKNOWN || pEntry->d_type==DT_LNK) |
| 948 | - ? (file_isdir(zSubpath)==1) : (pEntry->d_type==DT_DIR) ) | |
| 948 | + ? (file_isdir(zSubpath, ExtFILE)==1) : (pEntry->d_type==DT_DIR) ) | |
| 949 | 949 | #else |
| 950 | - if( file_isdir(zSubpath)==1 ) | |
| 950 | + if( file_isdir(zSubpath, ExtFILE)==1 ) | |
| 951 | 951 | #endif |
| 952 | 952 | { |
| 953 | 953 | recon_read_dir(zSubpath); |
| 954 | 954 | }else{ |
| 955 | 955 | blob_init(&path, 0, 0); |
| 956 | 956 | blob_appendf(&path, "%s", zSubpath); |
| 957 | - if( blob_read_from_file(&aContent, blob_str(&path))==-1 ){ | |
| 957 | + if( blob_read_from_file(&aContent, blob_str(&path), ExtFILE)==-1 ){ | |
| 958 | 958 | fossil_fatal("some unknown error occurred while reading \"%s\"", |
| 959 | 959 | blob_str(&path)); |
| 960 | 960 | } |
| 961 | 961 | content_put(&aContent); |
| 962 | 962 | blob_reset(&path); |
| @@ -989,11 +989,11 @@ | ||
| 989 | 989 | void reconstruct_cmd(void) { |
| 990 | 990 | char *zPassword; |
| 991 | 991 | if( g.argc!=4 ){ |
| 992 | 992 | usage("FILENAME DIRECTORY"); |
| 993 | 993 | } |
| 994 | - if( file_isdir(g.argv[3])!=1 ){ | |
| 994 | + if( file_isdir(g.argv[3], ExtFILE)!=1 ){ | |
| 995 | 995 | fossil_print("\"%s\" is not a directory\n\n", g.argv[3]); |
| 996 | 996 | usage("FILENAME DIRECTORY"); |
| 997 | 997 | } |
| 998 | 998 | db_create_repository(g.argv[2]); |
| 999 | 999 | db_open_repository(g.argv[2]); |
| @@ -1071,11 +1071,11 @@ | ||
| 1071 | 1071 | if( g.argc!=3 ){ |
| 1072 | 1072 | usage ("?OPTIONS? DESTINATION"); |
| 1073 | 1073 | } |
| 1074 | 1074 | /* get and check argument destination directory */ |
| 1075 | 1075 | zDestDir = g.argv[g.argc-1]; |
| 1076 | - if( !*zDestDir || !file_isdir(zDestDir)) { | |
| 1076 | + if( !*zDestDir || !file_isdir(zDestDir, ExtFILE)) { | |
| 1077 | 1077 | fossil_fatal("DESTINATION(%s) is not a directory!",zDestDir); |
| 1078 | 1078 | } |
| 1079 | 1079 | #ifndef _WIN32 |
| 1080 | 1080 | if( file_access(zDestDir, W_OK) ){ |
| 1081 | 1081 | fossil_fatal("DESTINATION(%s) is not writeable!",zDestDir); |
| 1082 | 1082 |
| --- src/rebuild.c | |
| +++ src/rebuild.c | |
| @@ -943,20 +943,20 @@ | |
| 943 | zUtf8Name = fossil_path_to_utf8(pEntry->d_name); |
| 944 | zSubpath = mprintf("%s/%s", zPath, zUtf8Name); |
| 945 | fossil_path_free(zUtf8Name); |
| 946 | #ifdef _DIRENT_HAVE_D_TYPE |
| 947 | if( (pEntry->d_type==DT_UNKNOWN || pEntry->d_type==DT_LNK) |
| 948 | ? (file_isdir(zSubpath)==1) : (pEntry->d_type==DT_DIR) ) |
| 949 | #else |
| 950 | if( file_isdir(zSubpath)==1 ) |
| 951 | #endif |
| 952 | { |
| 953 | recon_read_dir(zSubpath); |
| 954 | }else{ |
| 955 | blob_init(&path, 0, 0); |
| 956 | blob_appendf(&path, "%s", zSubpath); |
| 957 | if( blob_read_from_file(&aContent, blob_str(&path))==-1 ){ |
| 958 | fossil_fatal("some unknown error occurred while reading \"%s\"", |
| 959 | blob_str(&path)); |
| 960 | } |
| 961 | content_put(&aContent); |
| 962 | blob_reset(&path); |
| @@ -989,11 +989,11 @@ | |
| 989 | void reconstruct_cmd(void) { |
| 990 | char *zPassword; |
| 991 | if( g.argc!=4 ){ |
| 992 | usage("FILENAME DIRECTORY"); |
| 993 | } |
| 994 | if( file_isdir(g.argv[3])!=1 ){ |
| 995 | fossil_print("\"%s\" is not a directory\n\n", g.argv[3]); |
| 996 | usage("FILENAME DIRECTORY"); |
| 997 | } |
| 998 | db_create_repository(g.argv[2]); |
| 999 | db_open_repository(g.argv[2]); |
| @@ -1071,11 +1071,11 @@ | |
| 1071 | if( g.argc!=3 ){ |
| 1072 | usage ("?OPTIONS? DESTINATION"); |
| 1073 | } |
| 1074 | /* get and check argument destination directory */ |
| 1075 | zDestDir = g.argv[g.argc-1]; |
| 1076 | if( !*zDestDir || !file_isdir(zDestDir)) { |
| 1077 | fossil_fatal("DESTINATION(%s) is not a directory!",zDestDir); |
| 1078 | } |
| 1079 | #ifndef _WIN32 |
| 1080 | if( file_access(zDestDir, W_OK) ){ |
| 1081 | fossil_fatal("DESTINATION(%s) is not writeable!",zDestDir); |
| 1082 |
| --- src/rebuild.c | |
| +++ src/rebuild.c | |
| @@ -943,20 +943,20 @@ | |
| 943 | zUtf8Name = fossil_path_to_utf8(pEntry->d_name); |
| 944 | zSubpath = mprintf("%s/%s", zPath, zUtf8Name); |
| 945 | fossil_path_free(zUtf8Name); |
| 946 | #ifdef _DIRENT_HAVE_D_TYPE |
| 947 | if( (pEntry->d_type==DT_UNKNOWN || pEntry->d_type==DT_LNK) |
| 948 | ? (file_isdir(zSubpath, ExtFILE)==1) : (pEntry->d_type==DT_DIR) ) |
| 949 | #else |
| 950 | if( file_isdir(zSubpath, ExtFILE)==1 ) |
| 951 | #endif |
| 952 | { |
| 953 | recon_read_dir(zSubpath); |
| 954 | }else{ |
| 955 | blob_init(&path, 0, 0); |
| 956 | blob_appendf(&path, "%s", zSubpath); |
| 957 | if( blob_read_from_file(&aContent, blob_str(&path), ExtFILE)==-1 ){ |
| 958 | fossil_fatal("some unknown error occurred while reading \"%s\"", |
| 959 | blob_str(&path)); |
| 960 | } |
| 961 | content_put(&aContent); |
| 962 | blob_reset(&path); |
| @@ -989,11 +989,11 @@ | |
| 989 | void reconstruct_cmd(void) { |
| 990 | char *zPassword; |
| 991 | if( g.argc!=4 ){ |
| 992 | usage("FILENAME DIRECTORY"); |
| 993 | } |
| 994 | if( file_isdir(g.argv[3], ExtFILE)!=1 ){ |
| 995 | fossil_print("\"%s\" is not a directory\n\n", g.argv[3]); |
| 996 | usage("FILENAME DIRECTORY"); |
| 997 | } |
| 998 | db_create_repository(g.argv[2]); |
| 999 | db_open_repository(g.argv[2]); |
| @@ -1071,11 +1071,11 @@ | |
| 1071 | if( g.argc!=3 ){ |
| 1072 | usage ("?OPTIONS? DESTINATION"); |
| 1073 | } |
| 1074 | /* get and check argument destination directory */ |
| 1075 | zDestDir = g.argv[g.argc-1]; |
| 1076 | if( !*zDestDir || !file_isdir(zDestDir, ExtFILE)) { |
| 1077 | fossil_fatal("DESTINATION(%s) is not a directory!",zDestDir); |
| 1078 | } |
| 1079 | #ifndef _WIN32 |
| 1080 | if( file_access(zDestDir, W_OK) ){ |
| 1081 | fossil_fatal("DESTINATION(%s) is not writeable!",zDestDir); |
| 1082 |
+2
-2
| --- src/search.c | ||
| +++ src/search.c | ||
| @@ -351,11 +351,11 @@ | ||
| 351 | 351 | if( zBegin==0 ) zBegin = "[["; |
| 352 | 352 | if( zEnd==0 ) zEnd = "]]"; |
| 353 | 353 | if( zGap==0 ) zGap = " ... "; |
| 354 | 354 | p = search_init(g.argv[2], zBegin, zEnd, zGap, flg); |
| 355 | 355 | for(i=3; i<g.argc; i++){ |
| 356 | - blob_read_from_file(&x, g.argv[i]); | |
| 356 | + blob_read_from_file(&x, g.argv[i], ExtFILE); | |
| 357 | 357 | zDoc = blob_str(&x); |
| 358 | 358 | score = search_match(p, 1, (const char**)&zDoc); |
| 359 | 359 | fossil_print("%s: %d\n", g.argv[i], p->iScore); |
| 360 | 360 | blob_reset(&x); |
| 361 | 361 | if( score ){ |
| @@ -1422,11 +1422,11 @@ | ||
| 1422 | 1422 | */ |
| 1423 | 1423 | void test_convert_stext(void){ |
| 1424 | 1424 | Blob in, out; |
| 1425 | 1425 | db_find_and_open_repository(0,0); |
| 1426 | 1426 | if( g.argc!=4 ) usage("FILENAME MIMETYPE"); |
| 1427 | - blob_read_from_file(&in, g.argv[2]); | |
| 1427 | + blob_read_from_file(&in, g.argv[2], ExtFILE); | |
| 1428 | 1428 | blob_init(&out, 0, 0); |
| 1429 | 1429 | get_stext_by_mimetype(&in, g.argv[3], &out); |
| 1430 | 1430 | fossil_print("%s\n",blob_str(&out)); |
| 1431 | 1431 | blob_reset(&in); |
| 1432 | 1432 | blob_reset(&out); |
| 1433 | 1433 |
| --- src/search.c | |
| +++ src/search.c | |
| @@ -351,11 +351,11 @@ | |
| 351 | if( zBegin==0 ) zBegin = "[["; |
| 352 | if( zEnd==0 ) zEnd = "]]"; |
| 353 | if( zGap==0 ) zGap = " ... "; |
| 354 | p = search_init(g.argv[2], zBegin, zEnd, zGap, flg); |
| 355 | for(i=3; i<g.argc; i++){ |
| 356 | blob_read_from_file(&x, g.argv[i]); |
| 357 | zDoc = blob_str(&x); |
| 358 | score = search_match(p, 1, (const char**)&zDoc); |
| 359 | fossil_print("%s: %d\n", g.argv[i], p->iScore); |
| 360 | blob_reset(&x); |
| 361 | if( score ){ |
| @@ -1422,11 +1422,11 @@ | |
| 1422 | */ |
| 1423 | void test_convert_stext(void){ |
| 1424 | Blob in, out; |
| 1425 | db_find_and_open_repository(0,0); |
| 1426 | if( g.argc!=4 ) usage("FILENAME MIMETYPE"); |
| 1427 | blob_read_from_file(&in, g.argv[2]); |
| 1428 | blob_init(&out, 0, 0); |
| 1429 | get_stext_by_mimetype(&in, g.argv[3], &out); |
| 1430 | fossil_print("%s\n",blob_str(&out)); |
| 1431 | blob_reset(&in); |
| 1432 | blob_reset(&out); |
| 1433 |
| --- src/search.c | |
| +++ src/search.c | |
| @@ -351,11 +351,11 @@ | |
| 351 | if( zBegin==0 ) zBegin = "[["; |
| 352 | if( zEnd==0 ) zEnd = "]]"; |
| 353 | if( zGap==0 ) zGap = " ... "; |
| 354 | p = search_init(g.argv[2], zBegin, zEnd, zGap, flg); |
| 355 | for(i=3; i<g.argc; i++){ |
| 356 | blob_read_from_file(&x, g.argv[i], ExtFILE); |
| 357 | zDoc = blob_str(&x); |
| 358 | score = search_match(p, 1, (const char**)&zDoc); |
| 359 | fossil_print("%s: %d\n", g.argv[i], p->iScore); |
| 360 | blob_reset(&x); |
| 361 | if( score ){ |
| @@ -1422,11 +1422,11 @@ | |
| 1422 | */ |
| 1423 | void test_convert_stext(void){ |
| 1424 | Blob in, out; |
| 1425 | db_find_and_open_repository(0,0); |
| 1426 | if( g.argc!=4 ) usage("FILENAME MIMETYPE"); |
| 1427 | blob_read_from_file(&in, g.argv[2], ExtFILE); |
| 1428 | blob_init(&out, 0, 0); |
| 1429 | get_stext_by_mimetype(&in, g.argv[3], &out); |
| 1430 | fossil_print("%s\n",blob_str(&out)); |
| 1431 | blob_reset(&in); |
| 1432 | blob_reset(&out); |
| 1433 |
+13
-3
| --- src/sha1.c | ||
| +++ src/sha1.c | ||
| @@ -352,17 +352,17 @@ | ||
| 352 | 352 | ** Compute the SHA1 checksum of a file on disk. Store the resulting |
| 353 | 353 | ** checksum in the blob pCksum. pCksum is assumed to be initialized. |
| 354 | 354 | ** |
| 355 | 355 | ** Return the number of errors. |
| 356 | 356 | */ |
| 357 | -int sha1sum_file(const char *zFilename, Blob *pCksum){ | |
| 357 | +int sha1sum_file(const char *zFilename, int eFType, Blob *pCksum){ | |
| 358 | 358 | FILE *in; |
| 359 | 359 | SHA1Context ctx; |
| 360 | 360 | unsigned char zResult[20]; |
| 361 | 361 | char zBuf[10240]; |
| 362 | 362 | |
| 363 | - if( file_wd_islink(zFilename) ){ | |
| 363 | + if( eFType==RepoFILE && file_islink(zFilename) ){ | |
| 364 | 364 | /* Instead of file content, return sha1 of link destination path */ |
| 365 | 365 | Blob destinationPath; |
| 366 | 366 | int rc; |
| 367 | 367 | |
| 368 | 368 | blob_read_link(&destinationPath, zFilename); |
| @@ -520,23 +520,33 @@ | ||
| 520 | 520 | ** |
| 521 | 521 | ** Usage: %fossil sha1sum FILE... |
| 522 | 522 | ** |
| 523 | 523 | ** Compute an SHA1 checksum of all files named on the command-line. |
| 524 | 524 | ** If a file is named "-" then take its content from standard input. |
| 525 | +** Options: | |
| 526 | +** | |
| 527 | +** -h, --dereference If FILE is a symbolic link, compute the hash | |
| 528 | +** on the object that the link points to. Normally, | |
| 529 | +** the hash is over the name of the object that | |
| 530 | +** the link points to. | |
| 525 | 531 | */ |
| 526 | 532 | void sha1sum_test(void){ |
| 527 | 533 | int i; |
| 528 | 534 | Blob in; |
| 529 | 535 | Blob cksum; |
| 536 | + int eFType = SymFILE; | |
| 537 | + if( find_option("dereference","h",0)!=0 ){ | |
| 538 | + eFType = ExtFILE; | |
| 539 | + } | |
| 530 | 540 | |
| 531 | 541 | for(i=2; i<g.argc; i++){ |
| 532 | 542 | blob_init(&cksum, "************** not found ***************", -1); |
| 533 | 543 | if( g.argv[i][0]=='-' && g.argv[i][1]==0 ){ |
| 534 | 544 | blob_read_from_channel(&in, stdin, -1); |
| 535 | 545 | sha1sum_blob(&in, &cksum); |
| 536 | 546 | }else{ |
| 537 | - sha1sum_file(g.argv[i], &cksum); | |
| 547 | + sha1sum_file(g.argv[i], eFType, &cksum); | |
| 538 | 548 | } |
| 539 | 549 | fossil_print("%s %s\n", blob_str(&cksum), g.argv[i]); |
| 540 | 550 | blob_reset(&cksum); |
| 541 | 551 | } |
| 542 | 552 | } |
| 543 | 553 |
| --- src/sha1.c | |
| +++ src/sha1.c | |
| @@ -352,17 +352,17 @@ | |
| 352 | ** Compute the SHA1 checksum of a file on disk. Store the resulting |
| 353 | ** checksum in the blob pCksum. pCksum is assumed to be initialized. |
| 354 | ** |
| 355 | ** Return the number of errors. |
| 356 | */ |
| 357 | int sha1sum_file(const char *zFilename, Blob *pCksum){ |
| 358 | FILE *in; |
| 359 | SHA1Context ctx; |
| 360 | unsigned char zResult[20]; |
| 361 | char zBuf[10240]; |
| 362 | |
| 363 | if( file_wd_islink(zFilename) ){ |
| 364 | /* Instead of file content, return sha1 of link destination path */ |
| 365 | Blob destinationPath; |
| 366 | int rc; |
| 367 | |
| 368 | blob_read_link(&destinationPath, zFilename); |
| @@ -520,23 +520,33 @@ | |
| 520 | ** |
| 521 | ** Usage: %fossil sha1sum FILE... |
| 522 | ** |
| 523 | ** Compute an SHA1 checksum of all files named on the command-line. |
| 524 | ** If a file is named "-" then take its content from standard input. |
| 525 | */ |
| 526 | void sha1sum_test(void){ |
| 527 | int i; |
| 528 | Blob in; |
| 529 | Blob cksum; |
| 530 | |
| 531 | for(i=2; i<g.argc; i++){ |
| 532 | blob_init(&cksum, "************** not found ***************", -1); |
| 533 | if( g.argv[i][0]=='-' && g.argv[i][1]==0 ){ |
| 534 | blob_read_from_channel(&in, stdin, -1); |
| 535 | sha1sum_blob(&in, &cksum); |
| 536 | }else{ |
| 537 | sha1sum_file(g.argv[i], &cksum); |
| 538 | } |
| 539 | fossil_print("%s %s\n", blob_str(&cksum), g.argv[i]); |
| 540 | blob_reset(&cksum); |
| 541 | } |
| 542 | } |
| 543 |
| --- src/sha1.c | |
| +++ src/sha1.c | |
| @@ -352,17 +352,17 @@ | |
| 352 | ** Compute the SHA1 checksum of a file on disk. Store the resulting |
| 353 | ** checksum in the blob pCksum. pCksum is assumed to be initialized. |
| 354 | ** |
| 355 | ** Return the number of errors. |
| 356 | */ |
| 357 | int sha1sum_file(const char *zFilename, int eFType, Blob *pCksum){ |
| 358 | FILE *in; |
| 359 | SHA1Context ctx; |
| 360 | unsigned char zResult[20]; |
| 361 | char zBuf[10240]; |
| 362 | |
| 363 | if( eFType==RepoFILE && file_islink(zFilename) ){ |
| 364 | /* Instead of file content, return sha1 of link destination path */ |
| 365 | Blob destinationPath; |
| 366 | int rc; |
| 367 | |
| 368 | blob_read_link(&destinationPath, zFilename); |
| @@ -520,23 +520,33 @@ | |
| 520 | ** |
| 521 | ** Usage: %fossil sha1sum FILE... |
| 522 | ** |
| 523 | ** Compute an SHA1 checksum of all files named on the command-line. |
| 524 | ** If a file is named "-" then take its content from standard input. |
| 525 | ** Options: |
| 526 | ** |
| 527 | ** -h, --dereference If FILE is a symbolic link, compute the hash |
| 528 | ** on the object that the link points to. Normally, |
| 529 | ** the hash is over the name of the object that |
| 530 | ** the link points to. |
| 531 | */ |
| 532 | void sha1sum_test(void){ |
| 533 | int i; |
| 534 | Blob in; |
| 535 | Blob cksum; |
| 536 | int eFType = SymFILE; |
| 537 | if( find_option("dereference","h",0)!=0 ){ |
| 538 | eFType = ExtFILE; |
| 539 | } |
| 540 | |
| 541 | for(i=2; i<g.argc; i++){ |
| 542 | blob_init(&cksum, "************** not found ***************", -1); |
| 543 | if( g.argv[i][0]=='-' && g.argv[i][1]==0 ){ |
| 544 | blob_read_from_channel(&in, stdin, -1); |
| 545 | sha1sum_blob(&in, &cksum); |
| 546 | }else{ |
| 547 | sha1sum_file(g.argv[i], eFType, &cksum); |
| 548 | } |
| 549 | fossil_print("%s %s\n", blob_str(&cksum), g.argv[i]); |
| 550 | blob_reset(&cksum); |
| 551 | } |
| 552 | } |
| 553 |
+13
-9
| --- src/sha3.c | ||
| +++ src/sha3.c | ||
| @@ -545,16 +545,16 @@ | ||
| 545 | 545 | ** Compute the SHA3 checksum of a file on disk. Store the resulting |
| 546 | 546 | ** checksum in the blob pCksum. pCksum is assumed to be initialized. |
| 547 | 547 | ** |
| 548 | 548 | ** Return the number of errors. |
| 549 | 549 | */ |
| 550 | -int sha3sum_file(const char *zFilename, int iSize, Blob *pCksum){ | |
| 550 | +int sha3sum_file(const char *zFilename, int eFType, int iSize, Blob *pCksum){ | |
| 551 | 551 | FILE *in; |
| 552 | 552 | SHA3Context ctx; |
| 553 | 553 | char zBuf[10240]; |
| 554 | 554 | |
| 555 | - if( file_wd_islink(zFilename) ){ | |
| 555 | + if( eFType==RepoFILE && file_islink(zFilename) ){ | |
| 556 | 556 | /* Instead of file content, return sha3 of link destination path */ |
| 557 | 557 | Blob destinationPath; |
| 558 | 558 | int rc; |
| 559 | 559 | |
| 560 | 560 | blob_read_link(&destinationPath, zFilename); |
| @@ -629,23 +629,27 @@ | ||
| 629 | 629 | ** To be clear: The official NIST FIPS-202 implementation of SHA3 |
| 630 | 630 | ** with the added 01 padding is used, not the original Keccak submission. |
| 631 | 631 | ** |
| 632 | 632 | ** Options: |
| 633 | 633 | ** |
| 634 | -** --224 Compute a SHA3-224 hash | |
| 635 | -** --256 Compute a SHA3-256 hash (the default) | |
| 636 | -** --384 Compute a SHA3-384 hash | |
| 637 | -** --512 Compute a SHA3-512 hash | |
| 638 | -** --size N An N-bit hash. N must be a multiple of 32 between 128 | |
| 639 | -** and 512. | |
| 634 | +** --224 Compute a SHA3-224 hash | |
| 635 | +** --256 Compute a SHA3-256 hash (the default) | |
| 636 | +** --384 Compute a SHA3-384 hash | |
| 637 | +** --512 Compute a SHA3-512 hash | |
| 638 | +** --size N An N-bit hash. N must be a multiple of 32 between | |
| 639 | +** 128 and 512. | |
| 640 | +** -h, --dereference If FILE is a symbolic link, compute the hash on | |
| 641 | +** the object pointed to, not on the link itself. | |
| 640 | 642 | */ |
| 641 | 643 | void sha3sum_test(void){ |
| 642 | 644 | int i; |
| 643 | 645 | Blob in; |
| 644 | 646 | Blob cksum; |
| 645 | 647 | int iSize = 256; |
| 648 | + int eFType = SymFILE; | |
| 646 | 649 | |
| 650 | + if( find_option("dereference","h",0) ) eFType = ExtFILE; | |
| 647 | 651 | if( find_option("224",0,0)!=0 ) iSize = 224; |
| 648 | 652 | else if( find_option("256",0,0)!=0 ) iSize = 256; |
| 649 | 653 | else if( find_option("384",0,0)!=0 ) iSize = 384; |
| 650 | 654 | else if( find_option("512",0,0)!=0 ) iSize = 512; |
| 651 | 655 | else{ |
| @@ -664,11 +668,11 @@ | ||
| 664 | 668 | blob_init(&cksum, "************** not found ***************", -1); |
| 665 | 669 | if( g.argv[i][0]=='-' && g.argv[i][1]==0 ){ |
| 666 | 670 | blob_read_from_channel(&in, stdin, -1); |
| 667 | 671 | sha3sum_blob(&in, iSize, &cksum); |
| 668 | 672 | }else{ |
| 669 | - sha3sum_file(g.argv[i], iSize, &cksum); | |
| 673 | + sha3sum_file(g.argv[i], eFType, iSize, &cksum); | |
| 670 | 674 | } |
| 671 | 675 | fossil_print("%s %s\n", blob_str(&cksum), g.argv[i]); |
| 672 | 676 | blob_reset(&cksum); |
| 673 | 677 | } |
| 674 | 678 | } |
| 675 | 679 |
| --- src/sha3.c | |
| +++ src/sha3.c | |
| @@ -545,16 +545,16 @@ | |
| 545 | ** Compute the SHA3 checksum of a file on disk. Store the resulting |
| 546 | ** checksum in the blob pCksum. pCksum is assumed to be initialized. |
| 547 | ** |
| 548 | ** Return the number of errors. |
| 549 | */ |
| 550 | int sha3sum_file(const char *zFilename, int iSize, Blob *pCksum){ |
| 551 | FILE *in; |
| 552 | SHA3Context ctx; |
| 553 | char zBuf[10240]; |
| 554 | |
| 555 | if( file_wd_islink(zFilename) ){ |
| 556 | /* Instead of file content, return sha3 of link destination path */ |
| 557 | Blob destinationPath; |
| 558 | int rc; |
| 559 | |
| 560 | blob_read_link(&destinationPath, zFilename); |
| @@ -629,23 +629,27 @@ | |
| 629 | ** To be clear: The official NIST FIPS-202 implementation of SHA3 |
| 630 | ** with the added 01 padding is used, not the original Keccak submission. |
| 631 | ** |
| 632 | ** Options: |
| 633 | ** |
| 634 | ** --224 Compute a SHA3-224 hash |
| 635 | ** --256 Compute a SHA3-256 hash (the default) |
| 636 | ** --384 Compute a SHA3-384 hash |
| 637 | ** --512 Compute a SHA3-512 hash |
| 638 | ** --size N An N-bit hash. N must be a multiple of 32 between 128 |
| 639 | ** and 512. |
| 640 | */ |
| 641 | void sha3sum_test(void){ |
| 642 | int i; |
| 643 | Blob in; |
| 644 | Blob cksum; |
| 645 | int iSize = 256; |
| 646 | |
| 647 | if( find_option("224",0,0)!=0 ) iSize = 224; |
| 648 | else if( find_option("256",0,0)!=0 ) iSize = 256; |
| 649 | else if( find_option("384",0,0)!=0 ) iSize = 384; |
| 650 | else if( find_option("512",0,0)!=0 ) iSize = 512; |
| 651 | else{ |
| @@ -664,11 +668,11 @@ | |
| 664 | blob_init(&cksum, "************** not found ***************", -1); |
| 665 | if( g.argv[i][0]=='-' && g.argv[i][1]==0 ){ |
| 666 | blob_read_from_channel(&in, stdin, -1); |
| 667 | sha3sum_blob(&in, iSize, &cksum); |
| 668 | }else{ |
| 669 | sha3sum_file(g.argv[i], iSize, &cksum); |
| 670 | } |
| 671 | fossil_print("%s %s\n", blob_str(&cksum), g.argv[i]); |
| 672 | blob_reset(&cksum); |
| 673 | } |
| 674 | } |
| 675 |
| --- src/sha3.c | |
| +++ src/sha3.c | |
| @@ -545,16 +545,16 @@ | |
| 545 | ** Compute the SHA3 checksum of a file on disk. Store the resulting |
| 546 | ** checksum in the blob pCksum. pCksum is assumed to be initialized. |
| 547 | ** |
| 548 | ** Return the number of errors. |
| 549 | */ |
| 550 | int sha3sum_file(const char *zFilename, int eFType, int iSize, Blob *pCksum){ |
| 551 | FILE *in; |
| 552 | SHA3Context ctx; |
| 553 | char zBuf[10240]; |
| 554 | |
| 555 | if( eFType==RepoFILE && file_islink(zFilename) ){ |
| 556 | /* Instead of file content, return sha3 of link destination path */ |
| 557 | Blob destinationPath; |
| 558 | int rc; |
| 559 | |
| 560 | blob_read_link(&destinationPath, zFilename); |
| @@ -629,23 +629,27 @@ | |
| 629 | ** To be clear: The official NIST FIPS-202 implementation of SHA3 |
| 630 | ** with the added 01 padding is used, not the original Keccak submission. |
| 631 | ** |
| 632 | ** Options: |
| 633 | ** |
| 634 | ** --224 Compute a SHA3-224 hash |
| 635 | ** --256 Compute a SHA3-256 hash (the default) |
| 636 | ** --384 Compute a SHA3-384 hash |
| 637 | ** --512 Compute a SHA3-512 hash |
| 638 | ** --size N An N-bit hash. N must be a multiple of 32 between |
| 639 | ** 128 and 512. |
| 640 | ** -h, --dereference If FILE is a symbolic link, compute the hash on |
| 641 | ** the object pointed to, not on the link itself. |
| 642 | */ |
| 643 | void sha3sum_test(void){ |
| 644 | int i; |
| 645 | Blob in; |
| 646 | Blob cksum; |
| 647 | int iSize = 256; |
| 648 | int eFType = SymFILE; |
| 649 | |
| 650 | if( find_option("dereference","h",0) ) eFType = ExtFILE; |
| 651 | if( find_option("224",0,0)!=0 ) iSize = 224; |
| 652 | else if( find_option("256",0,0)!=0 ) iSize = 256; |
| 653 | else if( find_option("384",0,0)!=0 ) iSize = 384; |
| 654 | else if( find_option("512",0,0)!=0 ) iSize = 512; |
| 655 | else{ |
| @@ -664,11 +668,11 @@ | |
| 668 | blob_init(&cksum, "************** not found ***************", -1); |
| 669 | if( g.argv[i][0]=='-' && g.argv[i][1]==0 ){ |
| 670 | blob_read_from_channel(&in, stdin, -1); |
| 671 | sha3sum_blob(&in, iSize, &cksum); |
| 672 | }else{ |
| 673 | sha3sum_file(g.argv[i], eFType, iSize, &cksum); |
| 674 | } |
| 675 | fossil_print("%s %s\n", blob_str(&cksum), g.argv[i]); |
| 676 | blob_reset(&cksum); |
| 677 | } |
| 678 | } |
| 679 |
+2
-2
| --- src/skins.c | ||
| +++ src/skins.c | ||
| @@ -136,13 +136,13 @@ | ||
| 136 | 136 | const char *skin_get(const char *zWhat){ |
| 137 | 137 | const char *zOut; |
| 138 | 138 | char *z; |
| 139 | 139 | if( zAltSkinDir ){ |
| 140 | 140 | char *z = mprintf("%s/%s.txt", zAltSkinDir, zWhat); |
| 141 | - if( file_isfile(z) ){ | |
| 141 | + if( file_isfile(z, ExtFILE) ){ | |
| 142 | 142 | Blob x; |
| 143 | - blob_read_from_file(&x, z); | |
| 143 | + blob_read_from_file(&x, z, ExtFILE); | |
| 144 | 144 | fossil_free(z); |
| 145 | 145 | return blob_str(&x); |
| 146 | 146 | } |
| 147 | 147 | fossil_free(z); |
| 148 | 148 | } |
| 149 | 149 |
| --- src/skins.c | |
| +++ src/skins.c | |
| @@ -136,13 +136,13 @@ | |
| 136 | const char *skin_get(const char *zWhat){ |
| 137 | const char *zOut; |
| 138 | char *z; |
| 139 | if( zAltSkinDir ){ |
| 140 | char *z = mprintf("%s/%s.txt", zAltSkinDir, zWhat); |
| 141 | if( file_isfile(z) ){ |
| 142 | Blob x; |
| 143 | blob_read_from_file(&x, z); |
| 144 | fossil_free(z); |
| 145 | return blob_str(&x); |
| 146 | } |
| 147 | fossil_free(z); |
| 148 | } |
| 149 |
| --- src/skins.c | |
| +++ src/skins.c | |
| @@ -136,13 +136,13 @@ | |
| 136 | const char *skin_get(const char *zWhat){ |
| 137 | const char *zOut; |
| 138 | char *z; |
| 139 | if( zAltSkinDir ){ |
| 140 | char *z = mprintf("%s/%s.txt", zAltSkinDir, zWhat); |
| 141 | if( file_isfile(z, ExtFILE) ){ |
| 142 | Blob x; |
| 143 | blob_read_from_file(&x, z, ExtFILE); |
| 144 | fossil_free(z); |
| 145 | return blob_str(&x); |
| 146 | } |
| 147 | fossil_free(z); |
| 148 | } |
| 149 |
+9
-22
| --- src/stash.c | ||
| +++ src/stash.c | ||
| @@ -89,11 +89,10 @@ | ||
| 89 | 89 | int rid = db_column_int(&q, 3); |
| 90 | 90 | const char *zName = db_column_text(&q, 4); |
| 91 | 91 | const char *zOrig = db_column_text(&q, 5); |
| 92 | 92 | char *zPath = mprintf("%s%s", g.zLocalRoot, zName); |
| 93 | 93 | Blob content; |
| 94 | - int isNewLink = file_wd_islink(zPath); | |
| 95 | 94 | |
| 96 | 95 | db_bind_int(&ins, ":rid", rid); |
| 97 | 96 | db_bind_int(&ins, ":isadd", rid==0); |
| 98 | 97 | db_bind_int(&ins, ":isrm", deleted); |
| 99 | 98 | db_bind_int(&ins, ":isexe", db_column_int(&q, 1)); |
| @@ -101,36 +100,28 @@ | ||
| 101 | 100 | db_bind_text(&ins, ":orig", zOrig); |
| 102 | 101 | db_bind_text(&ins, ":new", zName); |
| 103 | 102 | |
| 104 | 103 | if( rid==0 ){ |
| 105 | 104 | /* A new file */ |
| 106 | - if( isNewLink ){ | |
| 107 | - blob_read_link(&content, zPath); | |
| 108 | - }else{ | |
| 109 | - blob_read_from_file(&content, zPath); | |
| 110 | - } | |
| 105 | + blob_read_from_file(&content, zPath, RepoFILE); | |
| 111 | 106 | db_bind_blob(&ins, ":content", &content); |
| 112 | 107 | }else if( deleted ){ |
| 113 | 108 | blob_zero(&content); |
| 114 | 109 | db_bind_null(&ins, ":content"); |
| 115 | 110 | }else{ |
| 116 | 111 | /* A modified file */ |
| 117 | 112 | Blob orig; |
| 118 | 113 | Blob disk; |
| 119 | 114 | |
| 120 | - if( isNewLink ){ | |
| 121 | - blob_read_link(&disk, zPath); | |
| 122 | - }else{ | |
| 123 | - blob_read_from_file(&disk, zPath); | |
| 124 | - } | |
| 115 | + blob_read_from_file(&disk, zPath, RepoFILE); | |
| 125 | 116 | content_get(rid, &orig); |
| 126 | 117 | blob_delta_create(&orig, &disk, &content); |
| 127 | 118 | blob_reset(&orig); |
| 128 | 119 | blob_reset(&disk); |
| 129 | 120 | db_bind_blob(&ins, ":content", &content); |
| 130 | 121 | } |
| 131 | - db_bind_int(&ins, ":islink", isNewLink); | |
| 122 | + db_bind_int(&ins, ":islink", file_islink(zPath)); | |
| 132 | 123 | db_step(&ins); |
| 133 | 124 | db_reset(&ins); |
| 134 | 125 | fossil_free(zPath); |
| 135 | 126 | blob_reset(&content); |
| 136 | 127 | } |
| @@ -225,23 +216,19 @@ | ||
| 225 | 216 | blob_zero(&delta); |
| 226 | 217 | if( rid==0 ){ |
| 227 | 218 | db_multi_exec("INSERT OR IGNORE INTO sfile(pathname) VALUES(%Q)", zNew); |
| 228 | 219 | db_ephemeral_blob(&q, 6, &delta); |
| 229 | 220 | blob_write_to_file(&delta, zNPath); |
| 230 | - file_wd_setexe(zNPath, isExec); | |
| 221 | + file_setexe(zNPath, isExec); | |
| 231 | 222 | }else if( isRemoved ){ |
| 232 | 223 | fossil_print("DELETE %s\n", zOrig); |
| 233 | 224 | file_delete(zOPath); |
| 234 | 225 | }else{ |
| 235 | 226 | Blob a, b, out, disk; |
| 236 | - int isNewLink = file_wd_islink(zOPath); | |
| 227 | + int isNewLink = file_islink(zOPath); | |
| 237 | 228 | db_ephemeral_blob(&q, 6, &delta); |
| 238 | - if( isNewLink ){ | |
| 239 | - blob_read_link(&disk, zOPath); | |
| 240 | - }else{ | |
| 241 | - blob_read_from_file(&disk, zOPath); | |
| 242 | - } | |
| 229 | + blob_read_from_file(&disk, zOPath, RepoFILE); | |
| 243 | 230 | content_get(rid, &a); |
| 244 | 231 | blob_delta_apply(&a, &delta, &b); |
| 245 | 232 | if( isLink == isNewLink && blob_compare(&disk, &a)==0 ){ |
| 246 | 233 | if( isLink || isNewLink ){ |
| 247 | 234 | file_delete(zNPath); |
| @@ -249,11 +236,11 @@ | ||
| 249 | 236 | if( isLink ){ |
| 250 | 237 | symlink_create(blob_str(&b), zNPath); |
| 251 | 238 | }else{ |
| 252 | 239 | blob_write_to_file(&b, zNPath); |
| 253 | 240 | } |
| 254 | - file_wd_setexe(zNPath, isExec); | |
| 241 | + file_setexe(zNPath, isExec); | |
| 255 | 242 | fossil_print("UPDATE %s\n", zNew); |
| 256 | 243 | }else{ |
| 257 | 244 | int rc; |
| 258 | 245 | if( isLink || isNewLink ){ |
| 259 | 246 | rc = -1; |
| @@ -261,11 +248,11 @@ | ||
| 261 | 248 | fossil_print("***** Cannot merge symlink %s\n", zNew); |
| 262 | 249 | }else{ |
| 263 | 250 | rc = merge_3way(&a, zOPath, &b, &out, 0); |
| 264 | 251 | blob_write_to_file(&out, zNPath); |
| 265 | 252 | blob_reset(&out); |
| 266 | - file_wd_setexe(zNPath, isExec); | |
| 253 | + file_setexe(zNPath, isExec); | |
| 267 | 254 | } |
| 268 | 255 | if( rc ){ |
| 269 | 256 | fossil_print("CONFLICT %s\n", zNew); |
| 270 | 257 | nConflict++; |
| 271 | 258 | }else{ |
| @@ -343,11 +330,11 @@ | ||
| 343 | 330 | zBinGlob, fIncludeBinary, diffFlags); |
| 344 | 331 | }else{ |
| 345 | 332 | } |
| 346 | 333 | }else{ |
| 347 | 334 | Blob delta; |
| 348 | - int isOrigLink = file_wd_islink(zOPath); | |
| 335 | + int isOrigLink = file_islink(zOPath); | |
| 349 | 336 | db_ephemeral_blob(&q, 6, &delta); |
| 350 | 337 | fossil_print("CHANGED %s\n", zNew); |
| 351 | 338 | if( !isOrigLink != !isLink ){ |
| 352 | 339 | diff_print_index(zNew, diffFlags); |
| 353 | 340 | diff_print_filenames(zOrig, zNew, diffFlags); |
| 354 | 341 |
| --- src/stash.c | |
| +++ src/stash.c | |
| @@ -89,11 +89,10 @@ | |
| 89 | int rid = db_column_int(&q, 3); |
| 90 | const char *zName = db_column_text(&q, 4); |
| 91 | const char *zOrig = db_column_text(&q, 5); |
| 92 | char *zPath = mprintf("%s%s", g.zLocalRoot, zName); |
| 93 | Blob content; |
| 94 | int isNewLink = file_wd_islink(zPath); |
| 95 | |
| 96 | db_bind_int(&ins, ":rid", rid); |
| 97 | db_bind_int(&ins, ":isadd", rid==0); |
| 98 | db_bind_int(&ins, ":isrm", deleted); |
| 99 | db_bind_int(&ins, ":isexe", db_column_int(&q, 1)); |
| @@ -101,36 +100,28 @@ | |
| 101 | db_bind_text(&ins, ":orig", zOrig); |
| 102 | db_bind_text(&ins, ":new", zName); |
| 103 | |
| 104 | if( rid==0 ){ |
| 105 | /* A new file */ |
| 106 | if( isNewLink ){ |
| 107 | blob_read_link(&content, zPath); |
| 108 | }else{ |
| 109 | blob_read_from_file(&content, zPath); |
| 110 | } |
| 111 | db_bind_blob(&ins, ":content", &content); |
| 112 | }else if( deleted ){ |
| 113 | blob_zero(&content); |
| 114 | db_bind_null(&ins, ":content"); |
| 115 | }else{ |
| 116 | /* A modified file */ |
| 117 | Blob orig; |
| 118 | Blob disk; |
| 119 | |
| 120 | if( isNewLink ){ |
| 121 | blob_read_link(&disk, zPath); |
| 122 | }else{ |
| 123 | blob_read_from_file(&disk, zPath); |
| 124 | } |
| 125 | content_get(rid, &orig); |
| 126 | blob_delta_create(&orig, &disk, &content); |
| 127 | blob_reset(&orig); |
| 128 | blob_reset(&disk); |
| 129 | db_bind_blob(&ins, ":content", &content); |
| 130 | } |
| 131 | db_bind_int(&ins, ":islink", isNewLink); |
| 132 | db_step(&ins); |
| 133 | db_reset(&ins); |
| 134 | fossil_free(zPath); |
| 135 | blob_reset(&content); |
| 136 | } |
| @@ -225,23 +216,19 @@ | |
| 225 | blob_zero(&delta); |
| 226 | if( rid==0 ){ |
| 227 | db_multi_exec("INSERT OR IGNORE INTO sfile(pathname) VALUES(%Q)", zNew); |
| 228 | db_ephemeral_blob(&q, 6, &delta); |
| 229 | blob_write_to_file(&delta, zNPath); |
| 230 | file_wd_setexe(zNPath, isExec); |
| 231 | }else if( isRemoved ){ |
| 232 | fossil_print("DELETE %s\n", zOrig); |
| 233 | file_delete(zOPath); |
| 234 | }else{ |
| 235 | Blob a, b, out, disk; |
| 236 | int isNewLink = file_wd_islink(zOPath); |
| 237 | db_ephemeral_blob(&q, 6, &delta); |
| 238 | if( isNewLink ){ |
| 239 | blob_read_link(&disk, zOPath); |
| 240 | }else{ |
| 241 | blob_read_from_file(&disk, zOPath); |
| 242 | } |
| 243 | content_get(rid, &a); |
| 244 | blob_delta_apply(&a, &delta, &b); |
| 245 | if( isLink == isNewLink && blob_compare(&disk, &a)==0 ){ |
| 246 | if( isLink || isNewLink ){ |
| 247 | file_delete(zNPath); |
| @@ -249,11 +236,11 @@ | |
| 249 | if( isLink ){ |
| 250 | symlink_create(blob_str(&b), zNPath); |
| 251 | }else{ |
| 252 | blob_write_to_file(&b, zNPath); |
| 253 | } |
| 254 | file_wd_setexe(zNPath, isExec); |
| 255 | fossil_print("UPDATE %s\n", zNew); |
| 256 | }else{ |
| 257 | int rc; |
| 258 | if( isLink || isNewLink ){ |
| 259 | rc = -1; |
| @@ -261,11 +248,11 @@ | |
| 261 | fossil_print("***** Cannot merge symlink %s\n", zNew); |
| 262 | }else{ |
| 263 | rc = merge_3way(&a, zOPath, &b, &out, 0); |
| 264 | blob_write_to_file(&out, zNPath); |
| 265 | blob_reset(&out); |
| 266 | file_wd_setexe(zNPath, isExec); |
| 267 | } |
| 268 | if( rc ){ |
| 269 | fossil_print("CONFLICT %s\n", zNew); |
| 270 | nConflict++; |
| 271 | }else{ |
| @@ -343,11 +330,11 @@ | |
| 343 | zBinGlob, fIncludeBinary, diffFlags); |
| 344 | }else{ |
| 345 | } |
| 346 | }else{ |
| 347 | Blob delta; |
| 348 | int isOrigLink = file_wd_islink(zOPath); |
| 349 | db_ephemeral_blob(&q, 6, &delta); |
| 350 | fossil_print("CHANGED %s\n", zNew); |
| 351 | if( !isOrigLink != !isLink ){ |
| 352 | diff_print_index(zNew, diffFlags); |
| 353 | diff_print_filenames(zOrig, zNew, diffFlags); |
| 354 |
| --- src/stash.c | |
| +++ src/stash.c | |
| @@ -89,11 +89,10 @@ | |
| 89 | int rid = db_column_int(&q, 3); |
| 90 | const char *zName = db_column_text(&q, 4); |
| 91 | const char *zOrig = db_column_text(&q, 5); |
| 92 | char *zPath = mprintf("%s%s", g.zLocalRoot, zName); |
| 93 | Blob content; |
| 94 | |
| 95 | db_bind_int(&ins, ":rid", rid); |
| 96 | db_bind_int(&ins, ":isadd", rid==0); |
| 97 | db_bind_int(&ins, ":isrm", deleted); |
| 98 | db_bind_int(&ins, ":isexe", db_column_int(&q, 1)); |
| @@ -101,36 +100,28 @@ | |
| 100 | db_bind_text(&ins, ":orig", zOrig); |
| 101 | db_bind_text(&ins, ":new", zName); |
| 102 | |
| 103 | if( rid==0 ){ |
| 104 | /* A new file */ |
| 105 | blob_read_from_file(&content, zPath, RepoFILE); |
| 106 | db_bind_blob(&ins, ":content", &content); |
| 107 | }else if( deleted ){ |
| 108 | blob_zero(&content); |
| 109 | db_bind_null(&ins, ":content"); |
| 110 | }else{ |
| 111 | /* A modified file */ |
| 112 | Blob orig; |
| 113 | Blob disk; |
| 114 | |
| 115 | blob_read_from_file(&disk, zPath, RepoFILE); |
| 116 | content_get(rid, &orig); |
| 117 | blob_delta_create(&orig, &disk, &content); |
| 118 | blob_reset(&orig); |
| 119 | blob_reset(&disk); |
| 120 | db_bind_blob(&ins, ":content", &content); |
| 121 | } |
| 122 | db_bind_int(&ins, ":islink", file_islink(zPath)); |
| 123 | db_step(&ins); |
| 124 | db_reset(&ins); |
| 125 | fossil_free(zPath); |
| 126 | blob_reset(&content); |
| 127 | } |
| @@ -225,23 +216,19 @@ | |
| 216 | blob_zero(&delta); |
| 217 | if( rid==0 ){ |
| 218 | db_multi_exec("INSERT OR IGNORE INTO sfile(pathname) VALUES(%Q)", zNew); |
| 219 | db_ephemeral_blob(&q, 6, &delta); |
| 220 | blob_write_to_file(&delta, zNPath); |
| 221 | file_setexe(zNPath, isExec); |
| 222 | }else if( isRemoved ){ |
| 223 | fossil_print("DELETE %s\n", zOrig); |
| 224 | file_delete(zOPath); |
| 225 | }else{ |
| 226 | Blob a, b, out, disk; |
| 227 | int isNewLink = file_islink(zOPath); |
| 228 | db_ephemeral_blob(&q, 6, &delta); |
| 229 | blob_read_from_file(&disk, zOPath, RepoFILE); |
| 230 | content_get(rid, &a); |
| 231 | blob_delta_apply(&a, &delta, &b); |
| 232 | if( isLink == isNewLink && blob_compare(&disk, &a)==0 ){ |
| 233 | if( isLink || isNewLink ){ |
| 234 | file_delete(zNPath); |
| @@ -249,11 +236,11 @@ | |
| 236 | if( isLink ){ |
| 237 | symlink_create(blob_str(&b), zNPath); |
| 238 | }else{ |
| 239 | blob_write_to_file(&b, zNPath); |
| 240 | } |
| 241 | file_setexe(zNPath, isExec); |
| 242 | fossil_print("UPDATE %s\n", zNew); |
| 243 | }else{ |
| 244 | int rc; |
| 245 | if( isLink || isNewLink ){ |
| 246 | rc = -1; |
| @@ -261,11 +248,11 @@ | |
| 248 | fossil_print("***** Cannot merge symlink %s\n", zNew); |
| 249 | }else{ |
| 250 | rc = merge_3way(&a, zOPath, &b, &out, 0); |
| 251 | blob_write_to_file(&out, zNPath); |
| 252 | blob_reset(&out); |
| 253 | file_setexe(zNPath, isExec); |
| 254 | } |
| 255 | if( rc ){ |
| 256 | fossil_print("CONFLICT %s\n", zNew); |
| 257 | nConflict++; |
| 258 | }else{ |
| @@ -343,11 +330,11 @@ | |
| 330 | zBinGlob, fIncludeBinary, diffFlags); |
| 331 | }else{ |
| 332 | } |
| 333 | }else{ |
| 334 | Blob delta; |
| 335 | int isOrigLink = file_islink(zOPath); |
| 336 | db_ephemeral_blob(&q, 6, &delta); |
| 337 | fossil_print("CHANGED %s\n", zNew); |
| 338 | if( !isOrigLink != !isLink ){ |
| 339 | diff_print_index(zNew, diffFlags); |
| 340 | diff_print_filenames(zOrig, zNew, diffFlags); |
| 341 |
+4
-4
| --- src/stat.c | ||
| +++ src/stat.c | ||
| @@ -86,11 +86,11 @@ | ||
| 86 | 86 | if( g.perm.Admin || g.perm.Setup || db_get_boolean("test_env_enable",0) ){ |
| 87 | 87 | style_submenu_element("Environment", "test_env"); |
| 88 | 88 | } |
| 89 | 89 | @ <table class="label-value"> |
| 90 | 90 | @ <tr><th>Repository Size:</th><td> |
| 91 | - fsize = file_size(g.zRepositoryName); | |
| 91 | + fsize = file_size(g.zRepositoryName, ExtFILE); | |
| 92 | 92 | bigSizeName(sizeof(zBuf), zBuf, fsize); |
| 93 | 93 | @ %s(zBuf) |
| 94 | 94 | @ </td></tr> |
| 95 | 95 | if( !brief ){ |
| 96 | 96 | @ <tr><th>Number Of Artifacts:</th><td> |
| @@ -241,11 +241,11 @@ | ||
| 241 | 241 | if( (z = db_get("project-name",0))!=0 |
| 242 | 242 | || (z = db_get("short-project-name",0))!=0 |
| 243 | 243 | ){ |
| 244 | 244 | fossil_print("%*s%s\n", colWidth, "project-name:", z); |
| 245 | 245 | } |
| 246 | - fsize = file_size(g.zRepositoryName); | |
| 246 | + fsize = file_size(g.zRepositoryName, ExtFILE); | |
| 247 | 247 | bigSizeName(sizeof(zBuf), zBuf, fsize); |
| 248 | 248 | fossil_print( "%*s%s\n", colWidth, "repository-size:", zBuf ); |
| 249 | 249 | if( !brief ){ |
| 250 | 250 | n = db_int(0, "SELECT count(*) FROM blob"); |
| 251 | 251 | m = db_int(0, "SELECT count(*) FROM delta"); |
| @@ -534,11 +534,11 @@ | ||
| 534 | 534 | db_multi_exec( |
| 535 | 535 | "INSERT INTO piechart(amt,label) VALUES(%d,'freelist')", |
| 536 | 536 | nPageFree |
| 537 | 537 | ); |
| 538 | 538 | } |
| 539 | - fsize = file_size(g.zRepositoryName); | |
| 539 | + fsize = file_size(g.zRepositoryName, ExtFILE); | |
| 540 | 540 | approxSizeName(sizeof(zBuf), zBuf, fsize); |
| 541 | 541 | @ <h2>Repository Size: %s(zBuf)</h2> |
| 542 | 542 | @ <center><svg width='800' height='500'> |
| 543 | 543 | piechart_render(800,500,PIE_OTHER|PIE_PERCENT); |
| 544 | 544 | @ </svg></center> |
| @@ -560,14 +560,14 @@ | ||
| 560 | 560 | db_multi_exec( |
| 561 | 561 | "INSERT INTO piechart(amt,label) VALUES(%d,'freelist')", |
| 562 | 562 | nPageFree |
| 563 | 563 | ); |
| 564 | 564 | } |
| 565 | - fsize = file_size(g.zLocalDbName); | |
| 565 | + fsize = file_size(g.zLocalDbName, ExtFILE); | |
| 566 | 566 | approxSizeName(sizeof(zBuf), zBuf, fsize); |
| 567 | 567 | @ <h2>%h(file_tail(g.zLocalDbName)) Size: %s(zBuf)</h2> |
| 568 | 568 | @ <center><svg width='800' height='500'> |
| 569 | 569 | piechart_render(800,500,PIE_OTHER|PIE_PERCENT); |
| 570 | 570 | @ </svg></center> |
| 571 | 571 | } |
| 572 | 572 | style_footer(); |
| 573 | 573 | } |
| 574 | 574 |
| --- src/stat.c | |
| +++ src/stat.c | |
| @@ -86,11 +86,11 @@ | |
| 86 | if( g.perm.Admin || g.perm.Setup || db_get_boolean("test_env_enable",0) ){ |
| 87 | style_submenu_element("Environment", "test_env"); |
| 88 | } |
| 89 | @ <table class="label-value"> |
| 90 | @ <tr><th>Repository Size:</th><td> |
| 91 | fsize = file_size(g.zRepositoryName); |
| 92 | bigSizeName(sizeof(zBuf), zBuf, fsize); |
| 93 | @ %s(zBuf) |
| 94 | @ </td></tr> |
| 95 | if( !brief ){ |
| 96 | @ <tr><th>Number Of Artifacts:</th><td> |
| @@ -241,11 +241,11 @@ | |
| 241 | if( (z = db_get("project-name",0))!=0 |
| 242 | || (z = db_get("short-project-name",0))!=0 |
| 243 | ){ |
| 244 | fossil_print("%*s%s\n", colWidth, "project-name:", z); |
| 245 | } |
| 246 | fsize = file_size(g.zRepositoryName); |
| 247 | bigSizeName(sizeof(zBuf), zBuf, fsize); |
| 248 | fossil_print( "%*s%s\n", colWidth, "repository-size:", zBuf ); |
| 249 | if( !brief ){ |
| 250 | n = db_int(0, "SELECT count(*) FROM blob"); |
| 251 | m = db_int(0, "SELECT count(*) FROM delta"); |
| @@ -534,11 +534,11 @@ | |
| 534 | db_multi_exec( |
| 535 | "INSERT INTO piechart(amt,label) VALUES(%d,'freelist')", |
| 536 | nPageFree |
| 537 | ); |
| 538 | } |
| 539 | fsize = file_size(g.zRepositoryName); |
| 540 | approxSizeName(sizeof(zBuf), zBuf, fsize); |
| 541 | @ <h2>Repository Size: %s(zBuf)</h2> |
| 542 | @ <center><svg width='800' height='500'> |
| 543 | piechart_render(800,500,PIE_OTHER|PIE_PERCENT); |
| 544 | @ </svg></center> |
| @@ -560,14 +560,14 @@ | |
| 560 | db_multi_exec( |
| 561 | "INSERT INTO piechart(amt,label) VALUES(%d,'freelist')", |
| 562 | nPageFree |
| 563 | ); |
| 564 | } |
| 565 | fsize = file_size(g.zLocalDbName); |
| 566 | approxSizeName(sizeof(zBuf), zBuf, fsize); |
| 567 | @ <h2>%h(file_tail(g.zLocalDbName)) Size: %s(zBuf)</h2> |
| 568 | @ <center><svg width='800' height='500'> |
| 569 | piechart_render(800,500,PIE_OTHER|PIE_PERCENT); |
| 570 | @ </svg></center> |
| 571 | } |
| 572 | style_footer(); |
| 573 | } |
| 574 |
| --- src/stat.c | |
| +++ src/stat.c | |
| @@ -86,11 +86,11 @@ | |
| 86 | if( g.perm.Admin || g.perm.Setup || db_get_boolean("test_env_enable",0) ){ |
| 87 | style_submenu_element("Environment", "test_env"); |
| 88 | } |
| 89 | @ <table class="label-value"> |
| 90 | @ <tr><th>Repository Size:</th><td> |
| 91 | fsize = file_size(g.zRepositoryName, ExtFILE); |
| 92 | bigSizeName(sizeof(zBuf), zBuf, fsize); |
| 93 | @ %s(zBuf) |
| 94 | @ </td></tr> |
| 95 | if( !brief ){ |
| 96 | @ <tr><th>Number Of Artifacts:</th><td> |
| @@ -241,11 +241,11 @@ | |
| 241 | if( (z = db_get("project-name",0))!=0 |
| 242 | || (z = db_get("short-project-name",0))!=0 |
| 243 | ){ |
| 244 | fossil_print("%*s%s\n", colWidth, "project-name:", z); |
| 245 | } |
| 246 | fsize = file_size(g.zRepositoryName, ExtFILE); |
| 247 | bigSizeName(sizeof(zBuf), zBuf, fsize); |
| 248 | fossil_print( "%*s%s\n", colWidth, "repository-size:", zBuf ); |
| 249 | if( !brief ){ |
| 250 | n = db_int(0, "SELECT count(*) FROM blob"); |
| 251 | m = db_int(0, "SELECT count(*) FROM delta"); |
| @@ -534,11 +534,11 @@ | |
| 534 | db_multi_exec( |
| 535 | "INSERT INTO piechart(amt,label) VALUES(%d,'freelist')", |
| 536 | nPageFree |
| 537 | ); |
| 538 | } |
| 539 | fsize = file_size(g.zRepositoryName, ExtFILE); |
| 540 | approxSizeName(sizeof(zBuf), zBuf, fsize); |
| 541 | @ <h2>Repository Size: %s(zBuf)</h2> |
| 542 | @ <center><svg width='800' height='500'> |
| 543 | piechart_render(800,500,PIE_OTHER|PIE_PERCENT); |
| 544 | @ </svg></center> |
| @@ -560,14 +560,14 @@ | |
| 560 | db_multi_exec( |
| 561 | "INSERT INTO piechart(amt,label) VALUES(%d,'freelist')", |
| 562 | nPageFree |
| 563 | ); |
| 564 | } |
| 565 | fsize = file_size(g.zLocalDbName, ExtFILE); |
| 566 | approxSizeName(sizeof(zBuf), zBuf, fsize); |
| 567 | @ <h2>%h(file_tail(g.zLocalDbName)) Size: %s(zBuf)</h2> |
| 568 | @ <center><svg width='800' height='500'> |
| 569 | piechart_render(800,500,PIE_OTHER|PIE_PERCENT); |
| 570 | @ </svg></center> |
| 571 | } |
| 572 | style_footer(); |
| 573 | } |
| 574 |
+1
-1
| --- src/style.c | ||
| +++ src/style.c | ||
| @@ -803,11 +803,11 @@ | ||
| 803 | 803 | void contains_selector_cmd(void){ |
| 804 | 804 | int found; |
| 805 | 805 | char *zSelector; |
| 806 | 806 | Blob css; |
| 807 | 807 | if( g.argc!=4 ) usage("FILENAME SELECTOR"); |
| 808 | - blob_read_from_file(&css, g.argv[2]); | |
| 808 | + blob_read_from_file(&css, g.argv[2], ExtFILE); | |
| 809 | 809 | zSelector = g.argv[3]; |
| 810 | 810 | found = containsSelector(blob_str(&css), zSelector); |
| 811 | 811 | fossil_print("%s %s\n", zSelector, found ? "found" : "not found"); |
| 812 | 812 | blob_reset(&css); |
| 813 | 813 | } |
| 814 | 814 |
| --- src/style.c | |
| +++ src/style.c | |
| @@ -803,11 +803,11 @@ | |
| 803 | void contains_selector_cmd(void){ |
| 804 | int found; |
| 805 | char *zSelector; |
| 806 | Blob css; |
| 807 | if( g.argc!=4 ) usage("FILENAME SELECTOR"); |
| 808 | blob_read_from_file(&css, g.argv[2]); |
| 809 | zSelector = g.argv[3]; |
| 810 | found = containsSelector(blob_str(&css), zSelector); |
| 811 | fossil_print("%s %s\n", zSelector, found ? "found" : "not found"); |
| 812 | blob_reset(&css); |
| 813 | } |
| 814 |
| --- src/style.c | |
| +++ src/style.c | |
| @@ -803,11 +803,11 @@ | |
| 803 | void contains_selector_cmd(void){ |
| 804 | int found; |
| 805 | char *zSelector; |
| 806 | Blob css; |
| 807 | if( g.argc!=4 ) usage("FILENAME SELECTOR"); |
| 808 | blob_read_from_file(&css, g.argv[2], ExtFILE); |
| 809 | zSelector = g.argv[3]; |
| 810 | found = containsSelector(blob_str(&css), zSelector); |
| 811 | fossil_print("%s %s\n", zSelector, found ? "found" : "not found"); |
| 812 | blob_reset(&css); |
| 813 | } |
| 814 |
+9
-3
| --- src/tar.c | ||
| +++ src/tar.c | ||
| @@ -424,24 +424,30 @@ | ||
| 424 | 424 | /* |
| 425 | 425 | ** COMMAND: test-tarball |
| 426 | 426 | ** |
| 427 | 427 | ** Generate a GZIP-compressed tarball in the file given by the first argument |
| 428 | 428 | ** that contains files given in the second and subsequent arguments. |
| 429 | +** | |
| 430 | +** -h, --dereference Follow symlinks; archive the files they point to. | |
| 429 | 431 | */ |
| 430 | 432 | void test_tarball_cmd(void){ |
| 431 | 433 | int i; |
| 432 | 434 | Blob zip; |
| 435 | + int eFType = SymFILE; | |
| 433 | 436 | if( g.argc<3 ){ |
| 434 | - usage("ARCHIVE FILE...."); | |
| 437 | + usage("ARCHIVE [options] FILE...."); | |
| 438 | + } | |
| 439 | + if( find_option("dereference","h",0) ){ | |
| 440 | + eFType = ExtFILE; | |
| 435 | 441 | } |
| 436 | 442 | sqlite3_open(":memory:", &g.db); |
| 437 | 443 | tar_begin(-1); |
| 438 | 444 | for(i=3; i<g.argc; i++){ |
| 439 | 445 | Blob file; |
| 440 | 446 | blob_zero(&file); |
| 441 | - blob_read_from_file(&file, g.argv[i]); | |
| 442 | - tar_add_file(g.argv[i], &file, file_wd_perm(0), file_wd_mtime(0)); | |
| 447 | + blob_read_from_file(&file, g.argv[i], eFType); | |
| 448 | + tar_add_file(g.argv[i], &file, file_perm(0,0), file_mtime(0,0)); | |
| 443 | 449 | blob_reset(&file); |
| 444 | 450 | } |
| 445 | 451 | tar_finish(&zip); |
| 446 | 452 | blob_write_to_file(&zip, g.argv[2]); |
| 447 | 453 | } |
| 448 | 454 |
| --- src/tar.c | |
| +++ src/tar.c | |
| @@ -424,24 +424,30 @@ | |
| 424 | /* |
| 425 | ** COMMAND: test-tarball |
| 426 | ** |
| 427 | ** Generate a GZIP-compressed tarball in the file given by the first argument |
| 428 | ** that contains files given in the second and subsequent arguments. |
| 429 | */ |
| 430 | void test_tarball_cmd(void){ |
| 431 | int i; |
| 432 | Blob zip; |
| 433 | if( g.argc<3 ){ |
| 434 | usage("ARCHIVE FILE...."); |
| 435 | } |
| 436 | sqlite3_open(":memory:", &g.db); |
| 437 | tar_begin(-1); |
| 438 | for(i=3; i<g.argc; i++){ |
| 439 | Blob file; |
| 440 | blob_zero(&file); |
| 441 | blob_read_from_file(&file, g.argv[i]); |
| 442 | tar_add_file(g.argv[i], &file, file_wd_perm(0), file_wd_mtime(0)); |
| 443 | blob_reset(&file); |
| 444 | } |
| 445 | tar_finish(&zip); |
| 446 | blob_write_to_file(&zip, g.argv[2]); |
| 447 | } |
| 448 |
| --- src/tar.c | |
| +++ src/tar.c | |
| @@ -424,24 +424,30 @@ | |
| 424 | /* |
| 425 | ** COMMAND: test-tarball |
| 426 | ** |
| 427 | ** Generate a GZIP-compressed tarball in the file given by the first argument |
| 428 | ** that contains files given in the second and subsequent arguments. |
| 429 | ** |
| 430 | ** -h, --dereference Follow symlinks; archive the files they point to. |
| 431 | */ |
| 432 | void test_tarball_cmd(void){ |
| 433 | int i; |
| 434 | Blob zip; |
| 435 | int eFType = SymFILE; |
| 436 | if( g.argc<3 ){ |
| 437 | usage("ARCHIVE [options] FILE...."); |
| 438 | } |
| 439 | if( find_option("dereference","h",0) ){ |
| 440 | eFType = ExtFILE; |
| 441 | } |
| 442 | sqlite3_open(":memory:", &g.db); |
| 443 | tar_begin(-1); |
| 444 | for(i=3; i<g.argc; i++){ |
| 445 | Blob file; |
| 446 | blob_zero(&file); |
| 447 | blob_read_from_file(&file, g.argv[i], eFType); |
| 448 | tar_add_file(g.argv[i], &file, file_perm(0,0), file_mtime(0,0)); |
| 449 | blob_reset(&file); |
| 450 | } |
| 451 | tar_finish(&zip); |
| 452 | blob_write_to_file(&zip, g.argv[2]); |
| 453 | } |
| 454 |
+2
-2
| --- src/th_main.c | ||
| +++ src/th_main.c | ||
| @@ -2519,11 +2519,11 @@ | ||
| 2519 | 2519 | verify_all_options(); |
| 2520 | 2520 | if( g.argc<3 ){ |
| 2521 | 2521 | usage("FILE"); |
| 2522 | 2522 | } |
| 2523 | 2523 | blob_zero(&in); |
| 2524 | - blob_read_from_file(&in, g.argv[2]); | |
| 2524 | + blob_read_from_file(&in, g.argv[2], ExtFILE); | |
| 2525 | 2525 | Th_Render(blob_str(&in)); |
| 2526 | 2526 | Th_PrintTraceLog(); |
| 2527 | 2527 | if( forceCgi ) cgi_reply(); |
| 2528 | 2528 | } |
| 2529 | 2529 | |
| @@ -2622,11 +2622,11 @@ | ||
| 2622 | 2622 | verify_all_options(); |
| 2623 | 2623 | if( g.argc!=3 ){ |
| 2624 | 2624 | usage("file"); |
| 2625 | 2625 | } |
| 2626 | 2626 | blob_zero(&in); |
| 2627 | - blob_read_from_file(&in, g.argv[2]); | |
| 2627 | + blob_read_from_file(&in, g.argv[2], ExtFILE); | |
| 2628 | 2628 | Th_FossilInit(TH_INIT_DEFAULT); |
| 2629 | 2629 | rc = Th_Eval(g.interp, 0, blob_str(&in), -1); |
| 2630 | 2630 | zRc = Th_ReturnCodeName(rc, 1); |
| 2631 | 2631 | fossil_print("%s%s%s\n", zRc, zRc ? ": " : "", Th_GetResult(g.interp, 0)); |
| 2632 | 2632 | Th_PrintTraceLog(); |
| 2633 | 2633 |
| --- src/th_main.c | |
| +++ src/th_main.c | |
| @@ -2519,11 +2519,11 @@ | |
| 2519 | verify_all_options(); |
| 2520 | if( g.argc<3 ){ |
| 2521 | usage("FILE"); |
| 2522 | } |
| 2523 | blob_zero(&in); |
| 2524 | blob_read_from_file(&in, g.argv[2]); |
| 2525 | Th_Render(blob_str(&in)); |
| 2526 | Th_PrintTraceLog(); |
| 2527 | if( forceCgi ) cgi_reply(); |
| 2528 | } |
| 2529 | |
| @@ -2622,11 +2622,11 @@ | |
| 2622 | verify_all_options(); |
| 2623 | if( g.argc!=3 ){ |
| 2624 | usage("file"); |
| 2625 | } |
| 2626 | blob_zero(&in); |
| 2627 | blob_read_from_file(&in, g.argv[2]); |
| 2628 | Th_FossilInit(TH_INIT_DEFAULT); |
| 2629 | rc = Th_Eval(g.interp, 0, blob_str(&in), -1); |
| 2630 | zRc = Th_ReturnCodeName(rc, 1); |
| 2631 | fossil_print("%s%s%s\n", zRc, zRc ? ": " : "", Th_GetResult(g.interp, 0)); |
| 2632 | Th_PrintTraceLog(); |
| 2633 |
| --- src/th_main.c | |
| +++ src/th_main.c | |
| @@ -2519,11 +2519,11 @@ | |
| 2519 | verify_all_options(); |
| 2520 | if( g.argc<3 ){ |
| 2521 | usage("FILE"); |
| 2522 | } |
| 2523 | blob_zero(&in); |
| 2524 | blob_read_from_file(&in, g.argv[2], ExtFILE); |
| 2525 | Th_Render(blob_str(&in)); |
| 2526 | Th_PrintTraceLog(); |
| 2527 | if( forceCgi ) cgi_reply(); |
| 2528 | } |
| 2529 | |
| @@ -2622,11 +2622,11 @@ | |
| 2622 | verify_all_options(); |
| 2623 | if( g.argc!=3 ){ |
| 2624 | usage("file"); |
| 2625 | } |
| 2626 | blob_zero(&in); |
| 2627 | blob_read_from_file(&in, g.argv[2], ExtFILE); |
| 2628 | Th_FossilInit(TH_INIT_DEFAULT); |
| 2629 | rc = Th_Eval(g.interp, 0, blob_str(&in), -1); |
| 2630 | zRc = Th_ReturnCodeName(rc, 1); |
| 2631 | fossil_print("%s%s%s\n", zRc, zRc ? ": " : "", Th_GetResult(g.interp, 0)); |
| 2632 | Th_PrintTraceLog(); |
| 2633 |
+2
-2
| --- src/th_tcl.c | ||
| +++ src/th_tcl.c | ||
| @@ -846,11 +846,11 @@ | ||
| 846 | 846 | ** interpreter and initialize the stubs mechanism; otherwise, simply setup |
| 847 | 847 | ** the function pointers provided by the caller with the statically linked |
| 848 | 848 | ** functions. |
| 849 | 849 | */ |
| 850 | 850 | char *fossil_getenv(const char *zName); /* file.h */ |
| 851 | -int file_isdir(const char *zPath); /* file.h */ | |
| 851 | +int file_isdir(const char *zPath, int); /* file.h */ | |
| 852 | 852 | char *file_dirname(const char *zPath); /* file.h */ |
| 853 | 853 | void fossil_free(void *p); /* util.h */ |
| 854 | 854 | |
| 855 | 855 | static int loadTcl( |
| 856 | 856 | Th_Interp *interp, |
| @@ -875,11 +875,11 @@ | ||
| 875 | 875 | do { |
| 876 | 876 | char *zFileName; |
| 877 | 877 | void *hLibrary; |
| 878 | 878 | if( !zEnvPath ){ |
| 879 | 879 | zFileName = aFileName; /* NOTE: Assume present in PATH. */ |
| 880 | - }else if( file_isdir(zEnvPath)==1 ){ | |
| 880 | + }else if( file_isdir(zEnvPath, ExtFILE)==1 ){ | |
| 881 | 881 | #if TCL_USE_SET_DLL_DIRECTORY |
| 882 | 882 | SetDllDirectory(zEnvPath); /* NOTE: Maybe needed for "zlib1.dll". */ |
| 883 | 883 | #endif /* TCL_USE_SET_DLL_DIRECTORY */ |
| 884 | 884 | /* NOTE: The environment variable contains a directory name. */ |
| 885 | 885 | zFileName = sqlite3_mprintf("%s%c%s%c", zEnvPath, TCL_DIRECTORY_SEP, |
| 886 | 886 |
| --- src/th_tcl.c | |
| +++ src/th_tcl.c | |
| @@ -846,11 +846,11 @@ | |
| 846 | ** interpreter and initialize the stubs mechanism; otherwise, simply setup |
| 847 | ** the function pointers provided by the caller with the statically linked |
| 848 | ** functions. |
| 849 | */ |
| 850 | char *fossil_getenv(const char *zName); /* file.h */ |
| 851 | int file_isdir(const char *zPath); /* file.h */ |
| 852 | char *file_dirname(const char *zPath); /* file.h */ |
| 853 | void fossil_free(void *p); /* util.h */ |
| 854 | |
| 855 | static int loadTcl( |
| 856 | Th_Interp *interp, |
| @@ -875,11 +875,11 @@ | |
| 875 | do { |
| 876 | char *zFileName; |
| 877 | void *hLibrary; |
| 878 | if( !zEnvPath ){ |
| 879 | zFileName = aFileName; /* NOTE: Assume present in PATH. */ |
| 880 | }else if( file_isdir(zEnvPath)==1 ){ |
| 881 | #if TCL_USE_SET_DLL_DIRECTORY |
| 882 | SetDllDirectory(zEnvPath); /* NOTE: Maybe needed for "zlib1.dll". */ |
| 883 | #endif /* TCL_USE_SET_DLL_DIRECTORY */ |
| 884 | /* NOTE: The environment variable contains a directory name. */ |
| 885 | zFileName = sqlite3_mprintf("%s%c%s%c", zEnvPath, TCL_DIRECTORY_SEP, |
| 886 |
| --- src/th_tcl.c | |
| +++ src/th_tcl.c | |
| @@ -846,11 +846,11 @@ | |
| 846 | ** interpreter and initialize the stubs mechanism; otherwise, simply setup |
| 847 | ** the function pointers provided by the caller with the statically linked |
| 848 | ** functions. |
| 849 | */ |
| 850 | char *fossil_getenv(const char *zName); /* file.h */ |
| 851 | int file_isdir(const char *zPath, int); /* file.h */ |
| 852 | char *file_dirname(const char *zPath); /* file.h */ |
| 853 | void fossil_free(void *p); /* util.h */ |
| 854 | |
| 855 | static int loadTcl( |
| 856 | Th_Interp *interp, |
| @@ -875,11 +875,11 @@ | |
| 875 | do { |
| 876 | char *zFileName; |
| 877 | void *hLibrary; |
| 878 | if( !zEnvPath ){ |
| 879 | zFileName = aFileName; /* NOTE: Assume present in PATH. */ |
| 880 | }else if( file_isdir(zEnvPath, ExtFILE)==1 ){ |
| 881 | #if TCL_USE_SET_DLL_DIRECTORY |
| 882 | SetDllDirectory(zEnvPath); /* NOTE: Maybe needed for "zlib1.dll". */ |
| 883 | #endif /* TCL_USE_SET_DLL_DIRECTORY */ |
| 884 | /* NOTE: The environment variable contains a directory name. */ |
| 885 | zFileName = sqlite3_mprintf("%s%c%s%c", zEnvPath, TCL_DIRECTORY_SEP, |
| 886 |
+9
-17
| --- src/undo.c | ||
| +++ src/undo.c | ||
| @@ -54,19 +54,15 @@ | ||
| 54 | 54 | int old_link; |
| 55 | 55 | Blob current; |
| 56 | 56 | Blob new; |
| 57 | 57 | zFullname = mprintf("%s/%s", g.zLocalRoot, zPathname); |
| 58 | 58 | old_link = db_column_int(&q, 3); |
| 59 | - new_exists = file_wd_size(zFullname)>=0; | |
| 60 | - new_link = file_wd_islink(0); | |
| 59 | + new_exists = file_size(zFullname, RepoFILE)>=0; | |
| 60 | + new_link = file_islink(0); | |
| 61 | 61 | if( new_exists ){ |
| 62 | - if( new_link ){ | |
| 63 | - blob_read_link(¤t, zFullname); | |
| 64 | - }else{ | |
| 65 | - blob_read_from_file(¤t, zFullname); | |
| 66 | - } | |
| 67 | - new_exe = file_wd_isexe(0); | |
| 62 | + blob_read_from_file(¤t, zFullname, RepoFILE); | |
| 63 | + new_exe = file_isexe(0,0); | |
| 68 | 64 | }else{ |
| 69 | 65 | blob_zero(¤t); |
| 70 | 66 | new_exe = 0; |
| 71 | 67 | } |
| 72 | 68 | blob_zero(&new); |
| @@ -87,11 +83,11 @@ | ||
| 87 | 83 | if( old_link ){ |
| 88 | 84 | symlink_create(blob_str(&new), zFullname); |
| 89 | 85 | }else{ |
| 90 | 86 | blob_write_to_file(&new, zFullname); |
| 91 | 87 | } |
| 92 | - file_wd_setexe(zFullname, old_exe); | |
| 88 | + file_setexe(zFullname, old_exe); | |
| 93 | 89 | }else{ |
| 94 | 90 | fossil_print("DELETE %s\n", zPathname); |
| 95 | 91 | file_delete(zFullname); |
| 96 | 92 | } |
| 97 | 93 | blob_reset(&new); |
| @@ -317,28 +313,24 @@ | ||
| 317 | 313 | int result; |
| 318 | 314 | |
| 319 | 315 | if( undoDisable ) return UNDO_DISABLED; |
| 320 | 316 | if( !undoActive ) return UNDO_INACTIVE; |
| 321 | 317 | zFullname = mprintf("%s%s", g.zLocalRoot, zPathname); |
| 322 | - size = file_wd_size(zFullname); | |
| 318 | + size = file_size(zFullname, RepoFILE); | |
| 323 | 319 | if( limit<0 || size<=limit ){ |
| 324 | 320 | int existsFlag = (size>=0); |
| 325 | - int isLink = file_wd_islink(zFullname); | |
| 321 | + int isLink = file_islink(zFullname); | |
| 326 | 322 | Stmt q; |
| 327 | 323 | Blob content; |
| 328 | 324 | db_prepare(&q, |
| 329 | 325 | "INSERT OR IGNORE INTO" |
| 330 | 326 | " undo(pathname,redoflag,existsflag,isExe,isLink,content)" |
| 331 | 327 | " VALUES(%Q,0,%d,%d,%d,:c)", |
| 332 | - zPathname, existsFlag, file_wd_isexe(zFullname), isLink | |
| 328 | + zPathname, existsFlag, file_isexe(zFullname,RepoFILE), isLink | |
| 333 | 329 | ); |
| 334 | 330 | if( existsFlag ){ |
| 335 | - if( isLink ){ | |
| 336 | - blob_read_link(&content, zFullname); | |
| 337 | - }else{ | |
| 338 | - blob_read_from_file(&content, zFullname); | |
| 339 | - } | |
| 331 | + blob_read_from_file(&content, zFullname, RepoFILE); | |
| 340 | 332 | db_bind_blob(&q, ":c", &content); |
| 341 | 333 | } |
| 342 | 334 | db_step(&q); |
| 343 | 335 | db_finalize(&q); |
| 344 | 336 | if( existsFlag ){ |
| 345 | 337 |
| --- src/undo.c | |
| +++ src/undo.c | |
| @@ -54,19 +54,15 @@ | |
| 54 | int old_link; |
| 55 | Blob current; |
| 56 | Blob new; |
| 57 | zFullname = mprintf("%s/%s", g.zLocalRoot, zPathname); |
| 58 | old_link = db_column_int(&q, 3); |
| 59 | new_exists = file_wd_size(zFullname)>=0; |
| 60 | new_link = file_wd_islink(0); |
| 61 | if( new_exists ){ |
| 62 | if( new_link ){ |
| 63 | blob_read_link(¤t, zFullname); |
| 64 | }else{ |
| 65 | blob_read_from_file(¤t, zFullname); |
| 66 | } |
| 67 | new_exe = file_wd_isexe(0); |
| 68 | }else{ |
| 69 | blob_zero(¤t); |
| 70 | new_exe = 0; |
| 71 | } |
| 72 | blob_zero(&new); |
| @@ -87,11 +83,11 @@ | |
| 87 | if( old_link ){ |
| 88 | symlink_create(blob_str(&new), zFullname); |
| 89 | }else{ |
| 90 | blob_write_to_file(&new, zFullname); |
| 91 | } |
| 92 | file_wd_setexe(zFullname, old_exe); |
| 93 | }else{ |
| 94 | fossil_print("DELETE %s\n", zPathname); |
| 95 | file_delete(zFullname); |
| 96 | } |
| 97 | blob_reset(&new); |
| @@ -317,28 +313,24 @@ | |
| 317 | int result; |
| 318 | |
| 319 | if( undoDisable ) return UNDO_DISABLED; |
| 320 | if( !undoActive ) return UNDO_INACTIVE; |
| 321 | zFullname = mprintf("%s%s", g.zLocalRoot, zPathname); |
| 322 | size = file_wd_size(zFullname); |
| 323 | if( limit<0 || size<=limit ){ |
| 324 | int existsFlag = (size>=0); |
| 325 | int isLink = file_wd_islink(zFullname); |
| 326 | Stmt q; |
| 327 | Blob content; |
| 328 | db_prepare(&q, |
| 329 | "INSERT OR IGNORE INTO" |
| 330 | " undo(pathname,redoflag,existsflag,isExe,isLink,content)" |
| 331 | " VALUES(%Q,0,%d,%d,%d,:c)", |
| 332 | zPathname, existsFlag, file_wd_isexe(zFullname), isLink |
| 333 | ); |
| 334 | if( existsFlag ){ |
| 335 | if( isLink ){ |
| 336 | blob_read_link(&content, zFullname); |
| 337 | }else{ |
| 338 | blob_read_from_file(&content, zFullname); |
| 339 | } |
| 340 | db_bind_blob(&q, ":c", &content); |
| 341 | } |
| 342 | db_step(&q); |
| 343 | db_finalize(&q); |
| 344 | if( existsFlag ){ |
| 345 |
| --- src/undo.c | |
| +++ src/undo.c | |
| @@ -54,19 +54,15 @@ | |
| 54 | int old_link; |
| 55 | Blob current; |
| 56 | Blob new; |
| 57 | zFullname = mprintf("%s/%s", g.zLocalRoot, zPathname); |
| 58 | old_link = db_column_int(&q, 3); |
| 59 | new_exists = file_size(zFullname, RepoFILE)>=0; |
| 60 | new_link = file_islink(0); |
| 61 | if( new_exists ){ |
| 62 | blob_read_from_file(¤t, zFullname, RepoFILE); |
| 63 | new_exe = file_isexe(0,0); |
| 64 | }else{ |
| 65 | blob_zero(¤t); |
| 66 | new_exe = 0; |
| 67 | } |
| 68 | blob_zero(&new); |
| @@ -87,11 +83,11 @@ | |
| 83 | if( old_link ){ |
| 84 | symlink_create(blob_str(&new), zFullname); |
| 85 | }else{ |
| 86 | blob_write_to_file(&new, zFullname); |
| 87 | } |
| 88 | file_setexe(zFullname, old_exe); |
| 89 | }else{ |
| 90 | fossil_print("DELETE %s\n", zPathname); |
| 91 | file_delete(zFullname); |
| 92 | } |
| 93 | blob_reset(&new); |
| @@ -317,28 +313,24 @@ | |
| 313 | int result; |
| 314 | |
| 315 | if( undoDisable ) return UNDO_DISABLED; |
| 316 | if( !undoActive ) return UNDO_INACTIVE; |
| 317 | zFullname = mprintf("%s%s", g.zLocalRoot, zPathname); |
| 318 | size = file_size(zFullname, RepoFILE); |
| 319 | if( limit<0 || size<=limit ){ |
| 320 | int existsFlag = (size>=0); |
| 321 | int isLink = file_islink(zFullname); |
| 322 | Stmt q; |
| 323 | Blob content; |
| 324 | db_prepare(&q, |
| 325 | "INSERT OR IGNORE INTO" |
| 326 | " undo(pathname,redoflag,existsflag,isExe,isLink,content)" |
| 327 | " VALUES(%Q,0,%d,%d,%d,:c)", |
| 328 | zPathname, existsFlag, file_isexe(zFullname,RepoFILE), isLink |
| 329 | ); |
| 330 | if( existsFlag ){ |
| 331 | blob_read_from_file(&content, zFullname, RepoFILE); |
| 332 | db_bind_blob(&q, ":c", &content); |
| 333 | } |
| 334 | db_step(&q); |
| 335 | db_finalize(&q); |
| 336 | if( existsFlag ){ |
| 337 |
+2
-2
| --- src/unversioned.c | ||
| +++ src/unversioned.c | ||
| @@ -301,11 +301,11 @@ | ||
| 301 | 301 | } |
| 302 | 302 | if( zError ){ |
| 303 | 303 | fossil_fatal("unversioned filenames may not %s: %Q", zError, zIn); |
| 304 | 304 | } |
| 305 | 305 | blob_init(&file,0,0); |
| 306 | - blob_read_from_file(&file, g.argv[i]); | |
| 306 | + blob_read_from_file(&file, g.argv[i], ExtFILE); | |
| 307 | 307 | unversioned_write(zIn, &file, mtime); |
| 308 | 308 | blob_reset(&file); |
| 309 | 309 | } |
| 310 | 310 | db_end_transaction(0); |
| 311 | 311 | }else if( memcmp(zCmd, "cat", nCmd)==0 ){ |
| @@ -350,11 +350,11 @@ | ||
| 350 | 350 | if( fossil_system(zCmd) ){ |
| 351 | 351 | fossil_fatal("editor aborted: %Q", zCmd); |
| 352 | 352 | } |
| 353 | 353 | fossil_free(zCmd); |
| 354 | 354 | blob_reset(&content); |
| 355 | - blob_read_from_file(&content, zTFile); | |
| 355 | + blob_read_from_file(&content, zTFile, ExtFILE); | |
| 356 | 356 | #if defined(_WIN32) || defined(__CYGWIN__) |
| 357 | 357 | blob_to_lf_only(&content); |
| 358 | 358 | #endif |
| 359 | 359 | file_delete(zTFile); |
| 360 | 360 | if( zMtime==0 ) mtime = time(0); |
| 361 | 361 |
| --- src/unversioned.c | |
| +++ src/unversioned.c | |
| @@ -301,11 +301,11 @@ | |
| 301 | } |
| 302 | if( zError ){ |
| 303 | fossil_fatal("unversioned filenames may not %s: %Q", zError, zIn); |
| 304 | } |
| 305 | blob_init(&file,0,0); |
| 306 | blob_read_from_file(&file, g.argv[i]); |
| 307 | unversioned_write(zIn, &file, mtime); |
| 308 | blob_reset(&file); |
| 309 | } |
| 310 | db_end_transaction(0); |
| 311 | }else if( memcmp(zCmd, "cat", nCmd)==0 ){ |
| @@ -350,11 +350,11 @@ | |
| 350 | if( fossil_system(zCmd) ){ |
| 351 | fossil_fatal("editor aborted: %Q", zCmd); |
| 352 | } |
| 353 | fossil_free(zCmd); |
| 354 | blob_reset(&content); |
| 355 | blob_read_from_file(&content, zTFile); |
| 356 | #if defined(_WIN32) || defined(__CYGWIN__) |
| 357 | blob_to_lf_only(&content); |
| 358 | #endif |
| 359 | file_delete(zTFile); |
| 360 | if( zMtime==0 ) mtime = time(0); |
| 361 |
| --- src/unversioned.c | |
| +++ src/unversioned.c | |
| @@ -301,11 +301,11 @@ | |
| 301 | } |
| 302 | if( zError ){ |
| 303 | fossil_fatal("unversioned filenames may not %s: %Q", zError, zIn); |
| 304 | } |
| 305 | blob_init(&file,0,0); |
| 306 | blob_read_from_file(&file, g.argv[i], ExtFILE); |
| 307 | unversioned_write(zIn, &file, mtime); |
| 308 | blob_reset(&file); |
| 309 | } |
| 310 | db_end_transaction(0); |
| 311 | }else if( memcmp(zCmd, "cat", nCmd)==0 ){ |
| @@ -350,11 +350,11 @@ | |
| 350 | if( fossil_system(zCmd) ){ |
| 351 | fossil_fatal("editor aborted: %Q", zCmd); |
| 352 | } |
| 353 | fossil_free(zCmd); |
| 354 | blob_reset(&content); |
| 355 | blob_read_from_file(&content, zTFile, ExtFILE); |
| 356 | #if defined(_WIN32) || defined(__CYGWIN__) |
| 357 | blob_to_lf_only(&content); |
| 358 | #endif |
| 359 | file_delete(zTFile); |
| 360 | if( zMtime==0 ) mtime = time(0); |
| 361 |
+13
-11
| --- src/update.c | ||
| +++ src/update.c | ||
| @@ -353,11 +353,11 @@ | ||
| 353 | 353 | blob_zero(&sql); |
| 354 | 354 | blob_append(&sql, "DELETE FROM fv WHERE ", -1); |
| 355 | 355 | zSep = ""; |
| 356 | 356 | for(i=3; i<g.argc; i++){ |
| 357 | 357 | file_tree_name(g.argv[i], &treename, 0, 1); |
| 358 | - if( file_wd_isdir(g.argv[i])==1 ){ | |
| 358 | + if( file_isdir(g.argv[i], RepoFILE)==1 ){ | |
| 359 | 359 | if( blob_size(&treename) != 1 || blob_str(&treename)[0] != '.' ){ |
| 360 | 360 | blob_append_sql(&sql, "%sfn NOT GLOB '%q/*' ", |
| 361 | 361 | zSep /*safe-for-%s*/, blob_str(&treename)); |
| 362 | 362 | }else{ |
| 363 | 363 | blob_reset(&sql); |
| @@ -418,11 +418,11 @@ | ||
| 418 | 418 | */ |
| 419 | 419 | fossil_print("CONFLICT %s\n", zName); |
| 420 | 420 | nConflict++; |
| 421 | 421 | }else if( idt>0 && idv==0 ){ |
| 422 | 422 | /* File added in the target. */ |
| 423 | - if( file_wd_isfile_or_link(zFullPath) ){ | |
| 423 | + if( file_isfile_or_link(zFullPath) ){ | |
| 424 | 424 | fossil_print("ADD %s - overwrites an unmanaged file\n", zName); |
| 425 | 425 | nOverwrite++; |
| 426 | 426 | }else{ |
| 427 | 427 | fossil_print("ADD %s\n", zName); |
| 428 | 428 | } |
| @@ -435,11 +435,11 @@ | ||
| 435 | 435 | }else{ |
| 436 | 436 | fossil_print("UPDATE %s\n", zName); |
| 437 | 437 | } |
| 438 | 438 | if( !dryRunFlag && !internalUpdate ) undo_save(zName); |
| 439 | 439 | if( !dryRunFlag ) vfile_to_disk(0, idt, 0, 0); |
| 440 | - }else if( idt>0 && idv>0 && !deleted && file_wd_size(zFullPath)<0 ){ | |
| 440 | + }else if( idt>0 && idv>0 && !deleted && file_size(zFullPath, RepoFILE)<0 ){ | |
| 441 | 441 | /* The file missing from the local check-out. Restore it to the |
| 442 | 442 | ** version that appears in the target. */ |
| 443 | 443 | fossil_print("UPDATE %s\n", zName); |
| 444 | 444 | if( !dryRunFlag && !internalUpdate ) undo_save(zName); |
| 445 | 445 | if( !dryRunFlag ) vfile_to_disk(0, idt, 0, 0); |
| @@ -466,11 +466,11 @@ | ||
| 466 | 466 | if( nameChng ){ |
| 467 | 467 | fossil_print("MERGE %s -> %s\n", zName, zNewName); |
| 468 | 468 | }else{ |
| 469 | 469 | fossil_print("MERGE %s\n", zName); |
| 470 | 470 | } |
| 471 | - if( islinkv || islinkt /* || file_wd_islink(zFullPath) */ ){ | |
| 471 | + if( islinkv || islinkt ){ | |
| 472 | 472 | fossil_print("***** Cannot merge symlink %s\n", zNewName); |
| 473 | 473 | nConflict++; |
| 474 | 474 | }else{ |
| 475 | 475 | unsigned mergeFlags = dryRunFlag ? MERGE_DRYRUN : 0; |
| 476 | 476 | if( !dryRunFlag && !internalUpdate ) undo_save(zName); |
| @@ -478,20 +478,20 @@ | ||
| 478 | 478 | content_get(ridv, &v); |
| 479 | 479 | rc = merge_3way(&v, zFullPath, &t, &r, mergeFlags); |
| 480 | 480 | if( rc>=0 ){ |
| 481 | 481 | if( !dryRunFlag ){ |
| 482 | 482 | blob_write_to_file(&r, zFullNewPath); |
| 483 | - file_wd_setexe(zFullNewPath, isexe); | |
| 483 | + file_setexe(zFullNewPath, isexe); | |
| 484 | 484 | } |
| 485 | 485 | if( rc>0 ){ |
| 486 | 486 | fossil_print("***** %d merge conflicts in %s\n", rc, zNewName); |
| 487 | 487 | nConflict++; |
| 488 | 488 | } |
| 489 | 489 | }else{ |
| 490 | 490 | if( !dryRunFlag ){ |
| 491 | 491 | blob_write_to_file(&t, zFullNewPath); |
| 492 | - file_wd_setexe(zFullNewPath, isexe); | |
| 492 | + file_setexe(zFullNewPath, isexe); | |
| 493 | 493 | } |
| 494 | 494 | fossil_print("***** Cannot merge binary file %s\n", zNewName); |
| 495 | 495 | nConflict++; |
| 496 | 496 | } |
| 497 | 497 | } |
| @@ -603,15 +603,15 @@ | ||
| 603 | 603 | } |
| 604 | 604 | blob_init(&dirsList, zEmptyDirs, -1); |
| 605 | 605 | while( blob_token(&dirsList, &dirName) ){ |
| 606 | 606 | char *zDir = blob_str(&dirName); |
| 607 | 607 | char *zPath = mprintf("%s/%s", g.zLocalRoot, zDir); |
| 608 | - switch( file_wd_isdir(zPath) ){ | |
| 608 | + switch( file_isdir(zPath, RepoFILE) ){ | |
| 609 | 609 | case 0: { /* doesn't exist */ |
| 610 | 610 | fossil_free(zPath); |
| 611 | 611 | zPath = mprintf("%s/%s/x", g.zLocalRoot, zDir); |
| 612 | - if( file_mkfolder(zPath, 0, 1)!=0 ) { | |
| 612 | + if( file_mkfolder(zPath, RepoFILE, 0, 1)!=0 ) { | |
| 613 | 613 | fossil_warning("couldn't create directory %s as " |
| 614 | 614 | "required by empty-dirs setting", zDir); |
| 615 | 615 | } |
| 616 | 616 | break; |
| 617 | 617 | } |
| @@ -850,21 +850,23 @@ | ||
| 850 | 850 | |
| 851 | 851 | /* Get contents of reverted-to file. */ |
| 852 | 852 | content_get(fast_uuid_to_rid(pRvFile->zUuid), &record); |
| 853 | 853 | |
| 854 | 854 | undo_save(zFile); |
| 855 | - if( file_wd_size(zFull)>=0 && (rvPerm==PERM_LNK || file_wd_islink(0)) ){ | |
| 855 | + if( file_size(zFull, RepoFILE)>=0 | |
| 856 | + && (rvPerm==PERM_LNK || file_islink(0)) | |
| 857 | + ){ | |
| 856 | 858 | file_delete(zFull); |
| 857 | 859 | } |
| 858 | 860 | if( rvPerm==PERM_LNK ){ |
| 859 | 861 | symlink_create(blob_str(&record), zFull); |
| 860 | 862 | }else{ |
| 861 | 863 | blob_write_to_file(&record, zFull); |
| 862 | 864 | } |
| 863 | - file_wd_setexe(zFull, rvPerm==PERM_EXE); | |
| 865 | + file_setexe(zFull, rvPerm==PERM_EXE); | |
| 864 | 866 | fossil_print("REVERT %s\n", zFile); |
| 865 | - mtime = file_wd_mtime(zFull); | |
| 867 | + mtime = file_mtime(zFull, RepoFILE); | |
| 866 | 868 | db_multi_exec( |
| 867 | 869 | "UPDATE vfile" |
| 868 | 870 | " SET mtime=%lld, chnged=%d, deleted=0, isexe=%d, islink=%d,mrid=rid" |
| 869 | 871 | " WHERE pathname=%Q OR origname=%Q", |
| 870 | 872 | mtime, rvChnged, rvPerm==PERM_EXE, rvPerm==PERM_LNK, zFile, zFile |
| 871 | 873 |
| --- src/update.c | |
| +++ src/update.c | |
| @@ -353,11 +353,11 @@ | |
| 353 | blob_zero(&sql); |
| 354 | blob_append(&sql, "DELETE FROM fv WHERE ", -1); |
| 355 | zSep = ""; |
| 356 | for(i=3; i<g.argc; i++){ |
| 357 | file_tree_name(g.argv[i], &treename, 0, 1); |
| 358 | if( file_wd_isdir(g.argv[i])==1 ){ |
| 359 | if( blob_size(&treename) != 1 || blob_str(&treename)[0] != '.' ){ |
| 360 | blob_append_sql(&sql, "%sfn NOT GLOB '%q/*' ", |
| 361 | zSep /*safe-for-%s*/, blob_str(&treename)); |
| 362 | }else{ |
| 363 | blob_reset(&sql); |
| @@ -418,11 +418,11 @@ | |
| 418 | */ |
| 419 | fossil_print("CONFLICT %s\n", zName); |
| 420 | nConflict++; |
| 421 | }else if( idt>0 && idv==0 ){ |
| 422 | /* File added in the target. */ |
| 423 | if( file_wd_isfile_or_link(zFullPath) ){ |
| 424 | fossil_print("ADD %s - overwrites an unmanaged file\n", zName); |
| 425 | nOverwrite++; |
| 426 | }else{ |
| 427 | fossil_print("ADD %s\n", zName); |
| 428 | } |
| @@ -435,11 +435,11 @@ | |
| 435 | }else{ |
| 436 | fossil_print("UPDATE %s\n", zName); |
| 437 | } |
| 438 | if( !dryRunFlag && !internalUpdate ) undo_save(zName); |
| 439 | if( !dryRunFlag ) vfile_to_disk(0, idt, 0, 0); |
| 440 | }else if( idt>0 && idv>0 && !deleted && file_wd_size(zFullPath)<0 ){ |
| 441 | /* The file missing from the local check-out. Restore it to the |
| 442 | ** version that appears in the target. */ |
| 443 | fossil_print("UPDATE %s\n", zName); |
| 444 | if( !dryRunFlag && !internalUpdate ) undo_save(zName); |
| 445 | if( !dryRunFlag ) vfile_to_disk(0, idt, 0, 0); |
| @@ -466,11 +466,11 @@ | |
| 466 | if( nameChng ){ |
| 467 | fossil_print("MERGE %s -> %s\n", zName, zNewName); |
| 468 | }else{ |
| 469 | fossil_print("MERGE %s\n", zName); |
| 470 | } |
| 471 | if( islinkv || islinkt /* || file_wd_islink(zFullPath) */ ){ |
| 472 | fossil_print("***** Cannot merge symlink %s\n", zNewName); |
| 473 | nConflict++; |
| 474 | }else{ |
| 475 | unsigned mergeFlags = dryRunFlag ? MERGE_DRYRUN : 0; |
| 476 | if( !dryRunFlag && !internalUpdate ) undo_save(zName); |
| @@ -478,20 +478,20 @@ | |
| 478 | content_get(ridv, &v); |
| 479 | rc = merge_3way(&v, zFullPath, &t, &r, mergeFlags); |
| 480 | if( rc>=0 ){ |
| 481 | if( !dryRunFlag ){ |
| 482 | blob_write_to_file(&r, zFullNewPath); |
| 483 | file_wd_setexe(zFullNewPath, isexe); |
| 484 | } |
| 485 | if( rc>0 ){ |
| 486 | fossil_print("***** %d merge conflicts in %s\n", rc, zNewName); |
| 487 | nConflict++; |
| 488 | } |
| 489 | }else{ |
| 490 | if( !dryRunFlag ){ |
| 491 | blob_write_to_file(&t, zFullNewPath); |
| 492 | file_wd_setexe(zFullNewPath, isexe); |
| 493 | } |
| 494 | fossil_print("***** Cannot merge binary file %s\n", zNewName); |
| 495 | nConflict++; |
| 496 | } |
| 497 | } |
| @@ -603,15 +603,15 @@ | |
| 603 | } |
| 604 | blob_init(&dirsList, zEmptyDirs, -1); |
| 605 | while( blob_token(&dirsList, &dirName) ){ |
| 606 | char *zDir = blob_str(&dirName); |
| 607 | char *zPath = mprintf("%s/%s", g.zLocalRoot, zDir); |
| 608 | switch( file_wd_isdir(zPath) ){ |
| 609 | case 0: { /* doesn't exist */ |
| 610 | fossil_free(zPath); |
| 611 | zPath = mprintf("%s/%s/x", g.zLocalRoot, zDir); |
| 612 | if( file_mkfolder(zPath, 0, 1)!=0 ) { |
| 613 | fossil_warning("couldn't create directory %s as " |
| 614 | "required by empty-dirs setting", zDir); |
| 615 | } |
| 616 | break; |
| 617 | } |
| @@ -850,21 +850,23 @@ | |
| 850 | |
| 851 | /* Get contents of reverted-to file. */ |
| 852 | content_get(fast_uuid_to_rid(pRvFile->zUuid), &record); |
| 853 | |
| 854 | undo_save(zFile); |
| 855 | if( file_wd_size(zFull)>=0 && (rvPerm==PERM_LNK || file_wd_islink(0)) ){ |
| 856 | file_delete(zFull); |
| 857 | } |
| 858 | if( rvPerm==PERM_LNK ){ |
| 859 | symlink_create(blob_str(&record), zFull); |
| 860 | }else{ |
| 861 | blob_write_to_file(&record, zFull); |
| 862 | } |
| 863 | file_wd_setexe(zFull, rvPerm==PERM_EXE); |
| 864 | fossil_print("REVERT %s\n", zFile); |
| 865 | mtime = file_wd_mtime(zFull); |
| 866 | db_multi_exec( |
| 867 | "UPDATE vfile" |
| 868 | " SET mtime=%lld, chnged=%d, deleted=0, isexe=%d, islink=%d,mrid=rid" |
| 869 | " WHERE pathname=%Q OR origname=%Q", |
| 870 | mtime, rvChnged, rvPerm==PERM_EXE, rvPerm==PERM_LNK, zFile, zFile |
| 871 |
| --- src/update.c | |
| +++ src/update.c | |
| @@ -353,11 +353,11 @@ | |
| 353 | blob_zero(&sql); |
| 354 | blob_append(&sql, "DELETE FROM fv WHERE ", -1); |
| 355 | zSep = ""; |
| 356 | for(i=3; i<g.argc; i++){ |
| 357 | file_tree_name(g.argv[i], &treename, 0, 1); |
| 358 | if( file_isdir(g.argv[i], RepoFILE)==1 ){ |
| 359 | if( blob_size(&treename) != 1 || blob_str(&treename)[0] != '.' ){ |
| 360 | blob_append_sql(&sql, "%sfn NOT GLOB '%q/*' ", |
| 361 | zSep /*safe-for-%s*/, blob_str(&treename)); |
| 362 | }else{ |
| 363 | blob_reset(&sql); |
| @@ -418,11 +418,11 @@ | |
| 418 | */ |
| 419 | fossil_print("CONFLICT %s\n", zName); |
| 420 | nConflict++; |
| 421 | }else if( idt>0 && idv==0 ){ |
| 422 | /* File added in the target. */ |
| 423 | if( file_isfile_or_link(zFullPath) ){ |
| 424 | fossil_print("ADD %s - overwrites an unmanaged file\n", zName); |
| 425 | nOverwrite++; |
| 426 | }else{ |
| 427 | fossil_print("ADD %s\n", zName); |
| 428 | } |
| @@ -435,11 +435,11 @@ | |
| 435 | }else{ |
| 436 | fossil_print("UPDATE %s\n", zName); |
| 437 | } |
| 438 | if( !dryRunFlag && !internalUpdate ) undo_save(zName); |
| 439 | if( !dryRunFlag ) vfile_to_disk(0, idt, 0, 0); |
| 440 | }else if( idt>0 && idv>0 && !deleted && file_size(zFullPath, RepoFILE)<0 ){ |
| 441 | /* The file missing from the local check-out. Restore it to the |
| 442 | ** version that appears in the target. */ |
| 443 | fossil_print("UPDATE %s\n", zName); |
| 444 | if( !dryRunFlag && !internalUpdate ) undo_save(zName); |
| 445 | if( !dryRunFlag ) vfile_to_disk(0, idt, 0, 0); |
| @@ -466,11 +466,11 @@ | |
| 466 | if( nameChng ){ |
| 467 | fossil_print("MERGE %s -> %s\n", zName, zNewName); |
| 468 | }else{ |
| 469 | fossil_print("MERGE %s\n", zName); |
| 470 | } |
| 471 | if( islinkv || islinkt ){ |
| 472 | fossil_print("***** Cannot merge symlink %s\n", zNewName); |
| 473 | nConflict++; |
| 474 | }else{ |
| 475 | unsigned mergeFlags = dryRunFlag ? MERGE_DRYRUN : 0; |
| 476 | if( !dryRunFlag && !internalUpdate ) undo_save(zName); |
| @@ -478,20 +478,20 @@ | |
| 478 | content_get(ridv, &v); |
| 479 | rc = merge_3way(&v, zFullPath, &t, &r, mergeFlags); |
| 480 | if( rc>=0 ){ |
| 481 | if( !dryRunFlag ){ |
| 482 | blob_write_to_file(&r, zFullNewPath); |
| 483 | file_setexe(zFullNewPath, isexe); |
| 484 | } |
| 485 | if( rc>0 ){ |
| 486 | fossil_print("***** %d merge conflicts in %s\n", rc, zNewName); |
| 487 | nConflict++; |
| 488 | } |
| 489 | }else{ |
| 490 | if( !dryRunFlag ){ |
| 491 | blob_write_to_file(&t, zFullNewPath); |
| 492 | file_setexe(zFullNewPath, isexe); |
| 493 | } |
| 494 | fossil_print("***** Cannot merge binary file %s\n", zNewName); |
| 495 | nConflict++; |
| 496 | } |
| 497 | } |
| @@ -603,15 +603,15 @@ | |
| 603 | } |
| 604 | blob_init(&dirsList, zEmptyDirs, -1); |
| 605 | while( blob_token(&dirsList, &dirName) ){ |
| 606 | char *zDir = blob_str(&dirName); |
| 607 | char *zPath = mprintf("%s/%s", g.zLocalRoot, zDir); |
| 608 | switch( file_isdir(zPath, RepoFILE) ){ |
| 609 | case 0: { /* doesn't exist */ |
| 610 | fossil_free(zPath); |
| 611 | zPath = mprintf("%s/%s/x", g.zLocalRoot, zDir); |
| 612 | if( file_mkfolder(zPath, RepoFILE, 0, 1)!=0 ) { |
| 613 | fossil_warning("couldn't create directory %s as " |
| 614 | "required by empty-dirs setting", zDir); |
| 615 | } |
| 616 | break; |
| 617 | } |
| @@ -850,21 +850,23 @@ | |
| 850 | |
| 851 | /* Get contents of reverted-to file. */ |
| 852 | content_get(fast_uuid_to_rid(pRvFile->zUuid), &record); |
| 853 | |
| 854 | undo_save(zFile); |
| 855 | if( file_size(zFull, RepoFILE)>=0 |
| 856 | && (rvPerm==PERM_LNK || file_islink(0)) |
| 857 | ){ |
| 858 | file_delete(zFull); |
| 859 | } |
| 860 | if( rvPerm==PERM_LNK ){ |
| 861 | symlink_create(blob_str(&record), zFull); |
| 862 | }else{ |
| 863 | blob_write_to_file(&record, zFull); |
| 864 | } |
| 865 | file_setexe(zFull, rvPerm==PERM_EXE); |
| 866 | fossil_print("REVERT %s\n", zFile); |
| 867 | mtime = file_mtime(zFull, RepoFILE); |
| 868 | db_multi_exec( |
| 869 | "UPDATE vfile" |
| 870 | " SET mtime=%lld, chnged=%d, deleted=0, isexe=%d, islink=%d,mrid=rid" |
| 871 | " WHERE pathname=%Q OR origname=%Q", |
| 872 | mtime, rvChnged, rvPerm==PERM_EXE, rvPerm==PERM_LNK, zFile, zFile |
| 873 |
+3
-3
| --- src/url.c | ||
| +++ src/url.c | ||
| @@ -244,16 +244,16 @@ | ||
| 244 | 244 | i = 7; |
| 245 | 245 | }else{ |
| 246 | 246 | i = 5; |
| 247 | 247 | } |
| 248 | 248 | zFile = mprintf("%s", &zUrl[i]); |
| 249 | - }else if( file_isfile(zUrl) ){ | |
| 249 | + }else if( file_isfile(zUrl, ExtFILE) ){ | |
| 250 | 250 | pUrlData->isFile = 1; |
| 251 | 251 | zFile = mprintf("%s", zUrl); |
| 252 | - }else if( file_isdir(zUrl)==1 ){ | |
| 252 | + }else if( file_isdir(zUrl, ExtFILE)==1 ){ | |
| 253 | 253 | zFile = mprintf("%s/FOSSIL", zUrl); |
| 254 | - if( file_isfile(zFile) ){ | |
| 254 | + if( file_isfile(zFile, ExtFILE) ){ | |
| 255 | 255 | pUrlData->isFile = 1; |
| 256 | 256 | }else{ |
| 257 | 257 | free(zFile); |
| 258 | 258 | zFile = 0; |
| 259 | 259 | fossil_fatal("unknown repository: %s", zUrl); |
| 260 | 260 |
| --- src/url.c | |
| +++ src/url.c | |
| @@ -244,16 +244,16 @@ | |
| 244 | i = 7; |
| 245 | }else{ |
| 246 | i = 5; |
| 247 | } |
| 248 | zFile = mprintf("%s", &zUrl[i]); |
| 249 | }else if( file_isfile(zUrl) ){ |
| 250 | pUrlData->isFile = 1; |
| 251 | zFile = mprintf("%s", zUrl); |
| 252 | }else if( file_isdir(zUrl)==1 ){ |
| 253 | zFile = mprintf("%s/FOSSIL", zUrl); |
| 254 | if( file_isfile(zFile) ){ |
| 255 | pUrlData->isFile = 1; |
| 256 | }else{ |
| 257 | free(zFile); |
| 258 | zFile = 0; |
| 259 | fossil_fatal("unknown repository: %s", zUrl); |
| 260 |
| --- src/url.c | |
| +++ src/url.c | |
| @@ -244,16 +244,16 @@ | |
| 244 | i = 7; |
| 245 | }else{ |
| 246 | i = 5; |
| 247 | } |
| 248 | zFile = mprintf("%s", &zUrl[i]); |
| 249 | }else if( file_isfile(zUrl, ExtFILE) ){ |
| 250 | pUrlData->isFile = 1; |
| 251 | zFile = mprintf("%s", zUrl); |
| 252 | }else if( file_isdir(zUrl, ExtFILE)==1 ){ |
| 253 | zFile = mprintf("%s/FOSSIL", zUrl); |
| 254 | if( file_isfile(zFile, ExtFILE) ){ |
| 255 | pUrlData->isFile = 1; |
| 256 | }else{ |
| 257 | free(zFile); |
| 258 | zFile = 0; |
| 259 | fossil_fatal("unknown repository: %s", zUrl); |
| 260 |
+28
-32
| --- src/vfile.c | ||
| +++ src/vfile.c | ||
| @@ -202,20 +202,20 @@ | ||
| 202 | 202 | rid = db_column_int(&q, 2); |
| 203 | 203 | isDeleted = db_column_int(&q, 3); |
| 204 | 204 | oldChnged = chnged = db_column_int(&q, 4); |
| 205 | 205 | oldMtime = db_column_int64(&q, 7); |
| 206 | 206 | origSize = db_column_int64(&q, 6); |
| 207 | - currentSize = file_wd_size(zName); | |
| 208 | - currentMtime = file_wd_mtime(0); | |
| 207 | + currentSize = file_size(zName, RepoFILE); | |
| 208 | + currentMtime = file_mtime(0, 0); | |
| 209 | 209 | #ifndef _WIN32 |
| 210 | 210 | origPerm = db_column_int(&q, 8); |
| 211 | - currentPerm = file_wd_perm(zName); | |
| 211 | + currentPerm = file_perm(zName, RepoFILE); | |
| 212 | 212 | #endif |
| 213 | 213 | if( chnged==0 && (isDeleted || rid==0) ){ |
| 214 | 214 | /* "fossil rm" or "fossil add" always change the file */ |
| 215 | 215 | chnged = 1; |
| 216 | - }else if( !file_wd_isfile_or_link(0) && currentSize>=0 ){ | |
| 216 | + }else if( !file_isfile_or_link(0) && currentSize>=0 ){ | |
| 217 | 217 | if( cksigFlags & CKSIG_ENOTFILE ){ |
| 218 | 218 | fossil_warning("not an ordinary file: %s", zName); |
| 219 | 219 | nErr++; |
| 220 | 220 | } |
| 221 | 221 | chnged = 1; |
| @@ -247,11 +247,11 @@ | ||
| 247 | 247 | if( (cksigFlags & CKSIG_SETMTIME) && (chnged==0 || chnged==2 || chnged==4) ){ |
| 248 | 248 | i64 desiredMtime; |
| 249 | 249 | if( mtime_of_manifest_file(vid,rid,&desiredMtime)==0 ){ |
| 250 | 250 | if( currentMtime!=desiredMtime ){ |
| 251 | 251 | file_set_mtime(zName, desiredMtime); |
| 252 | - currentMtime = file_wd_mtime(zName); | |
| 252 | + currentMtime = file_mtime(zName, RepoFILE); | |
| 253 | 253 | } |
| 254 | 254 | } |
| 255 | 255 | } |
| 256 | 256 | #ifndef _WIN32 |
| 257 | 257 | if( origPerm!=PERM_LNK && currentPerm==PERM_LNK ){ |
| @@ -316,17 +316,17 @@ | ||
| 316 | 316 | isExe = db_column_int(&q, 3); |
| 317 | 317 | isLink = db_column_int(&q, 4); |
| 318 | 318 | content_get(rid, &content); |
| 319 | 319 | if( file_is_the_same(&content, zName) ){ |
| 320 | 320 | blob_reset(&content); |
| 321 | - if( file_wd_setexe(zName, isExe) ){ | |
| 321 | + if( file_setexe(zName, isExe) ){ | |
| 322 | 322 | db_multi_exec("UPDATE vfile SET mtime=%lld WHERE id=%d", |
| 323 | - file_wd_mtime(zName), id); | |
| 323 | + file_mtime(zName, RepoFILE), id); | |
| 324 | 324 | } |
| 325 | 325 | continue; |
| 326 | 326 | } |
| 327 | - if( promptFlag && file_wd_size(zName)>=0 ){ | |
| 327 | + if( promptFlag && file_size(zName, RepoFILE)>=0 ){ | |
| 328 | 328 | Blob ans; |
| 329 | 329 | char *zMsg; |
| 330 | 330 | char cReply; |
| 331 | 331 | zMsg = mprintf("overwrite %s (a=always/y/N)? ", zName); |
| 332 | 332 | prompt_user(zMsg, &ans); |
| @@ -339,26 +339,26 @@ | ||
| 339 | 339 | blob_reset(&content); |
| 340 | 340 | continue; |
| 341 | 341 | } |
| 342 | 342 | } |
| 343 | 343 | if( verbose ) fossil_print("%s\n", &zName[nRepos]); |
| 344 | - if( file_wd_isdir(zName)==1 ){ | |
| 344 | + if( file_isdir(zName, RepoFILE)==1 ){ | |
| 345 | 345 | /*TODO(dchest): remove directories? */ |
| 346 | 346 | fossil_fatal("%s is directory, cannot overwrite", zName); |
| 347 | 347 | } |
| 348 | - if( file_wd_size(zName)>=0 && (isLink || file_wd_islink(0)) ){ | |
| 348 | + if( file_size(zName, RepoFILE)>=0 && (isLink || file_islink(0)) ){ | |
| 349 | 349 | file_delete(zName); |
| 350 | 350 | } |
| 351 | 351 | if( isLink ){ |
| 352 | 352 | symlink_create(blob_str(&content), zName); |
| 353 | 353 | }else{ |
| 354 | 354 | blob_write_to_file(&content, zName); |
| 355 | 355 | } |
| 356 | - file_wd_setexe(zName, isExe); | |
| 356 | + file_setexe(zName, isExe); | |
| 357 | 357 | blob_reset(&content); |
| 358 | 358 | db_multi_exec("UPDATE vfile SET mtime=%lld WHERE id=%d", |
| 359 | - file_wd_mtime(zName), id); | |
| 359 | + file_mtime(zName, RepoFILE), id); | |
| 360 | 360 | } |
| 361 | 361 | db_finalize(&q); |
| 362 | 362 | } |
| 363 | 363 | |
| 364 | 364 | |
| @@ -387,15 +387,15 @@ | ||
| 387 | 387 | int vfile_top_of_checkout(const char *zPath){ |
| 388 | 388 | char *zFile; |
| 389 | 389 | int fileFound = 0; |
| 390 | 390 | |
| 391 | 391 | zFile = mprintf("%s/_FOSSIL_", zPath); |
| 392 | - fileFound = file_size(zFile)>=1024; | |
| 392 | + fileFound = file_size(zFile, ExtFILE)>=1024; | |
| 393 | 393 | fossil_free(zFile); |
| 394 | 394 | if( !fileFound ){ |
| 395 | 395 | zFile = mprintf("%s/.fslckout", zPath); |
| 396 | - fileFound = file_size(zFile)>=1024; | |
| 396 | + fileFound = file_size(zFile, ExtFILE)>=1024; | |
| 397 | 397 | fossil_free(zFile); |
| 398 | 398 | } |
| 399 | 399 | |
| 400 | 400 | /* Check for ".fos" for legacy support. But the use of ".fos" as the |
| 401 | 401 | ** per-checkout database name is deprecated. At some point, all support |
| @@ -402,11 +402,11 @@ | ||
| 402 | 402 | ** for ".fos" will end and this code should be removed. This comment |
| 403 | 403 | ** added on 2012-02-04. |
| 404 | 404 | */ |
| 405 | 405 | if( !fileFound ){ |
| 406 | 406 | zFile = mprintf("%s/.fos", zPath); |
| 407 | - fileFound = file_size(zFile)>=1024; | |
| 407 | + fileFound = file_size(zFile, ExtFILE)>=1024; | |
| 408 | 408 | fossil_free(zFile); |
| 409 | 409 | } |
| 410 | 410 | return fileFound; |
| 411 | 411 | } |
| 412 | 412 | |
| @@ -522,30 +522,30 @@ | ||
| 522 | 522 | if( glob_match(pIgnore1, &zPath[nPrefix+1]) || |
| 523 | 523 | glob_match(pIgnore2, &zPath[nPrefix+1]) ){ |
| 524 | 524 | /* do nothing */ |
| 525 | 525 | #ifdef _DIRENT_HAVE_D_TYPE |
| 526 | 526 | }else if( (pEntry->d_type==DT_UNKNOWN || pEntry->d_type==DT_LNK) |
| 527 | - ? (file_wd_isdir(zPath)==1) : (pEntry->d_type==DT_DIR) ){ | |
| 527 | + ? (file_isdir(zPath, RepoFILE)==1) : (pEntry->d_type==DT_DIR) ){ | |
| 528 | 528 | #else |
| 529 | - }else if( file_wd_isdir(zPath)==1 ){ | |
| 529 | + }else if( file_isdir(zPath, RepoFILE)==1 ){ | |
| 530 | 530 | #endif |
| 531 | 531 | if( !vfile_top_of_checkout(zPath) ){ |
| 532 | 532 | vfile_scan(pPath, nPrefix, scanFlags, pIgnore1, pIgnore2); |
| 533 | 533 | } |
| 534 | 534 | #ifdef _DIRENT_HAVE_D_TYPE |
| 535 | 535 | }else if( (pEntry->d_type==DT_UNKNOWN || pEntry->d_type==DT_LNK) |
| 536 | - ? (file_wd_isfile_or_link(zPath)) : (pEntry->d_type==DT_REG) ){ | |
| 536 | + ? (file_isfile_or_link(zPath)) : (pEntry->d_type==DT_REG) ){ | |
| 537 | 537 | #else |
| 538 | - }else if( file_wd_isfile_or_link(zPath) ){ | |
| 538 | + }else if( file_isfile_or_link(zPath) ){ | |
| 539 | 539 | #endif |
| 540 | 540 | if( (scanFlags & SCAN_TEMP)==0 || is_temporary_file(zUtf8) ){ |
| 541 | 541 | db_bind_text(&ins, ":file", &zPath[nPrefix+1]); |
| 542 | 542 | if( scanFlags & SCAN_MTIME ){ |
| 543 | - db_bind_int(&ins, ":mtime", file_mtime(zPath)); | |
| 543 | + db_bind_int(&ins, ":mtime", file_mtime(zPath, RepoFILE)); | |
| 544 | 544 | } |
| 545 | 545 | if( scanFlags & SCAN_SIZE ){ |
| 546 | - db_bind_int(&ins, ":size", file_size(zPath)); | |
| 546 | + db_bind_int(&ins, ":size", file_size(zPath, RepoFILE)); | |
| 547 | 547 | } |
| 548 | 548 | db_step(&ins); |
| 549 | 549 | db_reset(&ins); |
| 550 | 550 | } |
| 551 | 551 | } |
| @@ -642,13 +642,13 @@ | ||
| 642 | 642 | if( glob_match(pIgnore1, &zPath[nPrefix+1]) || |
| 643 | 643 | glob_match(pIgnore2, &zPath[nPrefix+1]) ){ |
| 644 | 644 | /* do nothing */ |
| 645 | 645 | #ifdef _DIRENT_HAVE_D_TYPE |
| 646 | 646 | }else if( (pEntry->d_type==DT_UNKNOWN || pEntry->d_type==DT_LNK) |
| 647 | - ? (file_wd_isdir(zPath)==1) : (pEntry->d_type==DT_DIR) ){ | |
| 647 | + ? (file_isdir(zPath, RepoFILE)==1) : (pEntry->d_type==DT_DIR) ){ | |
| 648 | 648 | #else |
| 649 | - }else if( file_wd_isdir(zPath)==1 ){ | |
| 649 | + }else if( file_isdir(zPath, RepoFILE)==1 ){ | |
| 650 | 650 | #endif |
| 651 | 651 | if( (scanFlags & SCAN_NESTED) || !vfile_top_of_checkout(zPath) ){ |
| 652 | 652 | char *zSavePath = mprintf("%s", zPath); |
| 653 | 653 | int count = vfile_dir_scan(pPath, nPrefix, scanFlags, pIgnore1, |
| 654 | 654 | pIgnore2); |
| @@ -659,13 +659,13 @@ | ||
| 659 | 659 | fossil_free(zSavePath); |
| 660 | 660 | result += count; /* found X normal files? */ |
| 661 | 661 | } |
| 662 | 662 | #ifdef _DIRENT_HAVE_D_TYPE |
| 663 | 663 | }else if( (pEntry->d_type==DT_UNKNOWN || pEntry->d_type==DT_LNK) |
| 664 | - ? (file_wd_isfile_or_link(zPath)) : (pEntry->d_type==DT_REG) ){ | |
| 664 | + ? (file_isfile_or_link(zPath)) : (pEntry->d_type==DT_REG) ){ | |
| 665 | 665 | #else |
| 666 | - }else if( file_wd_isfile_or_link(zPath) ){ | |
| 666 | + }else if( file_isfile_or_link(zPath) ){ | |
| 667 | 667 | #endif |
| 668 | 668 | db_bind_text(&upd, ":file", zOrigPath); |
| 669 | 669 | db_step(&upd); |
| 670 | 670 | db_reset(&upd); |
| 671 | 671 | result++; /* found 1 normal file */ |
| @@ -726,11 +726,11 @@ | ||
| 726 | 726 | const char *zName = db_column_text(&q, 1); |
| 727 | 727 | int isSelected = db_column_int(&q, 3); |
| 728 | 728 | |
| 729 | 729 | if( isSelected ){ |
| 730 | 730 | md5sum_step_text(zName, -1); |
| 731 | - if( file_wd_islink(zFullpath) ){ | |
| 731 | + if( file_islink(zFullpath) ){ | |
| 732 | 732 | /* Instead of file content, use link destination path */ |
| 733 | 733 | Blob pathBuf; |
| 734 | 734 | |
| 735 | 735 | sqlite3_snprintf(sizeof(zBuf), zBuf, " %ld\n", |
| 736 | 736 | blob_read_link(&pathBuf, zFullpath)); |
| @@ -786,11 +786,11 @@ | ||
| 786 | 786 | char *zOut = 0; |
| 787 | 787 | do{ |
| 788 | 788 | sqlite3_free(zOut); |
| 789 | 789 | sqlite3_randomness(8, &r); |
| 790 | 790 | zOut = sqlite3_mprintf("file-%08llx", r); |
| 791 | - }while( file_size(zOut)>=0 ); | |
| 791 | + }while( file_size(zOut, ExtFILE)>=0 ); | |
| 792 | 792 | blob_write_to_file(pBlob, zOut); |
| 793 | 793 | return zOut; |
| 794 | 794 | } |
| 795 | 795 | |
| 796 | 796 | /* |
| @@ -815,15 +815,11 @@ | ||
| 815 | 815 | const char *zFullpath = db_column_text(&q, 0); |
| 816 | 816 | const char *zName = db_column_text(&q, 1); |
| 817 | 817 | int rid = db_column_int(&q, 2); |
| 818 | 818 | |
| 819 | 819 | blob_zero(&disk); |
| 820 | - if( file_wd_islink(zFullpath) ){ | |
| 821 | - rc = blob_read_link(&disk, zFullpath); | |
| 822 | - }else{ | |
| 823 | - rc = blob_read_from_file(&disk, zFullpath); | |
| 824 | - } | |
| 820 | + rc = blob_read_from_file(&disk, zFullpath, RepoFILE); | |
| 825 | 821 | if( rc<0 ){ |
| 826 | 822 | fossil_print("ERROR: cannot read file [%s]\n", zFullpath); |
| 827 | 823 | blob_reset(&disk); |
| 828 | 824 | continue; |
| 829 | 825 | } |
| 830 | 826 |
| --- src/vfile.c | |
| +++ src/vfile.c | |
| @@ -202,20 +202,20 @@ | |
| 202 | rid = db_column_int(&q, 2); |
| 203 | isDeleted = db_column_int(&q, 3); |
| 204 | oldChnged = chnged = db_column_int(&q, 4); |
| 205 | oldMtime = db_column_int64(&q, 7); |
| 206 | origSize = db_column_int64(&q, 6); |
| 207 | currentSize = file_wd_size(zName); |
| 208 | currentMtime = file_wd_mtime(0); |
| 209 | #ifndef _WIN32 |
| 210 | origPerm = db_column_int(&q, 8); |
| 211 | currentPerm = file_wd_perm(zName); |
| 212 | #endif |
| 213 | if( chnged==0 && (isDeleted || rid==0) ){ |
| 214 | /* "fossil rm" or "fossil add" always change the file */ |
| 215 | chnged = 1; |
| 216 | }else if( !file_wd_isfile_or_link(0) && currentSize>=0 ){ |
| 217 | if( cksigFlags & CKSIG_ENOTFILE ){ |
| 218 | fossil_warning("not an ordinary file: %s", zName); |
| 219 | nErr++; |
| 220 | } |
| 221 | chnged = 1; |
| @@ -247,11 +247,11 @@ | |
| 247 | if( (cksigFlags & CKSIG_SETMTIME) && (chnged==0 || chnged==2 || chnged==4) ){ |
| 248 | i64 desiredMtime; |
| 249 | if( mtime_of_manifest_file(vid,rid,&desiredMtime)==0 ){ |
| 250 | if( currentMtime!=desiredMtime ){ |
| 251 | file_set_mtime(zName, desiredMtime); |
| 252 | currentMtime = file_wd_mtime(zName); |
| 253 | } |
| 254 | } |
| 255 | } |
| 256 | #ifndef _WIN32 |
| 257 | if( origPerm!=PERM_LNK && currentPerm==PERM_LNK ){ |
| @@ -316,17 +316,17 @@ | |
| 316 | isExe = db_column_int(&q, 3); |
| 317 | isLink = db_column_int(&q, 4); |
| 318 | content_get(rid, &content); |
| 319 | if( file_is_the_same(&content, zName) ){ |
| 320 | blob_reset(&content); |
| 321 | if( file_wd_setexe(zName, isExe) ){ |
| 322 | db_multi_exec("UPDATE vfile SET mtime=%lld WHERE id=%d", |
| 323 | file_wd_mtime(zName), id); |
| 324 | } |
| 325 | continue; |
| 326 | } |
| 327 | if( promptFlag && file_wd_size(zName)>=0 ){ |
| 328 | Blob ans; |
| 329 | char *zMsg; |
| 330 | char cReply; |
| 331 | zMsg = mprintf("overwrite %s (a=always/y/N)? ", zName); |
| 332 | prompt_user(zMsg, &ans); |
| @@ -339,26 +339,26 @@ | |
| 339 | blob_reset(&content); |
| 340 | continue; |
| 341 | } |
| 342 | } |
| 343 | if( verbose ) fossil_print("%s\n", &zName[nRepos]); |
| 344 | if( file_wd_isdir(zName)==1 ){ |
| 345 | /*TODO(dchest): remove directories? */ |
| 346 | fossil_fatal("%s is directory, cannot overwrite", zName); |
| 347 | } |
| 348 | if( file_wd_size(zName)>=0 && (isLink || file_wd_islink(0)) ){ |
| 349 | file_delete(zName); |
| 350 | } |
| 351 | if( isLink ){ |
| 352 | symlink_create(blob_str(&content), zName); |
| 353 | }else{ |
| 354 | blob_write_to_file(&content, zName); |
| 355 | } |
| 356 | file_wd_setexe(zName, isExe); |
| 357 | blob_reset(&content); |
| 358 | db_multi_exec("UPDATE vfile SET mtime=%lld WHERE id=%d", |
| 359 | file_wd_mtime(zName), id); |
| 360 | } |
| 361 | db_finalize(&q); |
| 362 | } |
| 363 | |
| 364 | |
| @@ -387,15 +387,15 @@ | |
| 387 | int vfile_top_of_checkout(const char *zPath){ |
| 388 | char *zFile; |
| 389 | int fileFound = 0; |
| 390 | |
| 391 | zFile = mprintf("%s/_FOSSIL_", zPath); |
| 392 | fileFound = file_size(zFile)>=1024; |
| 393 | fossil_free(zFile); |
| 394 | if( !fileFound ){ |
| 395 | zFile = mprintf("%s/.fslckout", zPath); |
| 396 | fileFound = file_size(zFile)>=1024; |
| 397 | fossil_free(zFile); |
| 398 | } |
| 399 | |
| 400 | /* Check for ".fos" for legacy support. But the use of ".fos" as the |
| 401 | ** per-checkout database name is deprecated. At some point, all support |
| @@ -402,11 +402,11 @@ | |
| 402 | ** for ".fos" will end and this code should be removed. This comment |
| 403 | ** added on 2012-02-04. |
| 404 | */ |
| 405 | if( !fileFound ){ |
| 406 | zFile = mprintf("%s/.fos", zPath); |
| 407 | fileFound = file_size(zFile)>=1024; |
| 408 | fossil_free(zFile); |
| 409 | } |
| 410 | return fileFound; |
| 411 | } |
| 412 | |
| @@ -522,30 +522,30 @@ | |
| 522 | if( glob_match(pIgnore1, &zPath[nPrefix+1]) || |
| 523 | glob_match(pIgnore2, &zPath[nPrefix+1]) ){ |
| 524 | /* do nothing */ |
| 525 | #ifdef _DIRENT_HAVE_D_TYPE |
| 526 | }else if( (pEntry->d_type==DT_UNKNOWN || pEntry->d_type==DT_LNK) |
| 527 | ? (file_wd_isdir(zPath)==1) : (pEntry->d_type==DT_DIR) ){ |
| 528 | #else |
| 529 | }else if( file_wd_isdir(zPath)==1 ){ |
| 530 | #endif |
| 531 | if( !vfile_top_of_checkout(zPath) ){ |
| 532 | vfile_scan(pPath, nPrefix, scanFlags, pIgnore1, pIgnore2); |
| 533 | } |
| 534 | #ifdef _DIRENT_HAVE_D_TYPE |
| 535 | }else if( (pEntry->d_type==DT_UNKNOWN || pEntry->d_type==DT_LNK) |
| 536 | ? (file_wd_isfile_or_link(zPath)) : (pEntry->d_type==DT_REG) ){ |
| 537 | #else |
| 538 | }else if( file_wd_isfile_or_link(zPath) ){ |
| 539 | #endif |
| 540 | if( (scanFlags & SCAN_TEMP)==0 || is_temporary_file(zUtf8) ){ |
| 541 | db_bind_text(&ins, ":file", &zPath[nPrefix+1]); |
| 542 | if( scanFlags & SCAN_MTIME ){ |
| 543 | db_bind_int(&ins, ":mtime", file_mtime(zPath)); |
| 544 | } |
| 545 | if( scanFlags & SCAN_SIZE ){ |
| 546 | db_bind_int(&ins, ":size", file_size(zPath)); |
| 547 | } |
| 548 | db_step(&ins); |
| 549 | db_reset(&ins); |
| 550 | } |
| 551 | } |
| @@ -642,13 +642,13 @@ | |
| 642 | if( glob_match(pIgnore1, &zPath[nPrefix+1]) || |
| 643 | glob_match(pIgnore2, &zPath[nPrefix+1]) ){ |
| 644 | /* do nothing */ |
| 645 | #ifdef _DIRENT_HAVE_D_TYPE |
| 646 | }else if( (pEntry->d_type==DT_UNKNOWN || pEntry->d_type==DT_LNK) |
| 647 | ? (file_wd_isdir(zPath)==1) : (pEntry->d_type==DT_DIR) ){ |
| 648 | #else |
| 649 | }else if( file_wd_isdir(zPath)==1 ){ |
| 650 | #endif |
| 651 | if( (scanFlags & SCAN_NESTED) || !vfile_top_of_checkout(zPath) ){ |
| 652 | char *zSavePath = mprintf("%s", zPath); |
| 653 | int count = vfile_dir_scan(pPath, nPrefix, scanFlags, pIgnore1, |
| 654 | pIgnore2); |
| @@ -659,13 +659,13 @@ | |
| 659 | fossil_free(zSavePath); |
| 660 | result += count; /* found X normal files? */ |
| 661 | } |
| 662 | #ifdef _DIRENT_HAVE_D_TYPE |
| 663 | }else if( (pEntry->d_type==DT_UNKNOWN || pEntry->d_type==DT_LNK) |
| 664 | ? (file_wd_isfile_or_link(zPath)) : (pEntry->d_type==DT_REG) ){ |
| 665 | #else |
| 666 | }else if( file_wd_isfile_or_link(zPath) ){ |
| 667 | #endif |
| 668 | db_bind_text(&upd, ":file", zOrigPath); |
| 669 | db_step(&upd); |
| 670 | db_reset(&upd); |
| 671 | result++; /* found 1 normal file */ |
| @@ -726,11 +726,11 @@ | |
| 726 | const char *zName = db_column_text(&q, 1); |
| 727 | int isSelected = db_column_int(&q, 3); |
| 728 | |
| 729 | if( isSelected ){ |
| 730 | md5sum_step_text(zName, -1); |
| 731 | if( file_wd_islink(zFullpath) ){ |
| 732 | /* Instead of file content, use link destination path */ |
| 733 | Blob pathBuf; |
| 734 | |
| 735 | sqlite3_snprintf(sizeof(zBuf), zBuf, " %ld\n", |
| 736 | blob_read_link(&pathBuf, zFullpath)); |
| @@ -786,11 +786,11 @@ | |
| 786 | char *zOut = 0; |
| 787 | do{ |
| 788 | sqlite3_free(zOut); |
| 789 | sqlite3_randomness(8, &r); |
| 790 | zOut = sqlite3_mprintf("file-%08llx", r); |
| 791 | }while( file_size(zOut)>=0 ); |
| 792 | blob_write_to_file(pBlob, zOut); |
| 793 | return zOut; |
| 794 | } |
| 795 | |
| 796 | /* |
| @@ -815,15 +815,11 @@ | |
| 815 | const char *zFullpath = db_column_text(&q, 0); |
| 816 | const char *zName = db_column_text(&q, 1); |
| 817 | int rid = db_column_int(&q, 2); |
| 818 | |
| 819 | blob_zero(&disk); |
| 820 | if( file_wd_islink(zFullpath) ){ |
| 821 | rc = blob_read_link(&disk, zFullpath); |
| 822 | }else{ |
| 823 | rc = blob_read_from_file(&disk, zFullpath); |
| 824 | } |
| 825 | if( rc<0 ){ |
| 826 | fossil_print("ERROR: cannot read file [%s]\n", zFullpath); |
| 827 | blob_reset(&disk); |
| 828 | continue; |
| 829 | } |
| 830 |
| --- src/vfile.c | |
| +++ src/vfile.c | |
| @@ -202,20 +202,20 @@ | |
| 202 | rid = db_column_int(&q, 2); |
| 203 | isDeleted = db_column_int(&q, 3); |
| 204 | oldChnged = chnged = db_column_int(&q, 4); |
| 205 | oldMtime = db_column_int64(&q, 7); |
| 206 | origSize = db_column_int64(&q, 6); |
| 207 | currentSize = file_size(zName, RepoFILE); |
| 208 | currentMtime = file_mtime(0, 0); |
| 209 | #ifndef _WIN32 |
| 210 | origPerm = db_column_int(&q, 8); |
| 211 | currentPerm = file_perm(zName, RepoFILE); |
| 212 | #endif |
| 213 | if( chnged==0 && (isDeleted || rid==0) ){ |
| 214 | /* "fossil rm" or "fossil add" always change the file */ |
| 215 | chnged = 1; |
| 216 | }else if( !file_isfile_or_link(0) && currentSize>=0 ){ |
| 217 | if( cksigFlags & CKSIG_ENOTFILE ){ |
| 218 | fossil_warning("not an ordinary file: %s", zName); |
| 219 | nErr++; |
| 220 | } |
| 221 | chnged = 1; |
| @@ -247,11 +247,11 @@ | |
| 247 | if( (cksigFlags & CKSIG_SETMTIME) && (chnged==0 || chnged==2 || chnged==4) ){ |
| 248 | i64 desiredMtime; |
| 249 | if( mtime_of_manifest_file(vid,rid,&desiredMtime)==0 ){ |
| 250 | if( currentMtime!=desiredMtime ){ |
| 251 | file_set_mtime(zName, desiredMtime); |
| 252 | currentMtime = file_mtime(zName, RepoFILE); |
| 253 | } |
| 254 | } |
| 255 | } |
| 256 | #ifndef _WIN32 |
| 257 | if( origPerm!=PERM_LNK && currentPerm==PERM_LNK ){ |
| @@ -316,17 +316,17 @@ | |
| 316 | isExe = db_column_int(&q, 3); |
| 317 | isLink = db_column_int(&q, 4); |
| 318 | content_get(rid, &content); |
| 319 | if( file_is_the_same(&content, zName) ){ |
| 320 | blob_reset(&content); |
| 321 | if( file_setexe(zName, isExe) ){ |
| 322 | db_multi_exec("UPDATE vfile SET mtime=%lld WHERE id=%d", |
| 323 | file_mtime(zName, RepoFILE), id); |
| 324 | } |
| 325 | continue; |
| 326 | } |
| 327 | if( promptFlag && file_size(zName, RepoFILE)>=0 ){ |
| 328 | Blob ans; |
| 329 | char *zMsg; |
| 330 | char cReply; |
| 331 | zMsg = mprintf("overwrite %s (a=always/y/N)? ", zName); |
| 332 | prompt_user(zMsg, &ans); |
| @@ -339,26 +339,26 @@ | |
| 339 | blob_reset(&content); |
| 340 | continue; |
| 341 | } |
| 342 | } |
| 343 | if( verbose ) fossil_print("%s\n", &zName[nRepos]); |
| 344 | if( file_isdir(zName, RepoFILE)==1 ){ |
| 345 | /*TODO(dchest): remove directories? */ |
| 346 | fossil_fatal("%s is directory, cannot overwrite", zName); |
| 347 | } |
| 348 | if( file_size(zName, RepoFILE)>=0 && (isLink || file_islink(0)) ){ |
| 349 | file_delete(zName); |
| 350 | } |
| 351 | if( isLink ){ |
| 352 | symlink_create(blob_str(&content), zName); |
| 353 | }else{ |
| 354 | blob_write_to_file(&content, zName); |
| 355 | } |
| 356 | file_setexe(zName, isExe); |
| 357 | blob_reset(&content); |
| 358 | db_multi_exec("UPDATE vfile SET mtime=%lld WHERE id=%d", |
| 359 | file_mtime(zName, RepoFILE), id); |
| 360 | } |
| 361 | db_finalize(&q); |
| 362 | } |
| 363 | |
| 364 | |
| @@ -387,15 +387,15 @@ | |
| 387 | int vfile_top_of_checkout(const char *zPath){ |
| 388 | char *zFile; |
| 389 | int fileFound = 0; |
| 390 | |
| 391 | zFile = mprintf("%s/_FOSSIL_", zPath); |
| 392 | fileFound = file_size(zFile, ExtFILE)>=1024; |
| 393 | fossil_free(zFile); |
| 394 | if( !fileFound ){ |
| 395 | zFile = mprintf("%s/.fslckout", zPath); |
| 396 | fileFound = file_size(zFile, ExtFILE)>=1024; |
| 397 | fossil_free(zFile); |
| 398 | } |
| 399 | |
| 400 | /* Check for ".fos" for legacy support. But the use of ".fos" as the |
| 401 | ** per-checkout database name is deprecated. At some point, all support |
| @@ -402,11 +402,11 @@ | |
| 402 | ** for ".fos" will end and this code should be removed. This comment |
| 403 | ** added on 2012-02-04. |
| 404 | */ |
| 405 | if( !fileFound ){ |
| 406 | zFile = mprintf("%s/.fos", zPath); |
| 407 | fileFound = file_size(zFile, ExtFILE)>=1024; |
| 408 | fossil_free(zFile); |
| 409 | } |
| 410 | return fileFound; |
| 411 | } |
| 412 | |
| @@ -522,30 +522,30 @@ | |
| 522 | if( glob_match(pIgnore1, &zPath[nPrefix+1]) || |
| 523 | glob_match(pIgnore2, &zPath[nPrefix+1]) ){ |
| 524 | /* do nothing */ |
| 525 | #ifdef _DIRENT_HAVE_D_TYPE |
| 526 | }else if( (pEntry->d_type==DT_UNKNOWN || pEntry->d_type==DT_LNK) |
| 527 | ? (file_isdir(zPath, RepoFILE)==1) : (pEntry->d_type==DT_DIR) ){ |
| 528 | #else |
| 529 | }else if( file_isdir(zPath, RepoFILE)==1 ){ |
| 530 | #endif |
| 531 | if( !vfile_top_of_checkout(zPath) ){ |
| 532 | vfile_scan(pPath, nPrefix, scanFlags, pIgnore1, pIgnore2); |
| 533 | } |
| 534 | #ifdef _DIRENT_HAVE_D_TYPE |
| 535 | }else if( (pEntry->d_type==DT_UNKNOWN || pEntry->d_type==DT_LNK) |
| 536 | ? (file_isfile_or_link(zPath)) : (pEntry->d_type==DT_REG) ){ |
| 537 | #else |
| 538 | }else if( file_isfile_or_link(zPath) ){ |
| 539 | #endif |
| 540 | if( (scanFlags & SCAN_TEMP)==0 || is_temporary_file(zUtf8) ){ |
| 541 | db_bind_text(&ins, ":file", &zPath[nPrefix+1]); |
| 542 | if( scanFlags & SCAN_MTIME ){ |
| 543 | db_bind_int(&ins, ":mtime", file_mtime(zPath, RepoFILE)); |
| 544 | } |
| 545 | if( scanFlags & SCAN_SIZE ){ |
| 546 | db_bind_int(&ins, ":size", file_size(zPath, RepoFILE)); |
| 547 | } |
| 548 | db_step(&ins); |
| 549 | db_reset(&ins); |
| 550 | } |
| 551 | } |
| @@ -642,13 +642,13 @@ | |
| 642 | if( glob_match(pIgnore1, &zPath[nPrefix+1]) || |
| 643 | glob_match(pIgnore2, &zPath[nPrefix+1]) ){ |
| 644 | /* do nothing */ |
| 645 | #ifdef _DIRENT_HAVE_D_TYPE |
| 646 | }else if( (pEntry->d_type==DT_UNKNOWN || pEntry->d_type==DT_LNK) |
| 647 | ? (file_isdir(zPath, RepoFILE)==1) : (pEntry->d_type==DT_DIR) ){ |
| 648 | #else |
| 649 | }else if( file_isdir(zPath, RepoFILE)==1 ){ |
| 650 | #endif |
| 651 | if( (scanFlags & SCAN_NESTED) || !vfile_top_of_checkout(zPath) ){ |
| 652 | char *zSavePath = mprintf("%s", zPath); |
| 653 | int count = vfile_dir_scan(pPath, nPrefix, scanFlags, pIgnore1, |
| 654 | pIgnore2); |
| @@ -659,13 +659,13 @@ | |
| 659 | fossil_free(zSavePath); |
| 660 | result += count; /* found X normal files? */ |
| 661 | } |
| 662 | #ifdef _DIRENT_HAVE_D_TYPE |
| 663 | }else if( (pEntry->d_type==DT_UNKNOWN || pEntry->d_type==DT_LNK) |
| 664 | ? (file_isfile_or_link(zPath)) : (pEntry->d_type==DT_REG) ){ |
| 665 | #else |
| 666 | }else if( file_isfile_or_link(zPath) ){ |
| 667 | #endif |
| 668 | db_bind_text(&upd, ":file", zOrigPath); |
| 669 | db_step(&upd); |
| 670 | db_reset(&upd); |
| 671 | result++; /* found 1 normal file */ |
| @@ -726,11 +726,11 @@ | |
| 726 | const char *zName = db_column_text(&q, 1); |
| 727 | int isSelected = db_column_int(&q, 3); |
| 728 | |
| 729 | if( isSelected ){ |
| 730 | md5sum_step_text(zName, -1); |
| 731 | if( file_islink(zFullpath) ){ |
| 732 | /* Instead of file content, use link destination path */ |
| 733 | Blob pathBuf; |
| 734 | |
| 735 | sqlite3_snprintf(sizeof(zBuf), zBuf, " %ld\n", |
| 736 | blob_read_link(&pathBuf, zFullpath)); |
| @@ -786,11 +786,11 @@ | |
| 786 | char *zOut = 0; |
| 787 | do{ |
| 788 | sqlite3_free(zOut); |
| 789 | sqlite3_randomness(8, &r); |
| 790 | zOut = sqlite3_mprintf("file-%08llx", r); |
| 791 | }while( file_size(zOut, ExtFILE)>=0 ); |
| 792 | blob_write_to_file(pBlob, zOut); |
| 793 | return zOut; |
| 794 | } |
| 795 | |
| 796 | /* |
| @@ -815,15 +815,11 @@ | |
| 815 | const char *zFullpath = db_column_text(&q, 0); |
| 816 | const char *zName = db_column_text(&q, 1); |
| 817 | int rid = db_column_int(&q, 2); |
| 818 | |
| 819 | blob_zero(&disk); |
| 820 | rc = blob_read_from_file(&disk, zFullpath, RepoFILE); |
| 821 | if( rc<0 ){ |
| 822 | fossil_print("ERROR: cannot read file [%s]\n", zFullpath); |
| 823 | blob_reset(&disk); |
| 824 | continue; |
| 825 | } |
| 826 |
+2
-2
| --- src/wiki.c | ||
| +++ src/wiki.c | ||
| @@ -1251,11 +1251,11 @@ | ||
| 1251 | 1251 | } |
| 1252 | 1252 | zPageName = g.argv[3]; |
| 1253 | 1253 | if( g.argc==4 ){ |
| 1254 | 1254 | blob_read_from_channel(&content, stdin, -1); |
| 1255 | 1255 | }else{ |
| 1256 | - blob_read_from_file(&content, g.argv[4]); | |
| 1256 | + blob_read_from_file(&content, g.argv[4], ExtFILE); | |
| 1257 | 1257 | } |
| 1258 | 1258 | if( !zMimeType || !*zMimeType ){ |
| 1259 | 1259 | /* Try to deduce the mime type based on the prior version. */ |
| 1260 | 1260 | if ( !zETime ){ |
| 1261 | 1261 | rid = db_int(0, "SELECT x.rid FROM tag t, tagxref x" |
| @@ -1375,9 +1375,9 @@ | ||
| 1375 | 1375 | void test_markdown_render(void){ |
| 1376 | 1376 | Blob in, out; |
| 1377 | 1377 | verify_all_options(); |
| 1378 | 1378 | if( g.argc!=3 ) usage("FILE"); |
| 1379 | 1379 | blob_zero(&out); |
| 1380 | - blob_read_from_file(&in, g.argv[2]); | |
| 1380 | + blob_read_from_file(&in, g.argv[2], ExtFILE); | |
| 1381 | 1381 | markdown_to_html(&in, 0, &out); |
| 1382 | 1382 | blob_write_to_file(&out, "-"); |
| 1383 | 1383 | } |
| 1384 | 1384 |
| --- src/wiki.c | |
| +++ src/wiki.c | |
| @@ -1251,11 +1251,11 @@ | |
| 1251 | } |
| 1252 | zPageName = g.argv[3]; |
| 1253 | if( g.argc==4 ){ |
| 1254 | blob_read_from_channel(&content, stdin, -1); |
| 1255 | }else{ |
| 1256 | blob_read_from_file(&content, g.argv[4]); |
| 1257 | } |
| 1258 | if( !zMimeType || !*zMimeType ){ |
| 1259 | /* Try to deduce the mime type based on the prior version. */ |
| 1260 | if ( !zETime ){ |
| 1261 | rid = db_int(0, "SELECT x.rid FROM tag t, tagxref x" |
| @@ -1375,9 +1375,9 @@ | |
| 1375 | void test_markdown_render(void){ |
| 1376 | Blob in, out; |
| 1377 | verify_all_options(); |
| 1378 | if( g.argc!=3 ) usage("FILE"); |
| 1379 | blob_zero(&out); |
| 1380 | blob_read_from_file(&in, g.argv[2]); |
| 1381 | markdown_to_html(&in, 0, &out); |
| 1382 | blob_write_to_file(&out, "-"); |
| 1383 | } |
| 1384 |
| --- src/wiki.c | |
| +++ src/wiki.c | |
| @@ -1251,11 +1251,11 @@ | |
| 1251 | } |
| 1252 | zPageName = g.argv[3]; |
| 1253 | if( g.argc==4 ){ |
| 1254 | blob_read_from_channel(&content, stdin, -1); |
| 1255 | }else{ |
| 1256 | blob_read_from_file(&content, g.argv[4], ExtFILE); |
| 1257 | } |
| 1258 | if( !zMimeType || !*zMimeType ){ |
| 1259 | /* Try to deduce the mime type based on the prior version. */ |
| 1260 | if ( !zETime ){ |
| 1261 | rid = db_int(0, "SELECT x.rid FROM tag t, tagxref x" |
| @@ -1375,9 +1375,9 @@ | |
| 1375 | void test_markdown_render(void){ |
| 1376 | Blob in, out; |
| 1377 | verify_all_options(); |
| 1378 | if( g.argc!=3 ) usage("FILE"); |
| 1379 | blob_zero(&out); |
| 1380 | blob_read_from_file(&in, g.argv[2], ExtFILE); |
| 1381 | markdown_to_html(&in, 0, &out); |
| 1382 | blob_write_to_file(&out, "-"); |
| 1383 | } |
| 1384 |
+3
-3
| --- src/wikiformat.c | ||
| +++ src/wikiformat.c | ||
| @@ -1741,11 +1741,11 @@ | ||
| 1741 | 1741 | if( find_option("inline",0,0)!=0 ) flags |= WIKI_INLINE; |
| 1742 | 1742 | if( find_option("noblock",0,0)!=0 ) flags |= WIKI_NOBLOCK; |
| 1743 | 1743 | verify_all_options(); |
| 1744 | 1744 | if( g.argc!=3 ) usage("FILE"); |
| 1745 | 1745 | blob_zero(&out); |
| 1746 | - blob_read_from_file(&in, g.argv[2]); | |
| 1746 | + blob_read_from_file(&in, g.argv[2], ExtFILE); | |
| 1747 | 1747 | wiki_convert(&in, &out, flags); |
| 1748 | 1748 | blob_write_to_file(&out, "-"); |
| 1749 | 1749 | } |
| 1750 | 1750 | |
| 1751 | 1751 | /* |
| @@ -2104,11 +2104,11 @@ | ||
| 2104 | 2104 | void test_html_tidy(void){ |
| 2105 | 2105 | Blob in, out; |
| 2106 | 2106 | int i; |
| 2107 | 2107 | |
| 2108 | 2108 | for(i=2; i<g.argc; i++){ |
| 2109 | - blob_read_from_file(&in, g.argv[i]); | |
| 2109 | + blob_read_from_file(&in, g.argv[i], ExtFILE); | |
| 2110 | 2110 | blob_zero(&out); |
| 2111 | 2111 | htmlTidy(blob_str(&in), &out); |
| 2112 | 2112 | blob_reset(&in); |
| 2113 | 2113 | fossil_puts(blob_str(&out), 0); |
| 2114 | 2114 | blob_reset(&out); |
| @@ -2231,13 +2231,13 @@ | ||
| 2231 | 2231 | void test_html_to_text(void){ |
| 2232 | 2232 | Blob in, out; |
| 2233 | 2233 | int i; |
| 2234 | 2234 | |
| 2235 | 2235 | for(i=2; i<g.argc; i++){ |
| 2236 | - blob_read_from_file(&in, g.argv[i]); | |
| 2236 | + blob_read_from_file(&in, g.argv[i], ExtFILE); | |
| 2237 | 2237 | blob_zero(&out); |
| 2238 | 2238 | html_to_plaintext(blob_str(&in), &out); |
| 2239 | 2239 | blob_reset(&in); |
| 2240 | 2240 | fossil_puts(blob_str(&out), 0); |
| 2241 | 2241 | blob_reset(&out); |
| 2242 | 2242 | } |
| 2243 | 2243 | } |
| 2244 | 2244 |
| --- src/wikiformat.c | |
| +++ src/wikiformat.c | |
| @@ -1741,11 +1741,11 @@ | |
| 1741 | if( find_option("inline",0,0)!=0 ) flags |= WIKI_INLINE; |
| 1742 | if( find_option("noblock",0,0)!=0 ) flags |= WIKI_NOBLOCK; |
| 1743 | verify_all_options(); |
| 1744 | if( g.argc!=3 ) usage("FILE"); |
| 1745 | blob_zero(&out); |
| 1746 | blob_read_from_file(&in, g.argv[2]); |
| 1747 | wiki_convert(&in, &out, flags); |
| 1748 | blob_write_to_file(&out, "-"); |
| 1749 | } |
| 1750 | |
| 1751 | /* |
| @@ -2104,11 +2104,11 @@ | |
| 2104 | void test_html_tidy(void){ |
| 2105 | Blob in, out; |
| 2106 | int i; |
| 2107 | |
| 2108 | for(i=2; i<g.argc; i++){ |
| 2109 | blob_read_from_file(&in, g.argv[i]); |
| 2110 | blob_zero(&out); |
| 2111 | htmlTidy(blob_str(&in), &out); |
| 2112 | blob_reset(&in); |
| 2113 | fossil_puts(blob_str(&out), 0); |
| 2114 | blob_reset(&out); |
| @@ -2231,13 +2231,13 @@ | |
| 2231 | void test_html_to_text(void){ |
| 2232 | Blob in, out; |
| 2233 | int i; |
| 2234 | |
| 2235 | for(i=2; i<g.argc; i++){ |
| 2236 | blob_read_from_file(&in, g.argv[i]); |
| 2237 | blob_zero(&out); |
| 2238 | html_to_plaintext(blob_str(&in), &out); |
| 2239 | blob_reset(&in); |
| 2240 | fossil_puts(blob_str(&out), 0); |
| 2241 | blob_reset(&out); |
| 2242 | } |
| 2243 | } |
| 2244 |
| --- src/wikiformat.c | |
| +++ src/wikiformat.c | |
| @@ -1741,11 +1741,11 @@ | |
| 1741 | if( find_option("inline",0,0)!=0 ) flags |= WIKI_INLINE; |
| 1742 | if( find_option("noblock",0,0)!=0 ) flags |= WIKI_NOBLOCK; |
| 1743 | verify_all_options(); |
| 1744 | if( g.argc!=3 ) usage("FILE"); |
| 1745 | blob_zero(&out); |
| 1746 | blob_read_from_file(&in, g.argv[2], ExtFILE); |
| 1747 | wiki_convert(&in, &out, flags); |
| 1748 | blob_write_to_file(&out, "-"); |
| 1749 | } |
| 1750 | |
| 1751 | /* |
| @@ -2104,11 +2104,11 @@ | |
| 2104 | void test_html_tidy(void){ |
| 2105 | Blob in, out; |
| 2106 | int i; |
| 2107 | |
| 2108 | for(i=2; i<g.argc; i++){ |
| 2109 | blob_read_from_file(&in, g.argv[i], ExtFILE); |
| 2110 | blob_zero(&out); |
| 2111 | htmlTidy(blob_str(&in), &out); |
| 2112 | blob_reset(&in); |
| 2113 | fossil_puts(blob_str(&out), 0); |
| 2114 | blob_reset(&out); |
| @@ -2231,13 +2231,13 @@ | |
| 2231 | void test_html_to_text(void){ |
| 2232 | Blob in, out; |
| 2233 | int i; |
| 2234 | |
| 2235 | for(i=2; i<g.argc; i++){ |
| 2236 | blob_read_from_file(&in, g.argv[i], ExtFILE); |
| 2237 | blob_zero(&out); |
| 2238 | html_to_plaintext(blob_str(&in), &out); |
| 2239 | blob_reset(&in); |
| 2240 | fossil_puts(blob_str(&out), 0); |
| 2241 | blob_reset(&out); |
| 2242 | } |
| 2243 | } |
| 2244 |
+4
-3
| --- src/winfile.c | ||
| +++ src/winfile.c | ||
| @@ -29,14 +29,15 @@ | ||
| 29 | 29 | # define LABEL_SECURITY_INFORMATION (0x00000010L) |
| 30 | 30 | #endif |
| 31 | 31 | |
| 32 | 32 | /* |
| 33 | 33 | ** Fill stat buf with information received from stat() or lstat(). |
| 34 | -** lstat() is called on Unix if isWd is TRUE and allow-symlinks setting is on. | |
| 35 | -** | |
| 34 | +** lstat() is called on Unix if eFType is RepoFile and the allow-symlinks | |
| 35 | +** setting is on. But as windows does not support symbolic links, the | |
| 36 | +** eFType parameter is ignored here. | |
| 36 | 37 | */ |
| 37 | -int win32_stat(const wchar_t *zFilename, struct fossilStat *buf, int isWd){ | |
| 38 | +int win32_stat(const wchar_t *zFilename, struct fossilStat *buf, int eFType){ | |
| 38 | 39 | WIN32_FILE_ATTRIBUTE_DATA attr; |
| 39 | 40 | int rc = GetFileAttributesExW(zFilename, GetFileExInfoStandard, &attr); |
| 40 | 41 | if( rc ){ |
| 41 | 42 | ULARGE_INTEGER ull; |
| 42 | 43 | ull.LowPart = attr.ftLastWriteTime.dwLowDateTime; |
| 43 | 44 |
| --- src/winfile.c | |
| +++ src/winfile.c | |
| @@ -29,14 +29,15 @@ | |
| 29 | # define LABEL_SECURITY_INFORMATION (0x00000010L) |
| 30 | #endif |
| 31 | |
| 32 | /* |
| 33 | ** Fill stat buf with information received from stat() or lstat(). |
| 34 | ** lstat() is called on Unix if isWd is TRUE and allow-symlinks setting is on. |
| 35 | ** |
| 36 | */ |
| 37 | int win32_stat(const wchar_t *zFilename, struct fossilStat *buf, int isWd){ |
| 38 | WIN32_FILE_ATTRIBUTE_DATA attr; |
| 39 | int rc = GetFileAttributesExW(zFilename, GetFileExInfoStandard, &attr); |
| 40 | if( rc ){ |
| 41 | ULARGE_INTEGER ull; |
| 42 | ull.LowPart = attr.ftLastWriteTime.dwLowDateTime; |
| 43 |
| --- src/winfile.c | |
| +++ src/winfile.c | |
| @@ -29,14 +29,15 @@ | |
| 29 | # define LABEL_SECURITY_INFORMATION (0x00000010L) |
| 30 | #endif |
| 31 | |
| 32 | /* |
| 33 | ** Fill stat buf with information received from stat() or lstat(). |
| 34 | ** lstat() is called on Unix if eFType is RepoFile and the allow-symlinks |
| 35 | ** setting is on. But as windows does not support symbolic links, the |
| 36 | ** eFType parameter is ignored here. |
| 37 | */ |
| 38 | int win32_stat(const wchar_t *zFilename, struct fossilStat *buf, int eFType){ |
| 39 | WIN32_FILE_ATTRIBUTE_DATA attr; |
| 40 | int rc = GetFileAttributesExW(zFilename, GetFileExInfoStandard, &attr); |
| 41 | if( rc ){ |
| 42 | ULARGE_INTEGER ull; |
| 43 | ull.LowPart = attr.ftLastWriteTime.dwLowDateTime; |
| 44 |
+2
-2
| --- src/winhttp.c | ||
| +++ src/winhttp.c | ||
| @@ -105,11 +105,11 @@ | ||
| 105 | 105 | /* The event is either invalid, signaled, or abandoned. Bail |
| 106 | 106 | ** out now because those conditions should indicate the parent |
| 107 | 107 | ** thread is dead or dying. */ |
| 108 | 108 | break; |
| 109 | 109 | } |
| 110 | - if( file_size(zStopper)>=0 ){ | |
| 110 | + if( file_size(zStopper, ExtFILE)>=0 ){ | |
| 111 | 111 | /* The stopper file has been found. Attempt to close the server |
| 112 | 112 | ** listener socket now and then exit. */ |
| 113 | 113 | closesocket(listener); |
| 114 | 114 | p->listener = INVALID_SOCKET; |
| 115 | 115 | break; |
| @@ -852,11 +852,11 @@ | ||
| 852 | 852 | winhttp_fatal("create", zSvcName, |
| 853 | 853 | "port number must be in the range 1 - 65535."); |
| 854 | 854 | } |
| 855 | 855 | if( !zRepository ){ |
| 856 | 856 | db_must_be_within_tree(); |
| 857 | - }else if( file_isdir(zRepository)==1 ){ | |
| 857 | + }else if( file_isdir(zRepository, ExtFILE)==1 ){ | |
| 858 | 858 | g.zRepositoryName = mprintf("%s", zRepository); |
| 859 | 859 | file_simplify_name(g.zRepositoryName, -1, 0); |
| 860 | 860 | }else{ |
| 861 | 861 | db_open_repository(zRepository); |
| 862 | 862 | } |
| 863 | 863 |
| --- src/winhttp.c | |
| +++ src/winhttp.c | |
| @@ -105,11 +105,11 @@ | |
| 105 | /* The event is either invalid, signaled, or abandoned. Bail |
| 106 | ** out now because those conditions should indicate the parent |
| 107 | ** thread is dead or dying. */ |
| 108 | break; |
| 109 | } |
| 110 | if( file_size(zStopper)>=0 ){ |
| 111 | /* The stopper file has been found. Attempt to close the server |
| 112 | ** listener socket now and then exit. */ |
| 113 | closesocket(listener); |
| 114 | p->listener = INVALID_SOCKET; |
| 115 | break; |
| @@ -852,11 +852,11 @@ | |
| 852 | winhttp_fatal("create", zSvcName, |
| 853 | "port number must be in the range 1 - 65535."); |
| 854 | } |
| 855 | if( !zRepository ){ |
| 856 | db_must_be_within_tree(); |
| 857 | }else if( file_isdir(zRepository)==1 ){ |
| 858 | g.zRepositoryName = mprintf("%s", zRepository); |
| 859 | file_simplify_name(g.zRepositoryName, -1, 0); |
| 860 | }else{ |
| 861 | db_open_repository(zRepository); |
| 862 | } |
| 863 |
| --- src/winhttp.c | |
| +++ src/winhttp.c | |
| @@ -105,11 +105,11 @@ | |
| 105 | /* The event is either invalid, signaled, or abandoned. Bail |
| 106 | ** out now because those conditions should indicate the parent |
| 107 | ** thread is dead or dying. */ |
| 108 | break; |
| 109 | } |
| 110 | if( file_size(zStopper, ExtFILE)>=0 ){ |
| 111 | /* The stopper file has been found. Attempt to close the server |
| 112 | ** listener socket now and then exit. */ |
| 113 | closesocket(listener); |
| 114 | p->listener = INVALID_SOCKET; |
| 115 | break; |
| @@ -852,11 +852,11 @@ | |
| 852 | winhttp_fatal("create", zSvcName, |
| 853 | "port number must be in the range 1 - 65535."); |
| 854 | } |
| 855 | if( !zRepository ){ |
| 856 | db_must_be_within_tree(); |
| 857 | }else if( file_isdir(zRepository, ExtFILE)==1 ){ |
| 858 | g.zRepositoryName = mprintf("%s", zRepository); |
| 859 | file_simplify_name(g.zRepositoryName, -1, 0); |
| 860 | }else{ |
| 861 | db_open_repository(zRepository); |
| 862 | } |
| 863 |
+1
-1
| --- src/xfer.c | ||
| +++ src/xfer.c | ||
| @@ -1625,11 +1625,11 @@ | ||
| 1625 | 1625 | db_find_and_open_repository(0,0); |
| 1626 | 1626 | if( g.argc!=2 && g.argc!=3 ){ |
| 1627 | 1627 | usage("?MESSAGEFILE?"); |
| 1628 | 1628 | } |
| 1629 | 1629 | blob_zero(&g.cgiIn); |
| 1630 | - blob_read_from_file(&g.cgiIn, g.argc==2 ? "-" : g.argv[2]); | |
| 1630 | + blob_read_from_file(&g.cgiIn, g.argc==2 ? "-" : g.argv[2], ExtFILE); | |
| 1631 | 1631 | disableLogin = 1; |
| 1632 | 1632 | page_xfer(); |
| 1633 | 1633 | fossil_print("%s\n", cgi_extract_content()); |
| 1634 | 1634 | } |
| 1635 | 1635 | |
| 1636 | 1636 |
| --- src/xfer.c | |
| +++ src/xfer.c | |
| @@ -1625,11 +1625,11 @@ | |
| 1625 | db_find_and_open_repository(0,0); |
| 1626 | if( g.argc!=2 && g.argc!=3 ){ |
| 1627 | usage("?MESSAGEFILE?"); |
| 1628 | } |
| 1629 | blob_zero(&g.cgiIn); |
| 1630 | blob_read_from_file(&g.cgiIn, g.argc==2 ? "-" : g.argv[2]); |
| 1631 | disableLogin = 1; |
| 1632 | page_xfer(); |
| 1633 | fossil_print("%s\n", cgi_extract_content()); |
| 1634 | } |
| 1635 | |
| 1636 |
| --- src/xfer.c | |
| +++ src/xfer.c | |
| @@ -1625,11 +1625,11 @@ | |
| 1625 | db_find_and_open_repository(0,0); |
| 1626 | if( g.argc!=2 && g.argc!=3 ){ |
| 1627 | usage("?MESSAGEFILE?"); |
| 1628 | } |
| 1629 | blob_zero(&g.cgiIn); |
| 1630 | blob_read_from_file(&g.cgiIn, g.argc==2 ? "-" : g.argv[2], ExtFILE); |
| 1631 | disableLogin = 1; |
| 1632 | page_xfer(); |
| 1633 | fossil_print("%s\n", cgi_extract_content()); |
| 1634 | } |
| 1635 | |
| 1636 |
+6
-2
| --- src/zip.c | ||
| +++ src/zip.c | ||
| @@ -289,18 +289,22 @@ | ||
| 289 | 289 | */ |
| 290 | 290 | void filezip_cmd(void){ |
| 291 | 291 | int i; |
| 292 | 292 | Blob zip; |
| 293 | 293 | Blob file; |
| 294 | + int eFType = SymFILE; | |
| 294 | 295 | if( g.argc<3 ){ |
| 295 | 296 | usage("ARCHIVE FILE...."); |
| 297 | + } | |
| 298 | + if( find_option("dereference","h",0)!=0 ){ | |
| 299 | + eFType = ExtFILE; | |
| 296 | 300 | } |
| 297 | 301 | zip_open(); |
| 298 | 302 | for(i=3; i<g.argc; i++){ |
| 299 | 303 | blob_zero(&file); |
| 300 | - blob_read_from_file(&file, g.argv[i]); | |
| 301 | - zip_add_file(g.argv[i], &file, file_wd_perm(g.argv[i])); | |
| 304 | + blob_read_from_file(&file, g.argv[i], eFType); | |
| 305 | + zip_add_file(g.argv[i], &file, file_perm(0,0)); | |
| 302 | 306 | blob_reset(&file); |
| 303 | 307 | } |
| 304 | 308 | zip_close(&zip); |
| 305 | 309 | blob_write_to_file(&zip, g.argv[2]); |
| 306 | 310 | } |
| 307 | 311 |
| --- src/zip.c | |
| +++ src/zip.c | |
| @@ -289,18 +289,22 @@ | |
| 289 | */ |
| 290 | void filezip_cmd(void){ |
| 291 | int i; |
| 292 | Blob zip; |
| 293 | Blob file; |
| 294 | if( g.argc<3 ){ |
| 295 | usage("ARCHIVE FILE...."); |
| 296 | } |
| 297 | zip_open(); |
| 298 | for(i=3; i<g.argc; i++){ |
| 299 | blob_zero(&file); |
| 300 | blob_read_from_file(&file, g.argv[i]); |
| 301 | zip_add_file(g.argv[i], &file, file_wd_perm(g.argv[i])); |
| 302 | blob_reset(&file); |
| 303 | } |
| 304 | zip_close(&zip); |
| 305 | blob_write_to_file(&zip, g.argv[2]); |
| 306 | } |
| 307 |
| --- src/zip.c | |
| +++ src/zip.c | |
| @@ -289,18 +289,22 @@ | |
| 289 | */ |
| 290 | void filezip_cmd(void){ |
| 291 | int i; |
| 292 | Blob zip; |
| 293 | Blob file; |
| 294 | int eFType = SymFILE; |
| 295 | if( g.argc<3 ){ |
| 296 | usage("ARCHIVE FILE...."); |
| 297 | } |
| 298 | if( find_option("dereference","h",0)!=0 ){ |
| 299 | eFType = ExtFILE; |
| 300 | } |
| 301 | zip_open(); |
| 302 | for(i=3; i<g.argc; i++){ |
| 303 | blob_zero(&file); |
| 304 | blob_read_from_file(&file, g.argv[i], eFType); |
| 305 | zip_add_file(g.argv[i], &file, file_perm(0,0)); |
| 306 | blob_reset(&file); |
| 307 | } |
| 308 | zip_close(&zip); |
| 309 | blob_write_to_file(&zip, g.argv[2]); |
| 310 | } |
| 311 |