Skip to content
Snippets Groups Projects
Commit d4ee4133 authored by rswindell's avatar rswindell
Browse files

isdir() now supports file/path names that end in a slash on Win32.

(truncates the slash before calling stat).
parent 3872dc4b
No related branches found
No related tags found
No related merge requests found
......@@ -497,17 +497,33 @@ BOOL DLLCALL fexistcase(char *path)
#endif
}
#if !defined(S_ISDIR)
#define S_ISDIR(x) ((x)&S_IFDIR)
#endif
/****************************************************************************/
/* Returns TRUE if the filename specified is a directory */
/****************************************************************************/
BOOL DLLCALL isdir(const char *filename)
{
char path[MAX_PATH+1];
char* p;
struct stat st;
if(stat(filename, &st)!=0)
SAFECOPY(path,filename);
p=lastchar(path);
if(p!=path && (*p=='/' || *p==BACKSLASH)) { /* chop off trailing slash */
#if !defined(__unix__)
if(*(p-1)!=':') /* Don't change C:\ to C: */
#endif
*p=0;
}
if(stat(path, &st)!=0)
return(FALSE);
return((st.st_mode&S_IFDIR) ? TRUE : FALSE);
return(S_ISDIR(st.st_mode) ? TRUE : FALSE);
}
/****************************************************************************/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment