Commit d6e6cf7d authored by rswindell's avatar rswindell
Browse files

On Windows, the return value of getfattr() is not compatible with chmod()

(totally differnet bit values).
So create getfmode() which is a thin wrapper for stat() and can be used to read
a chmod()-comopatible value on all supported OSes.
parent 46e910aa
......@@ -676,7 +676,8 @@ BOOL DLLCALL isdir(const char *filename)
}
/****************************************************************************/
/* Returns the attributes (mode) for specified 'filename' */
/* Returns the attributes (mode) for specified 'filename' or -1 on failure. */
/* The return value on Windows is *not* compatible with chmod(). */
/****************************************************************************/
int DLLCALL getfattr(const char* filename)
{
......@@ -702,6 +703,21 @@ int DLLCALL getfattr(const char* filename)
#endif
}
/****************************************************************************/
/* Returns the mode / type flags for specified 'filename' */
/* The return value *is* compatible with chmod(), or -1 upon failure. */
/****************************************************************************/
int DLLCALL getfmode(const char* filename)
{
struct stat st;
if(stat(filename, &st) != 0)
return -1;
return st.st_mode;
}
#ifdef __unix__
int removecase(const char *path)
{
......
......@@ -227,6 +227,7 @@ DLLEXPORT BOOL DLLCALL isfullpath(const char* filename);
DLLEXPORT char* DLLCALL getfname(const char* path);
DLLEXPORT char* DLLCALL getfext(const char* path);
DLLEXPORT int DLLCALL getfattr(const char* filename);
DLLEXPORT int DLLCALL getfmode(const char* filename);
DLLEXPORT ulong DLLCALL getfilecount(const char *inpath, const char* spec);
DLLEXPORT char* DLLCALL getdirname(const char* path);
DLLEXPORT long DLLCALL getdirsize(const char* path, BOOL include_subdirs, BOOL subdir_only);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment