Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4896621f90 | |||
| d98b486b44 |
@@ -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
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user