Index: src/OFFile.h ================================================================== --- src/OFFile.h +++ src/OFFile.h @@ -11,10 +11,13 @@ #import #ifndef _WIN32 #import +#else +typedef int uid_t; +typedef int gid_t; #endif #import "OFObject.h" #import "OFStream.h" @@ -41,14 +44,12 @@ * \param path The path to the file of which the mode should be changed as a * C string * \param mode The new mode for the file * \return A boolean whether the operation succeeded */ -#ifndef _WIN32 -+ (BOOL)changeModeOfFile: (const char*)path ++ (void)changeModeOfFile: (const char*)path toMode: (mode_t)mode; -#endif /** * Changes the owner of a file. * * Not available on Windows. @@ -57,23 +58,21 @@ * C string * \param owner The new owner for the file * \param group The new group for the file * \return A boolean whether the operation succeeded */ -#ifndef _WIN32 -+ (BOOL)changeOwnerOfFile: (const char*)path ++ (void)changeOwnerOfFile: (const char*)path toOwner: (uid_t)owner andGroup: (gid_t)group; -#endif /** * Deletes a file. * * \param path The path to the file of which should be deleted as a C string * \return A boolean whether the operation succeeded */ -+ (BOOL)delete: (const char*)path; ++ (void)delete: (const char*)path; /** * Hardlinks a file. * * Not available on Windows. @@ -80,14 +79,12 @@ * * \param src The path to the file of which should be linked as a C string * \param dest The path to where the file should be linked as a C string * \return A boolean whether the operation succeeded */ -#ifndef _WIN32 -+ (BOOL)link: (const char*)src ++ (void)link: (const char*)src to: (const char*)dest; -#endif /** * Symlinks a file. * * Not available on Windows. @@ -94,14 +91,12 @@ * * \param src The path to the file of which should be symlinked as a C string * \param dest The path to where the file should be symlinked as a C string * \return A boolean whether the operation succeeded */ -#ifndef _WIN32 -+ (BOOL)symlink: (const char*)src ++ (void)symlink: (const char*)src to: (const char*)dest; -#endif /** * Initializes an already allocated OFFile. * * \param path The path to the file to open as a C string Index: src/OFFile.m ================================================================== --- src/OFFile.m +++ src/OFFile.m @@ -29,50 +29,55 @@ { return [[self alloc] initWithPath: path andMode: mode]; } ++ (void)changeModeOfFile: (const char*)path + toMode: (mode_t)mode +{ + /* + * FIXME: On error, throw exception + * FIXME: On Win32, change write access + */ #ifndef _WIN32 -+ (BOOL)changeModeOfFile: (const char*)path - toMode: (mode_t)mode -{ - // FIXME: On error, throw exception - return (chmod(path, mode) == 0 ? YES : NO); -} + chmod(path, mode); #endif +} -#ifndef _WIN32 -+ (BOOL)changeOwnerOfFile: (const char*)path ++ (void)changeOwnerOfFile: (const char*)path toOwner: (uid_t)owner andGroup: (gid_t)group { - // FIXME: On error, throw exception - return (chown(path, owner, group) == 0 ? YES : NO); -} -#endif - -+ (BOOL)delete: (const char*)path -{ - // FIXME: On error, throw exception - return (unlink(path) == 0 ? YES : NO); -} - -#ifndef _WIN32 -+ (BOOL)link: (const char*)src - to: (const char*)dest -{ - // FIXME: On error, throw exception - return (link(src, dest) == 0 ? YES : NO); -} - -+ (BOOL)symlink: (const char*)src - to: (const char*)dest -{ - // FIXME: On error, throw exception - return (symlink(src, dest) == 0 ? YES : NO); -} -#endif + /* FIXME: On error, throw exception */ +#ifndef _WIN32 + chown(path, owner, group); +#endif +} + ++ (void)delete: (const char*)path +{ + /* FIXME: On error, throw exception */ + unlink(path); +} + ++ (void)link: (const char*)src + to: (const char*)dest +{ + /* FIXME: On error, throw exception */ +#ifndef _WIN32 + link(src, dest); +#endif +} + ++ (void)symlink: (const char*)src + to: (const char*)dest +{ + /* FIXME: On error, throw exception */ +#ifndef _WIN32 + symlink(src, dest); +#endif +} - initWithPath: (const char*)path andMode: (const char*)mode { if ((self = [super init])) {