Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions FTPKit/FTPHandle.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
13 changes: 13 additions & 0 deletions FTPKit/FTPHandle.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down