Index: src/OFFile.h ================================================================== --- src/OFFile.h +++ src/OFFile.h @@ -91,10 +91,20 @@ * * @param path The path to check * @return A boolean whether there is a directory at the specified path */ + (bool)directoryExistsAtPath: (OFString*)path; + +#ifdef OF_HAVE_SYMLINK +/*! + * @brief Checks whether a symbolic link exists at the specified path. + * + * @param path The path to check + * @return A boolean whether there is a symbolic link at the specified path + */ ++ (bool)symbolicLinkExistsAtPath: (OFString*)path; +#endif /*! * @brief Creates a directory at the specified path. * * @param path The path of the directory Index: src/OFFile.m ================================================================== --- src/OFFile.m +++ src/OFFile.m @@ -238,10 +238,29 @@ if (S_ISDIR(s.st_mode)) return true; return false; } + +#ifdef OF_HAVE_SYMLINK ++ (bool)symbolicLinkExistsAtPath: (OFString*)path +{ + struct stat s; + + if (path == nil) + @throw [OFInvalidArgumentException exception]; + + if (lstat([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE], + &s) == -1) + return false; + + if (S_ISLNK(s.st_mode)) + return true; + + return false; +} +#endif + (void)createDirectoryAtPath: (OFString*)path { if (path == nil) @throw [OFInvalidArgumentException exception];