src/Platform-Posix.cpp
changeset 252 1dee2330aa78
parent 251 ca99a81745fe
     1.1 --- a/src/Platform-Posix.cpp	Tue Jan 01 15:34:07 2013 -0800
     1.2 +++ b/src/Platform-Posix.cpp	Tue Jan 01 16:28:34 2013 -0800
     1.3 @@ -17,6 +17,7 @@
     1.4   * JITCraft. If not, see http://www.gnu.org/licenses/.
     1.5   */
     1.6  #include <sys/mman.h>
     1.7 +#include <sys/stat.h>
     1.8  #include <limits.h>
     1.9  #include <string.h>
    1.10  #include <stdlib.h>
    1.11 @@ -154,3 +155,19 @@
    1.12      return "/";
    1.13  }
    1.14  
    1.15 +OS::PathType
    1.16 +OS::InspectPath(const char *path)
    1.17 +{
    1.18 +    struct stat s;
    1.19 +    int result = stat(path, &s);
    1.20 +    if (result != 0)
    1.21 +        return OS::Path_Invalid;
    1.22 +
    1.23 +    if (s.st_mode & S_IFDIR)
    1.24 +        return OS::Path_Folder;
    1.25 +    if (s.st_mode & S_IFREG)
    1.26 +        return OS::Path_File;
    1.27 +
    1.28 +    return OS::Path_Invalid;
    1.29 +}
    1.30 +