Index: src/OFFile.m ================================================================== --- src/OFFile.m +++ src/OFFile.m @@ -333,10 +333,15 @@ } + (void)renameFileAtPath: (OFString*)from toPath: (OFString*)to { + if ([self directoryExistsAtPath: to]) { + OFString *filename = [self lastComponentOfPath: from]; + to = [OFString stringWithPath: to, filename, nil]; + } + #ifndef _WIN32 if (rename([from cString], [to cString])) #else if (!MoveFile([from cString], [to cString])) #endif @@ -365,19 +370,29 @@ #ifndef _WIN32 + (void)linkFileAtPath: (OFString*)src toPath: (OFString*)dest { + if ([self directoryExistsAtPath: dest]) { + OFString *filename = [self lastComponentOfPath: src]; + dest = [OFString stringWithPath: dest, filename, nil]; + } + if (link([src cString], [dest cString]) != 0) @throw [OFLinkFailedException newWithClass: self sourcePath: src destinationPath: dest]; } + (void)symlinkFileAtPath: (OFString*)src toPath: (OFString*)dest { + if ([self directoryExistsAtPath: dest]) { + OFString *filename = [self lastComponentOfPath: src]; + dest = [OFString stringWithPath: dest, filename, nil]; + } + if (symlink([src cString], [dest cString]) != 0) @throw [OFSymlinkFailedException newWithClass: self sourcePath: src destinationPath: dest]; }