47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
#if defined(_WIN32) && (defined(__MSVCRT__) || defined(_MSC_VER))
# undef stat
# define stat _stati64
#endif
/*
** On Windows S_ISLNK always returns FALSE.
*/
#if defined(_WIN32)
# define S_ISLNK(x) (0)
#endif
static int fileStatValid = 0;
static struct stat fileStat;
/*
** Fill stat buf with information received from stat() or lstat().
|
|
|
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
#if defined(_WIN32) && (defined(__MSVCRT__) || defined(_MSC_VER))
# undef stat
# define stat _stati64
#endif
/*
** On Windows S_ISLNK always returns FALSE.
*/
#if !defined(S_ISLNK)
# define S_ISLNK(x) (0)
#endif
static int fileStatValid = 0;
static struct stat fileStat;
/*
** Fill stat buf with information received from stat() or lstat().
|
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
|
** - 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_wd_perm(const char *zFilename){
if( getStat(zFilename, 1) ) 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
|
|
|
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
|
** - 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_wd_perm(const char *zFilename){
if( getStat(zFilename, 1) ) return PERM_REG;
#if defined(_WIN32)
# ifndef S_IXUSR
# 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
|