Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Refactor file_perm(), file_islink(), and file_isexe(). Now file_perm() calls stat only once. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | symlinks |
| Files: | files | file ages | folders |
| SHA1: |
eac23495a950cdd232e10b507de516be |
| User & Date: | dmitry 2011-09-01 22:56:34.666 |
Context
|
2011-09-01
| ||
| 23:18 | Merge latest changes from trunk. check-in: 2b1a4797dd user: dmitry tags: symlinks | |
| 22:56 | Refactor file_perm(), file_islink(), and file_isexe(). Now file_perm() calls stat only once. check-in: eac23495a9 user: dmitry tags: symlinks | |
| 22:55 | Fix merge when merging UPDATEs a symlink to a regular file and vice versa. check-in: 82a95b4692 user: dmitry tags: symlinks | |
Changes
Changes to src/file.c.
| ︙ | ︙ | |||
98 99 100 101 102 103 104 |
** and symlinks are allowed.
** Return false for directories, devices, fifos, etc.
*/
int file_isfile_or_link(const char *zFilename){
#if !defined(_WIN32)
if ( g.allowSymlinks ){
return getStat(zFilename) ? 0 : S_ISREG(fileStat.st_mode) || S_ISLNK(fileStat.st_mode);
| < < | | < < < < < < < < < < < < < < < < < < < | 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
** and symlinks are allowed.
** Return false for directories, devices, fifos, etc.
*/
int file_isfile_or_link(const char *zFilename){
#if !defined(_WIN32)
if ( g.allowSymlinks ){
return getStat(zFilename) ? 0 : S_ISREG(fileStat.st_mode) || S_ISLNK(fileStat.st_mode);
}
#endif
return getStat(zFilename) ? 0 : S_ISREG(fileStat.st_mode);
}
/*
** Return TRUE if the named file is an ordinary file. Return false
** for directories, devices, fifos, symlinks, etc.
*/
int file_isfile(const char *zFilename){
return getStat(zFilename) ? 0 : S_ISREG(fileStat.st_mode);
}
/*
** 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 create_symlink(const char *zTargetFile, const char *zLinkFile){
|
| ︙ | ︙ | |||
178 179 180 181 182 183 184 |
blob_set(&content, zTargetFile);
blob_write_to_file(&content, zLinkFile);
blob_reset(&content);
}
}
/*
| > | > | | | | > > > > | > > > > > > > > > > > | > > | > > | < | < < < < | 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 |
blob_set(&content, zTargetFile);
blob_write_to_file(&content, zLinkFile);
blob_reset(&content);
}
}
/*
** Return file permissions (normal, executable, or symlink):
** - PERM_EXE if file is executable;
** - PERM_LNK on Unix if file is symlink and allow-symlinks option is on;
** - PERM_REG for all other cases (regular file, directory, fifo, etc).
*/
int file_perm(const char *zFilename){
if( getStat(zFilename) ) return PERM_REG;
#if defined(_WIN32)
# if defined(__DMC__) || defined(_MSC_VER)
# define S_IXUSR _S_IEXEC
# endif
if( S_ISREG(fileStat.st_mode) && ((S_IXUSR)&fileStat.st_mode)!=0 )
return PERM_EXE;
else
return PERM_REG;
#else
if( S_ISREG(fileStat.st_mode) &&
((S_IXUSR|S_IXGRP|S_IXOTH)&fileStat.st_mode)!=0 )
return PERM_EXE;
else if( g.allowSymlinks && S_ISLNK(fileStat.st_mode) )
return PERM_LNK;
else
return PERM_REG;
#endif
}
/*
** Return TRUE if the named file is an executable. Return false
** for directories, devices, fifos, symlinks, etc.
*/
int file_isexe(const char *zFilename){
return file_perm(zFilename)==PERM_EXE;
}
/*
** Return TRUE if the named file is a symlink and symlinks are allowed.
** Return false for all other cases.
**
** On Windows, always return False.
*/
int file_islink(const char *zFilename){
return file_perm(zFilename)==PERM_LNK;
}
/*
** Return 1 if zFilename is a directory. Return 0 if zFilename
** does not exist. Return 2 if zFilename exists but is something
** other than a directory.
*/
|
| ︙ | ︙ |