From 9b9a74d97ddc4e76d8a5f0c1b67c1c2df04c9362 Mon Sep 17 00:00:00 2001 From: ReDetection Date: Mon, 23 Mar 2015 13:52:49 +0600 Subject: [PATCH] attributes getter added --- FTPKit/FTPHandle.h | 7 +++++++ FTPKit/FTPHandle.m | 13 +++++++++++++ 2 files changed, 20 insertions(+) diff --git a/FTPKit/FTPHandle.h b/FTPKit/FTPHandle.h index 09a022c..107012d 100644 --- a/FTPKit/FTPHandle.h +++ b/FTPKit/FTPHandle.h @@ -56,6 +56,13 @@ typedef enum { */ - (instancetype)initWithPath:(NSString *)path type:(FTPHandleType)type; +/** +* Attributes getter — useful when creating a copy of FTPHandle. +* +* @return attributes dictionary +*/ +- (NSDictionary *)attributes; + /** If mode set, returns string representation of file permissions. diff --git a/FTPKit/FTPHandle.m b/FTPKit/FTPHandle.m index ae18f5f..cfa310f 100644 --- a/FTPKit/FTPHandle.m +++ b/FTPKit/FTPHandle.m @@ -79,6 +79,19 @@ - (instancetype)initWithPath:(NSString *)aPath type:(FTPHandleType)aType return self; } +- (NSDictionary *)attributes { + NSMutableDictionary *result = [NSMutableDictionary dictionaryWithCapacity:8]; + result[(NSString *)kCFFTPResourceSize] = @(self.size); + result[(NSString *)kCFFTPResourceType] = @(self.type); + result[(NSString *)kCFFTPResourceMode] = @(self.mode); + if (self.link) result[(NSString *)kCFFTPResourceLink] = self.link; + if (self.name) result[(NSString *)kCFFTPResourceName] = self.name; + if (self.group) result[(NSString *)kCFFTPResourceGroup] = self.group; + if (self.owner) result[(NSString *)kCFFTPResourceOwner] = self.owner; + if (self.modified) result[(NSString *) kCFFTPResourceModDate] = self.modified; + return result; +} + - (NSString *)permissions { char modeCStr[12];