Fossil SCM

Merge fixes and refactoring from symlinks branch.

dmitry 2011-09-08 13:02 trunk merge
Commit c05f6afaf22849c99af333f88583435a473e8ba5
+2 -2
--- src/add.c
+++ src/add.c
@@ -108,11 +108,11 @@
108108
}else{
109109
char *zFullname = mprintf("%s%s", g.zLocalRoot, zPath);
110110
db_multi_exec(
111111
"INSERT INTO vfile(vid,deleted,rid,mrid,pathname,isexe,islink)"
112112
"VALUES(%d,0,0,0,%Q,%d,%d)",
113
- vid, zPath, file_isexe(zFullname), file_islink(zFullname));
113
+ vid, zPath, file_wd_isexe(zFullname), file_wd_islink(zFullname));
114114
fossil_free(zFullname);
115115
}
116116
if( db_changes() ){
117117
fossil_print("ADDED %s\n", zPath);
118118
return 1;
@@ -426,11 +426,11 @@
426426
const char * zFile;
427427
const char * zPath;
428428
429429
zFile = db_column_text(&q, 0);
430430
zPath = db_column_text(&q, 1);
431
- if( !file_isfile_or_link(zPath) ){
431
+ if( !file_wd_isfile_or_link(zPath) ){
432432
if( !isTest ){
433433
db_multi_exec("UPDATE vfile SET deleted=1 WHERE pathname=%Q", zFile);
434434
}
435435
fossil_print("DELETED %s\n", zFile);
436436
nDelete++;
437437
--- src/add.c
+++ src/add.c
@@ -108,11 +108,11 @@
108 }else{
109 char *zFullname = mprintf("%s%s", g.zLocalRoot, zPath);
110 db_multi_exec(
111 "INSERT INTO vfile(vid,deleted,rid,mrid,pathname,isexe,islink)"
112 "VALUES(%d,0,0,0,%Q,%d,%d)",
113 vid, zPath, file_isexe(zFullname), file_islink(zFullname));
114 fossil_free(zFullname);
115 }
116 if( db_changes() ){
117 fossil_print("ADDED %s\n", zPath);
118 return 1;
@@ -426,11 +426,11 @@
426 const char * zFile;
427 const char * zPath;
428
429 zFile = db_column_text(&q, 0);
430 zPath = db_column_text(&q, 1);
431 if( !file_isfile_or_link(zPath) ){
432 if( !isTest ){
433 db_multi_exec("UPDATE vfile SET deleted=1 WHERE pathname=%Q", zFile);
434 }
435 fossil_print("DELETED %s\n", zFile);
436 nDelete++;
437
--- src/add.c
+++ src/add.c
@@ -108,11 +108,11 @@
108 }else{
109 char *zFullname = mprintf("%s%s", g.zLocalRoot, zPath);
110 db_multi_exec(
111 "INSERT INTO vfile(vid,deleted,rid,mrid,pathname,isexe,islink)"
112 "VALUES(%d,0,0,0,%Q,%d,%d)",
113 vid, zPath, file_wd_isexe(zFullname), file_wd_islink(zFullname));
114 fossil_free(zFullname);
115 }
116 if( db_changes() ){
117 fossil_print("ADDED %s\n", zPath);
118 return 1;
@@ -426,11 +426,11 @@
426 const char * zFile;
427 const char * zPath;
428
429 zFile = db_column_text(&q, 0);
430 zPath = db_column_text(&q, 1);
431 if( !file_wd_isfile_or_link(zPath) ){
432 if( !isTest ){
433 db_multi_exec("UPDATE vfile SET deleted=1 WHERE pathname=%Q", zFile);
434 }
435 fossil_print("DELETED %s\n", zFile);
436 nDelete++;
437
+1 -1
--- src/blob.c
+++ src/blob.c
@@ -681,11 +681,11 @@
681681
FILE *in;
682682
if( zFilename==0 || zFilename[0]==0
683683
|| (zFilename[0]=='-' && zFilename[1]==0) ){
684684
return blob_read_from_channel(pBlob, stdin, -1);
685685
}
686
- size = file_size(zFilename);
686
+ size = file_wd_size(zFilename);
687687
blob_zero(pBlob);
688688
if( size<0 ){
689689
fossil_fatal("no such file: %s", zFilename);
690690
}
691691
if( size==0 ){
692692
--- src/blob.c
+++ src/blob.c
@@ -681,11 +681,11 @@
681 FILE *in;
682 if( zFilename==0 || zFilename[0]==0
683 || (zFilename[0]=='-' && zFilename[1]==0) ){
684 return blob_read_from_channel(pBlob, stdin, -1);
685 }
686 size = file_size(zFilename);
687 blob_zero(pBlob);
688 if( size<0 ){
689 fossil_fatal("no such file: %s", zFilename);
690 }
691 if( size==0 ){
692
--- src/blob.c
+++ src/blob.c
@@ -681,11 +681,11 @@
681 FILE *in;
682 if( zFilename==0 || zFilename[0]==0
683 || (zFilename[0]=='-' && zFilename[1]==0) ){
684 return blob_read_from_channel(pBlob, stdin, -1);
685 }
686 size = file_wd_size(zFilename);
687 blob_zero(pBlob);
688 if( size<0 ){
689 fossil_fatal("no such file: %s", zFilename);
690 }
691 if( size==0 ){
692
+5 -5
--- src/checkin.c
+++ src/checkin.c
@@ -64,11 +64,11 @@
6464
}
6565
}
6666
blob_append(report, zPrefix, nPrefix);
6767
if( isDeleted ){
6868
blob_appendf(report, "DELETED %s\n", zDisplayName);
69
- }else if( !file_isfile_or_link(zFullName) ){
69
+ }else if( !file_wd_isfile_or_link(zFullName) ){
7070
if( file_access(zFullName, 0)==0 ){
7171
blob_appendf(report, "NOT_A_FILE %s\n", zDisplayName);
7272
if( missingIsFatal ){
7373
fossil_warning("not a file: %s", zDisplayName);
7474
nErr++;
@@ -227,11 +227,11 @@
227227
fossil_print("%s\n", zPathname);
228228
}else if( isNew ){
229229
fossil_print("ADDED %s\n", zPathname);
230230
}else if( isDeleted ){
231231
fossil_print("DELETED %s\n", zPathname);
232
- }else if( !file_isfile_or_link(zFullName) ){
232
+ }else if( !file_wd_isfile_or_link(zFullName) ){
233233
if( file_access(zFullName, 0)==0 ){
234234
fossil_print("NOT_A_FILE %s\n", zPathname);
235235
}else{
236236
fossil_print("MISSING %s\n", zPathname);
237237
}
@@ -661,16 +661,16 @@
661661
** the filesystem. On windows, the "executable" bit is retained
662662
** unchanged from the original.
663663
*/
664664
blob_resize(&filename, nBasename);
665665
blob_append(&filename, zName, -1);
666
- isexe = file_isexe(blob_str(&filename));
666
+ isexe = file_wd_isexe(blob_str(&filename));
667667
668668
/* For unix, check if the file on the filesystem is symlink.
669669
** On windows, the bit is retained unchanged from original.
670670
*/
671
- isLink = file_islink(blob_str(&filename));
671
+ isLink = file_wd_islink(blob_str(&filename));
672672
#endif
673673
if( isexe ){
674674
zPerm = " x";
675675
}else if( isLink ){
676676
zPerm = " l"; /* note: symlinks don't have executable bit on unix */
@@ -1071,11 +1071,11 @@
10711071
zFullname = db_column_text(&q, 1);
10721072
rid = db_column_int(&q, 2);
10731073
crnlOk = db_column_int(&q, 3);
10741074
10751075
blob_zero(&content);
1076
- if( file_islink(zFullname) ){
1076
+ if( file_wd_islink(zFullname) ){
10771077
/* Instead of file content, put link destination path */
10781078
blob_read_link(&content, zFullname);
10791079
}else{
10801080
blob_read_from_file(&content, zFullname);
10811081
}
10821082
--- src/checkin.c
+++ src/checkin.c
@@ -64,11 +64,11 @@
64 }
65 }
66 blob_append(report, zPrefix, nPrefix);
67 if( isDeleted ){
68 blob_appendf(report, "DELETED %s\n", zDisplayName);
69 }else if( !file_isfile_or_link(zFullName) ){
70 if( file_access(zFullName, 0)==0 ){
71 blob_appendf(report, "NOT_A_FILE %s\n", zDisplayName);
72 if( missingIsFatal ){
73 fossil_warning("not a file: %s", zDisplayName);
74 nErr++;
@@ -227,11 +227,11 @@
227 fossil_print("%s\n", zPathname);
228 }else if( isNew ){
229 fossil_print("ADDED %s\n", zPathname);
230 }else if( isDeleted ){
231 fossil_print("DELETED %s\n", zPathname);
232 }else if( !file_isfile_or_link(zFullName) ){
233 if( file_access(zFullName, 0)==0 ){
234 fossil_print("NOT_A_FILE %s\n", zPathname);
235 }else{
236 fossil_print("MISSING %s\n", zPathname);
237 }
@@ -661,16 +661,16 @@
661 ** the filesystem. On windows, the "executable" bit is retained
662 ** unchanged from the original.
663 */
664 blob_resize(&filename, nBasename);
665 blob_append(&filename, zName, -1);
666 isexe = file_isexe(blob_str(&filename));
667
668 /* For unix, check if the file on the filesystem is symlink.
669 ** On windows, the bit is retained unchanged from original.
670 */
671 isLink = file_islink(blob_str(&filename));
672 #endif
673 if( isexe ){
674 zPerm = " x";
675 }else if( isLink ){
676 zPerm = " l"; /* note: symlinks don't have executable bit on unix */
@@ -1071,11 +1071,11 @@
1071 zFullname = db_column_text(&q, 1);
1072 rid = db_column_int(&q, 2);
1073 crnlOk = db_column_int(&q, 3);
1074
1075 blob_zero(&content);
1076 if( file_islink(zFullname) ){
1077 /* Instead of file content, put link destination path */
1078 blob_read_link(&content, zFullname);
1079 }else{
1080 blob_read_from_file(&content, zFullname);
1081 }
1082
--- src/checkin.c
+++ src/checkin.c
@@ -64,11 +64,11 @@
64 }
65 }
66 blob_append(report, zPrefix, nPrefix);
67 if( isDeleted ){
68 blob_appendf(report, "DELETED %s\n", zDisplayName);
69 }else if( !file_wd_isfile_or_link(zFullName) ){
70 if( file_access(zFullName, 0)==0 ){
71 blob_appendf(report, "NOT_A_FILE %s\n", zDisplayName);
72 if( missingIsFatal ){
73 fossil_warning("not a file: %s", zDisplayName);
74 nErr++;
@@ -227,11 +227,11 @@
227 fossil_print("%s\n", zPathname);
228 }else if( isNew ){
229 fossil_print("ADDED %s\n", zPathname);
230 }else if( isDeleted ){
231 fossil_print("DELETED %s\n", zPathname);
232 }else if( !file_wd_isfile_or_link(zFullName) ){
233 if( file_access(zFullName, 0)==0 ){
234 fossil_print("NOT_A_FILE %s\n", zPathname);
235 }else{
236 fossil_print("MISSING %s\n", zPathname);
237 }
@@ -661,16 +661,16 @@
661 ** the filesystem. On windows, the "executable" bit is retained
662 ** unchanged from the original.
663 */
664 blob_resize(&filename, nBasename);
665 blob_append(&filename, zName, -1);
666 isexe = file_wd_isexe(blob_str(&filename));
667
668 /* For unix, check if the file on the filesystem is symlink.
669 ** On windows, the bit is retained unchanged from original.
670 */
671 isLink = file_wd_islink(blob_str(&filename));
672 #endif
673 if( isexe ){
674 zPerm = " x";
675 }else if( isLink ){
676 zPerm = " l"; /* note: symlinks don't have executable bit on unix */
@@ -1071,11 +1071,11 @@
1071 zFullname = db_column_text(&q, 1);
1072 rid = db_column_int(&q, 2);
1073 crnlOk = db_column_int(&q, 3);
1074
1075 blob_zero(&content);
1076 if( file_wd_islink(zFullname) ){
1077 /* Instead of file content, put link destination path */
1078 blob_read_link(&content, zFullname);
1079 }else{
1080 blob_read_from_file(&content, zFullname);
1081 }
1082
+1 -1
--- src/checkout.c
+++ src/checkout.c
@@ -113,11 +113,11 @@
113113
manifest_file_rewind(pManifest);
114114
while( (pFile = manifest_file_next(pManifest, 0))!=0 ){
115115
int isExe;
116116
blob_append(&filename, pFile->zName, -1);
117117
isExe = pFile->zPerm && strstr(pFile->zPerm, "x");
118
- file_setexe(blob_str(&filename), isExe);
118
+ file_wd_setexe(blob_str(&filename), isExe);
119119
set_or_clear_isexe(pFile->zName, vid, isExe);
120120
blob_resize(&filename, baseLen);
121121
}
122122
blob_reset(&filename);
123123
manifest_destroy(pManifest);
124124
--- src/checkout.c
+++ src/checkout.c
@@ -113,11 +113,11 @@
113 manifest_file_rewind(pManifest);
114 while( (pFile = manifest_file_next(pManifest, 0))!=0 ){
115 int isExe;
116 blob_append(&filename, pFile->zName, -1);
117 isExe = pFile->zPerm && strstr(pFile->zPerm, "x");
118 file_setexe(blob_str(&filename), isExe);
119 set_or_clear_isexe(pFile->zName, vid, isExe);
120 blob_resize(&filename, baseLen);
121 }
122 blob_reset(&filename);
123 manifest_destroy(pManifest);
124
--- src/checkout.c
+++ src/checkout.c
@@ -113,11 +113,11 @@
113 manifest_file_rewind(pManifest);
114 while( (pFile = manifest_file_next(pManifest, 0))!=0 ){
115 int isExe;
116 blob_append(&filename, pFile->zName, -1);
117 isExe = pFile->zPerm && strstr(pFile->zPerm, "x");
118 file_wd_setexe(blob_str(&filename), isExe);
119 set_or_clear_isexe(pFile->zName, vid, isExe);
120 blob_resize(&filename, baseLen);
121 }
122 blob_reset(&filename);
123 manifest_destroy(pManifest);
124
+4 -4
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -71,14 +71,14 @@
7171
Blob file2; /* Content of zFile2 */
7272
const char *zName2; /* Name of zFile2 for display */
7373
7474
/* Read content of zFile2 into memory */
7575
blob_zero(&file2);
76
- if( file_size(zFile2)<0 ){
76
+ if( file_wd_size(zFile2)<0 ){
7777
zName2 = "/dev/null";
7878
}else{
79
- if( file_islink(zFile2) ){
79
+ if( file_wd_islink(zFile2) ){
8080
blob_read_link(&file2, zFile2);
8181
}else{
8282
blob_read_from_file(&file2, zFile2);
8383
}
8484
zName2 = zName;
@@ -193,11 +193,11 @@
193193
Blob fname;
194194
Blob content;
195195
int isLink;
196196
file_tree_name(zFileTreeName, &fname, 1);
197197
historical_version_of_file(zFrom, blob_str(&fname), &content, &isLink, 0, 0);
198
- if( !isLink != !file_islink(zFrom) ){
198
+ if( !isLink != !file_wd_islink(zFrom) ){
199199
diff_printf("cannot compute difference between symlink and regular file\n");
200200
}else{
201201
diff_file(&content, zFileTreeName, zFileTreeName, zDiffCmd, ignoreEolWs);
202202
}
203203
blob_reset(&content);
@@ -288,11 +288,11 @@
288288
srcid = 0;
289289
if( !asNewFile ){ showDiff = 0; }
290290
}
291291
if( showDiff ){
292292
Blob content;
293
- if( !isLink != !file_islink(zFullName) ){
293
+ if( !isLink != !file_wd_islink(zFullName) ){
294294
diff_print_index(zPathname);
295295
diff_printf("--- %s\n+++ %s\n", zPathname, zPathname);
296296
diff_printf("cannot compute difference between symlink and regular file\n");
297297
continue;
298298
}
299299
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -71,14 +71,14 @@
71 Blob file2; /* Content of zFile2 */
72 const char *zName2; /* Name of zFile2 for display */
73
74 /* Read content of zFile2 into memory */
75 blob_zero(&file2);
76 if( file_size(zFile2)<0 ){
77 zName2 = "/dev/null";
78 }else{
79 if( file_islink(zFile2) ){
80 blob_read_link(&file2, zFile2);
81 }else{
82 blob_read_from_file(&file2, zFile2);
83 }
84 zName2 = zName;
@@ -193,11 +193,11 @@
193 Blob fname;
194 Blob content;
195 int isLink;
196 file_tree_name(zFileTreeName, &fname, 1);
197 historical_version_of_file(zFrom, blob_str(&fname), &content, &isLink, 0, 0);
198 if( !isLink != !file_islink(zFrom) ){
199 diff_printf("cannot compute difference between symlink and regular file\n");
200 }else{
201 diff_file(&content, zFileTreeName, zFileTreeName, zDiffCmd, ignoreEolWs);
202 }
203 blob_reset(&content);
@@ -288,11 +288,11 @@
288 srcid = 0;
289 if( !asNewFile ){ showDiff = 0; }
290 }
291 if( showDiff ){
292 Blob content;
293 if( !isLink != !file_islink(zFullName) ){
294 diff_print_index(zPathname);
295 diff_printf("--- %s\n+++ %s\n", zPathname, zPathname);
296 diff_printf("cannot compute difference between symlink and regular file\n");
297 continue;
298 }
299
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -71,14 +71,14 @@
71 Blob file2; /* Content of zFile2 */
72 const char *zName2; /* Name of zFile2 for display */
73
74 /* Read content of zFile2 into memory */
75 blob_zero(&file2);
76 if( file_wd_size(zFile2)<0 ){
77 zName2 = "/dev/null";
78 }else{
79 if( file_wd_islink(zFile2) ){
80 blob_read_link(&file2, zFile2);
81 }else{
82 blob_read_from_file(&file2, zFile2);
83 }
84 zName2 = zName;
@@ -193,11 +193,11 @@
193 Blob fname;
194 Blob content;
195 int isLink;
196 file_tree_name(zFileTreeName, &fname, 1);
197 historical_version_of_file(zFrom, blob_str(&fname), &content, &isLink, 0, 0);
198 if( !isLink != !file_wd_islink(zFrom) ){
199 diff_printf("cannot compute difference between symlink and regular file\n");
200 }else{
201 diff_file(&content, zFileTreeName, zFileTreeName, zDiffCmd, ignoreEolWs);
202 }
203 blob_reset(&content);
@@ -288,11 +288,11 @@
288 srcid = 0;
289 if( !asNewFile ){ showDiff = 0; }
290 }
291 if( showDiff ){
292 Blob content;
293 if( !isLink != !file_wd_islink(zFullName) ){
294 diff_print_index(zPathname);
295 diff_printf("--- %s\n+++ %s\n", zPathname, zPathname);
296 diff_printf("cannot compute difference between symlink and regular file\n");
297 continue;
298 }
299
+102 -49
--- src/file.c
+++ src/file.c
@@ -13,11 +13,16 @@
1313
** [email protected]
1414
** http://www.hwaci.com/drh/
1515
**
1616
*******************************************************************************
1717
**
18
-** File utilities
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.
1924
*/
2025
#include "config.h"
2126
#include <sys/types.h>
2227
#include <sys/stat.h>
2328
#include <unistd.h>
@@ -32,98 +37,126 @@
3237
** larger than 2GB.
3338
*/
3439
#if defined(_WIN32) && defined(__MSVCRT__)
3540
# define stat _stati64
3641
#endif
42
+/*
43
+** On Windows S_ISLNK always returns FALSE.
44
+*/
45
+#if defined(_WIN32)
46
+# define S_ISLNK(x) (0)
47
+#endif
3748
static int fileStatValid = 0;
3849
static struct stat fileStat;
3950
40
-static int fossil_stat(const char *zFilename, struct stat *buf){
51
+/*
52
+** Fill stat buf with information received from stat() or lstat().
53
+** lstat() is called on Unix if isWd is TRUE and allow-symlinks setting is on.
54
+**
55
+*/
56
+static int fossil_stat(const char *zFilename, struct stat *buf, int isWd){
4157
#if !defined(_WIN32)
42
- if( g.allowSymlinks ){
58
+ if( isWd && g.allowSymlinks ){
4359
return lstat(zFilename, buf);
4460
}else{
4561
return stat(zFilename, buf);
4662
}
4763
#else
48
- return stat(zFilename, buf);
64
+ int rc = 0;
65
+ char *zMbcs = fossil_utf8_to_mbcs(zFilename);
66
+ rc = stat(zMbcs, buf);
67
+ fossil_mbcs_free(zMbcs);
68
+ return rc;
4969
#endif
5070
}
5171
5272
/*
5373
** Fill in the fileStat variable for the file named zFilename.
5474
** If zFilename==0, then use the previous value of fileStat if
5575
** there is a previous value.
5676
**
77
+** If isWd is TRUE, do lstat() instead of stat() if allow-symlinks is on.
78
+**
5779
** Return the number of errors. No error messages are generated.
5880
*/
59
-static int getStat(const char *zFilename){
81
+static int getStat(const char *zFilename, int isWd){
6082
int rc = 0;
6183
if( zFilename==0 ){
6284
if( fileStatValid==0 ) rc = 1;
6385
}else{
64
- char *zMbcs = fossil_utf8_to_mbcs(zFilename);
65
- if( fossil_stat(zMbcs, &fileStat)!=0 ){
86
+ if( fossil_stat(zFilename, &fileStat, isWd)!=0 ){
6687
fileStatValid = 0;
6788
rc = 1;
6889
}else{
6990
fileStatValid = 1;
7091
rc = 0;
7192
}
72
- fossil_mbcs_free(zMbcs);
7393
}
7494
return rc;
7595
}
76
-
7796
7897
/*
7998
** Return the size of a file in bytes. Return -1 if the file does not
8099
** exist. If zFilename is NULL, return the size of the most recently
81100
** stat-ed file.
82101
*/
83102
i64 file_size(const char *zFilename){
84
- return getStat(zFilename) ? -1 : fileStat.st_size;
103
+ return getStat(zFilename, 0) ? -1 : fileStat.st_size;
104
+}
105
+
106
+/*
107
+** Same as file_size(), but takes into account symlinks.
108
+*/
109
+i64 file_wd_size(const char *zFilename){
110
+ return getStat(zFilename, 1) ? -1 : fileStat.st_size;
85111
}
86112
87113
/*
88114
** Return the modification time for a file. Return -1 if the file
89115
** does not exist. If zFilename is NULL return the size of the most
90116
** recently stat-ed file.
91117
*/
92118
i64 file_mtime(const char *zFilename){
93
- return getStat(zFilename) ? -1 : fileStat.st_mtime;
119
+ return getStat(zFilename, 0) ? -1 : fileStat.st_mtime;
120
+}
121
+
122
+/*
123
+** Same as file_mtime(), but takes into account symlinks.
124
+*/
125
+i64 file_wd_mtime(const char *zFilename){
126
+ return getStat(zFilename, 1) ? -1 : fileStat.st_mtime;
94127
}
95128
96129
/*
97130
** Return TRUE if the named file is an ordinary file or symlink
98131
** and symlinks are allowed.
99132
** Return false for directories, devices, fifos, etc.
100133
*/
101
-int file_isfile_or_link(const char *zFilename){
102
-#if !defined(_WIN32)
103
- if ( g.allowSymlinks ){
104
- return getStat(zFilename) ? 0 : S_ISREG(fileStat.st_mode) || S_ISLNK(fileStat.st_mode);
105
- }
106
-#endif
107
- return getStat(zFilename) ? 0 : S_ISREG(fileStat.st_mode);
134
+int file_wd_isfile_or_link(const char *zFilename){
135
+ return getStat(zFilename, 1) ? 0 : S_ISREG(fileStat.st_mode) ||
136
+ S_ISLNK(fileStat.st_mode);
108137
}
109138
110139
/*
111140
** Return TRUE if the named file is an ordinary file. Return false
112141
** for directories, devices, fifos, symlinks, etc.
113142
*/
114143
int file_isfile(const char *zFilename){
115
- return getStat(zFilename) ? 0 : S_ISREG(fileStat.st_mode);
144
+ return getStat(zFilename, 0) ? 0 : S_ISREG(fileStat.st_mode);
145
+}
146
+
147
+int file_wd_isfile(const char *zFilename){
148
+ return getStat(zFilename, 1) ? 0 : S_ISREG(fileStat.st_mode);
116149
}
117150
118151
/*
119152
** Create symlink to file on Unix, or plain-text file with
120153
** symlink target if "allow-symlinks" is off or we're on Windows.
121154
**
122155
** Arguments: target file (symlink will point to it), link file
123156
**/
124
-void create_symlink(const char *zTargetFile, const char *zLinkFile){
157
+void symlink_create(const char *zTargetFile, const char *zLinkFile){
125158
#if !defined(_WIN32)
126159
if( g.allowSymlinks ){
127160
int i, nName;
128161
char *zName, zBuf[1000];
129162
@@ -157,19 +190,29 @@
157190
blob_set(&content, zTargetFile);
158191
blob_write_to_file(&content, zLinkFile);
159192
blob_reset(&content);
160193
}
161194
}
195
+
196
+/*
197
+** Copy symbolic link from zFrom to zTo.
198
+*/
199
+void symlink_copy(const char *zFrom, const char *zTo){
200
+ Blob content;
201
+ blob_read_link(&content, zFrom);
202
+ symlink_create(blob_str(&content), zTo);
203
+ blob_reset(&content);
204
+}
162205
163206
/*
164207
** Return file permissions (normal, executable, or symlink):
165208
** - PERM_EXE if file is executable;
166209
** - PERM_LNK on Unix if file is symlink and allow-symlinks option is on;
167210
** - PERM_REG for all other cases (regular file, directory, fifo, etc).
168211
*/
169
-int file_perm(const char *zFilename){
170
- if( getStat(zFilename) ) return PERM_REG;
212
+int file_wd_perm(const char *zFilename){
213
+ if( getStat(zFilename, 1) ) return PERM_REG;
171214
#if defined(_WIN32)
172215
# if defined(__DMC__) || defined(_MSC_VER)
173216
# define S_IXUSR _S_IEXEC
174217
# endif
175218
if( S_ISREG(fileStat.st_mode) && ((S_IXUSR)&fileStat.st_mode)!=0 )
@@ -189,22 +232,22 @@
189232
190233
/*
191234
** Return TRUE if the named file is an executable. Return false
192235
** for directories, devices, fifos, symlinks, etc.
193236
*/
194
-int file_isexe(const char *zFilename){
195
- return file_perm(zFilename)==PERM_EXE;
237
+int file_wd_isexe(const char *zFilename){
238
+ return file_wd_perm(zFilename)==PERM_EXE;
196239
}
197240
198241
/*
199242
** Return TRUE if the named file is a symlink and symlinks are allowed.
200243
** Return false for all other cases.
201244
**
202245
** On Windows, always return False.
203246
*/
204
-int file_islink(const char *zFilename){
205
- return file_perm(zFilename)==PERM_LNK;
247
+int file_wd_islink(const char *zFilename){
248
+ return file_wd_perm(zFilename)==PERM_LNK;
206249
}
207250
208251
/*
209252
** Return 1 if zFilename is a directory. Return 0 if zFilename
210253
** does not exist. Return 2 if zFilename exists but is something
@@ -214,25 +257,35 @@
214257
int rc;
215258
216259
if( zFilename ){
217260
char *zFN = mprintf("%s", zFilename);
218261
file_simplify_name(zFN, -1);
219
- rc = getStat(zFN);
262
+ rc = getStat(zFN, 0);
263
+ free(zFN);
264
+ }else{
265
+ rc = getStat(0, 0);
266
+ }
267
+ return rc ? 0 : (S_ISDIR(fileStat.st_mode) ? 1 : 2);
268
+}
269
+
270
+/*
271
+** Same as file_isdir(), but takes into account symlinks.
272
+*/
273
+int file_wd_isdir(const char *zFilename){
274
+ int rc;
275
+
276
+ if( zFilename ){
277
+ char *zFN = mprintf("%s", zFilename);
278
+ file_simplify_name(zFN, -1);
279
+ rc = getStat(zFN, 1);
220280
free(zFN);
221281
}else{
222
- rc = getStat(0);
223
- }
224
-#if !defined(_WIN32)
225
- if( g.allowSymlinks ){
226
- return rc ? 0 : (S_ISDIR(fileStat.st_mode) && !S_ISLNK(fileStat.st_mode) ? 1 : 2);
227
- }else{
228
- return rc ? 0 : (S_ISDIR(fileStat.st_mode) ? 1 : 2);
229
- }
230
-#else
231
- return rc ? 0 : (S_ISDIR(fileStat.st_mode) ? 1 : 2);
232
-#endif
233
-}
282
+ rc = getStat(0, 1);
283
+ }
284
+ return rc ? 0 : (S_ISDIR(fileStat.st_mode) ? 1 : 2);
285
+}
286
+
234287
235288
/*
236289
** Wrapper around the access() system call.
237290
*/
238291
int file_access(const char *zFilename, int flags){
@@ -300,15 +353,15 @@
300353
301354
/*
302355
** Set or clear the execute bit on a file. Return true if a change
303356
** occurred and false if this routine is a no-op.
304357
*/
305
-int file_setexe(const char *zFilename, int onoff){
358
+int file_wd_setexe(const char *zFilename, int onoff){
306359
int rc = 0;
307360
#if !defined(_WIN32)
308361
struct stat buf;
309
- if( fossil_stat(zFilename, &buf)!=0 || S_ISLNK(buf.st_mode) ) return 0;
362
+ if( fossil_stat(zFilename, &buf, 1)!=0 || S_ISLNK(buf.st_mode) ) return 0;
310363
if( onoff ){
311364
int targetMode = (buf.st_mode & 0444)>>2;
312365
if( (buf.st_mode & 0111)!=targetMode ){
313366
chmod(zFilename, buf.st_mode | targetMode);
314367
rc = 1;
@@ -569,19 +622,19 @@
569622
char zBuf[100];
570623
const char *zName = g.argv[i];
571624
file_canonical_name(zName, &x);
572625
fossil_print("[%s] -> [%s]\n", zName, blob_buffer(&x));
573626
blob_reset(&x);
574
- sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", file_size(zName));
627
+ sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", file_wd_size(zName));
575628
fossil_print(" file_size = %s\n", zBuf);
576
- sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", file_mtime(zName));
629
+ sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", file_wd_mtime(zName));
577630
fossil_print(" file_mtime = %s\n", zBuf);
578
- fossil_print(" file_isfile = %d\n", file_isfile(zName));
579
- fossil_print(" file_isfile_or_link = %d\n", file_isfile_or_link(zName));
580
- fossil_print(" file_islink = %d\n", file_islink(zName));
581
- fossil_print(" file_isexe = %d\n", file_isexe(zName));
582
- fossil_print(" file_isdir = %d\n", file_isdir(zName));
631
+ fossil_print(" file_isfile = %d\n", file_wd_isfile(zName));
632
+ fossil_print(" file_isfile_or_link = %d\n",file_wd_isfile_or_link(zName));
633
+ fossil_print(" file_islink = %d\n", file_wd_islink(zName));
634
+ fossil_print(" file_isexe = %d\n", file_wd_isexe(zName));
635
+ fossil_print(" file_isdir = %d\n", file_wd_isdir(zName));
583636
}
584637
}
585638
586639
/*
587640
** Return TRUE if the given filename is canonical.
@@ -846,11 +899,11 @@
846899
Blob onDisk;
847900
848901
iSize = file_size(zName);
849902
if( iSize<0 ) return 0;
850903
if( iSize!=blob_size(pContent) ) return 0;
851
- if( file_islink(zName) ){
904
+ if( file_wd_islink(zName) ){
852905
blob_read_link(&onDisk, zName);
853906
}else{
854907
blob_read_from_file(&onDisk, zName);
855908
}
856909
rc = blob_compare(&onDisk, pContent);
857910
--- src/file.c
+++ src/file.c
@@ -13,11 +13,16 @@
13 ** [email protected]
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>
@@ -32,98 +37,126 @@
32 ** larger than 2GB.
33 */
34 #if defined(_WIN32) && defined(__MSVCRT__)
35 # define stat _stati64
36 #endif
 
 
 
 
 
 
37 static int fileStatValid = 0;
38 static struct stat fileStat;
39
40 static int fossil_stat(const char *zFilename, struct stat *buf){
 
 
 
 
 
41 #if !defined(_WIN32)
42 if( g.allowSymlinks ){
43 return lstat(zFilename, buf);
44 }else{
45 return stat(zFilename, buf);
46 }
47 #else
48 return stat(zFilename, buf);
 
 
 
 
49 #endif
50 }
51
52 /*
53 ** Fill in the fileStat variable for the file named zFilename.
54 ** If zFilename==0, then use the previous value of fileStat if
55 ** there is a previous value.
56 **
 
 
57 ** Return the number of errors. No error messages are generated.
58 */
59 static int getStat(const char *zFilename){
60 int rc = 0;
61 if( zFilename==0 ){
62 if( fileStatValid==0 ) rc = 1;
63 }else{
64 char *zMbcs = fossil_utf8_to_mbcs(zFilename);
65 if( fossil_stat(zMbcs, &fileStat)!=0 ){
66 fileStatValid = 0;
67 rc = 1;
68 }else{
69 fileStatValid = 1;
70 rc = 0;
71 }
72 fossil_mbcs_free(zMbcs);
73 }
74 return rc;
75 }
76
77
78 /*
79 ** Return the size of a file in bytes. Return -1 if the file does not
80 ** exist. If zFilename is NULL, return the size of the most recently
81 ** stat-ed file.
82 */
83 i64 file_size(const char *zFilename){
84 return getStat(zFilename) ? -1 : fileStat.st_size;
 
 
 
 
 
 
 
85 }
86
87 /*
88 ** Return the modification time for a file. Return -1 if the file
89 ** does not exist. If zFilename is NULL return the size of the most
90 ** recently stat-ed file.
91 */
92 i64 file_mtime(const char *zFilename){
93 return getStat(zFilename) ? -1 : fileStat.st_mtime;
 
 
 
 
 
 
 
94 }
95
96 /*
97 ** Return TRUE if the named file is an ordinary file or symlink
98 ** and symlinks are allowed.
99 ** Return false for directories, devices, fifos, etc.
100 */
101 int file_isfile_or_link(const char *zFilename){
102 #if !defined(_WIN32)
103 if ( g.allowSymlinks ){
104 return getStat(zFilename) ? 0 : S_ISREG(fileStat.st_mode) || S_ISLNK(fileStat.st_mode);
105 }
106 #endif
107 return getStat(zFilename) ? 0 : S_ISREG(fileStat.st_mode);
108 }
109
110 /*
111 ** Return TRUE if the named file is an ordinary file. Return false
112 ** for directories, devices, fifos, symlinks, etc.
113 */
114 int file_isfile(const char *zFilename){
115 return getStat(zFilename) ? 0 : S_ISREG(fileStat.st_mode);
 
 
 
 
116 }
117
118 /*
119 ** Create symlink to file on Unix, or plain-text file with
120 ** symlink target if "allow-symlinks" is off or we're on Windows.
121 **
122 ** Arguments: target file (symlink will point to it), link file
123 **/
124 void create_symlink(const char *zTargetFile, const char *zLinkFile){
125 #if !defined(_WIN32)
126 if( g.allowSymlinks ){
127 int i, nName;
128 char *zName, zBuf[1000];
129
@@ -157,19 +190,29 @@
157 blob_set(&content, zTargetFile);
158 blob_write_to_file(&content, zLinkFile);
159 blob_reset(&content);
160 }
161 }
 
 
 
 
 
 
 
 
 
 
162
163 /*
164 ** Return file permissions (normal, executable, or symlink):
165 ** - PERM_EXE if file is executable;
166 ** - PERM_LNK on Unix if file is symlink and allow-symlinks option is on;
167 ** - PERM_REG for all other cases (regular file, directory, fifo, etc).
168 */
169 int file_perm(const char *zFilename){
170 if( getStat(zFilename) ) return PERM_REG;
171 #if defined(_WIN32)
172 # if defined(__DMC__) || defined(_MSC_VER)
173 # define S_IXUSR _S_IEXEC
174 # endif
175 if( S_ISREG(fileStat.st_mode) && ((S_IXUSR)&fileStat.st_mode)!=0 )
@@ -189,22 +232,22 @@
189
190 /*
191 ** Return TRUE if the named file is an executable. Return false
192 ** for directories, devices, fifos, symlinks, etc.
193 */
194 int file_isexe(const char *zFilename){
195 return file_perm(zFilename)==PERM_EXE;
196 }
197
198 /*
199 ** Return TRUE if the named file is a symlink and symlinks are allowed.
200 ** Return false for all other cases.
201 **
202 ** On Windows, always return False.
203 */
204 int file_islink(const char *zFilename){
205 return file_perm(zFilename)==PERM_LNK;
206 }
207
208 /*
209 ** Return 1 if zFilename is a directory. Return 0 if zFilename
210 ** does not exist. Return 2 if zFilename exists but is something
@@ -214,25 +257,35 @@
214 int rc;
215
216 if( zFilename ){
217 char *zFN = mprintf("%s", zFilename);
218 file_simplify_name(zFN, -1);
219 rc = getStat(zFN);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
220 free(zFN);
221 }else{
222 rc = getStat(0);
223 }
224 #if !defined(_WIN32)
225 if( g.allowSymlinks ){
226 return rc ? 0 : (S_ISDIR(fileStat.st_mode) && !S_ISLNK(fileStat.st_mode) ? 1 : 2);
227 }else{
228 return rc ? 0 : (S_ISDIR(fileStat.st_mode) ? 1 : 2);
229 }
230 #else
231 return rc ? 0 : (S_ISDIR(fileStat.st_mode) ? 1 : 2);
232 #endif
233 }
234
235 /*
236 ** Wrapper around the access() system call.
237 */
238 int file_access(const char *zFilename, int flags){
@@ -300,15 +353,15 @@
300
301 /*
302 ** Set or clear the execute bit on a file. Return true if a change
303 ** occurred and false if this routine is a no-op.
304 */
305 int file_setexe(const char *zFilename, int onoff){
306 int rc = 0;
307 #if !defined(_WIN32)
308 struct stat buf;
309 if( fossil_stat(zFilename, &buf)!=0 || S_ISLNK(buf.st_mode) ) return 0;
310 if( onoff ){
311 int targetMode = (buf.st_mode & 0444)>>2;
312 if( (buf.st_mode & 0111)!=targetMode ){
313 chmod(zFilename, buf.st_mode | targetMode);
314 rc = 1;
@@ -569,19 +622,19 @@
569 char zBuf[100];
570 const char *zName = g.argv[i];
571 file_canonical_name(zName, &x);
572 fossil_print("[%s] -> [%s]\n", zName, blob_buffer(&x));
573 blob_reset(&x);
574 sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", file_size(zName));
575 fossil_print(" file_size = %s\n", zBuf);
576 sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", file_mtime(zName));
577 fossil_print(" file_mtime = %s\n", zBuf);
578 fossil_print(" file_isfile = %d\n", file_isfile(zName));
579 fossil_print(" file_isfile_or_link = %d\n", file_isfile_or_link(zName));
580 fossil_print(" file_islink = %d\n", file_islink(zName));
581 fossil_print(" file_isexe = %d\n", file_isexe(zName));
582 fossil_print(" file_isdir = %d\n", file_isdir(zName));
583 }
584 }
585
586 /*
587 ** Return TRUE if the given filename is canonical.
@@ -846,11 +899,11 @@
846 Blob onDisk;
847
848 iSize = file_size(zName);
849 if( iSize<0 ) return 0;
850 if( iSize!=blob_size(pContent) ) return 0;
851 if( file_islink(zName) ){
852 blob_read_link(&onDisk, zName);
853 }else{
854 blob_read_from_file(&onDisk, zName);
855 }
856 rc = blob_compare(&onDisk, pContent);
857
--- src/file.c
+++ src/file.c
@@ -13,11 +13,16 @@
13 ** [email protected]
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>
@@ -32,98 +37,126 @@
37 ** larger than 2GB.
38 */
39 #if defined(_WIN32) && defined(__MSVCRT__)
40 # define stat _stati64
41 #endif
42 /*
43 ** On Windows S_ISLNK always returns FALSE.
44 */
45 #if defined(_WIN32)
46 # define S_ISLNK(x) (0)
47 #endif
48 static int fileStatValid = 0;
49 static struct stat fileStat;
50
51 /*
52 ** Fill stat buf with information received from stat() or lstat().
53 ** lstat() is called on Unix if isWd is TRUE and allow-symlinks setting is on.
54 **
55 */
56 static int fossil_stat(const char *zFilename, struct stat *buf, int isWd){
57 #if !defined(_WIN32)
58 if( isWd && g.allowSymlinks ){
59 return lstat(zFilename, buf);
60 }else{
61 return stat(zFilename, buf);
62 }
63 #else
64 int rc = 0;
65 char *zMbcs = fossil_utf8_to_mbcs(zFilename);
66 rc = stat(zMbcs, buf);
67 fossil_mbcs_free(zMbcs);
68 return rc;
69 #endif
70 }
71
72 /*
73 ** Fill in the fileStat variable for the file named zFilename.
74 ** If zFilename==0, then use the previous value of fileStat if
75 ** there is a previous value.
76 **
77 ** If isWd is TRUE, do lstat() instead of stat() if allow-symlinks is on.
78 **
79 ** Return the number of errors. No error messages are generated.
80 */
81 static int getStat(const char *zFilename, int isWd){
82 int rc = 0;
83 if( zFilename==0 ){
84 if( fileStatValid==0 ) rc = 1;
85 }else{
86 if( fossil_stat(zFilename, &fileStat, isWd)!=0 ){
 
87 fileStatValid = 0;
88 rc = 1;
89 }else{
90 fileStatValid = 1;
91 rc = 0;
92 }
 
93 }
94 return rc;
95 }
 
96
97 /*
98 ** Return the size of a file in bytes. Return -1 if the file does not
99 ** exist. If zFilename is NULL, return the size of the most recently
100 ** stat-ed file.
101 */
102 i64 file_size(const char *zFilename){
103 return getStat(zFilename, 0) ? -1 : fileStat.st_size;
104 }
105
106 /*
107 ** Same as file_size(), but takes into account symlinks.
108 */
109 i64 file_wd_size(const char *zFilename){
110 return getStat(zFilename, 1) ? -1 : fileStat.st_size;
111 }
112
113 /*
114 ** Return the modification time for a file. Return -1 if the file
115 ** does not exist. If zFilename is NULL return the size of the most
116 ** recently stat-ed file.
117 */
118 i64 file_mtime(const char *zFilename){
119 return getStat(zFilename, 0) ? -1 : fileStat.st_mtime;
120 }
121
122 /*
123 ** Same as file_mtime(), but takes into account symlinks.
124 */
125 i64 file_wd_mtime(const char *zFilename){
126 return getStat(zFilename, 1) ? -1 : fileStat.st_mtime;
127 }
128
129 /*
130 ** Return TRUE if the named file is an ordinary file or symlink
131 ** and symlinks are allowed.
132 ** Return false for directories, devices, fifos, etc.
133 */
134 int file_wd_isfile_or_link(const char *zFilename){
135 return getStat(zFilename, 1) ? 0 : S_ISREG(fileStat.st_mode) ||
136 S_ISLNK(fileStat.st_mode);
 
 
 
 
137 }
138
139 /*
140 ** Return TRUE if the named file is an ordinary file. Return false
141 ** for directories, devices, fifos, symlinks, etc.
142 */
143 int file_isfile(const char *zFilename){
144 return getStat(zFilename, 0) ? 0 : S_ISREG(fileStat.st_mode);
145 }
146
147 int file_wd_isfile(const char *zFilename){
148 return getStat(zFilename, 1) ? 0 : S_ISREG(fileStat.st_mode);
149 }
150
151 /*
152 ** Create symlink to file on Unix, or plain-text file with
153 ** symlink target if "allow-symlinks" is off or we're on Windows.
154 **
155 ** Arguments: target file (symlink will point to it), link file
156 **/
157 void symlink_create(const char *zTargetFile, const char *zLinkFile){
158 #if !defined(_WIN32)
159 if( g.allowSymlinks ){
160 int i, nName;
161 char *zName, zBuf[1000];
162
@@ -157,19 +190,29 @@
190 blob_set(&content, zTargetFile);
191 blob_write_to_file(&content, zLinkFile);
192 blob_reset(&content);
193 }
194 }
195
196 /*
197 ** Copy symbolic link from zFrom to zTo.
198 */
199 void symlink_copy(const char *zFrom, const char *zTo){
200 Blob content;
201 blob_read_link(&content, zFrom);
202 symlink_create(blob_str(&content), zTo);
203 blob_reset(&content);
204 }
205
206 /*
207 ** Return file permissions (normal, executable, or symlink):
208 ** - PERM_EXE if file is executable;
209 ** - PERM_LNK on Unix if file is symlink and allow-symlinks option is on;
210 ** - PERM_REG for all other cases (regular file, directory, fifo, etc).
211 */
212 int file_wd_perm(const char *zFilename){
213 if( getStat(zFilename, 1) ) return PERM_REG;
214 #if defined(_WIN32)
215 # if defined(__DMC__) || defined(_MSC_VER)
216 # define S_IXUSR _S_IEXEC
217 # endif
218 if( S_ISREG(fileStat.st_mode) && ((S_IXUSR)&fileStat.st_mode)!=0 )
@@ -189,22 +232,22 @@
232
233 /*
234 ** Return TRUE if the named file is an executable. Return false
235 ** for directories, devices, fifos, symlinks, etc.
236 */
237 int file_wd_isexe(const char *zFilename){
238 return file_wd_perm(zFilename)==PERM_EXE;
239 }
240
241 /*
242 ** Return TRUE if the named file is a symlink and symlinks are allowed.
243 ** Return false for all other cases.
244 **
245 ** On Windows, always return False.
246 */
247 int file_wd_islink(const char *zFilename){
248 return file_wd_perm(zFilename)==PERM_LNK;
249 }
250
251 /*
252 ** Return 1 if zFilename is a directory. Return 0 if zFilename
253 ** does not exist. Return 2 if zFilename exists but is something
@@ -214,25 +257,35 @@
257 int rc;
258
259 if( zFilename ){
260 char *zFN = mprintf("%s", zFilename);
261 file_simplify_name(zFN, -1);
262 rc = getStat(zFN, 0);
263 free(zFN);
264 }else{
265 rc = getStat(0, 0);
266 }
267 return rc ? 0 : (S_ISDIR(fileStat.st_mode) ? 1 : 2);
268 }
269
270 /*
271 ** Same as file_isdir(), but takes into account symlinks.
272 */
273 int file_wd_isdir(const char *zFilename){
274 int rc;
275
276 if( zFilename ){
277 char *zFN = mprintf("%s", zFilename);
278 file_simplify_name(zFN, -1);
279 rc = getStat(zFN, 1);
280 free(zFN);
281 }else{
282 rc = getStat(0, 1);
283 }
284 return rc ? 0 : (S_ISDIR(fileStat.st_mode) ? 1 : 2);
285 }
286
 
 
 
 
 
 
 
287
288 /*
289 ** Wrapper around the access() system call.
290 */
291 int file_access(const char *zFilename, int flags){
@@ -300,15 +353,15 @@
353
354 /*
355 ** Set or clear the execute bit on a file. Return true if a change
356 ** occurred and false if this routine is a no-op.
357 */
358 int file_wd_setexe(const char *zFilename, int onoff){
359 int rc = 0;
360 #if !defined(_WIN32)
361 struct stat buf;
362 if( fossil_stat(zFilename, &buf, 1)!=0 || S_ISLNK(buf.st_mode) ) return 0;
363 if( onoff ){
364 int targetMode = (buf.st_mode & 0444)>>2;
365 if( (buf.st_mode & 0111)!=targetMode ){
366 chmod(zFilename, buf.st_mode | targetMode);
367 rc = 1;
@@ -569,19 +622,19 @@
622 char zBuf[100];
623 const char *zName = g.argv[i];
624 file_canonical_name(zName, &x);
625 fossil_print("[%s] -> [%s]\n", zName, blob_buffer(&x));
626 blob_reset(&x);
627 sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", file_wd_size(zName));
628 fossil_print(" file_size = %s\n", zBuf);
629 sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", file_wd_mtime(zName));
630 fossil_print(" file_mtime = %s\n", zBuf);
631 fossil_print(" file_isfile = %d\n", file_wd_isfile(zName));
632 fossil_print(" file_isfile_or_link = %d\n",file_wd_isfile_or_link(zName));
633 fossil_print(" file_islink = %d\n", file_wd_islink(zName));
634 fossil_print(" file_isexe = %d\n", file_wd_isexe(zName));
635 fossil_print(" file_isdir = %d\n", file_wd_isdir(zName));
636 }
637 }
638
639 /*
640 ** Return TRUE if the given filename is canonical.
@@ -846,11 +899,11 @@
899 Blob onDisk;
900
901 iSize = file_size(zName);
902 if( iSize<0 ) return 0;
903 if( iSize!=blob_size(pContent) ) return 0;
904 if( file_wd_islink(zName) ){
905 blob_read_link(&onDisk, zName);
906 }else{
907 blob_read_from_file(&onDisk, zName);
908 }
909 rc = blob_compare(&onDisk, pContent);
910
+7 -3
--- src/merge.c
+++ src/merge.c
@@ -391,11 +391,11 @@
391391
fossil_print("MERGE %s (pivot=%d v1=%d v2=%d)\n",
392392
zName, ridp, ridm, ridv);
393393
}else{
394394
fossil_print("MERGE %s\n", zName);
395395
}
396
- if( islinkv || islinkm /* || file_islink(zFullPath) */ ){
396
+ if( islinkv || islinkm /* || file_wd_islink(zFullPath) */ ){
397397
fossil_print("***** Cannot merge symlink %s\n", zName);
398398
nConflict++;
399399
}else{
400400
undo_save(zName);
401401
zFullPath = mprintf("%s/%s", g.zLocalRoot, zName);
@@ -408,11 +408,11 @@
408408
rc = merge_3way(&p, zFullPath, &m, &r);
409409
}
410410
if( rc>=0 ){
411411
if( !nochangeFlag ){
412412
blob_write_to_file(&r, zFullPath);
413
- file_setexe(zFullPath, isExe);
413
+ file_wd_setexe(zFullPath, isExe);
414414
}
415415
db_multi_exec("UPDATE vfile SET mtime=0 WHERE id=%d", idv);
416416
if( rc>0 ){
417417
fossil_print("***** %d merge conflicts in %s\n", rc, zName);
418418
nConflict++;
@@ -480,11 +480,15 @@
480480
" WHERE id=%d AND vid=%d", zNewName, idv, vid
481481
);
482482
if( !nochangeFlag ){
483483
char *zFullOldPath = mprintf("%s%s", g.zLocalRoot, zOldName);
484484
char *zFullNewPath = mprintf("%s%s", g.zLocalRoot, zNewName);
485
- file_copy(zFullOldPath, zFullNewPath);
485
+ if( file_wd_islink(zFullOldPath) ){
486
+ symlink_copy(zFullOldPath, zFullNewPath);
487
+ }else{
488
+ file_copy(zFullOldPath, zFullNewPath);
489
+ }
486490
file_delete(zFullOldPath);
487491
free(zFullNewPath);
488492
free(zFullOldPath);
489493
}
490494
}
491495
--- src/merge.c
+++ src/merge.c
@@ -391,11 +391,11 @@
391 fossil_print("MERGE %s (pivot=%d v1=%d v2=%d)\n",
392 zName, ridp, ridm, ridv);
393 }else{
394 fossil_print("MERGE %s\n", zName);
395 }
396 if( islinkv || islinkm /* || file_islink(zFullPath) */ ){
397 fossil_print("***** Cannot merge symlink %s\n", zName);
398 nConflict++;
399 }else{
400 undo_save(zName);
401 zFullPath = mprintf("%s/%s", g.zLocalRoot, zName);
@@ -408,11 +408,11 @@
408 rc = merge_3way(&p, zFullPath, &m, &r);
409 }
410 if( rc>=0 ){
411 if( !nochangeFlag ){
412 blob_write_to_file(&r, zFullPath);
413 file_setexe(zFullPath, isExe);
414 }
415 db_multi_exec("UPDATE vfile SET mtime=0 WHERE id=%d", idv);
416 if( rc>0 ){
417 fossil_print("***** %d merge conflicts in %s\n", rc, zName);
418 nConflict++;
@@ -480,11 +480,15 @@
480 " WHERE id=%d AND vid=%d", zNewName, idv, vid
481 );
482 if( !nochangeFlag ){
483 char *zFullOldPath = mprintf("%s%s", g.zLocalRoot, zOldName);
484 char *zFullNewPath = mprintf("%s%s", g.zLocalRoot, zNewName);
485 file_copy(zFullOldPath, zFullNewPath);
 
 
 
 
486 file_delete(zFullOldPath);
487 free(zFullNewPath);
488 free(zFullOldPath);
489 }
490 }
491
--- src/merge.c
+++ src/merge.c
@@ -391,11 +391,11 @@
391 fossil_print("MERGE %s (pivot=%d v1=%d v2=%d)\n",
392 zName, ridp, ridm, ridv);
393 }else{
394 fossil_print("MERGE %s\n", zName);
395 }
396 if( islinkv || islinkm /* || file_wd_islink(zFullPath) */ ){
397 fossil_print("***** Cannot merge symlink %s\n", zName);
398 nConflict++;
399 }else{
400 undo_save(zName);
401 zFullPath = mprintf("%s/%s", g.zLocalRoot, zName);
@@ -408,11 +408,11 @@
408 rc = merge_3way(&p, zFullPath, &m, &r);
409 }
410 if( rc>=0 ){
411 if( !nochangeFlag ){
412 blob_write_to_file(&r, zFullPath);
413 file_wd_setexe(zFullPath, isExe);
414 }
415 db_multi_exec("UPDATE vfile SET mtime=0 WHERE id=%d", idv);
416 if( rc>0 ){
417 fossil_print("***** %d merge conflicts in %s\n", rc, zName);
418 nConflict++;
@@ -480,11 +480,15 @@
480 " WHERE id=%d AND vid=%d", zNewName, idv, vid
481 );
482 if( !nochangeFlag ){
483 char *zFullOldPath = mprintf("%s%s", g.zLocalRoot, zOldName);
484 char *zFullNewPath = mprintf("%s%s", g.zLocalRoot, zNewName);
485 if( file_wd_islink(zFullOldPath) ){
486 symlink_copy(zFullOldPath, zFullNewPath);
487 }else{
488 file_copy(zFullOldPath, zFullNewPath);
489 }
490 file_delete(zFullOldPath);
491 free(zFullNewPath);
492 free(zFullOldPath);
493 }
494 }
495
+1 -1
--- src/merge3.c
+++ src/merge3.c
@@ -422,11 +422,11 @@
422422
azSubst[4] = "%merge"; azSubst[5] = zOther;
423423
azSubst[6] = "%output"; azSubst[7] = zOut;
424424
zCmd = string_subst(zGMerge, 8, azSubst);
425425
printf("%s\n", zCmd); fflush(stdout);
426426
fossil_system(zCmd);
427
- if( file_size(zOut)>=0 ){
427
+ if( file_wd_size(zOut)>=0 ){
428428
blob_read_from_file(pOut, zOut);
429429
file_delete(zPivot);
430430
file_delete(zOrig);
431431
file_delete(zOther);
432432
file_delete(zOut);
433433
--- src/merge3.c
+++ src/merge3.c
@@ -422,11 +422,11 @@
422 azSubst[4] = "%merge"; azSubst[5] = zOther;
423 azSubst[6] = "%output"; azSubst[7] = zOut;
424 zCmd = string_subst(zGMerge, 8, azSubst);
425 printf("%s\n", zCmd); fflush(stdout);
426 fossil_system(zCmd);
427 if( file_size(zOut)>=0 ){
428 blob_read_from_file(pOut, zOut);
429 file_delete(zPivot);
430 file_delete(zOrig);
431 file_delete(zOther);
432 file_delete(zOut);
433
--- src/merge3.c
+++ src/merge3.c
@@ -422,11 +422,11 @@
422 azSubst[4] = "%merge"; azSubst[5] = zOther;
423 azSubst[6] = "%output"; azSubst[7] = zOut;
424 zCmd = string_subst(zGMerge, 8, azSubst);
425 printf("%s\n", zCmd); fflush(stdout);
426 fossil_system(zCmd);
427 if( file_wd_size(zOut)>=0 ){
428 blob_read_from_file(pOut, zOut);
429 file_delete(zPivot);
430 file_delete(zOrig);
431 file_delete(zOther);
432 file_delete(zOut);
433
+1 -1
--- src/sha1.c
+++ src/sha1.c
@@ -281,11 +281,11 @@
281281
FILE *in;
282282
SHA1Context ctx;
283283
unsigned char zResult[20];
284284
char zBuf[10240];
285285
286
- if( file_islink(zFilename) ){
286
+ if( file_wd_islink(zFilename) ){
287287
/* Instead of file content, return sha1 of link destination path */
288288
Blob destinationPath;
289289
int rc;
290290
291291
blob_read_link(&destinationPath, zFilename);
292292
--- src/sha1.c
+++ src/sha1.c
@@ -281,11 +281,11 @@
281 FILE *in;
282 SHA1Context ctx;
283 unsigned char zResult[20];
284 char zBuf[10240];
285
286 if( file_islink(zFilename) ){
287 /* Instead of file content, return sha1 of link destination path */
288 Blob destinationPath;
289 int rc;
290
291 blob_read_link(&destinationPath, zFilename);
292
--- src/sha1.c
+++ src/sha1.c
@@ -281,11 +281,11 @@
281 FILE *in;
282 SHA1Context ctx;
283 unsigned char zResult[20];
284 char zBuf[10240];
285
286 if( file_wd_islink(zFilename) ){
287 /* Instead of file content, return sha1 of link destination path */
288 Blob destinationPath;
289 int rc;
290
291 blob_read_link(&destinationPath, zFilename);
292
+8 -8
--- src/stash.c
+++ src/stash.c
@@ -89,11 +89,11 @@
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_islink(zPath);
94
+ int isNewLink = file_wd_islink(zPath);
9595
9696
db_bind_int(&ins, ":rid", rid);
9797
db_bind_int(&ins, ":isadd", rid==0);
9898
db_bind_int(&ins, ":isrm", deleted);
9999
db_bind_int(&ins, ":isexe", db_column_int(&q, 1));
@@ -200,18 +200,18 @@
200200
undo_save(zNew);
201201
blob_zero(&delta);
202202
if( rid==0 ){
203203
db_ephemeral_blob(&q, 6, &delta);
204204
blob_write_to_file(&delta, zNPath);
205
- file_setexe(zNPath, isExec);
205
+ file_wd_setexe(zNPath, isExec);
206206
fossil_print("ADD %s\n", zNew);
207207
}else if( isRemoved ){
208208
fossil_print("DELETE %s\n", zOrig);
209209
file_delete(zOPath);
210210
}else{
211211
Blob a, b, out, disk;
212
- int isNewLink = file_islink(zOPath);
212
+ int isNewLink = file_wd_islink(zOPath);
213213
db_ephemeral_blob(&q, 6, &delta);
214214
if( isNewLink ){
215215
blob_read_link(&disk, zOPath);
216216
}else{
217217
blob_read_from_file(&disk, zOPath);
@@ -221,15 +221,15 @@
221221
if( blob_compare(&disk, &a)==0 && isLink == isNewLink ){
222222
if( isLink || isNewLink ){
223223
file_delete(zNPath);
224224
}
225225
if( isLink ){
226
- create_symlink(blob_str(&b), zNPath);
226
+ symlink_create(blob_str(&b), zNPath);
227227
}else{
228228
blob_write_to_file(&b, zNPath);
229229
}
230
- file_setexe(zNPath, isExec);
230
+ file_wd_setexe(zNPath, isExec);
231231
fossil_print("UPDATE %s\n", zNew);
232232
}else{
233233
int rc;
234234
if( isLink || isNewLink ){
235235
rc = -1;
@@ -237,11 +237,11 @@
237237
fossil_print("***** Cannot merge symlink %s\n", zNew);
238238
}else{
239239
rc = merge_3way(&a, zOPath, &b, &out);
240240
blob_write_to_file(&out, zNPath);
241241
blob_reset(&out);
242
- file_setexe(zNPath, isExec);
242
+ file_wd_setexe(zNPath, isExec);
243243
}
244244
if( rc ){
245245
fossil_print("CONFLICT %s\n", zNew);
246246
nConflict++;
247247
}else{
@@ -290,20 +290,20 @@
290290
fossil_print("ADDED %s\n", zNew);
291291
diff_print_index(zNew);
292292
diff_file_mem(&empty, &delta, zNew, zDiffCmd, 0);
293293
}else if( isRemoved ){
294294
fossil_print("DELETE %s\n", zOrig);
295
- if( file_islink(zOPath) ){
295
+ if( file_wd_islink(zOPath) ){
296296
blob_read_link(&delta, zOPath);
297297
}else{
298298
blob_read_from_file(&delta, zOPath);
299299
}
300300
diff_print_index(zNew);
301301
diff_file_mem(&delta, &empty, zOrig, zDiffCmd, 0);
302302
}else{
303303
Blob a, b, disk;
304
- int isOrigLink = file_islink(zOPath);
304
+ int isOrigLink = file_wd_islink(zOPath);
305305
db_ephemeral_blob(&q, 6, &delta);
306306
if( isOrigLink ){
307307
blob_read_link(&disk, zOPath);
308308
}else{
309309
blob_read_from_file(&disk, zOPath);
310310
--- src/stash.c
+++ src/stash.c
@@ -89,11 +89,11 @@
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_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));
@@ -200,18 +200,18 @@
200 undo_save(zNew);
201 blob_zero(&delta);
202 if( rid==0 ){
203 db_ephemeral_blob(&q, 6, &delta);
204 blob_write_to_file(&delta, zNPath);
205 file_setexe(zNPath, isExec);
206 fossil_print("ADD %s\n", zNew);
207 }else if( isRemoved ){
208 fossil_print("DELETE %s\n", zOrig);
209 file_delete(zOPath);
210 }else{
211 Blob a, b, out, disk;
212 int isNewLink = file_islink(zOPath);
213 db_ephemeral_blob(&q, 6, &delta);
214 if( isNewLink ){
215 blob_read_link(&disk, zOPath);
216 }else{
217 blob_read_from_file(&disk, zOPath);
@@ -221,15 +221,15 @@
221 if( blob_compare(&disk, &a)==0 && isLink == isNewLink ){
222 if( isLink || isNewLink ){
223 file_delete(zNPath);
224 }
225 if( isLink ){
226 create_symlink(blob_str(&b), zNPath);
227 }else{
228 blob_write_to_file(&b, zNPath);
229 }
230 file_setexe(zNPath, isExec);
231 fossil_print("UPDATE %s\n", zNew);
232 }else{
233 int rc;
234 if( isLink || isNewLink ){
235 rc = -1;
@@ -237,11 +237,11 @@
237 fossil_print("***** Cannot merge symlink %s\n", zNew);
238 }else{
239 rc = merge_3way(&a, zOPath, &b, &out);
240 blob_write_to_file(&out, zNPath);
241 blob_reset(&out);
242 file_setexe(zNPath, isExec);
243 }
244 if( rc ){
245 fossil_print("CONFLICT %s\n", zNew);
246 nConflict++;
247 }else{
@@ -290,20 +290,20 @@
290 fossil_print("ADDED %s\n", zNew);
291 diff_print_index(zNew);
292 diff_file_mem(&empty, &delta, zNew, zDiffCmd, 0);
293 }else if( isRemoved ){
294 fossil_print("DELETE %s\n", zOrig);
295 if( file_islink(zOPath) ){
296 blob_read_link(&delta, zOPath);
297 }else{
298 blob_read_from_file(&delta, zOPath);
299 }
300 diff_print_index(zNew);
301 diff_file_mem(&delta, &empty, zOrig, zDiffCmd, 0);
302 }else{
303 Blob a, b, disk;
304 int isOrigLink = file_islink(zOPath);
305 db_ephemeral_blob(&q, 6, &delta);
306 if( isOrigLink ){
307 blob_read_link(&disk, zOPath);
308 }else{
309 blob_read_from_file(&disk, zOPath);
310
--- src/stash.c
+++ src/stash.c
@@ -89,11 +89,11 @@
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));
@@ -200,18 +200,18 @@
200 undo_save(zNew);
201 blob_zero(&delta);
202 if( rid==0 ){
203 db_ephemeral_blob(&q, 6, &delta);
204 blob_write_to_file(&delta, zNPath);
205 file_wd_setexe(zNPath, isExec);
206 fossil_print("ADD %s\n", zNew);
207 }else if( isRemoved ){
208 fossil_print("DELETE %s\n", zOrig);
209 file_delete(zOPath);
210 }else{
211 Blob a, b, out, disk;
212 int isNewLink = file_wd_islink(zOPath);
213 db_ephemeral_blob(&q, 6, &delta);
214 if( isNewLink ){
215 blob_read_link(&disk, zOPath);
216 }else{
217 blob_read_from_file(&disk, zOPath);
@@ -221,15 +221,15 @@
221 if( blob_compare(&disk, &a)==0 && isLink == isNewLink ){
222 if( isLink || isNewLink ){
223 file_delete(zNPath);
224 }
225 if( isLink ){
226 symlink_create(blob_str(&b), zNPath);
227 }else{
228 blob_write_to_file(&b, zNPath);
229 }
230 file_wd_setexe(zNPath, isExec);
231 fossil_print("UPDATE %s\n", zNew);
232 }else{
233 int rc;
234 if( isLink || isNewLink ){
235 rc = -1;
@@ -237,11 +237,11 @@
237 fossil_print("***** Cannot merge symlink %s\n", zNew);
238 }else{
239 rc = merge_3way(&a, zOPath, &b, &out);
240 blob_write_to_file(&out, zNPath);
241 blob_reset(&out);
242 file_wd_setexe(zNPath, isExec);
243 }
244 if( rc ){
245 fossil_print("CONFLICT %s\n", zNew);
246 nConflict++;
247 }else{
@@ -290,20 +290,20 @@
290 fossil_print("ADDED %s\n", zNew);
291 diff_print_index(zNew);
292 diff_file_mem(&empty, &delta, zNew, zDiffCmd, 0);
293 }else if( isRemoved ){
294 fossil_print("DELETE %s\n", zOrig);
295 if( file_wd_islink(zOPath) ){
296 blob_read_link(&delta, zOPath);
297 }else{
298 blob_read_from_file(&delta, zOPath);
299 }
300 diff_print_index(zNew);
301 diff_file_mem(&delta, &empty, zOrig, zDiffCmd, 0);
302 }else{
303 Blob a, b, disk;
304 int isOrigLink = file_wd_islink(zOPath);
305 db_ephemeral_blob(&q, 6, &delta);
306 if( isOrigLink ){
307 blob_read_link(&disk, zOPath);
308 }else{
309 blob_read_from_file(&disk, zOPath);
310
+2 -2
--- src/tar.c
+++ src/tar.c
@@ -416,11 +416,11 @@
416416
417417
418418
/*
419419
** COMMAND: test-tarball
420420
**
421
-** Generate a GZIP-compresssed tarball in the file given by the first argument
421
+** Generate a GZIP-compressed tarball in the file given by the first argument
422422
** that contains files given in the second and subsequent arguments.
423423
*/
424424
void test_tarball_cmd(void){
425425
int i;
426426
Blob zip;
@@ -432,11 +432,11 @@
432432
tar_begin();
433433
for(i=3; i<g.argc; i++){
434434
blob_zero(&file);
435435
blob_read_from_file(&file, g.argv[i]);
436436
tar_add_file(g.argv[i], &file,
437
- file_perm(g.argv[i]), file_mtime(g.argv[i]));
437
+ file_wd_perm(g.argv[i]), file_wd_mtime(g.argv[i]));
438438
blob_reset(&file);
439439
}
440440
tar_finish(&zip);
441441
blob_write_to_file(&zip, g.argv[2]);
442442
}
443443
--- src/tar.c
+++ src/tar.c
@@ -416,11 +416,11 @@
416
417
418 /*
419 ** COMMAND: test-tarball
420 **
421 ** Generate a GZIP-compresssed tarball in the file given by the first argument
422 ** that contains files given in the second and subsequent arguments.
423 */
424 void test_tarball_cmd(void){
425 int i;
426 Blob zip;
@@ -432,11 +432,11 @@
432 tar_begin();
433 for(i=3; i<g.argc; i++){
434 blob_zero(&file);
435 blob_read_from_file(&file, g.argv[i]);
436 tar_add_file(g.argv[i], &file,
437 file_perm(g.argv[i]), file_mtime(g.argv[i]));
438 blob_reset(&file);
439 }
440 tar_finish(&zip);
441 blob_write_to_file(&zip, g.argv[2]);
442 }
443
--- src/tar.c
+++ src/tar.c
@@ -416,11 +416,11 @@
416
417
418 /*
419 ** COMMAND: test-tarball
420 **
421 ** Generate a GZIP-compressed tarball in the file given by the first argument
422 ** that contains files given in the second and subsequent arguments.
423 */
424 void test_tarball_cmd(void){
425 int i;
426 Blob zip;
@@ -432,11 +432,11 @@
432 tar_begin();
433 for(i=3; i<g.argc; i++){
434 blob_zero(&file);
435 blob_read_from_file(&file, g.argv[i]);
436 tar_add_file(g.argv[i], &file,
437 file_wd_perm(g.argv[i]), file_wd_mtime(g.argv[i]));
438 blob_reset(&file);
439 }
440 tar_finish(&zip);
441 blob_write_to_file(&zip, g.argv[2]);
442 }
443
+8 -8
--- src/undo.c
+++ src/undo.c
@@ -45,19 +45,19 @@
4545
int old_link;
4646
Blob current;
4747
Blob new;
4848
zFullname = mprintf("%s/%s", g.zLocalRoot, zPathname);
4949
old_link = db_column_int(&q, 3);
50
- new_link = file_islink(zFullname);
51
- new_exists = file_size(zFullname)>=0;
50
+ new_link = file_wd_islink(zFullname);
51
+ new_exists = file_wd_size(zFullname)>=0;
5252
if( new_exists ){
5353
if( new_link ){
5454
blob_read_link(&current, zFullname);
5555
}else{
5656
blob_read_from_file(&current, zFullname);
5757
}
58
- new_exe = file_isexe(zFullname);
58
+ new_exe = file_wd_isexe(zFullname);
5959
}else{
6060
blob_zero(&current);
6161
new_exe = 0;
6262
}
6363
blob_zero(&new);
@@ -74,15 +74,15 @@
7474
}
7575
if( new_exists && (new_link || old_link) ){
7676
file_delete(zFullname);
7777
}
7878
if( old_link ){
79
- create_symlink(blob_str(&new), zFullname);
79
+ symlink_create(blob_str(&new), zFullname);
8080
}else{
8181
blob_write_to_file(&new, zFullname);
8282
}
83
- file_setexe(zFullname, old_exe);
83
+ file_wd_setexe(zFullname, old_exe);
8484
}else{
8585
fossil_print("DELETE %s\n", zPathname);
8686
file_delete(zFullname);
8787
}
8888
blob_reset(&new);
@@ -270,17 +270,17 @@
270270
int isLink;
271271
Stmt q;
272272
273273
if( !undoActive ) return;
274274
zFullname = mprintf("%s%s", g.zLocalRoot, zPathname);
275
- existsFlag = file_size(zFullname)>=0;
276
- isLink = file_islink(zFullname);
275
+ existsFlag = file_wd_size(zFullname)>=0;
276
+ isLink = file_wd_islink(zFullname);
277277
db_prepare(&q,
278278
"INSERT OR IGNORE INTO"
279279
" undo(pathname,redoflag,existsflag,isExe,isLink,content)"
280280
" VALUES(%Q,0,%d,%d,%d,:c)",
281
- zPathname, existsFlag, file_isexe(zFullname), isLink
281
+ zPathname, existsFlag, file_wd_isexe(zFullname), isLink
282282
);
283283
if( existsFlag ){
284284
if( isLink ){
285285
blob_read_link(&content, zFullname);
286286
}else{
287287
--- src/undo.c
+++ src/undo.c
@@ -45,19 +45,19 @@
45 int old_link;
46 Blob current;
47 Blob new;
48 zFullname = mprintf("%s/%s", g.zLocalRoot, zPathname);
49 old_link = db_column_int(&q, 3);
50 new_link = file_islink(zFullname);
51 new_exists = file_size(zFullname)>=0;
52 if( new_exists ){
53 if( new_link ){
54 blob_read_link(&current, zFullname);
55 }else{
56 blob_read_from_file(&current, zFullname);
57 }
58 new_exe = file_isexe(zFullname);
59 }else{
60 blob_zero(&current);
61 new_exe = 0;
62 }
63 blob_zero(&new);
@@ -74,15 +74,15 @@
74 }
75 if( new_exists && (new_link || old_link) ){
76 file_delete(zFullname);
77 }
78 if( old_link ){
79 create_symlink(blob_str(&new), zFullname);
80 }else{
81 blob_write_to_file(&new, zFullname);
82 }
83 file_setexe(zFullname, old_exe);
84 }else{
85 fossil_print("DELETE %s\n", zPathname);
86 file_delete(zFullname);
87 }
88 blob_reset(&new);
@@ -270,17 +270,17 @@
270 int isLink;
271 Stmt q;
272
273 if( !undoActive ) return;
274 zFullname = mprintf("%s%s", g.zLocalRoot, zPathname);
275 existsFlag = file_size(zFullname)>=0;
276 isLink = file_islink(zFullname);
277 db_prepare(&q,
278 "INSERT OR IGNORE INTO"
279 " undo(pathname,redoflag,existsflag,isExe,isLink,content)"
280 " VALUES(%Q,0,%d,%d,%d,:c)",
281 zPathname, existsFlag, file_isexe(zFullname), isLink
282 );
283 if( existsFlag ){
284 if( isLink ){
285 blob_read_link(&content, zFullname);
286 }else{
287
--- src/undo.c
+++ src/undo.c
@@ -45,19 +45,19 @@
45 int old_link;
46 Blob current;
47 Blob new;
48 zFullname = mprintf("%s/%s", g.zLocalRoot, zPathname);
49 old_link = db_column_int(&q, 3);
50 new_link = file_wd_islink(zFullname);
51 new_exists = file_wd_size(zFullname)>=0;
52 if( new_exists ){
53 if( new_link ){
54 blob_read_link(&current, zFullname);
55 }else{
56 blob_read_from_file(&current, zFullname);
57 }
58 new_exe = file_wd_isexe(zFullname);
59 }else{
60 blob_zero(&current);
61 new_exe = 0;
62 }
63 blob_zero(&new);
@@ -74,15 +74,15 @@
74 }
75 if( new_exists && (new_link || old_link) ){
76 file_delete(zFullname);
77 }
78 if( old_link ){
79 symlink_create(blob_str(&new), zFullname);
80 }else{
81 blob_write_to_file(&new, zFullname);
82 }
83 file_wd_setexe(zFullname, old_exe);
84 }else{
85 fossil_print("DELETE %s\n", zPathname);
86 file_delete(zFullname);
87 }
88 blob_reset(&new);
@@ -270,17 +270,17 @@
270 int isLink;
271 Stmt q;
272
273 if( !undoActive ) return;
274 zFullname = mprintf("%s%s", g.zLocalRoot, zPathname);
275 existsFlag = file_wd_size(zFullname)>=0;
276 isLink = file_wd_islink(zFullname);
277 db_prepare(&q,
278 "INSERT OR IGNORE INTO"
279 " undo(pathname,redoflag,existsflag,isExe,isLink,content)"
280 " VALUES(%Q,0,%d,%d,%d,:c)",
281 zPathname, existsFlag, file_wd_isexe(zFullname), isLink
282 );
283 if( existsFlag ){
284 if( isLink ){
285 blob_read_link(&content, zFullname);
286 }else{
287
+8 -8
--- src/update.c
+++ src/update.c
@@ -367,11 +367,11 @@
367367
}else if( idt>0 && idv>0 && ridt!=ridv && chnged==0 ){
368368
/* The file is unedited. Change it to the target version */
369369
undo_save(zName);
370370
fossil_print("UPDATE %s\n", zName);
371371
if( !nochangeFlag ) vfile_to_disk(0, idt, 0, 0);
372
- }else if( idt>0 && idv>0 && file_size(zFullPath)<0 ){
372
+ }else if( idt>0 && idv>0 && file_wd_size(zFullPath)<0 ){
373373
/* The file missing from the local check-out. Restore it to the
374374
** version that appears in the target. */
375375
fossil_print("UPDATE %s\n", zName);
376376
undo_save(zName);
377377
if( !nochangeFlag ) vfile_to_disk(0, idt, 0, 0);
@@ -398,11 +398,11 @@
398398
if( nameChng ){
399399
fossil_print("MERGE %s -> %s\n", zName, zNewName);
400400
}else{
401401
fossil_print("MERGE %s\n", zName);
402402
}
403
- if( islinkv || islinkt /* || file_islink(zFullPath) */ ){
403
+ if( islinkv || islinkt /* || file_wd_islink(zFullPath) */ ){
404404
fossil_print("***** Cannot merge symlink %s\n", zNewName);
405405
nConflict++;
406406
}else{
407407
undo_save(zName);
408408
content_get(ridt, &t);
@@ -409,20 +409,20 @@
409409
content_get(ridv, &v);
410410
rc = merge_3way(&v, zFullPath, &t, &r);
411411
if( rc>=0 ){
412412
if( !nochangeFlag ){
413413
blob_write_to_file(&r, zFullNewPath);
414
- file_setexe(zFullNewPath, isexe);
414
+ file_wd_setexe(zFullNewPath, isexe);
415415
}
416416
if( rc>0 ){
417417
fossil_print("***** %d merge conflicts in %s\n", rc, zNewName);
418418
nConflict++;
419419
}
420420
}else{
421421
if( !nochangeFlag ){
422422
blob_write_to_file(&t, zFullNewPath);
423
- file_setexe(zFullNewPath, isexe);
423
+ file_wd_setexe(zFullNewPath, isexe);
424424
}
425425
fossil_print("***** Cannot merge binary file %s\n", zNewName);
426426
nConflict++;
427427
}
428428
}
@@ -668,21 +668,21 @@
668668
}
669669
db_multi_exec("DELETE FROM vfile WHERE pathname=%Q", zFile);
670670
}else{
671671
sqlite3_int64 mtime;
672672
undo_save(zFile);
673
- if( file_size(zFull)>=0 && (isLink || file_islink(zFull)) ){
673
+ if( file_wd_size(zFull)>=0 && (isLink || file_wd_islink(zFull)) ){
674674
file_delete(zFull);
675675
}
676676
if( isLink ){
677
- create_symlink(blob_str(&record), zFull);
677
+ symlink_create(blob_str(&record), zFull);
678678
}else{
679679
blob_write_to_file(&record, zFull);
680680
}
681
- file_setexe(zFull, isExe);
681
+ file_wd_setexe(zFull, isExe);
682682
fossil_print("REVERTED: %s\n", zFile);
683
- mtime = file_mtime(zFull);
683
+ mtime = file_wd_mtime(zFull);
684684
db_multi_exec(
685685
"UPDATE vfile"
686686
" SET mtime=%lld, chnged=0, deleted=0, isexe=%d, islink=%d, mrid=rid,"
687687
" pathname=coalesce(origname,pathname), origname=NULL"
688688
" WHERE pathname=%Q",
689689
--- src/update.c
+++ src/update.c
@@ -367,11 +367,11 @@
367 }else if( idt>0 && idv>0 && ridt!=ridv && chnged==0 ){
368 /* The file is unedited. Change it to the target version */
369 undo_save(zName);
370 fossil_print("UPDATE %s\n", zName);
371 if( !nochangeFlag ) vfile_to_disk(0, idt, 0, 0);
372 }else if( idt>0 && idv>0 && file_size(zFullPath)<0 ){
373 /* The file missing from the local check-out. Restore it to the
374 ** version that appears in the target. */
375 fossil_print("UPDATE %s\n", zName);
376 undo_save(zName);
377 if( !nochangeFlag ) vfile_to_disk(0, idt, 0, 0);
@@ -398,11 +398,11 @@
398 if( nameChng ){
399 fossil_print("MERGE %s -> %s\n", zName, zNewName);
400 }else{
401 fossil_print("MERGE %s\n", zName);
402 }
403 if( islinkv || islinkt /* || file_islink(zFullPath) */ ){
404 fossil_print("***** Cannot merge symlink %s\n", zNewName);
405 nConflict++;
406 }else{
407 undo_save(zName);
408 content_get(ridt, &t);
@@ -409,20 +409,20 @@
409 content_get(ridv, &v);
410 rc = merge_3way(&v, zFullPath, &t, &r);
411 if( rc>=0 ){
412 if( !nochangeFlag ){
413 blob_write_to_file(&r, zFullNewPath);
414 file_setexe(zFullNewPath, isexe);
415 }
416 if( rc>0 ){
417 fossil_print("***** %d merge conflicts in %s\n", rc, zNewName);
418 nConflict++;
419 }
420 }else{
421 if( !nochangeFlag ){
422 blob_write_to_file(&t, zFullNewPath);
423 file_setexe(zFullNewPath, isexe);
424 }
425 fossil_print("***** Cannot merge binary file %s\n", zNewName);
426 nConflict++;
427 }
428 }
@@ -668,21 +668,21 @@
668 }
669 db_multi_exec("DELETE FROM vfile WHERE pathname=%Q", zFile);
670 }else{
671 sqlite3_int64 mtime;
672 undo_save(zFile);
673 if( file_size(zFull)>=0 && (isLink || file_islink(zFull)) ){
674 file_delete(zFull);
675 }
676 if( isLink ){
677 create_symlink(blob_str(&record), zFull);
678 }else{
679 blob_write_to_file(&record, zFull);
680 }
681 file_setexe(zFull, isExe);
682 fossil_print("REVERTED: %s\n", zFile);
683 mtime = file_mtime(zFull);
684 db_multi_exec(
685 "UPDATE vfile"
686 " SET mtime=%lld, chnged=0, deleted=0, isexe=%d, islink=%d, mrid=rid,"
687 " pathname=coalesce(origname,pathname), origname=NULL"
688 " WHERE pathname=%Q",
689
--- src/update.c
+++ src/update.c
@@ -367,11 +367,11 @@
367 }else if( idt>0 && idv>0 && ridt!=ridv && chnged==0 ){
368 /* The file is unedited. Change it to the target version */
369 undo_save(zName);
370 fossil_print("UPDATE %s\n", zName);
371 if( !nochangeFlag ) vfile_to_disk(0, idt, 0, 0);
372 }else if( idt>0 && idv>0 && file_wd_size(zFullPath)<0 ){
373 /* The file missing from the local check-out. Restore it to the
374 ** version that appears in the target. */
375 fossil_print("UPDATE %s\n", zName);
376 undo_save(zName);
377 if( !nochangeFlag ) vfile_to_disk(0, idt, 0, 0);
@@ -398,11 +398,11 @@
398 if( nameChng ){
399 fossil_print("MERGE %s -> %s\n", zName, zNewName);
400 }else{
401 fossil_print("MERGE %s\n", zName);
402 }
403 if( islinkv || islinkt /* || file_wd_islink(zFullPath) */ ){
404 fossil_print("***** Cannot merge symlink %s\n", zNewName);
405 nConflict++;
406 }else{
407 undo_save(zName);
408 content_get(ridt, &t);
@@ -409,20 +409,20 @@
409 content_get(ridv, &v);
410 rc = merge_3way(&v, zFullPath, &t, &r);
411 if( rc>=0 ){
412 if( !nochangeFlag ){
413 blob_write_to_file(&r, zFullNewPath);
414 file_wd_setexe(zFullNewPath, isexe);
415 }
416 if( rc>0 ){
417 fossil_print("***** %d merge conflicts in %s\n", rc, zNewName);
418 nConflict++;
419 }
420 }else{
421 if( !nochangeFlag ){
422 blob_write_to_file(&t, zFullNewPath);
423 file_wd_setexe(zFullNewPath, isexe);
424 }
425 fossil_print("***** Cannot merge binary file %s\n", zNewName);
426 nConflict++;
427 }
428 }
@@ -668,21 +668,21 @@
668 }
669 db_multi_exec("DELETE FROM vfile WHERE pathname=%Q", zFile);
670 }else{
671 sqlite3_int64 mtime;
672 undo_save(zFile);
673 if( file_wd_size(zFull)>=0 && (isLink || file_wd_islink(zFull)) ){
674 file_delete(zFull);
675 }
676 if( isLink ){
677 symlink_create(blob_str(&record), zFull);
678 }else{
679 blob_write_to_file(&record, zFull);
680 }
681 file_wd_setexe(zFull, isExe);
682 fossil_print("REVERTED: %s\n", zFile);
683 mtime = file_wd_mtime(zFull);
684 db_multi_exec(
685 "UPDATE vfile"
686 " SET mtime=%lld, chnged=0, deleted=0, isexe=%d, islink=%d, mrid=rid,"
687 " pathname=coalesce(origname,pathname), origname=NULL"
688 " WHERE pathname=%Q",
689
+13 -13
--- src/vfile.c
+++ src/vfile.c
@@ -166,11 +166,11 @@
166166
isDeleted = db_column_int(&q, 3);
167167
oldChnged = db_column_int(&q, 4);
168168
oldMtime = db_column_int64(&q, 7);
169169
if( isDeleted ){
170170
chnged = 1;
171
- }else if( !file_isfile_or_link(zName) && file_size(0)>=0 ){
171
+ }else if( !file_wd_isfile_or_link(zName) && file_wd_size(0)>=0 ){
172172
if( notFileIsFatal ){
173173
fossil_warning("not an ordinary file: %s", zName);
174174
nErr++;
175175
}
176176
chnged = 1;
@@ -179,12 +179,12 @@
179179
}else if( rid==0 ){
180180
chnged = 1;
181181
}
182182
if( chnged!=1 ){
183183
i64 origSize = db_column_int64(&q, 6);
184
- currentMtime = file_mtime(0);
185
- if( origSize!=file_size(0) ){
184
+ currentMtime = file_wd_mtime(0);
185
+ if( origSize!=file_wd_size(0) ){
186186
/* A file size change is definitive - the file has changed. No
187187
** need to check the sha1sum */
188188
chnged = 1;
189189
}
190190
}
@@ -247,17 +247,17 @@
247247
isExe = db_column_int(&q, 3);
248248
isLink = db_column_int(&q, 4);
249249
content_get(rid, &content);
250250
if( file_is_the_same(&content, zName) ){
251251
blob_reset(&content);
252
- if( file_setexe(zName, isExe) ){
252
+ if( file_wd_setexe(zName, isExe) ){
253253
db_multi_exec("UPDATE vfile SET mtime=%lld WHERE id=%d",
254
- file_mtime(zName), id);
254
+ file_wd_mtime(zName), id);
255255
}
256256
continue;
257257
}
258
- if( promptFlag && file_size(zName)>=0 ){
258
+ if( promptFlag && file_wd_size(zName)>=0 ){
259259
Blob ans;
260260
char *zMsg;
261261
char cReply;
262262
zMsg = mprintf("overwrite %s (a=always/y/N)? ", zName);
263263
prompt_user(zMsg, &ans);
@@ -276,22 +276,22 @@
276276
if( verbose ) fossil_print("%s\n", &zName[nRepos]);
277277
if( file_isdir(zName) == 1 ){
278278
/*TODO(dchest): remove directories? */
279279
fossil_fatal("%s is directory, cannot overwrite\n", zName);
280280
}
281
- if( file_size(zName)>=0 && (isLink || file_islink(zName)) ){
281
+ if( file_wd_size(zName)>=0 && (isLink || file_wd_islink(zName)) ){
282282
file_delete(zName);
283283
}
284284
if( isLink ){
285
- create_symlink(blob_str(&content), zName);
285
+ symlink_create(blob_str(&content), zName);
286286
}else{
287287
blob_write_to_file(&content, zName);
288288
}
289
- file_setexe(zName, isExe);
289
+ file_wd_setexe(zName, isExe);
290290
blob_reset(&content);
291291
db_multi_exec("UPDATE vfile SET mtime=%lld WHERE id=%d",
292
- file_mtime(zName), id);
292
+ file_wd_mtime(zName), id);
293293
}
294294
db_finalize(&q);
295295
}
296296
297297
@@ -393,11 +393,11 @@
393393
/* do nothing */
394394
}else if( file_isdir(zPath)==1 ){
395395
if( !vfile_top_of_checkout(zPath) ){
396396
vfile_scan(pPath, nPrefix, allFlag, pIgnore);
397397
}
398
- }else if( file_isfile_or_link(zPath) ){
398
+ }else if( file_wd_isfile_or_link(zPath) ){
399399
db_bind_text(&ins, ":file", &zPath[nPrefix+1]);
400400
db_step(&ins);
401401
db_reset(&ins);
402402
}
403403
blob_resize(pPath, origSize);
@@ -452,11 +452,11 @@
452452
const char *zName = db_column_text(&q, 1);
453453
int isSelected = db_column_int(&q, 3);
454454
455455
if( isSelected ){
456456
md5sum_step_text(zName, -1);
457
- if( file_islink(zFullpath) ){
457
+ if( file_wd_islink(zFullpath) ){
458458
/* Instead of file content, use link destination path */
459459
Blob pathBuf;
460460
461461
sqlite3_snprintf(sizeof(zBuf), zBuf, " %ld\n",
462462
blob_read_link(&pathBuf, zFullpath));
@@ -524,11 +524,11 @@
524524
const char *zFullpath = db_column_text(&q, 0);
525525
const char *zName = db_column_text(&q, 1);
526526
int rid = db_column_int(&q, 2);
527527
528528
blob_zero(&disk);
529
- if( file_islink(zFullpath) ){
529
+ if( file_wd_islink(zFullpath) ){
530530
rc = blob_read_link(&disk, zFullpath);
531531
}else{
532532
rc = blob_read_from_file(&disk, zFullpath);
533533
}
534534
if( rc<0 ){
535535
--- src/vfile.c
+++ src/vfile.c
@@ -166,11 +166,11 @@
166 isDeleted = db_column_int(&q, 3);
167 oldChnged = db_column_int(&q, 4);
168 oldMtime = db_column_int64(&q, 7);
169 if( isDeleted ){
170 chnged = 1;
171 }else if( !file_isfile_or_link(zName) && file_size(0)>=0 ){
172 if( notFileIsFatal ){
173 fossil_warning("not an ordinary file: %s", zName);
174 nErr++;
175 }
176 chnged = 1;
@@ -179,12 +179,12 @@
179 }else if( rid==0 ){
180 chnged = 1;
181 }
182 if( chnged!=1 ){
183 i64 origSize = db_column_int64(&q, 6);
184 currentMtime = file_mtime(0);
185 if( origSize!=file_size(0) ){
186 /* A file size change is definitive - the file has changed. No
187 ** need to check the sha1sum */
188 chnged = 1;
189 }
190 }
@@ -247,17 +247,17 @@
247 isExe = db_column_int(&q, 3);
248 isLink = db_column_int(&q, 4);
249 content_get(rid, &content);
250 if( file_is_the_same(&content, zName) ){
251 blob_reset(&content);
252 if( file_setexe(zName, isExe) ){
253 db_multi_exec("UPDATE vfile SET mtime=%lld WHERE id=%d",
254 file_mtime(zName), id);
255 }
256 continue;
257 }
258 if( promptFlag && file_size(zName)>=0 ){
259 Blob ans;
260 char *zMsg;
261 char cReply;
262 zMsg = mprintf("overwrite %s (a=always/y/N)? ", zName);
263 prompt_user(zMsg, &ans);
@@ -276,22 +276,22 @@
276 if( verbose ) fossil_print("%s\n", &zName[nRepos]);
277 if( file_isdir(zName) == 1 ){
278 /*TODO(dchest): remove directories? */
279 fossil_fatal("%s is directory, cannot overwrite\n", zName);
280 }
281 if( file_size(zName)>=0 && (isLink || file_islink(zName)) ){
282 file_delete(zName);
283 }
284 if( isLink ){
285 create_symlink(blob_str(&content), zName);
286 }else{
287 blob_write_to_file(&content, zName);
288 }
289 file_setexe(zName, isExe);
290 blob_reset(&content);
291 db_multi_exec("UPDATE vfile SET mtime=%lld WHERE id=%d",
292 file_mtime(zName), id);
293 }
294 db_finalize(&q);
295 }
296
297
@@ -393,11 +393,11 @@
393 /* do nothing */
394 }else if( file_isdir(zPath)==1 ){
395 if( !vfile_top_of_checkout(zPath) ){
396 vfile_scan(pPath, nPrefix, allFlag, pIgnore);
397 }
398 }else if( file_isfile_or_link(zPath) ){
399 db_bind_text(&ins, ":file", &zPath[nPrefix+1]);
400 db_step(&ins);
401 db_reset(&ins);
402 }
403 blob_resize(pPath, origSize);
@@ -452,11 +452,11 @@
452 const char *zName = db_column_text(&q, 1);
453 int isSelected = db_column_int(&q, 3);
454
455 if( isSelected ){
456 md5sum_step_text(zName, -1);
457 if( file_islink(zFullpath) ){
458 /* Instead of file content, use link destination path */
459 Blob pathBuf;
460
461 sqlite3_snprintf(sizeof(zBuf), zBuf, " %ld\n",
462 blob_read_link(&pathBuf, zFullpath));
@@ -524,11 +524,11 @@
524 const char *zFullpath = db_column_text(&q, 0);
525 const char *zName = db_column_text(&q, 1);
526 int rid = db_column_int(&q, 2);
527
528 blob_zero(&disk);
529 if( file_islink(zFullpath) ){
530 rc = blob_read_link(&disk, zFullpath);
531 }else{
532 rc = blob_read_from_file(&disk, zFullpath);
533 }
534 if( rc<0 ){
535
--- src/vfile.c
+++ src/vfile.c
@@ -166,11 +166,11 @@
166 isDeleted = db_column_int(&q, 3);
167 oldChnged = db_column_int(&q, 4);
168 oldMtime = db_column_int64(&q, 7);
169 if( isDeleted ){
170 chnged = 1;
171 }else if( !file_wd_isfile_or_link(zName) && file_wd_size(0)>=0 ){
172 if( notFileIsFatal ){
173 fossil_warning("not an ordinary file: %s", zName);
174 nErr++;
175 }
176 chnged = 1;
@@ -179,12 +179,12 @@
179 }else if( rid==0 ){
180 chnged = 1;
181 }
182 if( chnged!=1 ){
183 i64 origSize = db_column_int64(&q, 6);
184 currentMtime = file_wd_mtime(0);
185 if( origSize!=file_wd_size(0) ){
186 /* A file size change is definitive - the file has changed. No
187 ** need to check the sha1sum */
188 chnged = 1;
189 }
190 }
@@ -247,17 +247,17 @@
247 isExe = db_column_int(&q, 3);
248 isLink = db_column_int(&q, 4);
249 content_get(rid, &content);
250 if( file_is_the_same(&content, zName) ){
251 blob_reset(&content);
252 if( file_wd_setexe(zName, isExe) ){
253 db_multi_exec("UPDATE vfile SET mtime=%lld WHERE id=%d",
254 file_wd_mtime(zName), id);
255 }
256 continue;
257 }
258 if( promptFlag && file_wd_size(zName)>=0 ){
259 Blob ans;
260 char *zMsg;
261 char cReply;
262 zMsg = mprintf("overwrite %s (a=always/y/N)? ", zName);
263 prompt_user(zMsg, &ans);
@@ -276,22 +276,22 @@
276 if( verbose ) fossil_print("%s\n", &zName[nRepos]);
277 if( file_isdir(zName) == 1 ){
278 /*TODO(dchest): remove directories? */
279 fossil_fatal("%s is directory, cannot overwrite\n", zName);
280 }
281 if( file_wd_size(zName)>=0 && (isLink || file_wd_islink(zName)) ){
282 file_delete(zName);
283 }
284 if( isLink ){
285 symlink_create(blob_str(&content), zName);
286 }else{
287 blob_write_to_file(&content, zName);
288 }
289 file_wd_setexe(zName, isExe);
290 blob_reset(&content);
291 db_multi_exec("UPDATE vfile SET mtime=%lld WHERE id=%d",
292 file_wd_mtime(zName), id);
293 }
294 db_finalize(&q);
295 }
296
297
@@ -393,11 +393,11 @@
393 /* do nothing */
394 }else if( file_isdir(zPath)==1 ){
395 if( !vfile_top_of_checkout(zPath) ){
396 vfile_scan(pPath, nPrefix, allFlag, pIgnore);
397 }
398 }else if( file_wd_isfile_or_link(zPath) ){
399 db_bind_text(&ins, ":file", &zPath[nPrefix+1]);
400 db_step(&ins);
401 db_reset(&ins);
402 }
403 blob_resize(pPath, origSize);
@@ -452,11 +452,11 @@
452 const char *zName = db_column_text(&q, 1);
453 int isSelected = db_column_int(&q, 3);
454
455 if( isSelected ){
456 md5sum_step_text(zName, -1);
457 if( file_wd_islink(zFullpath) ){
458 /* Instead of file content, use link destination path */
459 Blob pathBuf;
460
461 sqlite3_snprintf(sizeof(zBuf), zBuf, " %ld\n",
462 blob_read_link(&pathBuf, zFullpath));
@@ -524,11 +524,11 @@
524 const char *zFullpath = db_column_text(&q, 0);
525 const char *zName = db_column_text(&q, 1);
526 int rid = db_column_int(&q, 2);
527
528 blob_zero(&disk);
529 if( file_wd_islink(zFullpath) ){
530 rc = blob_read_link(&disk, zFullpath);
531 }else{
532 rc = blob_read_from_file(&disk, zFullpath);
533 }
534 if( rc<0 ){
535
+1 -1
--- src/zip.c
+++ src/zip.c
@@ -291,11 +291,11 @@
291291
}
292292
zip_open();
293293
for(i=3; i<g.argc; i++){
294294
blob_zero(&file);
295295
blob_read_from_file(&file, g.argv[i]);
296
- zip_add_file(g.argv[i], &file, file_perm(g.argv[i]));
296
+ zip_add_file(g.argv[i], &file, file_wd_perm(g.argv[i]));
297297
blob_reset(&file);
298298
}
299299
zip_close(&zip);
300300
blob_write_to_file(&zip, g.argv[2]);
301301
}
302302
--- src/zip.c
+++ src/zip.c
@@ -291,11 +291,11 @@
291 }
292 zip_open();
293 for(i=3; i<g.argc; i++){
294 blob_zero(&file);
295 blob_read_from_file(&file, g.argv[i]);
296 zip_add_file(g.argv[i], &file, file_perm(g.argv[i]));
297 blob_reset(&file);
298 }
299 zip_close(&zip);
300 blob_write_to_file(&zip, g.argv[2]);
301 }
302
--- src/zip.c
+++ src/zip.c
@@ -291,11 +291,11 @@
291 }
292 zip_open();
293 for(i=3; i<g.argc; i++){
294 blob_zero(&file);
295 blob_read_from_file(&file, g.argv[i]);
296 zip_add_file(g.argv[i], &file, file_wd_perm(g.argv[i]));
297 blob_reset(&file);
298 }
299 zip_close(&zip);
300 blob_write_to_file(&zip, g.argv[2]);
301 }
302

Keyboard Shortcuts

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