@@ -325,10 +325,20 @@ if (of_stat(path, &s) == -1) return false; return S_ISREG(s.st_mode); } + +- (bool)fileExistsAtURL: (OFURL *)URL +{ + void *pool = objc_autoreleasePoolPush(); + bool ret = [self fileExistsAtPath: [URL fileSystemRepresentation]]; + + objc_autoreleasePoolPop(pool); + + return ret; +} - (bool)directoryExistsAtPath: (OFString *)path { of_stat_t s; @@ -338,10 +348,20 @@ if (of_stat(path, &s) == -1) return false; return S_ISDIR(s.st_mode); } + +- (bool)directoryExistsAtURL: (OFURL *)URL +{ + void *pool = objc_autoreleasePoolPush(); + bool ret = [self directoryExistsAtPath: [URL fileSystemRepresentation]]; + + objc_autoreleasePoolPop(pool); + + return ret; +} #ifdef OF_FILE_MANAGER_SUPPORTS_SYMLINKS - (bool)symbolicLinkExistsAtPath: (OFString *)path { # ifndef OF_WINDOWS @@ -365,10 +385,21 @@ return true; return false; # endif } + +- (bool)symbolicLinkExistsAtURL: (OFURL *)URL +{ + void *pool = objc_autoreleasePoolPush(); + bool ret = [self symbolicLinkExistsAtPath: + [URL fileSystemRepresentation]]; + + objc_autoreleasePoolPop(pool); + + return ret; +} #endif - (void)createDirectoryAtPath: (OFString *)path { if (path == nil) @@ -455,10 +486,30 @@ objc_autoreleasePoolPop(pool); [currentPath autorelease]; } } + +- (void)createDirectoryAtURL: (OFURL *)URL +{ + void *pool = objc_autoreleasePoolPush(); + + [self createDirectoryAtPath: [URL fileSystemRepresentation]]; + + objc_autoreleasePoolPop(pool); +} + +- (void)createDirectoryAtURL: (OFURL *)URL + createParents: (bool)createParents +{ + void *pool = objc_autoreleasePoolPush(); + + [self createDirectoryAtPath: [URL fileSystemRepresentation] + createParents: createParents]; + + objc_autoreleasePoolPop(pool); +} - (OFArray *)contentsOfDirectoryAtPath: (OFString *)path { OFMutableArray *files; @@ -636,10 +687,23 @@ [files makeImmutable]; return files; } + +- (OFArray *)contentsOfDirectoryAtURL: (OFURL *)URL +{ + void *pool = objc_autoreleasePoolPush(); + OFArray *ret = [self contentsOfDirectoryAtPath: + [URL fileSystemRepresentation]]; + + [ret retain]; + + objc_autoreleasePoolPop(pool); + + return [ret autorelease]; +} - (void)changeCurrentDirectoryPath: (OFString *)path { if (path == nil) @throw [OFInvalidArgumentException exception]; @@ -687,10 +751,19 @@ @throw [OFChangeCurrentDirectoryPathFailedException exceptionWithPath: path errNo: errno]; #endif } + +- (void)changeCurrentDirectoryURL: (OFURL *)URL +{ + void *pool = objc_autoreleasePoolPush(); + + [self changeCurrentDirectoryPath: [URL fileSystemRepresentation]]; + + objc_autoreleasePoolPop(pool); +} - (of_offset_t)sizeOfFileAtPath: (OFString *)path { of_stat_t s; @@ -701,10 +774,21 @@ @throw [OFStatItemFailedException exceptionWithPath: path errNo: errno]; return s.st_size; } + +- (of_offset_t)sizeOfFileAtURL: (OFURL *)URL +{ + void *pool = objc_autoreleasePoolPush(); + of_offset_t ret = [self sizeOfFileAtPath: + [URL fileSystemRepresentation]]; + + objc_autoreleasePoolPop(pool); + + return ret; +} - (OFDate *)accessTimeOfItemAtPath: (OFString *)path { of_stat_t s; @@ -716,10 +800,23 @@ errNo: errno]; /* FIXME: We could be more precise on some OSes */ return [OFDate dateWithTimeIntervalSince1970: s.st_atime]; } + +- (OFDate *)accessTimeOfItemAtURL: (OFURL *)URL +{ + void *pool = objc_autoreleasePoolPush(); + OFDate *ret = [self accessTimeOfItemAtPath: + [URL fileSystemRepresentation]]; + + [ret retain]; + + objc_autoreleasePoolPop(pool); + + return [ret autorelease]; +} - (OFDate *)modificationDateOfItemAtPath: (OFString *)path { of_stat_t s; @@ -731,10 +828,23 @@ errNo: errno]; /* FIXME: We could be more precise on some OSes */ return [OFDate dateWithTimeIntervalSince1970: s.st_mtime]; } + +- (OFDate *)modificationDateOfItemAtURL: (OFURL *)URL +{ + void *pool = objc_autoreleasePoolPush(); + OFDate *ret = [self modificationDateOfItemAtPath: + [URL fileSystemRepresentation]]; + + [ret retain]; + + objc_autoreleasePoolPop(pool); + + return [ret autorelease]; +} - (OFDate *)statusChangeTimeOfItemAtPath: (OFString *)path { of_stat_t s; @@ -746,10 +856,23 @@ errNo: errno]; /* FIXME: We could be more precise on some OSes */ return [OFDate dateWithTimeIntervalSince1970: s.st_ctime]; } + +- (OFDate *)statusChangeTimeOfItemAtURL: (OFURL *)URL +{ + void *pool = objc_autoreleasePoolPush(); + OFDate *ret = [self statusChangeTimeOfItemAtPath: + [URL fileSystemRepresentation]]; + + [ret retain]; + + objc_autoreleasePoolPop(pool); + + return [ret autorelease]; +} #ifdef OF_FILE_MANAGER_SUPPORTS_PERMISSIONS - (uint16_t)permissionsOfItemAtPath: (OFString *)path { of_stat_t s; @@ -761,10 +884,21 @@ @throw [OFStatItemFailedException exceptionWithPath: path errNo: errno]; return s.st_mode & 07777; } + +- (uint16_t)permissionsOfItemAtURL: (OFURL *)URL +{ + void *pool = objc_autoreleasePoolPush(); + uint16_t ret = [self permissionsOfItemAtPath: + [URL fileSystemRepresentation]]; + + objc_autoreleasePoolPop(pool); + + return ret; +} - (void)changePermissionsOfItemAtPath: (OFString *)path permissions: (uint16_t)permissions { if (path == nil) @@ -781,10 +915,21 @@ @throw [OFChangePermissionsFailedException exceptionWithPath: path permissions: permissions errNo: errno]; } + +- (void)changePermissionsOfItemAtURL: (OFURL *)URL + permissions: (uint16_t)permissions +{ + void *pool = objc_autoreleasePoolPush(); + + [self changePermissionsOfItemAtPath: [URL fileSystemRepresentation] + permissions: permissions]; + + objc_autoreleasePoolPop(pool); +} #endif #ifdef OF_FILE_MANAGER_SUPPORTS_OWNER - (void)getUID: (uint16_t *)UID GID: (uint16_t *)GID @@ -802,10 +947,23 @@ if (UID != NULL) *UID = s.st_uid; if (GID != NULL) *GID = s.st_gid; } + +- (void)getUID: (uint16_t *)UID + GID: (uint16_t *)GID + ofItemAtURL: (OFURL *)URL +{ + void *pool = objc_autoreleasePoolPush(); + + [self getUID: UID + GID: GID + ofItemAtPath: [URL fileSystemRepresentation]]; + + objc_autoreleasePoolPop(pool); +} - (void)getOwner: (OFString **)owner group: (OFString **)group ofItemAtPath: (OFString *)path { @@ -838,10 +996,30 @@ } @finally { [passwdMutex unlock]; } # endif } + +- (void)getOwner: (OFString **)owner + group: (OFString **)group + ofItemAtURL: (OFURL *)URL +{ + void *pool = objc_autoreleasePoolPush(); + OFString *path = [URL fileSystemRepresentation]; + + [path retain]; + + objc_autoreleasePoolPop(pool); + + @try { + [self getOwner: owner + group: group + ofItemAtPath: path]; + } @finally { + [path release]; + } +} - (void)changeOwnerOfItemAtPath: (OFString *)path owner: (OFString *)owner group: (OFString *)group { @@ -895,10 +1073,23 @@ @throw [OFChangeOwnerFailedException exceptionWithPath: path owner: owner group: group errNo: errno]; } + +- (void)changeOwnerOfItemAtURL: (OFURL *)URL + owner: (OFString *)owner + group: (OFString *)group +{ + void *pool = objc_autoreleasePoolPush(); + + [self changeOwnerOfItemAtPath: [URL fileSystemRepresentation] + owner: owner + group: group]; + + objc_autoreleasePoolPop(pool); +} #endif - (void)copyItemAtPath: (OFString *)source toPath: (OFString *)destination { @@ -1040,10 +1231,21 @@ destinationPath: destination errNo: EINVAL]; objc_autoreleasePoolPop(pool); } + +- (void)copyItemAtURL: (OFURL *)source + toURL: (OFURL *)destination +{ + void *pool = objc_autoreleasePoolPush(); + + [self copyItemAtPath: [source fileSystemRepresentation] + toPath: [destination fileSystemRepresentation]]; + + objc_autoreleasePoolPop(pool); +} - (void)moveItemAtPath: (OFString *)source toPath: (OFString *)destination { of_stat_t s; @@ -1136,10 +1338,21 @@ #ifdef OF_WINDOWS objc_autoreleasePoolPop(pool); #endif } + +- (void)moveItemAtURL: (OFURL *)source + toURL: (OFURL *)destination +{ + void *pool = objc_autoreleasePoolPush(); + + [self moveItemAtPath: [source fileSystemRepresentation] + toPath: [destination fileSystemRepresentation]]; + + objc_autoreleasePoolPop(pool); +} - (void)removeItemAtPath: (OFString *)path { void *pool; of_stat_t s; @@ -1235,10 +1448,19 @@ } #endif objc_autoreleasePoolPop(pool); } + +- (void)removeItemAtURL: (OFURL *)URL +{ + void *pool = objc_autoreleasePoolPush(); + + [self removeItemAtPath: [URL fileSystemRepresentation]]; + + objc_autoreleasePoolPop(pool); +} #ifdef OF_FILE_MANAGER_SUPPORTS_LINKS - (void)linkItemAtPath: (OFString *)source toPath: (OFString *)destination { @@ -1266,10 +1488,21 @@ destinationPath: destination errNo: 0]; # endif + objc_autoreleasePoolPop(pool); +} + +- (void)linkItemAtURL: (OFURL *)source + toURL: (OFURL *)destination +{ + void *pool = objc_autoreleasePoolPush(); + + [self linkItemAtPath: [source fileSystemRepresentation] + toPath: [destination fileSystemRepresentation]]; + objc_autoreleasePoolPop(pool); } #endif #ifdef OF_FILE_MANAGER_SUPPORTS_SYMLINKS @@ -1303,10 +1536,21 @@ exceptionWithSourcePath: source destinationPath: destination errNo: 0]; # endif + objc_autoreleasePoolPop(pool); +} + +- (void)createSymbolicLinkAtURL: (OFURL *)destination + withDestinationURL: (OFURL *)source +{ + void *pool = objc_autoreleasePoolPush(); + + [self createSymbolicLinkAtPath: [destination fileSystemRepresentation] + withDestinationPath: [source fileSystemRepresentation]]; + objc_autoreleasePoolPop(pool); } - (OFString *)destinationOfSymbolicLinkAtPath: (OFString *)path { @@ -1375,7 +1619,20 @@ } @finally { CloseHandle(handle); } # endif } + +- (OFString *)destinationOfSymbolicLinkAtURL: (OFURL *)URL +{ + void *pool = objc_autoreleasePoolPush(); + OFString *ret = [self destinationOfSymbolicLinkAtPath: + [URL fileSystemRepresentation]]; + + [ret retain]; + + objc_autoreleasePoolPop(pool); + + return [ret autorelease]; +} #endif @end