| ︙ | | | ︙ | |
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
** lstat() is called on Unix if isWd is TRUE and allow-symlinks setting is on.
**
*/
static int fossil_stat(const char *zFilename, struct fossilStat *buf, int isWd){
int rc;
void *zMbcs = fossil_utf8_to_path(zFilename, 0);
#if !defined(_WIN32)
if( isWd && db_allow_symlinks() ){
rc = lstat(zMbcs, buf);
}else{
rc = stat(zMbcs, buf);
}
#else
rc = win32_stat(zMbcs, buf, isWd);
#endif
|
|
|
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
** lstat() is called on Unix if isWd is TRUE and allow-symlinks setting is on.
**
*/
static int fossil_stat(const char *zFilename, struct fossilStat *buf, int isWd){
int rc;
void *zMbcs = fossil_utf8_to_path(zFilename, 0);
#if !defined(_WIN32)
if( isWd && db_allow_symlinks(0) ){
rc = lstat(zMbcs, buf);
}else{
rc = stat(zMbcs, buf);
}
#else
rc = win32_stat(zMbcs, buf, isWd);
#endif
|
| ︙ | | | ︙ | |
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
|
** Create symlink to file on Unix, or plain-text file with
** symlink target if "allow-symlinks" is off or we're on Windows.
**
** Arguments: target file (symlink will point to it), link file
**/
void symlink_create(const char *zTargetFile, const char *zLinkFile){
#if !defined(_WIN32)
if( db_allow_symlinks() ){
int i, nName;
char *zName, zBuf[1000];
nName = strlen(zLinkFile);
if( nName>=sizeof(zBuf) ){
zName = mprintf("%s", zLinkFile);
}else{
|
|
|
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
|
** Create symlink to file on Unix, or plain-text file with
** symlink target if "allow-symlinks" is off or we're on Windows.
**
** Arguments: target file (symlink will point to it), link file
**/
void symlink_create(const char *zTargetFile, const char *zLinkFile){
#if !defined(_WIN32)
if( db_allow_symlinks(0) ){
int i, nName;
char *zName, zBuf[1000];
nName = strlen(zLinkFile);
if( nName>=sizeof(zBuf) ){
zName = mprintf("%s", zLinkFile);
}else{
|
| ︙ | | | ︙ | |
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
|
** - PERM_REG for all other cases (regular file, directory, fifo, etc).
*/
int file_wd_perm(const char *zFilename){
#if !defined(_WIN32)
if( !getStat(zFilename, 1) ){
if( S_ISREG(fileStat.st_mode) && ((S_IXUSR)&fileStat.st_mode)!=0 )
return PERM_EXE;
else if( db_allow_symlinks() && S_ISLNK(fileStat.st_mode) )
return PERM_LNK;
}
#endif
return PERM_REG;
}
/*
|
|
|
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
|
** - PERM_REG for all other cases (regular file, directory, fifo, etc).
*/
int file_wd_perm(const char *zFilename){
#if !defined(_WIN32)
if( !getStat(zFilename, 1) ){
if( S_ISREG(fileStat.st_mode) && ((S_IXUSR)&fileStat.st_mode)!=0 )
return PERM_EXE;
else if( db_allow_symlinks(0) && S_ISLNK(fileStat.st_mode) )
return PERM_LNK;
}
#endif
return PERM_REG;
}
/*
|
| ︙ | | | ︙ | |
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
|
zFN = mprintf("%s", zFilename);
file_simplify_name(zFN, -1, 0);
rc = getStat(zFN, 1);
if( rc ){
rc = 0; /* It does not exist at all. */
}else if( S_ISDIR(fileStat.st_mode) ){
rc = 1; /* It exists and is a real directory. */
}else if( !g.fNoDirSymlinks && S_ISLNK(fileStat.st_mode) ){
Blob content;
blob_read_link(&content, zFN); /* It exists and is a link. */
rc = file_wd_isdir(blob_str(&content)); /* Points to directory? */
blob_reset(&content);
}else{
rc = 2; /* It exists and is something else. */
}
|
|
|
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
|
zFN = mprintf("%s", zFilename);
file_simplify_name(zFN, -1, 0);
rc = getStat(zFN, 1);
if( rc ){
rc = 0; /* It does not exist at all. */
}else if( S_ISDIR(fileStat.st_mode) ){
rc = 1; /* It exists and is a real directory. */
}else if( !db_allow_symlinks(1) && S_ISLNK(fileStat.st_mode) ){
Blob content;
blob_read_link(&content, zFN); /* It exists and is a link. */
rc = file_wd_isdir(blob_str(&content)); /* Points to directory? */
blob_reset(&content);
}else{
rc = 2; /* It exists and is something else. */
}
|
| ︙ | | | ︙ | |