-
Notifications
You must be signed in to change notification settings - Fork 220
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
43 changed files
with
583 additions
and
687 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
3.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
FileBrowser.xcodeproj/xcshareddata/xcschemes/FileBrowser.xcscheme
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,19 +9,19 @@ | |
import Foundation | ||
|
||
/// FBFile is a class representing a file in FileBrowser | ||
public class FBFile: NSObject { | ||
open class FBFile: NSObject { | ||
/// Display name. String. | ||
public let displayName: String | ||
open let displayName: String | ||
// is Directory. Bool. | ||
public let isDirectory: Bool | ||
open let isDirectory: Bool | ||
/// File extension. | ||
public let fileExtension: String? | ||
open let fileExtension: String? | ||
/// File attributes (including size, creation date etc). | ||
public let fileAttributes: NSDictionary? | ||
open let fileAttributes: NSDictionary? | ||
/// NSURL file path. | ||
public let filePath: NSURL | ||
open let filePath: URL | ||
// FBFileType | ||
public let type: FBFileType | ||
open let type: FBFileType | ||
|
||
/** | ||
Initialize an FBFile object with a filePath | ||
|
@@ -30,7 +30,7 @@ public class FBFile: NSObject { | |
|
||
- returns: FBFile object. | ||
*/ | ||
init(filePath: NSURL) { | ||
init(filePath: URL) { | ||
self.filePath = filePath | ||
let isDirectory = checkDirectory(filePath) | ||
self.isDirectory = isDirectory | ||
|
@@ -49,7 +49,7 @@ public class FBFile: NSObject { | |
self.type = .Default | ||
} | ||
} | ||
self.displayName = filePath.lastPathComponent ?? String() | ||
self.displayName = filePath.lastPathComponent | ||
} | ||
} | ||
|
||
|
@@ -82,16 +82,16 @@ public enum FBFileType: String { | |
- returns: UIImage for file type | ||
*/ | ||
public func image() -> UIImage? { | ||
let bundle = NSBundle(forClass: FileParser.self) | ||
let bundle = Bundle(for: FileParser.self) | ||
var fileName = String() | ||
switch self { | ||
case Directory: fileName = "[email protected]" | ||
case JPG, PNG, GIF: fileName = "[email protected]" | ||
case PDF: fileName = "[email protected]" | ||
case ZIP: fileName = "[email protected]" | ||
case .Directory: fileName = "[email protected]" | ||
case .JPG, .PNG, .GIF: fileName = "[email protected]" | ||
case .PDF: fileName = "[email protected]" | ||
case .ZIP: fileName = "[email protected]" | ||
default: fileName = "[email protected]" | ||
} | ||
let file = UIImage(named: fileName, inBundle: bundle, compatibleWithTraitCollection: nil) | ||
let file = UIImage(named: fileName, in: bundle, compatibleWith: nil) | ||
return file | ||
} | ||
} | ||
|
@@ -103,26 +103,24 @@ public enum FBFileType: String { | |
|
||
- returns: isDirectory Bool. | ||
*/ | ||
func checkDirectory(filePath: NSURL) -> Bool { | ||
func checkDirectory(_ filePath: URL) -> Bool { | ||
var isDirectory = false | ||
do { | ||
var resourceValue: AnyObject? | ||
try filePath.getResourceValue(&resourceValue, forKey: NSURLIsDirectoryKey) | ||
if let number = resourceValue as? NSNumber where number == true { | ||
try (filePath as NSURL).getResourceValue(&resourceValue, forKey: URLResourceKey.isDirectoryKey) | ||
if let number = resourceValue as? NSNumber , number == true { | ||
isDirectory = true | ||
} | ||
} | ||
catch { } | ||
return isDirectory | ||
} | ||
|
||
func getFileAttributes(filePath: NSURL) -> NSDictionary? { | ||
guard let path = filePath.path else { | ||
return nil | ||
} | ||
func getFileAttributes(_ filePath: URL) -> NSDictionary? { | ||
let path = filePath.path | ||
let fileManager = FileParser.sharedInstance.fileManager | ||
do { | ||
let attributes = try fileManager.attributesOfItemAtPath(path) as NSDictionary | ||
let attributes = try fileManager.attributesOfItem(atPath: path) as NSDictionary | ||
return attributes | ||
} catch {} | ||
return nil | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.