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.

drh 2017-12-03 11:16 trunk merge
Commit 1772357fc203311d885398b8f0c8a3bd260dc9c80944a4e644ea32b5416d9adf
+11 -11
--- src/add.c
+++ src/add.c
@@ -23,20 +23,20 @@
2323
#include <assert.h>
2424
#include <dirent.h>
2525
#include "cygsup.h"
2626
2727
/*
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,
3030
** files in the checkout will not be moved by the "mv" command and
3131
** files in the checkout will not be removed by the "rm" command.
3232
**
3333
** If the FOSSIL_ENABLE_LEGACY_MV_RM compile-time option is used,
3434
** the "mv-rm-files" setting will be consulted instead of using
3535
** this value.
3636
**
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
3838
** the FOSSIL_ENABLE_LEGACY_MV_RM compile-time option must be used
3939
** -AND- the "mv-rm-files" setting must be set to zero.
4040
*/
4141
#ifndef FOSSIL_MV_RM_FILE
4242
#define FOSSIL_MV_RM_FILE (0)
@@ -185,15 +185,15 @@
185185
db_multi_exec("UPDATE vfile SET deleted=0"
186186
" WHERE pathname=%Q %s AND deleted",
187187
zPath, filename_collation());
188188
}else{
189189
char *zFullname = mprintf("%s%s", g.zLocalRoot, zPath);
190
- int isExe = file_wd_isexe(zFullname);
190
+ int isExe = file_isexe(zFullname, RepoFILE);
191191
db_multi_exec(
192192
"INSERT INTO vfile(vid,deleted,rid,mrid,pathname,isexe,islink)"
193193
"VALUES(%d,0,0,0,%Q,%d,%d)",
194
- vid, zPath, isExe, file_wd_islink(0));
194
+ vid, zPath, isExe, file_islink(0));
195195
fossil_free(zFullname);
196196
}
197197
if( db_changes() ){
198198
fossil_print("ADDED %s\n", zPath);
199199
return 1;
@@ -326,11 +326,11 @@
326326
file_tree_name(g.argv[i], &fullName, 0, 1);
327327
blob_reset(&fullName);
328328
329329
file_canonical_name(g.argv[i], &fullName, 0);
330330
zName = blob_str(&fullName);
331
- isDir = file_wd_isdir(zName);
331
+ isDir = file_isdir(zName, RepoFILE);
332332
if( isDir==1 ){
333333
vfile_scan(&fullName, nRoot-1, scanFlags, pClean, pIgnore);
334334
}else if( isDir==0 ){
335335
fossil_warning("not found: %s", zName);
336336
}else{
@@ -695,11 +695,11 @@
695695
const char *zFile;
696696
const char *zPath;
697697
698698
zFile = db_column_text(&q, 0);
699699
zPath = db_column_text(&q, 1);
700
- if( !file_wd_isfile_or_link(zPath) ){
700
+ if( !file_isfile_or_link(zPath) ){
701701
if( !dryRunFlag ){
702702
db_multi_exec("UPDATE vfile SET deleted=1 WHERE pathname=%Q", zFile);
703703
}
704704
fossil_print("DELETED %s\n", zFile);
705705
nDelete++;
@@ -797,18 +797,18 @@
797797
db_prepare(&move, "SELECT x, y FROM fmove ORDER BY x;");
798798
while( db_step(&move)==SQLITE_ROW ){
799799
const char *zOldName = db_column_text(&move, 0);
800800
const char *zNewName = db_column_text(&move, 1);
801801
if( !dryRunFlag ){
802
- int isOldDir = file_isdir(zOldName);
802
+ int isOldDir = file_isdir(zOldName, RepoFILE);
803803
if( isOldDir==1 ){
804
- int isNewDir = file_isdir(zNewName);
804
+ int isNewDir = file_isdir(zNewName, RepoFILE);
805805
if( isNewDir==0 ){
806806
file_rename(zOldName, zNewName, isOldDir, isNewDir);
807807
}
808808
}else{
809
- if( file_wd_islink(zOldName) ){
809
+ if( file_islink(zOldName) ){
810810
symlink_copy(zOldName, zNewName);
811811
}else{
812812
file_copy(zOldName, zNewName);
813813
}
814814
file_delete(zOldName);
@@ -900,11 +900,11 @@
900900
"UPDATE vfile SET origname=pathname WHERE origname IS NULL;"
901901
);
902902
db_multi_exec(
903903
"CREATE TEMP TABLE mv(f TEXT UNIQUE ON CONFLICT IGNORE, t TEXT);"
904904
);
905
- if( file_wd_isdir(zDest)!=1 ){
905
+ if( file_isdir(zDest, RepoFILE)!=1 ){
906906
Blob orig;
907907
if( g.argc!=4 ){
908908
usage("OLDNAME NEWNAME");
909909
}
910910
file_tree_name(g.argv[2], &orig, 0, 1);
911911
--- 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 @@
331331
sqlite3 *db;
332332
int rc;
333333
const char *z;
334334
file_canonical_name(g.argv[j], &fn, 0);
335335
z = blob_str(&fn);
336
- if( !file_isfile(z) ) continue;
336
+ if( !file_isfile(z, ExtFILE) ) continue;
337337
g.dbIgnoreErrors++;
338338
rc = sqlite3_open(z, &db);
339339
if( rc!=SQLITE_OK ){ sqlite3_close(db); g.dbIgnoreErrors--; continue; }
340340
rc = sqlite3_exec(db, "SELECT rcvid FROM blob, delta LIMIT 1", 0, 0, 0);
341341
sqlite3_close(db);
@@ -397,11 +397,11 @@
397397
#if !USE_SEE
398398
if( sqlite3_strglob("*.efossil", zFilename)==0 ) continue;
399399
#endif
400400
if( file_access(zFilename, F_OK)
401401
|| !file_is_canonical(zFilename)
402
- || (useCheckouts && file_isdir(zFilename)!=1)
402
+ || (useCheckouts && file_isdir(zFilename, ExtFILE)!=1)
403403
){
404404
db_multi_exec("INSERT INTO toDel VALUES(%Q)", db_column_text(&q, 1));
405405
nToDel++;
406406
continue;
407407
}
408408
--- 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 @@
764764
"SELECT substr(tagname,7) FROM tag WHERE tagid=(SELECT tagid FROM event WHERE objid='%d')",
765765
rid
766766
);
767767
zFile = g.argv[3];
768768
}
769
- blob_read_from_file(&content, zFile);
769
+ blob_read_from_file(&content, zFile, ExtFILE);
770770
user_select();
771771
attach_commit(
772772
zFile, /* The filename of the attachment */
773773
zTarget, /* The artifact uuid to attach to */
774774
blob_buffer(&content), /* The content of the attachment */
775775
--- 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 @@
783783
}
784784
785785
/*
786786
** Initialize a blob to be the content of a file. If the filename
787787
** 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.
788799
**
789800
** Any prior content of the blob is discarded, not freed.
790801
**
791802
** Return the number of bytes read. Calls fossil_fatal() on error (i.e.
792803
** it exit()s and does not return).
793804
*/
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
+){
795810
sqlite3_int64 size, got;
796811
FILE *in;
797812
if( zFilename==0 || zFilename[0]==0
798813
|| (zFilename[0]=='-' && zFilename[1]==0) ){
799814
return blob_read_from_channel(pBlob, stdin, -1);
800815
}
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);
802820
blob_zero(pBlob);
803821
if( size<0 ){
804822
fossil_fatal("no such file: %s", zFilename);
805823
}
806824
if( size==0 ){
@@ -842,15 +860,19 @@
842860
blob_zero(pBlob);
843861
return 0;
844862
#endif
845863
}
846864
847
-
848865
/*
849866
** Write the content of a blob into a file.
850867
**
851868
** 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.
852874
**
853875
** Return the number of bytes written.
854876
*/
855877
int blob_write_to_file(Blob *pBlob, const char *zFilename){
856878
FILE *out;
@@ -868,11 +890,11 @@
868890
#if defined(_WIN32)
869891
fflush(stdout);
870892
_setmode(_fileno(stdout), _O_TEXT);
871893
#endif
872894
}else{
873
- file_mkfolder(zFilename, 1, 0);
895
+ file_mkfolder(zFilename, ExtFILE, 1, 0);
874896
out = fossil_fopen(zFilename, "wb");
875897
if( out==0 ){
876898
#if _WIN32
877899
const char *zReserved = file_is_win_reserved(zFilename);
878900
if( zReserved ){
@@ -933,11 +955,11 @@
933955
** This is used to test and debug the blob_compress() routine.
934956
*/
935957
void compress_cmd(void){
936958
Blob f;
937959
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);
939961
blob_compress(&f, &f);
940962
blob_write_to_file(&f, g.argv[3]);
941963
}
942964
943965
/*
@@ -992,12 +1014,12 @@
9921014
** This is used to test and debug the blob_compress2() routine.
9931015
*/
9941016
void compress2_cmd(void){
9951017
Blob f1, f2;
9961018
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);
9991021
blob_compress2(&f1, &f2, &f1);
10001022
blob_write_to_file(&f1, g.argv[4]);
10011023
}
10021024
10031025
/*
@@ -1044,11 +1066,11 @@
10441066
** blob_compress() function.
10451067
*/
10461068
void uncompress_cmd(void){
10471069
Blob f;
10481070
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);
10501072
blob_uncompress(&f, &f);
10511073
blob_write_to_file(&f, g.argv[3]);
10521074
}
10531075
10541076
/*
@@ -1059,11 +1081,11 @@
10591081
*/
10601082
void test_cycle_compress(void){
10611083
int i;
10621084
Blob b1, b2, b3;
10631085
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);
10651087
blob_compress(&b1, &b2);
10661088
blob_uncompress(&b2, &b3);
10671089
if( blob_compare(&b1, &b3) ){
10681090
fossil_fatal("compress/uncompress cycle failed for %s", g.argv[i]);
10691091
}
10701092
--- 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 @@
5555
int doInit /* Initialize a new bundle, if true */
5656
){
5757
int rc;
5858
char *zErrMsg = 0;
5959
char *zSql;
60
- if( !doInit && file_size(zFile)<0 ){
60
+ if( !doInit && file_size(zFile, ExtFILE)<0 ){
6161
fossil_fatal("no such file: %s", zFile);
6262
}
6363
assert( g.db );
6464
zSql = sqlite3_mprintf("ATTACH %Q AS %Q", zFile, zBName);
6565
if( zSql==0 ) fossil_fatal("out of memory");
@@ -161,11 +161,11 @@
161161
"INSERT INTO bblob(blobid, uuid, sz, delta, data, notes) "
162162
"VALUES(NULL, $uuid, $sz, NULL, $data, $filename)");
163163
db_begin_transaction();
164164
for(i=4; i<g.argc; i++){
165165
int sz;
166
- blob_read_from_file(&content, g.argv[i]);
166
+ blob_read_from_file(&content, g.argv[i], ExtFILE);
167167
sz = blob_size(&content);
168168
sha1sum_blob(&content, &hash);
169169
blob_compress(&content, &content);
170170
db_bind_text(&q, "$uuid", blob_str(&hash));
171171
db_bind_int(&q, "$sz", sz);
172172
--- 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 @@
4949
i64 sz;
5050
5151
zDbName = cacheName();
5252
if( zDbName==0 ) return 0;
5353
if( bForce==0 ){
54
- sz = file_size(zDbName);
54
+ sz = file_size(zDbName, ExtFILE);
5555
if( sz<=0 ){
5656
fossil_free(zDbName);
5757
return 0;
5858
}
5959
}
@@ -317,11 +317,11 @@
317317
}
318318
sqlite3_finalize(pStmt);
319319
}
320320
sqlite3_close(db);
321321
fossil_print("Entries: %d Cache-file Size: %lld\n",
322
- nEntry, file_size(zDbName));
322
+ nEntry, file_size(zDbName, ExtFILE));
323323
fossil_free(zDbName);
324324
}
325325
}else if( strncmp(zCmd, "status", nCmd)==0 ){
326326
fossil_print("TBD...\n");
327327
}else{
@@ -365,11 +365,11 @@
365365
}
366366
sqlite3_finalize(pStmt);
367367
@ </ol>
368368
}
369369
zDbName = cacheName();
370
- bigSizeName(sizeof(zBuf), zBuf, file_size(zDbName));
370
+ bigSizeName(sizeof(zBuf), zBuf, file_size(zDbName, ExtFILE));
371371
@ <p>cache-file name: %h(zDbName)</p>
372372
@ <p>cache-file size: %s(zBuf)</p>
373373
fossil_free(zDbName);
374374
sqlite3_close(db);
375375
}
376376
--- 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 @@
8686
blob_reset(&name);
8787
}else{
8888
for(i=0; i<argc; i++){
8989
file_canonical_name(argv[i], &name, 0);
9090
zName = blob_str(&name);
91
- isDir = file_wd_isdir(zName);
91
+ isDir = file_isdir(zName, RepoFILE);
9292
if( isDir==1 ){
9393
vfile_scan(&name, nRoot-1, scanFlags, pIgnore, 0);
9494
}else if( isDir==0 ){
9595
fossil_warning("not found: %s", &zName[nRoot]);
9696
}else if( file_access(zName, R_OK) ){
@@ -209,11 +209,11 @@
209209
int isDeleted = db_column_int(&q, 3);
210210
int isChnged = db_column_int(&q, 4);
211211
int isNew = isManaged && !db_column_int(&q, 5);
212212
int isRenamed = db_column_int(&q, 6);
213213
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);
215215
216216
/* Determine the file change classification, if any. */
217217
if( isDeleted ){
218218
if( flags & C_DELETED ){
219219
zClass = "DELETED";
@@ -254,11 +254,11 @@
254254
zClass = "SYMLINK";
255255
}else if( (flags & C_META) && isChnged==8 ){
256256
zClass = "UNEXEC";
257257
}else if( (flags & C_META) && isChnged==9 ){
258258
zClass = "UNLINK";
259
- }else if( (flags & C_CONFLICT) && isChnged && !file_wd_islink(zFullName)
259
+ }else if( (flags & C_CONFLICT) && isChnged && !file_islink(zFullName)
260260
&& file_contains_merge_marker(zFullName) ){
261261
zClass = "CONFLICT";
262262
}else if( (flags & (C_EDITED | C_CHANGED)) && isChnged
263263
&& (isChnged<2 || isChnged>9) ){
264264
zClass = "EDITED";
@@ -764,11 +764,11 @@
764764
if( verboseFlag ){
765765
if( isNew ){
766766
type = "ADDED ";
767767
}else if( isDeleted ){
768768
type = "DELETED ";
769
- }else if( !file_wd_isfile_or_link(zFullName) ){
769
+ }else if( !file_isfile_or_link(zFullName) ){
770770
if( file_access(zFullName, F_OK)==0 ){
771771
type = "NOT_A_FILE ";
772772
}else{
773773
type = "MISSING ";
774774
}
@@ -1221,11 +1221,11 @@
12211221
fossil_print("%s\n", zCmd);
12221222
if( fossil_system(zCmd) ){
12231223
fossil_fatal("editor aborted: \"%s\"", zCmd);
12241224
}
12251225
1226
- blob_read_from_file(&reply, zFile);
1226
+ blob_read_from_file(&reply, zFile, ExtFILE);
12271227
}else{
12281228
char zIn[300];
12291229
blob_zero(&reply);
12301230
while( fgets(zIn, sizeof(zIn), stdin)!=0 ){
12311231
if( zIn[0]=='.' && (zIn[1]==0 || zIn[1]=='\r' || zIn[1]=='\n') ){
@@ -1562,11 +1562,11 @@
15621562
** itself is actually selected to be part of this check-in.
15631563
*/
15641564
if( isSelected ){
15651565
int mPerm;
15661566
1567
- mPerm = file_wd_perm(blob_str(&filename));
1567
+ mPerm = file_perm(blob_str(&filename), RepoFILE);
15681568
isExe = ( mPerm==PERM_EXE );
15691569
isLink = ( mPerm==PERM_LNK );
15701570
}
15711571
#endif
15721572
if( isExe ){
@@ -1908,15 +1908,11 @@
19081908
zName = db_column_text(&q, 1);
19091909
crlfOk = db_column_int(&q, 2);
19101910
binOk = db_column_int(&q, 3);
19111911
encodingOk = db_column_int(&q, 4);
19121912
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);
19181914
blob_zero(&reason);
19191915
fileRc = commit_warning(&content, crlfOk, binOk, encodingOk, 2,
19201916
zFullname, &reason);
19211917
if( fileRc || verboseFlag ){
19221918
fossil_print("%d\t%s\t%s\n", fileRc, zName, blob_str(&reason));
@@ -2303,11 +2299,11 @@
23032299
if( zComment ){
23042300
blob_zero(&comment);
23052301
blob_append(&comment, zComment, -1);
23062302
}else if( zComFile ){
23072303
blob_zero(&comment);
2308
- blob_read_from_file(&comment, zComFile);
2304
+ blob_read_from_file(&comment, zComFile, ExtFILE);
23092305
blob_to_utf8_no_bom(&comment, 1);
23102306
}else if( dryRunFlag ){
23112307
blob_zero(&comment);
23122308
}else if( !noPrompt ){
23132309
char *zInit = db_text(0, "SELECT value FROM vvar WHERE name='ci-comment'");
@@ -2374,16 +2370,11 @@
23742370
crlfOk = db_column_int(&q, 3);
23752371
binOk = db_column_int(&q, 4);
23762372
encodingOk = db_column_int(&q, 5);
23772373
23782374
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);
23852376
/* Do not emit any warnings when they are disabled. */
23862377
if( !noWarningFlag ){
23872378
abortCommit |= commit_warning(&content, crlfOk, binOk,
23882379
encodingOk, noPrompt,
23892380
zFullname, 0);
@@ -2491,11 +2482,11 @@
24912482
}
24922483
if( outputManifest & MFESTFLG_RAW ){
24932484
zManifestFile = mprintf("%smanifest", g.zLocalRoot);
24942485
blob_write_to_file(&manifest, zManifestFile);
24952486
blob_reset(&manifest);
2496
- blob_read_from_file(&manifest, zManifestFile);
2487
+ blob_read_from_file(&manifest, zManifestFile, ExtFILE);
24972488
free(zManifestFile);
24982489
}
24992490
25002491
nvid = content_put(&manifest);
25012492
if( nvid==0 ){
25022493
--- 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 @@
114114
manifest_file_rewind(pManifest);
115115
while( (pFile = manifest_file_next(pManifest, 0))!=0 ){
116116
int isExe;
117117
blob_append(&filename, pFile->zName, -1);
118118
isExe = pFile->zPerm && strstr(pFile->zPerm, "x");
119
- file_wd_setexe(blob_str(&filename), isExe);
119
+ file_setexe(blob_str(&filename), isExe);
120120
set_or_clear_isexe(pFile->zName, vid, isExe);
121121
blob_resize(&filename, baseLen);
122122
}
123123
blob_reset(&filename);
124124
manifest_destroy(pManifest);
125125
--- 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 @@
4646
if( rc==0 ){
4747
if( pOut==pIn ){
4848
blob_reset(pIn);
4949
}
5050
blob_zero(pOut);
51
- blob_read_from_file(pOut, zIn);
51
+ blob_read_from_file(pOut, zIn, ExtFILE);
5252
}else{
5353
if( pOut!=pIn ){
5454
blob_copy(pOut, pIn);
5555
}
5656
}
5757
--- 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 @@
144144
145145
if( g.argc < 4 ){
146146
usage("?OPTIONS? FILE-OR-URL NEW-REPOSITORY");
147147
}
148148
db_open_config(0, 0);
149
- if( -1 != file_size(g.argv[3]) ){
149
+ if( -1 != file_size(g.argv[3], ExtFILE) ){
150150
fossil_fatal("file already exists: %s", g.argv[3]);
151151
}
152152
153153
url_parse(g.argv[2], urlFlags);
154154
if( zDefaultUser==0 && g.url.user!=0 ) zDefaultUser = g.url.user;
155155
--- 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 @@
484484
}else{
485485
zOrigText = 0;
486486
}
487487
if( fromFile ){
488488
Blob fileData;
489
- blob_read_from_file(&fileData, zText);
489
+ blob_read_from_file(&fileData, zText, ExtFILE);
490490
zText = mprintf("%s", blob_str(&fileData));
491491
blob_reset(&fileData);
492492
if( zOrigText ){
493
- blob_read_from_file(&fileData, zOrigText);
493
+ blob_read_from_file(&fileData, zOrigText, ExtFILE);
494494
zOrigText = mprintf("%s", blob_str(&fileData));
495495
blob_reset(&fileData);
496496
}
497497
}
498498
if( decode ){
499499
--- 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 @@
729729
if( strncmp(zMethod, "import", n)==0
730730
|| strncmp(zMethod, "merge", n)==0 ){
731731
Blob in;
732732
int groupMask;
733733
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);
735735
db_begin_transaction();
736736
if( zMethod[0]=='i' ){
737737
groupMask = CONFIGSET_ALL | CONFIGSET_OVERWRITE;
738738
}else{
739739
groupMask = CONFIGSET_ALL;
@@ -983,13 +983,13 @@
983983
usage("VAR ?VALUE? ?--file FILE?");
984984
}
985985
zVar = g.argv[2];
986986
if( zFile ){
987987
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);
989989
}else if( zBlob ){
990
- blob_read_from_file(&x, zBlob);
990
+ blob_read_from_file(&x, zBlob, ExtFILE);
991991
}else{
992992
blob_init(&x,g.argv[3],-1);
993993
}
994994
db_prepare(&ins,
995995
"REPLACE INTO config(name,value,mtime)"
996996
--- 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 @@
705705
int rid;
706706
Blob content;
707707
if( g.argc!=3 ) usage("FILENAME");
708708
db_must_be_within_tree();
709709
user_select();
710
- blob_read_from_file(&content, g.argv[2]);
710
+ blob_read_from_file(&content, g.argv[2], ExtFILE);
711711
rid = content_put(&content);
712712
fossil_print("inserted as record %d\n", rid);
713713
}
714714
715715
/*
716716
--- 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
+11 -10
--- src/db.c
+++ src/db.c
@@ -1274,21 +1274,21 @@
12741274
if( isOptional ) return 0;
12751275
fossil_fatal("cannot locate home directory - please set the "
12761276
"FOSSIL_HOME or HOME environment variables");
12771277
}
12781278
#endif
1279
- if( file_isdir(zHome)!=1 ){
1279
+ if( file_isdir(zHome, ExtFILE)!=1 ){
12801280
if( isOptional ) return 0;
12811281
fossil_fatal("invalid home directory: %s", zHome);
12821282
}
12831283
#if defined(_WIN32) || defined(__CYGWIN__)
12841284
/* . filenames give some window systems problems and many apps problems */
12851285
zDbName = mprintf("%//_fossil", zHome);
12861286
#else
12871287
zDbName = mprintf("%s/.fossil", zHome);
12881288
#endif
1289
- if( file_size(zDbName)<1024*3 ){
1289
+ if( file_size(zDbName, ExtFILE)<1024*3 ){
12901290
if( file_access(zHome, W_OK) ){
12911291
if( isOptional ) return 0;
12921292
fossil_fatal("home directory %s must be writeable", zHome);
12931293
}
12941294
db_init_database(zDbName, zConfigSchema, (char*)0);
@@ -1352,11 +1352,11 @@
13521352
static int isValidLocalDb(const char *zDbName){
13531353
i64 lsize;
13541354
char *zVFileDef;
13551355
13561356
if( file_access(zDbName, F_OK) ) return 0;
1357
- lsize = file_size(zDbName);
1357
+ lsize = file_size(zDbName, ExtFILE);
13581358
if( lsize%1024!=0 || lsize<4096 ) return 0;
13591359
db_open_or_attach(zDbName, "localdb");
13601360
zVFileDef = db_text(0, "SELECT sql FROM localdb.sqlite_master"
13611361
" WHERE name=='vfile'");
13621362
if( zVFileDef==0 ) return 0;
@@ -1493,11 +1493,11 @@
14931493
}
14941494
if( zDbName==0 ){
14951495
db_err("unable to find the name of a repository database");
14961496
}
14971497
}
1498
- if( file_access(zDbName, R_OK) || file_size(zDbName)<1024 ){
1498
+ if( file_access(zDbName, R_OK) || file_size(zDbName, ExtFILE)<1024 ){
14991499
if( file_access(zDbName, F_OK) ){
15001500
#ifdef FOSSIL_ENABLE_JSON
15011501
g.json.resultCode = FSL_JSON_E_DB_NOT_FOUND;
15021502
#endif
15031503
fossil_panic("repository does not exist or"
@@ -1548,11 +1548,11 @@
15481548
**
15491549
** Error out if the repository cannot be opened.
15501550
*/
15511551
void db_find_and_open_repository(int bFlags, int nArgUsed){
15521552
const char *zRep = find_repository_option();
1553
- if( zRep && file_isdir(zRep)==1 ){
1553
+ if( zRep && file_isdir(zRep, ExtFILE)==1 ){
15541554
goto rep_not_found;
15551555
}
15561556
if( zRep==0 && nArgUsed && g.argc==nArgUsed+1 ){
15571557
zRep = g.argv[nArgUsed];
15581558
}
@@ -1983,11 +1983,11 @@
19831983
19841984
if( g.argc!=3 ){
19851985
usage("REPOSITORY-NAME");
19861986
}
19871987
1988
- if( -1 != file_size(g.argv[2]) ){
1988
+ if( -1 != file_size(g.argv[2], ExtFILE) ){
19891989
fossil_fatal("file already exists: %s", g.argv[2]);
19901990
}
19911991
19921992
db_create_repository(g.argv[2]);
19931993
db_open_repository(g.argv[2]);
@@ -2280,19 +2280,20 @@
22802280
if( historical_blob(g.zOpenRevision, blob_str(&versionedPathname),
22812281
&noWarnFile, 0) ){
22822282
noWarn = 1;
22832283
}
22842284
blob_reset(&noWarnFile);
2285
- }else if( file_size(blob_str(&versionedPathname))>=0 ){
2285
+ }else if( file_size(blob_str(&versionedPathname), ExtFILE)>=0 ){
22862286
/* File exists, and contains the value for this setting. Load from
22872287
** 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 ){
22892290
found = 1;
22902291
}
22912292
/* See if there's a no-warn flag */
22922293
blob_append(&versionedPathname, ".no-warn", -1);
2293
- if( file_size(blob_str(&versionedPathname))>=0 ){
2294
+ if( file_size(blob_str(&versionedPathname), ExtFILE)>=0 ){
22942295
noWarn = 1;
22952296
}
22962297
}
22972298
blob_reset(&versionedPathname);
22982299
if( found ){
@@ -2729,11 +2730,11 @@
27292730
/* Check to see if this is overridden by a versionable settings file */
27302731
Blob versionedPathname;
27312732
blob_zero(&versionedPathname);
27322733
blob_appendf(&versionedPathname, "%s.fossil-settings/%s",
27332734
g.zLocalRoot, pSetting->name);
2734
- if( file_size(blob_str(&versionedPathname))>=0 ){
2735
+ if( file_size(blob_str(&versionedPathname), ExtFILE)>=0 ){
27352736
fossil_print(" (overridden by contents of file .fossil-settings/%s)\n",
27362737
pSetting->name);
27372738
}
27382739
}
27392740
db_finalize(&q);
27402741
--- 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 @@
5353
void delta_create_cmd(void){
5454
Blob orig, target, delta;
5555
if( g.argc!=5 ){
5656
usage("ORIGIN TARGET DELTA");
5757
}
58
- if( blob_read_from_file(&orig, g.argv[2])<0 ){
58
+ if( blob_read_from_file(&orig, g.argv[2], ExtFILE)<0 ){
5959
fossil_fatal("cannot read %s", g.argv[2]);
6060
}
61
- if( blob_read_from_file(&target, g.argv[3])<0 ){
61
+ if( blob_read_from_file(&target, g.argv[3], ExtFILE)<0 ){
6262
fossil_fatal("cannot read %s", g.argv[3]);
6363
}
6464
blob_delta_create(&orig, &target, &delta);
6565
if( blob_write_to_file(&delta, g.argv[4])<blob_size(&delta) ){
6666
fossil_fatal("cannot write %s", g.argv[4]);
@@ -84,14 +84,14 @@
8484
int nInsert = 0;
8585
int sz1, sz2, sz3;
8686
if( g.argc!=4 ){
8787
usage("ORIGIN TARGET");
8888
}
89
- if( blob_read_from_file(&orig, g.argv[2])<0 ){
89
+ if( blob_read_from_file(&orig, g.argv[2], ExtFILE)<0 ){
9090
fossil_fatal("cannot read %s", g.argv[2]);
9191
}
92
- if( blob_read_from_file(&target, g.argv[3])<0 ){
92
+ if( blob_read_from_file(&target, g.argv[3], ExtFILE)<0 ){
9393
fossil_fatal("cannot read %s", g.argv[3]);
9494
}
9595
blob_delta_create(&orig, &target, &delta);
9696
delta_analyze(blob_buffer(&delta), blob_size(&delta), &nCopy, &nInsert);
9797
sz1 = blob_size(&orig);
@@ -152,14 +152,14 @@
152152
void delta_apply_cmd(void){
153153
Blob orig, target, delta;
154154
if( g.argc!=5 ){
155155
usage("ORIGIN DELTA TARGET");
156156
}
157
- if( blob_read_from_file(&orig, g.argv[2])<0 ){
157
+ if( blob_read_from_file(&orig, g.argv[2], ExtFILE)<0 ){
158158
fossil_fatal("cannot read %s", g.argv[2]);
159159
}
160
- if( blob_read_from_file(&delta, g.argv[3])<0 ){
160
+ if( blob_read_from_file(&delta, g.argv[3], ExtFILE)<0 ){
161161
fossil_fatal("cannot read %s", g.argv[3]);
162162
}
163163
blob_delta_apply(&orig, &delta, &target);
164164
if( blob_write_to_file(&target, g.argv[4])<blob_size(&target) ){
165165
fossil_fatal("cannot write %s", g.argv[4]);
@@ -182,16 +182,16 @@
182182
void cmd_test_delta(void){
183183
Blob f1, f2; /* Original file content */
184184
Blob d12, d21; /* Deltas from f1->f2 and f2->f1 */
185185
Blob a1, a2; /* Recovered file content */
186186
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);
189189
blob_delta_create(&f1, &f2, &d12);
190190
blob_delta_create(&f2, &f1, &d21);
191191
blob_delta_apply(&f1, &d12, &a2);
192192
blob_delta_apply(&f2, &d21, &a1);
193193
if( blob_compare(&f1,&a1) || blob_compare(&f2, &a2) ){
194194
fossil_fatal("delta test failed");
195195
}
196196
fossil_print("ok\n");
197197
}
198198
--- 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 @@
20152015
int r;
20162016
int i;
20172017
int *R;
20182018
u64 diffFlags = diff_options();
20192019
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);
20212021
for(i=3; i<g.argc; i++){
20222022
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);
20242024
R = text_diff(&a, &b, 0, 0, diffFlags);
20252025
for(r=0; R[r] || R[r+1] || R[r+2]; r += 3){
20262026
fossil_print(" copy %4d delete %4d insert %4d\n", R[r], R[r+1], R[r+2]);
20272027
}
20282028
/* free(R); */
@@ -2056,12 +2056,12 @@
20562056
}
20572057
diffFlag = diff_options();
20582058
verify_all_options();
20592059
if( g.argc!=4 ) usage("FILE1 FILE2");
20602060
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);
20632063
blob_zero(&out);
20642064
text_diff(&a, &b, &out, pRe, diffFlag);
20652065
blob_write_to_file(&out, "-");
20662066
re_free(pRe);
20672067
}
20682068
--- 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 @@
180180
Blob file2; /* Content of zFile2 */
181181
const char *zName2; /* Name of zFile2 for display */
182182
183183
/* Read content of zFile2 into memory */
184184
blob_zero(&file2);
185
- if( file_wd_size(zFile2)<0 ){
185
+ if( file_size(zFile2, ExtFILE)<0 ){
186186
zName2 = NULL_DEVICE;
187187
}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);
193189
zName2 = zName;
194190
}
195191
196192
/* Compute and output the differences */
197193
if( diffFlags & DIFF_BRIEF ){
@@ -237,16 +233,12 @@
237233
return;
238234
}
239235
glob_free(pBinary);
240236
}
241237
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);
248240
}
249241
if( looks_like_binary(&file2) ){
250242
fossil_print("%s",DIFF_CANNOT_COMPUTE_BINARY);
251243
blob_reset(&file2);
252244
return;
@@ -489,11 +481,11 @@
489481
if( !asNewFile ){ showDiff = 0; }
490482
}
491483
if( showDiff ){
492484
Blob content;
493485
int isBin;
494
- if( !isLink != !file_wd_islink(zFullName) ){
486
+ if( !isLink != !file_islink(zFullName) ){
495487
diff_print_index(zPathname, diffFlags);
496488
diff_print_filenames(zPathname, zPathname, diffFlags);
497489
fossil_print("%s",DIFF_CANNOT_COMPUTE_SYMLINK);
498490
continue;
499491
}
@@ -965,11 +957,11 @@
965957
if( pFileDir ){
966958
int i;
967959
for(i=0; pFileDir[i].zName; i++){
968960
if( pFileDir[i].nUsed==0
969961
&& strcmp(pFileDir[0].zName,".")!=0
970
- && !file_wd_isdir(g.argv[i+2])
962
+ && !file_isdir(g.argv[i+2], ExtFILE)
971963
){
972964
fossil_fatal("not found: '%s'", g.argv[i+2]);
973965
}
974966
fossil_free(pFileDir[i].zName);
975967
}
976968
--- 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 @@
649649
}else if( fossil_strcmp(zCheckin,"ckout")==0 ){
650650
/* Read from the local checkout */
651651
char *zFullpath;
652652
db_must_be_within_tree();
653653
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 ){
656656
rid = 1; /* Fake RID just to get the loop to end */
657657
}
658658
fossil_free(zFullpath);
659659
}else{
660660
vid = name_to_typed_rid(zCheckin, "ci");
661661
--- 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 @@
22
** Copyright (c) 2006 D. Richard Hipp
33
**
44
** This program is free software; you can redistribute it and/or
55
** modify it under the terms of the Simplified BSD License (also
66
** known as the "2-Clause License" or "FreeBSD License".)
7
-
7
+**
88
** This program is distributed in the hope that it will be useful,
99
** but without any warranty; without even the implied warranty of
1010
** merchantability or fitness for a particular purpose.
1111
**
1212
** Author contact information:
@@ -14,15 +14,10 @@
1414
** http://www.hwaci.com/drh/
1515
**
1616
*******************************************************************************
1717
**
1818
** 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.
2419
*/
2520
#include "config.h"
2621
#include <sys/types.h>
2722
#include <sys/stat.h>
2823
#include <unistd.h>
@@ -42,10 +37,36 @@
4237
# include <sys/time.h>
4338
#endif
4439
4540
#if INTERFACE
4641
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
+
4768
#include <dirent.h>
4869
#if defined(_WIN32)
4970
# define DIR _WDIR
5071
# define dirent _wdirent
5172
# define opendir _wopendir
@@ -52,10 +73,13 @@
5273
# define readdir _wreaddir
5374
# define closedir _wclosedir
5475
#endif /* _WIN32 */
5576
5677
#if defined(_WIN32) && (defined(__MSVCRT__) || defined(_MSC_VER))
78
+/*
79
+** File status information for windows systems.
80
+*/
5781
struct fossilStat {
5882
i64 st_size;
5983
i64 st_mtime;
6084
int st_mode;
6185
};
@@ -68,73 +92,88 @@
6892
#endif
6993
7094
#endif /* INTERFACE */
7195
7296
#if !defined(_WIN32) || !(defined(__MSVCRT__) || defined(_MSC_VER))
97
+/*
98
+** File status information for unix systems
99
+*/
73100
# define fossilStat stat
74101
#endif
75102
76103
/*
77104
** On Windows S_ISLNK always returns FALSE.
78105
*/
79106
#if !defined(S_ISLNK)
80107
# define S_ISLNK(x) (0)
81108
#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;
84117
85118
/*
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.
88129
*/
89130
static int fossil_stat(
90131
const char *zFilename, /* name of file or directory to inspect. */
91132
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. */
93134
){
94135
int rc;
95136
void *zMbcs = fossil_utf8_to_path(zFilename, 0);
96137
#if !defined(_WIN32)
97
- if( isWd && db_allow_symlinks() ){
138
+ if( eFType>=RepoFILE && (eFType==SymFILE || db_allow_symlinks()) ){
98139
rc = lstat(zMbcs, buf);
99140
}else{
100141
rc = stat(zMbcs, buf);
101142
}
102143
#else
103
- rc = win32_stat(zMbcs, buf, isWd);
144
+ rc = win32_stat(zMbcs, buf, eFType);
104145
#endif
105146
fossil_path_free(zMbcs);
106147
return rc;
107148
}
108149
109150
/*
110
-** Clears the fileStat variable and its associated validity flag.
151
+** Clears the fx.fileStat variable and its associated validity flag.
111152
*/
112153
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));
115156
}
116157
117158
/*
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
120161
** there is a previous value.
121162
**
122
-** If isWd is TRUE, do lstat() instead of stat() if allow-symlinks is on.
123
-**
124163
** Return the number of errors. No error messages are generated.
125164
*/
126
-static int getStat(const char *zFilename, int isWd){
165
+static int getStat(const char *zFilename, int eFType){
127166
int rc = 0;
128167
if( zFilename==0 ){
129
- if( fileStatValid==0 ) rc = 1;
168
+ if( fx.fileStatValid==0 ) rc = 1;
130169
}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;
133172
rc = 1;
134173
}else{
135
- fileStatValid = 1;
174
+ fx.fileStatValid = 1;
136175
rc = 0;
137176
}
138177
}
139178
return rc;
140179
}
@@ -142,83 +181,60 @@
142181
/*
143182
** Return the size of a file in bytes. Return -1 if the file does not
144183
** exist. If zFilename is NULL, return the size of the most recently
145184
** stat-ed file.
146185
*/
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;
156188
}
157189
158190
/*
159191
** Return the modification time for a file. Return -1 if the file
160192
** does not exist. If zFilename is NULL return the size of the most
161193
** recently stat-ed file.
162194
*/
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;
172197
}
173198
174199
/*
175200
** Return the mode bits for a file. Return -1 if the file does not
176201
** exist. If zFilename is NULL return the size of the most recently
177202
** stat-ed file.
178203
*/
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;
181206
}
182207
183208
/*
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);
198221
}
199222
200223
/*
201224
** Return TRUE if the named file is an ordinary file. Return false
202225
** for directories, devices, fifos, symlinks, etc.
203226
*/
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);
206229
}
207230
208231
/*
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.
218233
**
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.
220236
**/
221237
void symlink_create(const char *zTargetFile, const char *zLinkFile){
222238
#if !defined(_WIN32)
223239
if( db_allow_symlinks() ){
224240
int i, nName;
@@ -233,14 +249,14 @@
233249
}
234250
nName = file_simplify_name(zName, nName, 0);
235251
for(i=1; i<nName; i++){
236252
if( zName[i]=='/' ){
237253
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
+ }
242258
zName[i] = '/';
243259
}
244260
}
245261
if( symlink(zTargetFile, zName)!=0 ){
246262
fossil_fatal_recursive("unable to create symlink \"%s\"", zName);
@@ -269,17 +285,22 @@
269285
/*
270286
** Return file permissions (normal, executable, or symlink):
271287
** - PERM_EXE on Unix if file is executable;
272288
** - PERM_LNK on Unix if file is symlink and allow-symlinks option is on;
273289
** - 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.
274295
*/
275
-int file_wd_perm(const char *zFilename){
296
+int file_perm(const char *zFilename, int eFType){
276297
#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 )
279300
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) )
281302
return PERM_LNK;
282303
}
283304
#endif
284305
return PERM_REG;
285306
}
@@ -286,65 +307,42 @@
286307
287308
/*
288309
** Return TRUE if the named file is an executable. Return false
289310
** for directories, devices, fifos, symlinks, etc.
290311
*/
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;
293314
}
294315
295316
/*
296317
** Return TRUE if the named file is a symlink and symlinks are allowed.
297318
** Return false for all other cases.
298319
**
320
+** This routines RepoFILE - that zFilename is always a file under management.
321
+**
299322
** On Windows, always return False.
300323
*/
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;
303326
}
304327
305328
/*
306329
** Return 1 if zFilename is a directory. Return 0 if zFilename
307330
** does not exist. Return 2 if zFilename exists but is something
308331
** other than a directory.
309332
*/
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){
331334
int rc;
332335
char *zFN;
333336
334337
zFN = mprintf("%s", zFilename);
335338
file_simplify_name(zFN, -1, 0);
336
- rc = getStat(zFN, 1);
339
+ rc = getStat(zFN, eFType);
337340
if( rc ){
338341
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) ){
340343
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);
346344
}else{
347345
rc = 2; /* It exists and is something else. */
348346
}
349347
free(zFN);
350348
return rc;
@@ -397,11 +395,11 @@
397395
*/
398396
char *file_newname(const char *zBase, const char *zSuffix, int relFlag){
399397
char *z = 0;
400398
int cnt = 0;
401399
z = mprintf("%s-%s", zBase, zSuffix);
402
- while( file_size(z)>=0 ){
400
+ while( file_size(z, ExtFILE)>=0 ){
403401
fossil_free(z);
404402
z = mprintf("%s-%s-%d", zBase, zSuffix, cnt++);
405403
}
406404
if( relFlag ){
407405
Blob x;
@@ -473,11 +471,11 @@
473471
FILE *in, *out;
474472
int got;
475473
char zBuf[8192];
476474
in = fossil_fopen(zFrom, "rb");
477475
if( in==0 ) fossil_fatal("cannot open \"%s\" for reading", zFrom);
478
- file_mkfolder(zTo, 0, 0);
476
+ file_mkfolder(zTo, ExtFILE, 0, 0);
479477
out = fossil_fopen(zTo, "wb");
480478
if( out==0 ) fossil_fatal("cannot open \"%s\" for writing", zTo);
481479
while( (got=fread(zBuf, 1, sizeof(zBuf), in))>0 ){
482480
fwrite(zBuf, 1, got, out);
483481
}
@@ -502,16 +500,22 @@
502500
}
503501
504502
/*
505503
** Set or clear the execute bit on a file. Return true if a change
506504
** 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.
507509
*/
508
-int file_wd_setexe(const char *zFilename, int onoff){
510
+int file_setexe(const char *zFilename, int onoff){
509511
int rc = 0;
510512
#if !defined(_WIN32)
511513
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
+ }
513517
if( onoff ){
514518
int targetMode = (buf.st_mode & 0444)>>2;
515519
if( (buf.st_mode & 0100)==0 ){
516520
chmod(zFilename, buf.st_mode | targetMode);
517521
rc = 1;
@@ -564,17 +568,20 @@
564568
}
565569
db_open_or_attach(":memory:", "mem");
566570
iMTime = db_int64(0, "SELECT strftime('%%s',%Q)", g.argv[3]);
567571
zFile = g.argv[2];
568572
file_set_mtime(zFile, iMTime);
569
- iMTime = file_wd_mtime(zFile);
573
+ iMTime = file_mtime(zFile, RepoFILE);
570574
zDate = db_text(0, "SELECT datetime(%lld, 'unixepoch')", iMTime);
571575
fossil_print("Set mtime of \"%s\" to %s (%lld)\n", zFile, zDate, iMTime);
572576
}
573577
574578
/*
575579
** 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.
576583
**
577584
** Returns zero upon success.
578585
*/
579586
int file_delete(const char *zFilename){
580587
int rc;
@@ -588,18 +595,18 @@
588595
fossil_path_free(z);
589596
return rc;
590597
}
591598
592599
/*
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
595602
** with the same name.
596603
**
597604
** Return the number of errors.
598605
*/
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);
601608
if( rc==2 ){
602609
if( !forceFlag ) return 1;
603610
file_delete(zName);
604611
}
605612
if( rc!=1 ){
@@ -621,24 +628,31 @@
621628
** of directories does not already exist.
622629
**
623630
** On success, return zero. On error, return errorReturn if positive, otherwise
624631
** print an error message and abort.
625632
*/
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
+){
627639
int nName, rc = 0;
628640
char *zName;
629641
630642
nName = strlen(zFilename);
631643
zName = mprintf("%s", zFilename);
632644
nName = file_simplify_name(zName, nName, 0);
633645
while( nName>0 && zName[nName-1]!='/' ){ nName--; }
634646
if( nName ){
635647
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);
638650
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
+ ){
640654
if( errorReturn <= 0 ){
641655
fossil_fatal_recursive("unable to create directory %s", zName);
642656
}
643657
rc = errorReturn;
644658
}
@@ -654,11 +668,11 @@
654668
** must be empty and cannot be the current directory or the root directory.
655669
**
656670
** Returns zero upon success.
657671
*/
658672
int file_rmdir(const char *zName){
659
- int rc = file_wd_isdir(zName);
673
+ int rc = file_isdir(zName, RepoFILE);
660674
if( rc==2 ) return 1; /* cannot remove normal file */
661675
if( rc==1 ){
662676
#if defined(_WIN32)
663677
wchar_t *zMbcs = fossil_utf8_to_path(zName, 1);
664678
rc = _wrmdir(zMbcs);
@@ -994,35 +1008,34 @@
9941008
sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld (%s)", testFileStat.st_mtime, z);
9951009
fossil_free(z);
9961010
fossil_print(" l_stat_mtime = %s\n", zBuf);
9971011
fossil_print(" l_stat_mode = 0%o\n", testFileStat.st_mode);
9981012
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));
10241037
if( reset ) resetStat();
10251038
}
10261039
10271040
/*
10281041
** COMMAND: test-file-environment
@@ -1078,19 +1091,19 @@
10781091
char zBuf[100];
10791092
const char *zName = g.argv[i];
10801093
file_canonical_name(zName, &x, slashFlag);
10811094
fossil_print("[%s] -> [%s]\n", zName, blob_buffer(&x));
10821095
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));
10921105
}
10931106
}
10941107
10951108
/*
10961109
** Return TRUE if the given filename is canonical.
@@ -1426,11 +1439,11 @@
14261439
azDirs[0] = fossil_getenv("TMPDIR");
14271440
#endif
14281441
14291442
for(i=0; i<count(azDirs); i++){
14301443
if( azDirs[i]==0 ) continue;
1431
- if( !file_isdir(azDirs[i]) ) continue;
1444
+ if( !file_isdir(azDirs[i], ExtFILE) ) continue;
14321445
zDir = azDirs[i];
14331446
break;
14341447
}
14351448
14361449
do{
@@ -1440,11 +1453,11 @@
14401453
for(i=0; i<15; i++){
14411454
zRand[i] = (char)zChars[ ((unsigned char)zRand[i])%(sizeof(zChars)-1) ];
14421455
}
14431456
zRand[15] = 0;
14441457
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 );
14461459
14471460
#if defined(_WIN32)
14481461
fossil_path_free((char *)azDirs[0]);
14491462
fossil_path_free((char *)azDirs[1]);
14501463
fossil_path_free((char *)azDirs[2]);
@@ -1477,24 +1490,22 @@
14771490
14781491
/*
14791492
** Return true if a file named zName exists and has identical content
14801493
** to the blob pContent. If zName does not exist or if the content is
14811494
** different in any way, then return false.
1495
+**
1496
+** This routine assumes RepoFILE
14821497
*/
14831498
int file_is_the_same(Blob *pContent, const char *zName){
14841499
i64 iSize;
14851500
int rc;
14861501
Blob onDisk;
14871502
1488
- iSize = file_wd_size(zName);
1503
+ iSize = file_size(zName, RepoFILE);
14891504
if( iSize<0 ) return 0;
14901505
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);
14961507
rc = blob_compare(&onDisk, pContent);
14971508
blob_reset(&onDisk);
14981509
return rc==0;
14991510
}
15001511
@@ -1533,10 +1544,13 @@
15331544
return rc;
15341545
}
15351546
15361547
/*
15371548
** Like fopen() but always takes a UTF8 argument.
1549
+**
1550
+** This function assumes ExtFILE. In other words, symbolic links
1551
+** are always followed.
15381552
*/
15391553
FILE *fossil_fopen(const char *zName, const char *zMode){
15401554
#ifdef _WIN32
15411555
wchar_t *uMode = fossil_utf8_to_unicode(zMode);
15421556
wchar_t *uName = fossil_utf8_to_path(zName, 0);
15431557
--- 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 @@
323323
db_find_and_open_repository(0,0);
324324
verify_all_options();
325325
blob_init(&fusefs.content, 0, 0);
326326
if( g.argc!=3 ) usage("DIRECTORY");
327327
zMountPoint = g.argv[2];
328
- if( file_mkdir(zMountPoint, 0) ){
328
+ if( file_mkdir(zMountPoint, ExtFILE, 0) ){
329329
fossil_fatal("cannot make directory [%s]", zMountPoint);
330330
}
331331
azNewArgv[0] = g.argv[0];
332332
azNewArgv[1] = doDebug ? "-d" : "-f";
333333
azNewArgv[2] = "-s";
334334
--- 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 @@
132132
Blob b;
133133
char *zOut;
134134
if( g.argc!=3 ) usage("FILENAME");
135135
sqlite3_open(":memory:", &g.db);
136136
gzip_begin(-1);
137
- blob_read_from_file(&b, g.argv[2]);
137
+ blob_read_from_file(&b, g.argv[2], ExtFILE);
138138
zOut = mprintf("%s.gz", g.argv[2]);
139139
gzip_step(blob_buffer(&b), blob_size(&b));
140140
blob_reset(&b);
141141
gzip_finish(&b);
142142
blob_write_to_file(&b, zOut);
143143
--- 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 @@
133133
int hname_verify_file_hash(const char *zFile, const char *zHash, int nHash){
134134
int id = HNAME_ERROR;
135135
switch( nHash ){
136136
case HNAME_LEN_SHA1: {
137137
Blob hash;
138
- if( sha1sum_file(zFile, &hash) ) break;
138
+ if( sha1sum_file(zFile, RepoFILE, &hash) ) break;
139139
if( memcmp(blob_buffer(&hash),zHash,HNAME_LEN_SHA1)==0 ) id = HNAME_SHA1;
140140
blob_reset(&hash);
141141
break;
142142
}
143143
case HNAME_LEN_K256: {
144144
Blob hash;
145
- if( sha3sum_file(zFile, 256, &hash) ) break;
145
+ if( sha3sum_file(zFile, RepoFILE, 256, &hash) ) break;
146146
if( memcmp(blob_buffer(&hash),zHash,64)==0 ) id = HNAME_LEN_K256;
147147
blob_reset(&hash);
148148
break;
149149
}
150150
}
151151
--- 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 @@
109109
if( zCaSetting==0 || zCaSetting[0]=='\0' ){
110110
/* CA location not specified, use platform's default certificate store */
111111
X509_STORE_set_default_paths(SSL_CTX_get_cert_store(sslCtx));
112112
}else{
113113
/* User has specified a CA location, make sure it exists and use it */
114
- switch( file_isdir(zCaSetting) ){
114
+ switch( file_isdir(zCaSetting, ExtFILE) ){
115115
case 0: { /* doesn't exist */
116116
fossil_fatal("ssl-ca-location is set to '%s', "
117117
"but is not a file or directory", zCaSetting);
118118
break;
119119
}
120120
--- 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 @@
201201
int verboseFlag = find_option("verbose","v",0)!=0;
202202
if( !verboseFlag ){
203203
verboseFlag = find_option("detail","l",0)!=0; /* deprecated */
204204
}
205205
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
+ ){
207210
db_open_config(0, 0);
208211
db_open_repository(g.argv[2]);
209212
db_record_repository_filename(g.argv[2]);
210213
fossil_print("project-name: %s\n", db_get("project-name", "<unnamed>"));
211214
fossil_print("project-code: %s\n", db_get("project-code", "<none>"));
@@ -3117,11 +3120,11 @@
31173120
if( fEditComment ){
31183121
prepare_amend_comment(&comment, zComment, zUuid);
31193122
zNewComment = blob_str(&comment);
31203123
}else if( zComFile ){
31213124
blob_zero(&comment);
3122
- blob_read_from_file(&comment, zComFile);
3125
+ blob_read_from_file(&comment, zComFile, ExtFILE);
31233126
blob_to_utf8_no_bom(&comment, 1);
31243127
zNewComment = blob_str(&comment);
31253128
}
31263129
if( zNewComment && zNewComment[0]
31273130
&& comment_compare(zComment,zNewComment)==0 ) add_comment(zNewComment);
31283131
--- 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 @@
19281928
free(zTmp);
19291929
zTmp = db_get("project-description",NULL);
19301930
cson_object_set(jo, "projectDescription", json_new_string(zTmp));
19311931
free(zTmp);
19321932
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));
19351936
19361937
if(full){
19371938
n = db_int(0, "SELECT count(*) FROM blob");
19381939
m = db_int(0, "SELECT count(*) FROM delta");
19391940
cson_object_set(jo, "blobCount", cson_value_new_integer((cson_int_t)n));
19401941
--- 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
--- src/json_status.c
+++ src/json_status.c
@@ -114,11 +114,11 @@
114114
}else if( isNew ){
115115
zStatus = "new" /* maintenance reminder: MUST come
116116
BEFORE the isChnged checks. */;
117117
}else if( isRenamed ){
118118
zStatus = "renamed";
119
- }else if( !file_wd_isfile_or_link(zFullName) ){
119
+ }else if( !file_isfile_or_link(zFullName) ){
120120
if( file_access(zFullName, F_OK)==0 ){
121121
zStatus = "notAFile";
122122
++nErr;
123123
}else{
124124
zStatus = "missing";
125125
--- 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 @@
15651565
" ORDER BY +value",
15661566
zSelfCode
15671567
);
15681568
while( db_step(&q)==SQLITE_ROW ){
15691569
const char *zRepoName = db_column_text(&q, 1);
1570
- if( file_size(zRepoName)<0 ){
1570
+ if( file_size(zRepoName, ExtFILE)<0 ){
15711571
/* Silently remove non-existent repositories from the login group. */
15721572
const char *zLabel = db_column_text(&q, 0);
15731573
db_multi_exec(
15741574
"DELETE FROM config WHERE name GLOB 'peer-*-%q'",
15751575
&zLabel[10]
@@ -1661,11 +1661,11 @@
16611661
*pzErrMsg = mprintf("The \"other\" repository is the same as this one.");
16621662
return;
16631663
}
16641664
16651665
/* Make sure the other repository is a valid Fossil database */
1666
- if( file_size(zRepo)<0 ){
1666
+ if( file_size(zRepo, ExtFILE)<0 ){
16671667
*pzErrMsg = mprintf("repository file \"%s\" does not exist", zRepo);
16681668
return;
16691669
}
16701670
rc = sqlite3_open_v2(
16711671
zRepo, &pOther,
16721672
--- 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 @@
422422
423423
if( g.argc!=3 ) usage("FILENAME");
424424
if( zCount ){
425425
nRepeat = atoi(zCount);
426426
}
427
- blob_read_from_file(&blob, g.argv[2]);
427
+ blob_read_from_file(&blob, g.argv[2], ExtFILE);
428428
while( --nRepeat >= 0 ){
429429
fUtf8 = starts_with_utf8_bom(&blob, 0);
430430
fUtf16 = starts_with_utf16_bom(&blob, 0, &bRevUtf16);
431431
if( fForceUtf8 ){
432432
fUnicode = 0;
433433
--- 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 @@
11811181
}
11821182
11831183
file_canonical_name(zRepo, &dir, 0);
11841184
zDir = blob_str(&dir);
11851185
if( !noJail ){
1186
- if( file_isdir(zDir)==1 ){
1186
+ if( file_isdir(zDir, ExtFILE)==1 ){
11871187
if( file_chdir(zDir, 1) ){
11881188
fossil_fatal("unable to chroot into %s", zDir);
11891189
}
11901190
g.fJail = 1;
11911191
zRepo = "/";
@@ -1208,11 +1208,11 @@
12081208
i = setgid(sStat.st_gid);
12091209
i = i || setuid(sStat.st_uid);
12101210
if(i){
12111211
fossil_fatal("setgid/uid() failed with errno %d", errno);
12121212
}
1213
- if( g.db==0 && file_isfile(zRepo) ){
1213
+ if( g.db==0 && file_isfile(zRepo, ExtFILE) ){
12141214
db_open_repository(zRepo);
12151215
}
12161216
}
12171217
#endif
12181218
return zRepo;
@@ -1427,11 +1427,11 @@
14271427
** Special case: Assume any file with a basename of ".fossil" does
14281428
** not exist.
14291429
*/
14301430
zCleanRepo = file_cleanup_fullpath(zRepo);
14311431
if( szFile==0 && sqlite3_strglob("*/.fossil",zRepo)!=0 ){
1432
- szFile = file_size(zCleanRepo);
1432
+ szFile = file_size(zCleanRepo, ExtFILE);
14331433
if( g.fHttpTrace ){
14341434
char zBuf[24];
14351435
sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", szFile);
14361436
@ <!-- file_size(%h(zCleanRepo)) is %s(zBuf) -->
14371437
fprintf(stderr, "# file_size(%s) = %s\n", zCleanRepo, zBuf);
@@ -1447,11 +1447,11 @@
14471447
assert( fossil_strcmp(&zRepo[j], ".fossil")==0 );
14481448
zRepo[j] = 0; /* Remove the ".fossil" suffix */
14491449
14501450
/* The PATH_INFO prefix seen so far is a valid directory.
14511451
** 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 ){
14531453
fossil_free(zToFree);
14541454
i++;
14551455
continue;
14561456
}
14571457
@@ -1465,18 +1465,18 @@
14651465
** general-purpose web server. The "--file GLOB" mechanism is
14661466
** designed to allow the delivery of a few static images or HTML
14671467
** pages.
14681468
*/
14691469
if( pFileGlob!=0
1470
- && file_isfile(zCleanRepo)
1470
+ && file_isfile(zCleanRepo, ExtFILE)
14711471
&& glob_match(pFileGlob, file_cleanup_fullpath(zRepo))
14721472
&& sqlite3_strglob("*.fossil*",zRepo)!=0
14731473
&& (zMimetype = mimetype_from_name(zRepo))!=0
14741474
&& strcmp(zMimetype, "application/x-fossil-artifact")!=0
14751475
){
14761476
Blob content;
1477
- blob_read_from_file(&content, file_cleanup_fullpath(zRepo));
1477
+ blob_read_from_file(&content, file_cleanup_fullpath(zRepo), ExtFILE);
14781478
cgi_set_content_type(zMimetype);
14791479
cgi_set_content(&content);
14801480
cgi_reply();
14811481
return;
14821482
}
@@ -1844,11 +1844,11 @@
18441844
g.httpOut = stdout;
18451845
g.httpIn = stdin;
18461846
fossil_binary_mode(g.httpOut);
18471847
fossil_binary_mode(g.httpIn);
18481848
g.cgiOutput = 1;
1849
- blob_read_from_file(&config, zFile);
1849
+ blob_read_from_file(&config, zFile, ExtFILE);
18501850
while( blob_line(&config, &line) ){
18511851
if( !blob_token(&line, &key) ) continue;
18521852
if( blob_buffer(&key)[0]=='#' ) continue;
18531853
if( blob_eq(&key, "repository:") && blob_tail(&line, &value) ){
18541854
/* repository: FILENAME
@@ -2018,11 +2018,11 @@
20182018
static void find_server_repository(int arg, int fCreate){
20192019
if( g.argc<=arg ){
20202020
db_must_be_within_tree();
20212021
}else{
20222022
const char *zRepo = g.argv[arg];
2023
- int isDir = file_isdir(zRepo);
2023
+ int isDir = file_isdir(zRepo, ExtFILE);
20242024
if( isDir==1 ){
20252025
g.zRepositoryName = mprintf("%s", zRepo);
20262026
file_simplify_name(g.zRepositoryName, -1, 0);
20272027
}else{
20282028
if( isDir==0 && fCreate ){
20292029
--- 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 @@
10261026
int n = 1;
10271027
sqlite3_open(":memory:", &g.db);
10281028
if( g.argc!=3 && g.argc!=4 ){
10291029
usage("FILENAME");
10301030
}
1031
- blob_read_from_file(&b, g.argv[2]);
1031
+ blob_read_from_file(&b, g.argv[2], ExtFILE);
10321032
if( g.argc>3 ) n = atoi(g.argv[3]);
10331033
for(i=0; i<n; i++){
10341034
Blob b2;
10351035
Blob err;
10361036
blob_copy(&b2, &b);
10371037
--- 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 @@
548548
const char *zName = db_column_text(&q, 1);
549549
int isExe = db_column_int(&q, 2);
550550
fossil_print("%s %s\n", isExe ? "EXECUTABLE" : "UNEXEC", zName);
551551
if( !dryRunFlag ){
552552
char *zFullPath = mprintf("%s/%s", g.zLocalRoot, zName);
553
- file_wd_setexe(zFullPath, isExe);
553
+ file_setexe(zFullPath, isExe);
554554
free(zFullPath);
555555
db_multi_exec("UPDATE vfile SET isexe=%d WHERE id=%d", isExe, idv);
556556
}
557557
}
558558
db_finalize(&q);
@@ -628,11 +628,11 @@
628628
fossil_print("MERGE %s (pivot=%d v1=%d v2=%d)\n",
629629
zName, ridp, ridm, ridv);
630630
}else{
631631
fossil_print("MERGE %s\n", zName);
632632
}
633
- if( islinkv || islinkm /* || file_wd_islink(zFullPath) */ ){
633
+ if( islinkv || islinkm ){
634634
fossil_print("***** Cannot merge symlink %s\n", zName);
635635
nConflict++;
636636
}else{
637637
if( !dryRunFlag ) undo_save(zName);
638638
zFullPath = mprintf("%s/%s", g.zLocalRoot, zName);
@@ -646,11 +646,11 @@
646646
rc = merge_3way(&p, zFullPath, &m, &r, mergeFlags);
647647
}
648648
if( rc>=0 ){
649649
if( !dryRunFlag ){
650650
blob_write_to_file(&r, zFullPath);
651
- file_wd_setexe(zFullPath, isExe);
651
+ file_setexe(zFullPath, isExe);
652652
}
653653
db_multi_exec("UPDATE vfile SET mtime=0 WHERE id=%d", idv);
654654
if( rc>0 ){
655655
fossil_print("***** %d merge conflicts in %s\n", rc, zName);
656656
nConflict++;
@@ -736,28 +736,28 @@
736736
zFullOldPath = db_text(0,"SELECT tmpfn FROM tmprn WHERE fn=%Q", zOldName);
737737
if( !zFullOldPath ){
738738
zFullOldPath = mprintf("%s%s", g.zLocalRoot, zOldName);
739739
}
740740
zFullNewPath = mprintf("%s%s", g.zLocalRoot, zNewName);
741
- if( file_wd_size(zFullNewPath)>=0 ){
741
+ if( file_size(zFullNewPath, RepoFILE)>=0 ){
742742
Blob tmpPath;
743743
file_tempname(&tmpPath, "");
744744
db_multi_exec("INSERT INTO tmprn(fn,tmpfn) VALUES(%Q,%Q)",
745745
zNewName, blob_str(&tmpPath));
746
- if( file_wd_islink(zFullNewPath) ){
746
+ if( file_islink(zFullNewPath) ){
747747
symlink_copy(zFullNewPath, blob_str(&tmpPath));
748748
}else{
749749
file_copy(zFullNewPath, blob_str(&tmpPath));
750750
}
751751
blob_reset(&tmpPath);
752752
}
753
- if( file_wd_islink(zFullOldPath) ){
753
+ if( file_islink(zFullOldPath) ){
754754
symlink_copy(zFullOldPath, zFullNewPath);
755755
}else{
756756
file_copy(zFullOldPath, zFullNewPath);
757757
}
758
- file_wd_setexe(zFullNewPath, isExe);
758
+ file_setexe(zFullNewPath, isExe);
759759
file_delete(zFullOldPath);
760760
free(zFullNewPath);
761761
free(zFullOldPath);
762762
}
763763
}
@@ -789,11 +789,11 @@
789789
" SELECT %d,%d,0,rid,mrid,isexe,islink,pathname FROM vfile WHERE id=%d",
790790
vid, integrateFlag?5:3, idm
791791
);
792792
zName = db_column_text(&q, 1);
793793
zFullName = mprintf("%s%s", g.zLocalRoot, zName);
794
- if( file_wd_isfile_or_link(zFullName)
794
+ if( file_isfile_or_link(zFullName)
795795
&& !db_exists("SELECT 1 FROM fv WHERE fn=%Q", zName) ){
796796
fossil_print("ADDED %s (overwrites an unmanaged file)\n", zName);
797797
nOverwrite++;
798798
}else{
799799
fossil_print("ADDED %s\n", zName);
800800
--- 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 @@
333333
** Return true if the named file contains an unresolved merge marker line.
334334
*/
335335
int file_contains_merge_marker(const char *zFullpath){
336336
Blob file;
337337
int rc;
338
- blob_read_from_file(&file, zFullpath);
338
+ blob_read_from_file(&file, zFullpath, ExtFILE);
339339
rc = contains_merge_marker(&file);
340340
blob_reset(&file);
341341
return rc;
342342
}
343343
@@ -376,17 +376,17 @@
376376
verify_all_options();
377377
378378
if( g.argc!=6 ){
379379
usage("PIVOT V1 V2 MERGED");
380380
}
381
- if( blob_read_from_file(&pivot, g.argv[2])<0 ){
381
+ if( blob_read_from_file(&pivot, g.argv[2], ExtFILE)<0 ){
382382
fossil_fatal("cannot read %s", g.argv[2]);
383383
}
384
- if( blob_read_from_file(&v1, g.argv[3])<0 ){
384
+ if( blob_read_from_file(&v1, g.argv[3], ExtFILE)<0 ){
385385
fossil_fatal("cannot read %s", g.argv[3]);
386386
}
387
- if( blob_read_from_file(&v2, g.argv[4])<0 ){
387
+ if( blob_read_from_file(&v2, g.argv[4], ExtFILE)<0 ){
388388
fossil_fatal("cannot read %s", g.argv[4]);
389389
}
390390
nConflict = blob_merge(&pivot, &v1, &v2, &merged);
391391
if( blob_write_to_file(&merged, g.argv[5])<blob_size(&merged) ){
392392
fossil_fatal("cannot write %s", g.argv[4]);
@@ -466,11 +466,11 @@
466466
unsigned mergeFlags /* Flags that control operation */
467467
){
468468
Blob v1; /* Content of zV1 */
469469
int rc; /* Return code of subroutines and this routine */
470470
471
- blob_read_from_file(&v1, zV1);
471
+ blob_read_from_file(&v1, zV1, ExtFILE);
472472
rc = blob_merge(pPivot, &v1, pV2, pOut);
473473
if( rc!=0 && (mergeFlags & MERGE_DRYRUN)==0 ){
474474
char *zPivot; /* Name of the pivot file */
475475
char *zOrig; /* Name of the original content file */
476476
char *zOther; /* Name of the merge file */
@@ -496,12 +496,12 @@
496496
azSubst[4] = "%merge"; azSubst[5] = zOther;
497497
azSubst[6] = "%output"; azSubst[7] = zOut;
498498
zCmd = string_subst(zGMerge, 8, azSubst);
499499
printf("%s\n", zCmd); fflush(stdout);
500500
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);
503503
file_delete(zPivot);
504504
file_delete(zOrig);
505505
file_delete(zOther);
506506
file_delete(zOut);
507507
}
508508
--- 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 @@
943943
zUtf8Name = fossil_path_to_utf8(pEntry->d_name);
944944
zSubpath = mprintf("%s/%s", zPath, zUtf8Name);
945945
fossil_path_free(zUtf8Name);
946946
#ifdef _DIRENT_HAVE_D_TYPE
947947
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) )
949949
#else
950
- if( file_isdir(zSubpath)==1 )
950
+ if( file_isdir(zSubpath, ExtFILE)==1 )
951951
#endif
952952
{
953953
recon_read_dir(zSubpath);
954954
}else{
955955
blob_init(&path, 0, 0);
956956
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 ){
958958
fossil_fatal("some unknown error occurred while reading \"%s\"",
959959
blob_str(&path));
960960
}
961961
content_put(&aContent);
962962
blob_reset(&path);
@@ -989,11 +989,11 @@
989989
void reconstruct_cmd(void) {
990990
char *zPassword;
991991
if( g.argc!=4 ){
992992
usage("FILENAME DIRECTORY");
993993
}
994
- if( file_isdir(g.argv[3])!=1 ){
994
+ if( file_isdir(g.argv[3], ExtFILE)!=1 ){
995995
fossil_print("\"%s\" is not a directory\n\n", g.argv[3]);
996996
usage("FILENAME DIRECTORY");
997997
}
998998
db_create_repository(g.argv[2]);
999999
db_open_repository(g.argv[2]);
@@ -1071,11 +1071,11 @@
10711071
if( g.argc!=3 ){
10721072
usage ("?OPTIONS? DESTINATION");
10731073
}
10741074
/* get and check argument destination directory */
10751075
zDestDir = g.argv[g.argc-1];
1076
- if( !*zDestDir || !file_isdir(zDestDir)) {
1076
+ if( !*zDestDir || !file_isdir(zDestDir, ExtFILE)) {
10771077
fossil_fatal("DESTINATION(%s) is not a directory!",zDestDir);
10781078
}
10791079
#ifndef _WIN32
10801080
if( file_access(zDestDir, W_OK) ){
10811081
fossil_fatal("DESTINATION(%s) is not writeable!",zDestDir);
10821082
--- 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 @@
351351
if( zBegin==0 ) zBegin = "[[";
352352
if( zEnd==0 ) zEnd = "]]";
353353
if( zGap==0 ) zGap = " ... ";
354354
p = search_init(g.argv[2], zBegin, zEnd, zGap, flg);
355355
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);
357357
zDoc = blob_str(&x);
358358
score = search_match(p, 1, (const char**)&zDoc);
359359
fossil_print("%s: %d\n", g.argv[i], p->iScore);
360360
blob_reset(&x);
361361
if( score ){
@@ -1422,11 +1422,11 @@
14221422
*/
14231423
void test_convert_stext(void){
14241424
Blob in, out;
14251425
db_find_and_open_repository(0,0);
14261426
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);
14281428
blob_init(&out, 0, 0);
14291429
get_stext_by_mimetype(&in, g.argv[3], &out);
14301430
fossil_print("%s\n",blob_str(&out));
14311431
blob_reset(&in);
14321432
blob_reset(&out);
14331433
--- 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 @@
352352
** Compute the SHA1 checksum of a file on disk. Store the resulting
353353
** checksum in the blob pCksum. pCksum is assumed to be initialized.
354354
**
355355
** Return the number of errors.
356356
*/
357
-int sha1sum_file(const char *zFilename, Blob *pCksum){
357
+int sha1sum_file(const char *zFilename, int eFType, Blob *pCksum){
358358
FILE *in;
359359
SHA1Context ctx;
360360
unsigned char zResult[20];
361361
char zBuf[10240];
362362
363
- if( file_wd_islink(zFilename) ){
363
+ if( eFType==RepoFILE && file_islink(zFilename) ){
364364
/* Instead of file content, return sha1 of link destination path */
365365
Blob destinationPath;
366366
int rc;
367367
368368
blob_read_link(&destinationPath, zFilename);
@@ -520,23 +520,33 @@
520520
**
521521
** Usage: %fossil sha1sum FILE...
522522
**
523523
** Compute an SHA1 checksum of all files named on the command-line.
524524
** 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.
525531
*/
526532
void sha1sum_test(void){
527533
int i;
528534
Blob in;
529535
Blob cksum;
536
+ int eFType = SymFILE;
537
+ if( find_option("dereference","h",0)!=0 ){
538
+ eFType = ExtFILE;
539
+ }
530540
531541
for(i=2; i<g.argc; i++){
532542
blob_init(&cksum, "************** not found ***************", -1);
533543
if( g.argv[i][0]=='-' && g.argv[i][1]==0 ){
534544
blob_read_from_channel(&in, stdin, -1);
535545
sha1sum_blob(&in, &cksum);
536546
}else{
537
- sha1sum_file(g.argv[i], &cksum);
547
+ sha1sum_file(g.argv[i], eFType, &cksum);
538548
}
539549
fossil_print("%s %s\n", blob_str(&cksum), g.argv[i]);
540550
blob_reset(&cksum);
541551
}
542552
}
543553
--- 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 @@
545545
** Compute the SHA3 checksum of a file on disk. Store the resulting
546546
** checksum in the blob pCksum. pCksum is assumed to be initialized.
547547
**
548548
** Return the number of errors.
549549
*/
550
-int sha3sum_file(const char *zFilename, int iSize, Blob *pCksum){
550
+int sha3sum_file(const char *zFilename, int eFType, int iSize, Blob *pCksum){
551551
FILE *in;
552552
SHA3Context ctx;
553553
char zBuf[10240];
554554
555
- if( file_wd_islink(zFilename) ){
555
+ if( eFType==RepoFILE && file_islink(zFilename) ){
556556
/* Instead of file content, return sha3 of link destination path */
557557
Blob destinationPath;
558558
int rc;
559559
560560
blob_read_link(&destinationPath, zFilename);
@@ -629,23 +629,27 @@
629629
** To be clear: The official NIST FIPS-202 implementation of SHA3
630630
** with the added 01 padding is used, not the original Keccak submission.
631631
**
632632
** Options:
633633
**
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.
640642
*/
641643
void sha3sum_test(void){
642644
int i;
643645
Blob in;
644646
Blob cksum;
645647
int iSize = 256;
648
+ int eFType = SymFILE;
646649
650
+ if( find_option("dereference","h",0) ) eFType = ExtFILE;
647651
if( find_option("224",0,0)!=0 ) iSize = 224;
648652
else if( find_option("256",0,0)!=0 ) iSize = 256;
649653
else if( find_option("384",0,0)!=0 ) iSize = 384;
650654
else if( find_option("512",0,0)!=0 ) iSize = 512;
651655
else{
@@ -664,11 +668,11 @@
664668
blob_init(&cksum, "************** not found ***************", -1);
665669
if( g.argv[i][0]=='-' && g.argv[i][1]==0 ){
666670
blob_read_from_channel(&in, stdin, -1);
667671
sha3sum_blob(&in, iSize, &cksum);
668672
}else{
669
- sha3sum_file(g.argv[i], iSize, &cksum);
673
+ sha3sum_file(g.argv[i], eFType, iSize, &cksum);
670674
}
671675
fossil_print("%s %s\n", blob_str(&cksum), g.argv[i]);
672676
blob_reset(&cksum);
673677
}
674678
}
675679
--- 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 @@
136136
const char *skin_get(const char *zWhat){
137137
const char *zOut;
138138
char *z;
139139
if( zAltSkinDir ){
140140
char *z = mprintf("%s/%s.txt", zAltSkinDir, zWhat);
141
- if( file_isfile(z) ){
141
+ if( file_isfile(z, ExtFILE) ){
142142
Blob x;
143
- blob_read_from_file(&x, z);
143
+ blob_read_from_file(&x, z, ExtFILE);
144144
fossil_free(z);
145145
return blob_str(&x);
146146
}
147147
fossil_free(z);
148148
}
149149
--- 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 @@
8989
int rid = db_column_int(&q, 3);
9090
const char *zName = db_column_text(&q, 4);
9191
const char *zOrig = db_column_text(&q, 5);
9292
char *zPath = mprintf("%s%s", g.zLocalRoot, zName);
9393
Blob content;
94
- int isNewLink = file_wd_islink(zPath);
9594
9695
db_bind_int(&ins, ":rid", rid);
9796
db_bind_int(&ins, ":isadd", rid==0);
9897
db_bind_int(&ins, ":isrm", deleted);
9998
db_bind_int(&ins, ":isexe", db_column_int(&q, 1));
@@ -101,36 +100,28 @@
101100
db_bind_text(&ins, ":orig", zOrig);
102101
db_bind_text(&ins, ":new", zName);
103102
104103
if( rid==0 ){
105104
/* 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);
111106
db_bind_blob(&ins, ":content", &content);
112107
}else if( deleted ){
113108
blob_zero(&content);
114109
db_bind_null(&ins, ":content");
115110
}else{
116111
/* A modified file */
117112
Blob orig;
118113
Blob disk;
119114
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);
125116
content_get(rid, &orig);
126117
blob_delta_create(&orig, &disk, &content);
127118
blob_reset(&orig);
128119
blob_reset(&disk);
129120
db_bind_blob(&ins, ":content", &content);
130121
}
131
- db_bind_int(&ins, ":islink", isNewLink);
122
+ db_bind_int(&ins, ":islink", file_islink(zPath));
132123
db_step(&ins);
133124
db_reset(&ins);
134125
fossil_free(zPath);
135126
blob_reset(&content);
136127
}
@@ -225,23 +216,19 @@
225216
blob_zero(&delta);
226217
if( rid==0 ){
227218
db_multi_exec("INSERT OR IGNORE INTO sfile(pathname) VALUES(%Q)", zNew);
228219
db_ephemeral_blob(&q, 6, &delta);
229220
blob_write_to_file(&delta, zNPath);
230
- file_wd_setexe(zNPath, isExec);
221
+ file_setexe(zNPath, isExec);
231222
}else if( isRemoved ){
232223
fossil_print("DELETE %s\n", zOrig);
233224
file_delete(zOPath);
234225
}else{
235226
Blob a, b, out, disk;
236
- int isNewLink = file_wd_islink(zOPath);
227
+ int isNewLink = file_islink(zOPath);
237228
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);
243230
content_get(rid, &a);
244231
blob_delta_apply(&a, &delta, &b);
245232
if( isLink == isNewLink && blob_compare(&disk, &a)==0 ){
246233
if( isLink || isNewLink ){
247234
file_delete(zNPath);
@@ -249,11 +236,11 @@
249236
if( isLink ){
250237
symlink_create(blob_str(&b), zNPath);
251238
}else{
252239
blob_write_to_file(&b, zNPath);
253240
}
254
- file_wd_setexe(zNPath, isExec);
241
+ file_setexe(zNPath, isExec);
255242
fossil_print("UPDATE %s\n", zNew);
256243
}else{
257244
int rc;
258245
if( isLink || isNewLink ){
259246
rc = -1;
@@ -261,11 +248,11 @@
261248
fossil_print("***** Cannot merge symlink %s\n", zNew);
262249
}else{
263250
rc = merge_3way(&a, zOPath, &b, &out, 0);
264251
blob_write_to_file(&out, zNPath);
265252
blob_reset(&out);
266
- file_wd_setexe(zNPath, isExec);
253
+ file_setexe(zNPath, isExec);
267254
}
268255
if( rc ){
269256
fossil_print("CONFLICT %s\n", zNew);
270257
nConflict++;
271258
}else{
@@ -343,11 +330,11 @@
343330
zBinGlob, fIncludeBinary, diffFlags);
344331
}else{
345332
}
346333
}else{
347334
Blob delta;
348
- int isOrigLink = file_wd_islink(zOPath);
335
+ int isOrigLink = file_islink(zOPath);
349336
db_ephemeral_blob(&q, 6, &delta);
350337
fossil_print("CHANGED %s\n", zNew);
351338
if( !isOrigLink != !isLink ){
352339
diff_print_index(zNew, diffFlags);
353340
diff_print_filenames(zOrig, zNew, diffFlags);
354341
--- 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 @@
8686
if( g.perm.Admin || g.perm.Setup || db_get_boolean("test_env_enable",0) ){
8787
style_submenu_element("Environment", "test_env");
8888
}
8989
@ <table class="label-value">
9090
@ <tr><th>Repository&nbsp;Size:</th><td>
91
- fsize = file_size(g.zRepositoryName);
91
+ fsize = file_size(g.zRepositoryName, ExtFILE);
9292
bigSizeName(sizeof(zBuf), zBuf, fsize);
9393
@ %s(zBuf)
9494
@ </td></tr>
9595
if( !brief ){
9696
@ <tr><th>Number&nbsp;Of&nbsp;Artifacts:</th><td>
@@ -241,11 +241,11 @@
241241
if( (z = db_get("project-name",0))!=0
242242
|| (z = db_get("short-project-name",0))!=0
243243
){
244244
fossil_print("%*s%s\n", colWidth, "project-name:", z);
245245
}
246
- fsize = file_size(g.zRepositoryName);
246
+ fsize = file_size(g.zRepositoryName, ExtFILE);
247247
bigSizeName(sizeof(zBuf), zBuf, fsize);
248248
fossil_print( "%*s%s\n", colWidth, "repository-size:", zBuf );
249249
if( !brief ){
250250
n = db_int(0, "SELECT count(*) FROM blob");
251251
m = db_int(0, "SELECT count(*) FROM delta");
@@ -534,11 +534,11 @@
534534
db_multi_exec(
535535
"INSERT INTO piechart(amt,label) VALUES(%d,'freelist')",
536536
nPageFree
537537
);
538538
}
539
- fsize = file_size(g.zRepositoryName);
539
+ fsize = file_size(g.zRepositoryName, ExtFILE);
540540
approxSizeName(sizeof(zBuf), zBuf, fsize);
541541
@ <h2>Repository Size: %s(zBuf)</h2>
542542
@ <center><svg width='800' height='500'>
543543
piechart_render(800,500,PIE_OTHER|PIE_PERCENT);
544544
@ </svg></center>
@@ -560,14 +560,14 @@
560560
db_multi_exec(
561561
"INSERT INTO piechart(amt,label) VALUES(%d,'freelist')",
562562
nPageFree
563563
);
564564
}
565
- fsize = file_size(g.zLocalDbName);
565
+ fsize = file_size(g.zLocalDbName, ExtFILE);
566566
approxSizeName(sizeof(zBuf), zBuf, fsize);
567567
@ <h2>%h(file_tail(g.zLocalDbName)) Size: %s(zBuf)</h2>
568568
@ <center><svg width='800' height='500'>
569569
piechart_render(800,500,PIE_OTHER|PIE_PERCENT);
570570
@ </svg></center>
571571
}
572572
style_footer();
573573
}
574574
--- 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&nbsp;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&nbsp;Of&nbsp;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&nbsp;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&nbsp;Of&nbsp;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 @@
803803
void contains_selector_cmd(void){
804804
int found;
805805
char *zSelector;
806806
Blob css;
807807
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);
809809
zSelector = g.argv[3];
810810
found = containsSelector(blob_str(&css), zSelector);
811811
fossil_print("%s %s\n", zSelector, found ? "found" : "not found");
812812
blob_reset(&css);
813813
}
814814
--- 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 @@
424424
/*
425425
** COMMAND: test-tarball
426426
**
427427
** Generate a GZIP-compressed tarball in the file given by the first argument
428428
** that contains files given in the second and subsequent arguments.
429
+**
430
+** -h, --dereference Follow symlinks; archive the files they point to.
429431
*/
430432
void test_tarball_cmd(void){
431433
int i;
432434
Blob zip;
435
+ int eFType = SymFILE;
433436
if( g.argc<3 ){
434
- usage("ARCHIVE FILE....");
437
+ usage("ARCHIVE [options] FILE....");
438
+ }
439
+ if( find_option("dereference","h",0) ){
440
+ eFType = ExtFILE;
435441
}
436442
sqlite3_open(":memory:", &g.db);
437443
tar_begin(-1);
438444
for(i=3; i<g.argc; i++){
439445
Blob file;
440446
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));
443449
blob_reset(&file);
444450
}
445451
tar_finish(&zip);
446452
blob_write_to_file(&zip, g.argv[2]);
447453
}
448454
--- 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 @@
25192519
verify_all_options();
25202520
if( g.argc<3 ){
25212521
usage("FILE");
25222522
}
25232523
blob_zero(&in);
2524
- blob_read_from_file(&in, g.argv[2]);
2524
+ blob_read_from_file(&in, g.argv[2], ExtFILE);
25252525
Th_Render(blob_str(&in));
25262526
Th_PrintTraceLog();
25272527
if( forceCgi ) cgi_reply();
25282528
}
25292529
@@ -2622,11 +2622,11 @@
26222622
verify_all_options();
26232623
if( g.argc!=3 ){
26242624
usage("file");
26252625
}
26262626
blob_zero(&in);
2627
- blob_read_from_file(&in, g.argv[2]);
2627
+ blob_read_from_file(&in, g.argv[2], ExtFILE);
26282628
Th_FossilInit(TH_INIT_DEFAULT);
26292629
rc = Th_Eval(g.interp, 0, blob_str(&in), -1);
26302630
zRc = Th_ReturnCodeName(rc, 1);
26312631
fossil_print("%s%s%s\n", zRc, zRc ? ": " : "", Th_GetResult(g.interp, 0));
26322632
Th_PrintTraceLog();
26332633
--- 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 @@
846846
** interpreter and initialize the stubs mechanism; otherwise, simply setup
847847
** the function pointers provided by the caller with the statically linked
848848
** functions.
849849
*/
850850
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 */
852852
char *file_dirname(const char *zPath); /* file.h */
853853
void fossil_free(void *p); /* util.h */
854854
855855
static int loadTcl(
856856
Th_Interp *interp,
@@ -875,11 +875,11 @@
875875
do {
876876
char *zFileName;
877877
void *hLibrary;
878878
if( !zEnvPath ){
879879
zFileName = aFileName; /* NOTE: Assume present in PATH. */
880
- }else if( file_isdir(zEnvPath)==1 ){
880
+ }else if( file_isdir(zEnvPath, ExtFILE)==1 ){
881881
#if TCL_USE_SET_DLL_DIRECTORY
882882
SetDllDirectory(zEnvPath); /* NOTE: Maybe needed for "zlib1.dll". */
883883
#endif /* TCL_USE_SET_DLL_DIRECTORY */
884884
/* NOTE: The environment variable contains a directory name. */
885885
zFileName = sqlite3_mprintf("%s%c%s%c", zEnvPath, TCL_DIRECTORY_SEP,
886886
--- 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 @@
5454
int old_link;
5555
Blob current;
5656
Blob new;
5757
zFullname = mprintf("%s/%s", g.zLocalRoot, zPathname);
5858
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);
6161
if( new_exists ){
62
- if( new_link ){
63
- blob_read_link(&current, zFullname);
64
- }else{
65
- blob_read_from_file(&current, zFullname);
66
- }
67
- new_exe = file_wd_isexe(0);
62
+ blob_read_from_file(&current, zFullname, RepoFILE);
63
+ new_exe = file_isexe(0,0);
6864
}else{
6965
blob_zero(&current);
7066
new_exe = 0;
7167
}
7268
blob_zero(&new);
@@ -87,11 +83,11 @@
8783
if( old_link ){
8884
symlink_create(blob_str(&new), zFullname);
8985
}else{
9086
blob_write_to_file(&new, zFullname);
9187
}
92
- file_wd_setexe(zFullname, old_exe);
88
+ file_setexe(zFullname, old_exe);
9389
}else{
9490
fossil_print("DELETE %s\n", zPathname);
9591
file_delete(zFullname);
9692
}
9793
blob_reset(&new);
@@ -317,28 +313,24 @@
317313
int result;
318314
319315
if( undoDisable ) return UNDO_DISABLED;
320316
if( !undoActive ) return UNDO_INACTIVE;
321317
zFullname = mprintf("%s%s", g.zLocalRoot, zPathname);
322
- size = file_wd_size(zFullname);
318
+ size = file_size(zFullname, RepoFILE);
323319
if( limit<0 || size<=limit ){
324320
int existsFlag = (size>=0);
325
- int isLink = file_wd_islink(zFullname);
321
+ int isLink = file_islink(zFullname);
326322
Stmt q;
327323
Blob content;
328324
db_prepare(&q,
329325
"INSERT OR IGNORE INTO"
330326
" undo(pathname,redoflag,existsflag,isExe,isLink,content)"
331327
" VALUES(%Q,0,%d,%d,%d,:c)",
332
- zPathname, existsFlag, file_wd_isexe(zFullname), isLink
328
+ zPathname, existsFlag, file_isexe(zFullname,RepoFILE), isLink
333329
);
334330
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);
340332
db_bind_blob(&q, ":c", &content);
341333
}
342334
db_step(&q);
343335
db_finalize(&q);
344336
if( existsFlag ){
345337
--- 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(&current, zFullname);
64 }else{
65 blob_read_from_file(&current, zFullname);
66 }
67 new_exe = file_wd_isexe(0);
68 }else{
69 blob_zero(&current);
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(&current, zFullname, RepoFILE);
63 new_exe = file_isexe(0,0);
 
 
 
 
64 }else{
65 blob_zero(&current);
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
--- src/unversioned.c
+++ src/unversioned.c
@@ -301,11 +301,11 @@
301301
}
302302
if( zError ){
303303
fossil_fatal("unversioned filenames may not %s: %Q", zError, zIn);
304304
}
305305
blob_init(&file,0,0);
306
- blob_read_from_file(&file, g.argv[i]);
306
+ blob_read_from_file(&file, g.argv[i], ExtFILE);
307307
unversioned_write(zIn, &file, mtime);
308308
blob_reset(&file);
309309
}
310310
db_end_transaction(0);
311311
}else if( memcmp(zCmd, "cat", nCmd)==0 ){
@@ -350,11 +350,11 @@
350350
if( fossil_system(zCmd) ){
351351
fossil_fatal("editor aborted: %Q", zCmd);
352352
}
353353
fossil_free(zCmd);
354354
blob_reset(&content);
355
- blob_read_from_file(&content, zTFile);
355
+ blob_read_from_file(&content, zTFile, ExtFILE);
356356
#if defined(_WIN32) || defined(__CYGWIN__)
357357
blob_to_lf_only(&content);
358358
#endif
359359
file_delete(zTFile);
360360
if( zMtime==0 ) mtime = time(0);
361361
--- 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 @@
353353
blob_zero(&sql);
354354
blob_append(&sql, "DELETE FROM fv WHERE ", -1);
355355
zSep = "";
356356
for(i=3; i<g.argc; i++){
357357
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 ){
359359
if( blob_size(&treename) != 1 || blob_str(&treename)[0] != '.' ){
360360
blob_append_sql(&sql, "%sfn NOT GLOB '%q/*' ",
361361
zSep /*safe-for-%s*/, blob_str(&treename));
362362
}else{
363363
blob_reset(&sql);
@@ -418,11 +418,11 @@
418418
*/
419419
fossil_print("CONFLICT %s\n", zName);
420420
nConflict++;
421421
}else if( idt>0 && idv==0 ){
422422
/* File added in the target. */
423
- if( file_wd_isfile_or_link(zFullPath) ){
423
+ if( file_isfile_or_link(zFullPath) ){
424424
fossil_print("ADD %s - overwrites an unmanaged file\n", zName);
425425
nOverwrite++;
426426
}else{
427427
fossil_print("ADD %s\n", zName);
428428
}
@@ -435,11 +435,11 @@
435435
}else{
436436
fossil_print("UPDATE %s\n", zName);
437437
}
438438
if( !dryRunFlag && !internalUpdate ) undo_save(zName);
439439
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 ){
441441
/* The file missing from the local check-out. Restore it to the
442442
** version that appears in the target. */
443443
fossil_print("UPDATE %s\n", zName);
444444
if( !dryRunFlag && !internalUpdate ) undo_save(zName);
445445
if( !dryRunFlag ) vfile_to_disk(0, idt, 0, 0);
@@ -466,11 +466,11 @@
466466
if( nameChng ){
467467
fossil_print("MERGE %s -> %s\n", zName, zNewName);
468468
}else{
469469
fossil_print("MERGE %s\n", zName);
470470
}
471
- if( islinkv || islinkt /* || file_wd_islink(zFullPath) */ ){
471
+ if( islinkv || islinkt ){
472472
fossil_print("***** Cannot merge symlink %s\n", zNewName);
473473
nConflict++;
474474
}else{
475475
unsigned mergeFlags = dryRunFlag ? MERGE_DRYRUN : 0;
476476
if( !dryRunFlag && !internalUpdate ) undo_save(zName);
@@ -478,20 +478,20 @@
478478
content_get(ridv, &v);
479479
rc = merge_3way(&v, zFullPath, &t, &r, mergeFlags);
480480
if( rc>=0 ){
481481
if( !dryRunFlag ){
482482
blob_write_to_file(&r, zFullNewPath);
483
- file_wd_setexe(zFullNewPath, isexe);
483
+ file_setexe(zFullNewPath, isexe);
484484
}
485485
if( rc>0 ){
486486
fossil_print("***** %d merge conflicts in %s\n", rc, zNewName);
487487
nConflict++;
488488
}
489489
}else{
490490
if( !dryRunFlag ){
491491
blob_write_to_file(&t, zFullNewPath);
492
- file_wd_setexe(zFullNewPath, isexe);
492
+ file_setexe(zFullNewPath, isexe);
493493
}
494494
fossil_print("***** Cannot merge binary file %s\n", zNewName);
495495
nConflict++;
496496
}
497497
}
@@ -603,15 +603,15 @@
603603
}
604604
blob_init(&dirsList, zEmptyDirs, -1);
605605
while( blob_token(&dirsList, &dirName) ){
606606
char *zDir = blob_str(&dirName);
607607
char *zPath = mprintf("%s/%s", g.zLocalRoot, zDir);
608
- switch( file_wd_isdir(zPath) ){
608
+ switch( file_isdir(zPath, RepoFILE) ){
609609
case 0: { /* doesn't exist */
610610
fossil_free(zPath);
611611
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 ) {
613613
fossil_warning("couldn't create directory %s as "
614614
"required by empty-dirs setting", zDir);
615615
}
616616
break;
617617
}
@@ -850,21 +850,23 @@
850850
851851
/* Get contents of reverted-to file. */
852852
content_get(fast_uuid_to_rid(pRvFile->zUuid), &record);
853853
854854
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
+ ){
856858
file_delete(zFull);
857859
}
858860
if( rvPerm==PERM_LNK ){
859861
symlink_create(blob_str(&record), zFull);
860862
}else{
861863
blob_write_to_file(&record, zFull);
862864
}
863
- file_wd_setexe(zFull, rvPerm==PERM_EXE);
865
+ file_setexe(zFull, rvPerm==PERM_EXE);
864866
fossil_print("REVERT %s\n", zFile);
865
- mtime = file_wd_mtime(zFull);
867
+ mtime = file_mtime(zFull, RepoFILE);
866868
db_multi_exec(
867869
"UPDATE vfile"
868870
" SET mtime=%lld, chnged=%d, deleted=0, isexe=%d, islink=%d,mrid=rid"
869871
" WHERE pathname=%Q OR origname=%Q",
870872
mtime, rvChnged, rvPerm==PERM_EXE, rvPerm==PERM_LNK, zFile, zFile
871873
--- 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 @@
244244
i = 7;
245245
}else{
246246
i = 5;
247247
}
248248
zFile = mprintf("%s", &zUrl[i]);
249
- }else if( file_isfile(zUrl) ){
249
+ }else if( file_isfile(zUrl, ExtFILE) ){
250250
pUrlData->isFile = 1;
251251
zFile = mprintf("%s", zUrl);
252
- }else if( file_isdir(zUrl)==1 ){
252
+ }else if( file_isdir(zUrl, ExtFILE)==1 ){
253253
zFile = mprintf("%s/FOSSIL", zUrl);
254
- if( file_isfile(zFile) ){
254
+ if( file_isfile(zFile, ExtFILE) ){
255255
pUrlData->isFile = 1;
256256
}else{
257257
free(zFile);
258258
zFile = 0;
259259
fossil_fatal("unknown repository: %s", zUrl);
260260
--- 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 @@
202202
rid = db_column_int(&q, 2);
203203
isDeleted = db_column_int(&q, 3);
204204
oldChnged = chnged = db_column_int(&q, 4);
205205
oldMtime = db_column_int64(&q, 7);
206206
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);
209209
#ifndef _WIN32
210210
origPerm = db_column_int(&q, 8);
211
- currentPerm = file_wd_perm(zName);
211
+ currentPerm = file_perm(zName, RepoFILE);
212212
#endif
213213
if( chnged==0 && (isDeleted || rid==0) ){
214214
/* "fossil rm" or "fossil add" always change the file */
215215
chnged = 1;
216
- }else if( !file_wd_isfile_or_link(0) && currentSize>=0 ){
216
+ }else if( !file_isfile_or_link(0) && currentSize>=0 ){
217217
if( cksigFlags & CKSIG_ENOTFILE ){
218218
fossil_warning("not an ordinary file: %s", zName);
219219
nErr++;
220220
}
221221
chnged = 1;
@@ -247,11 +247,11 @@
247247
if( (cksigFlags & CKSIG_SETMTIME) && (chnged==0 || chnged==2 || chnged==4) ){
248248
i64 desiredMtime;
249249
if( mtime_of_manifest_file(vid,rid,&desiredMtime)==0 ){
250250
if( currentMtime!=desiredMtime ){
251251
file_set_mtime(zName, desiredMtime);
252
- currentMtime = file_wd_mtime(zName);
252
+ currentMtime = file_mtime(zName, RepoFILE);
253253
}
254254
}
255255
}
256256
#ifndef _WIN32
257257
if( origPerm!=PERM_LNK && currentPerm==PERM_LNK ){
@@ -316,17 +316,17 @@
316316
isExe = db_column_int(&q, 3);
317317
isLink = db_column_int(&q, 4);
318318
content_get(rid, &content);
319319
if( file_is_the_same(&content, zName) ){
320320
blob_reset(&content);
321
- if( file_wd_setexe(zName, isExe) ){
321
+ if( file_setexe(zName, isExe) ){
322322
db_multi_exec("UPDATE vfile SET mtime=%lld WHERE id=%d",
323
- file_wd_mtime(zName), id);
323
+ file_mtime(zName, RepoFILE), id);
324324
}
325325
continue;
326326
}
327
- if( promptFlag && file_wd_size(zName)>=0 ){
327
+ if( promptFlag && file_size(zName, RepoFILE)>=0 ){
328328
Blob ans;
329329
char *zMsg;
330330
char cReply;
331331
zMsg = mprintf("overwrite %s (a=always/y/N)? ", zName);
332332
prompt_user(zMsg, &ans);
@@ -339,26 +339,26 @@
339339
blob_reset(&content);
340340
continue;
341341
}
342342
}
343343
if( verbose ) fossil_print("%s\n", &zName[nRepos]);
344
- if( file_wd_isdir(zName)==1 ){
344
+ if( file_isdir(zName, RepoFILE)==1 ){
345345
/*TODO(dchest): remove directories? */
346346
fossil_fatal("%s is directory, cannot overwrite", zName);
347347
}
348
- if( file_wd_size(zName)>=0 && (isLink || file_wd_islink(0)) ){
348
+ if( file_size(zName, RepoFILE)>=0 && (isLink || file_islink(0)) ){
349349
file_delete(zName);
350350
}
351351
if( isLink ){
352352
symlink_create(blob_str(&content), zName);
353353
}else{
354354
blob_write_to_file(&content, zName);
355355
}
356
- file_wd_setexe(zName, isExe);
356
+ file_setexe(zName, isExe);
357357
blob_reset(&content);
358358
db_multi_exec("UPDATE vfile SET mtime=%lld WHERE id=%d",
359
- file_wd_mtime(zName), id);
359
+ file_mtime(zName, RepoFILE), id);
360360
}
361361
db_finalize(&q);
362362
}
363363
364364
@@ -387,15 +387,15 @@
387387
int vfile_top_of_checkout(const char *zPath){
388388
char *zFile;
389389
int fileFound = 0;
390390
391391
zFile = mprintf("%s/_FOSSIL_", zPath);
392
- fileFound = file_size(zFile)>=1024;
392
+ fileFound = file_size(zFile, ExtFILE)>=1024;
393393
fossil_free(zFile);
394394
if( !fileFound ){
395395
zFile = mprintf("%s/.fslckout", zPath);
396
- fileFound = file_size(zFile)>=1024;
396
+ fileFound = file_size(zFile, ExtFILE)>=1024;
397397
fossil_free(zFile);
398398
}
399399
400400
/* Check for ".fos" for legacy support. But the use of ".fos" as the
401401
** per-checkout database name is deprecated. At some point, all support
@@ -402,11 +402,11 @@
402402
** for ".fos" will end and this code should be removed. This comment
403403
** added on 2012-02-04.
404404
*/
405405
if( !fileFound ){
406406
zFile = mprintf("%s/.fos", zPath);
407
- fileFound = file_size(zFile)>=1024;
407
+ fileFound = file_size(zFile, ExtFILE)>=1024;
408408
fossil_free(zFile);
409409
}
410410
return fileFound;
411411
}
412412
@@ -522,30 +522,30 @@
522522
if( glob_match(pIgnore1, &zPath[nPrefix+1]) ||
523523
glob_match(pIgnore2, &zPath[nPrefix+1]) ){
524524
/* do nothing */
525525
#ifdef _DIRENT_HAVE_D_TYPE
526526
}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) ){
528528
#else
529
- }else if( file_wd_isdir(zPath)==1 ){
529
+ }else if( file_isdir(zPath, RepoFILE)==1 ){
530530
#endif
531531
if( !vfile_top_of_checkout(zPath) ){
532532
vfile_scan(pPath, nPrefix, scanFlags, pIgnore1, pIgnore2);
533533
}
534534
#ifdef _DIRENT_HAVE_D_TYPE
535535
}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) ){
537537
#else
538
- }else if( file_wd_isfile_or_link(zPath) ){
538
+ }else if( file_isfile_or_link(zPath) ){
539539
#endif
540540
if( (scanFlags & SCAN_TEMP)==0 || is_temporary_file(zUtf8) ){
541541
db_bind_text(&ins, ":file", &zPath[nPrefix+1]);
542542
if( scanFlags & SCAN_MTIME ){
543
- db_bind_int(&ins, ":mtime", file_mtime(zPath));
543
+ db_bind_int(&ins, ":mtime", file_mtime(zPath, RepoFILE));
544544
}
545545
if( scanFlags & SCAN_SIZE ){
546
- db_bind_int(&ins, ":size", file_size(zPath));
546
+ db_bind_int(&ins, ":size", file_size(zPath, RepoFILE));
547547
}
548548
db_step(&ins);
549549
db_reset(&ins);
550550
}
551551
}
@@ -642,13 +642,13 @@
642642
if( glob_match(pIgnore1, &zPath[nPrefix+1]) ||
643643
glob_match(pIgnore2, &zPath[nPrefix+1]) ){
644644
/* do nothing */
645645
#ifdef _DIRENT_HAVE_D_TYPE
646646
}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) ){
648648
#else
649
- }else if( file_wd_isdir(zPath)==1 ){
649
+ }else if( file_isdir(zPath, RepoFILE)==1 ){
650650
#endif
651651
if( (scanFlags & SCAN_NESTED) || !vfile_top_of_checkout(zPath) ){
652652
char *zSavePath = mprintf("%s", zPath);
653653
int count = vfile_dir_scan(pPath, nPrefix, scanFlags, pIgnore1,
654654
pIgnore2);
@@ -659,13 +659,13 @@
659659
fossil_free(zSavePath);
660660
result += count; /* found X normal files? */
661661
}
662662
#ifdef _DIRENT_HAVE_D_TYPE
663663
}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) ){
665665
#else
666
- }else if( file_wd_isfile_or_link(zPath) ){
666
+ }else if( file_isfile_or_link(zPath) ){
667667
#endif
668668
db_bind_text(&upd, ":file", zOrigPath);
669669
db_step(&upd);
670670
db_reset(&upd);
671671
result++; /* found 1 normal file */
@@ -726,11 +726,11 @@
726726
const char *zName = db_column_text(&q, 1);
727727
int isSelected = db_column_int(&q, 3);
728728
729729
if( isSelected ){
730730
md5sum_step_text(zName, -1);
731
- if( file_wd_islink(zFullpath) ){
731
+ if( file_islink(zFullpath) ){
732732
/* Instead of file content, use link destination path */
733733
Blob pathBuf;
734734
735735
sqlite3_snprintf(sizeof(zBuf), zBuf, " %ld\n",
736736
blob_read_link(&pathBuf, zFullpath));
@@ -786,11 +786,11 @@
786786
char *zOut = 0;
787787
do{
788788
sqlite3_free(zOut);
789789
sqlite3_randomness(8, &r);
790790
zOut = sqlite3_mprintf("file-%08llx", r);
791
- }while( file_size(zOut)>=0 );
791
+ }while( file_size(zOut, ExtFILE)>=0 );
792792
blob_write_to_file(pBlob, zOut);
793793
return zOut;
794794
}
795795
796796
/*
@@ -815,15 +815,11 @@
815815
const char *zFullpath = db_column_text(&q, 0);
816816
const char *zName = db_column_text(&q, 1);
817817
int rid = db_column_int(&q, 2);
818818
819819
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);
825821
if( rc<0 ){
826822
fossil_print("ERROR: cannot read file [%s]\n", zFullpath);
827823
blob_reset(&disk);
828824
continue;
829825
}
830826
--- 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 @@
12511251
}
12521252
zPageName = g.argv[3];
12531253
if( g.argc==4 ){
12541254
blob_read_from_channel(&content, stdin, -1);
12551255
}else{
1256
- blob_read_from_file(&content, g.argv[4]);
1256
+ blob_read_from_file(&content, g.argv[4], ExtFILE);
12571257
}
12581258
if( !zMimeType || !*zMimeType ){
12591259
/* Try to deduce the mime type based on the prior version. */
12601260
if ( !zETime ){
12611261
rid = db_int(0, "SELECT x.rid FROM tag t, tagxref x"
@@ -1375,9 +1375,9 @@
13751375
void test_markdown_render(void){
13761376
Blob in, out;
13771377
verify_all_options();
13781378
if( g.argc!=3 ) usage("FILE");
13791379
blob_zero(&out);
1380
- blob_read_from_file(&in, g.argv[2]);
1380
+ blob_read_from_file(&in, g.argv[2], ExtFILE);
13811381
markdown_to_html(&in, 0, &out);
13821382
blob_write_to_file(&out, "-");
13831383
}
13841384
--- 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
--- src/wikiformat.c
+++ src/wikiformat.c
@@ -1741,11 +1741,11 @@
17411741
if( find_option("inline",0,0)!=0 ) flags |= WIKI_INLINE;
17421742
if( find_option("noblock",0,0)!=0 ) flags |= WIKI_NOBLOCK;
17431743
verify_all_options();
17441744
if( g.argc!=3 ) usage("FILE");
17451745
blob_zero(&out);
1746
- blob_read_from_file(&in, g.argv[2]);
1746
+ blob_read_from_file(&in, g.argv[2], ExtFILE);
17471747
wiki_convert(&in, &out, flags);
17481748
blob_write_to_file(&out, "-");
17491749
}
17501750
17511751
/*
@@ -2104,11 +2104,11 @@
21042104
void test_html_tidy(void){
21052105
Blob in, out;
21062106
int i;
21072107
21082108
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);
21102110
blob_zero(&out);
21112111
htmlTidy(blob_str(&in), &out);
21122112
blob_reset(&in);
21132113
fossil_puts(blob_str(&out), 0);
21142114
blob_reset(&out);
@@ -2231,13 +2231,13 @@
22312231
void test_html_to_text(void){
22322232
Blob in, out;
22332233
int i;
22342234
22352235
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);
22372237
blob_zero(&out);
22382238
html_to_plaintext(blob_str(&in), &out);
22392239
blob_reset(&in);
22402240
fossil_puts(blob_str(&out), 0);
22412241
blob_reset(&out);
22422242
}
22432243
}
22442244
--- 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 @@
2929
# define LABEL_SECURITY_INFORMATION (0x00000010L)
3030
#endif
3131
3232
/*
3333
** 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.
3637
*/
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){
3839
WIN32_FILE_ATTRIBUTE_DATA attr;
3940
int rc = GetFileAttributesExW(zFilename, GetFileExInfoStandard, &attr);
4041
if( rc ){
4142
ULARGE_INTEGER ull;
4243
ull.LowPart = attr.ftLastWriteTime.dwLowDateTime;
4344
--- 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 @@
105105
/* The event is either invalid, signaled, or abandoned. Bail
106106
** out now because those conditions should indicate the parent
107107
** thread is dead or dying. */
108108
break;
109109
}
110
- if( file_size(zStopper)>=0 ){
110
+ if( file_size(zStopper, ExtFILE)>=0 ){
111111
/* The stopper file has been found. Attempt to close the server
112112
** listener socket now and then exit. */
113113
closesocket(listener);
114114
p->listener = INVALID_SOCKET;
115115
break;
@@ -852,11 +852,11 @@
852852
winhttp_fatal("create", zSvcName,
853853
"port number must be in the range 1 - 65535.");
854854
}
855855
if( !zRepository ){
856856
db_must_be_within_tree();
857
- }else if( file_isdir(zRepository)==1 ){
857
+ }else if( file_isdir(zRepository, ExtFILE)==1 ){
858858
g.zRepositoryName = mprintf("%s", zRepository);
859859
file_simplify_name(g.zRepositoryName, -1, 0);
860860
}else{
861861
db_open_repository(zRepository);
862862
}
863863
--- 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 @@
16251625
db_find_and_open_repository(0,0);
16261626
if( g.argc!=2 && g.argc!=3 ){
16271627
usage("?MESSAGEFILE?");
16281628
}
16291629
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);
16311631
disableLogin = 1;
16321632
page_xfer();
16331633
fossil_print("%s\n", cgi_extract_content());
16341634
}
16351635
16361636
--- 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 @@
289289
*/
290290
void filezip_cmd(void){
291291
int i;
292292
Blob zip;
293293
Blob file;
294
+ int eFType = SymFILE;
294295
if( g.argc<3 ){
295296
usage("ARCHIVE FILE....");
297
+ }
298
+ if( find_option("dereference","h",0)!=0 ){
299
+ eFType = ExtFILE;
296300
}
297301
zip_open();
298302
for(i=3; i<g.argc; i++){
299303
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));
302306
blob_reset(&file);
303307
}
304308
zip_close(&zip);
305309
blob_write_to_file(&zip, g.argv[2]);
306310
}
307311
--- 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

Keyboard Shortcuts

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