2 Commits

Author SHA1 Message Date
Roy Marmelstein 4896621f90 Adding file attributes to FBFile 2016-02-22 21:46:21 +01:00
Roy Marmelstein d98b486b44 Update README.md 2016-02-18 22:46:22 +01:00
2 changed files with 17 additions and 1 deletions
+16
View File
@@ -16,6 +16,8 @@ public class FBFile: NSObject {
public let isDirectory: Bool
/// File extension.
public let fileExtension: String?
/// File attributes (including size, creation date etc).
public let fileAttributes: NSDictionary?
/// NSURL file path.
public let filePath: NSURL
// FBFileType
@@ -34,10 +36,12 @@ public class FBFile: NSObject {
let isDirectory = checkDirectory(filePath)
self.isDirectory = isDirectory
if self.isDirectory {
self.fileAttributes = nil
self.fileExtension = nil
self.type = .Directory
}
else {
self.fileAttributes = getFileAttributes(self.filePath)
self.fileExtension = self.filePath.pathExtension
if let fileExtension = fileExtension {
self.type = FBFileType(rawValue: fileExtension) ?? .Default
@@ -118,3 +122,15 @@ func checkDirectory(filePath: NSURL) -> Bool {
catch { }
return isDirectory
}
func getFileAttributes(filePath: NSURL) -> NSDictionary? {
guard let path = filePath.path else {
return nil
}
let fileManager = FileParser.sharedInstance.fileManager
do {
let attributes = try fileManager.attributesOfItemAtPath(path) as NSDictionary
return attributes
} catch {}
return nil
}
+1 -1
View File
@@ -13,7 +13,7 @@ iOS Finder-style file browser in Swift with search, file previews and 3D touch.
| Features
--------------------------|------------------------------------------------------------
:iphone: | Browse files and folders with a familiar UI on iOS.
:iphone: | Browse and select files and folders with a familiar UI on iOS.
:mag: | Pull down to search.
:eyeglasses: | Preview most file types. Including plist and json.
:point_up_2: | 3D touch support for faster previews with Peek & Pop.