diff --git a/examples/Sample/Sample.xcodeproj/project.pbxproj b/examples/Sample/Sample.xcodeproj/project.pbxproj index b6a864b3efa1e189bf7733d40710edb86f6d2d55..f1b5aa5369675233a5ef2a22a887c087ada43a51 100644 --- a/examples/Sample/Sample.xcodeproj/project.pbxproj +++ b/examples/Sample/Sample.xcodeproj/project.pbxproj @@ -8,14 +8,13 @@ /* Begin PBXBuildFile section */ 3430F6711C45C930007473A6 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3430F6701C45C930007473A6 /* AppDelegate.swift */; }; - 3430F6731C45C930007473A6 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3430F6721C45C930007473A6 /* ViewController.swift */; }; 3430F6761C45C930007473A6 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 3430F6741C45C930007473A6 /* Main.storyboard */; }; 3430F6781C45C930007473A6 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 3430F6771C45C930007473A6 /* Assets.xcassets */; }; 3430F67B1C45C930007473A6 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 3430F6791C45C930007473A6 /* LaunchScreen.storyboard */; }; 3430F6861C45C930007473A6 /* SampleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3430F6851C45C930007473A6 /* SampleTests.swift */; }; 3430F6991C45C949007473A6 /* Zip.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3430F6961C45C93F007473A6 /* Zip.framework */; }; 3430F69A1C45C949007473A6 /* Zip.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3430F6961C45C93F007473A6 /* Zip.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; - 3430F69F1C45C96A007473A6 /* master.zip in Resources */ = {isa = PBXBuildFile; fileRef = 3430F69E1C45C96A007473A6 /* master.zip */; }; + 3467DAED1C4BADB700BA3DB8 /* FileBrowser.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3467DAEC1C4BADB700BA3DB8 /* FileBrowser.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -66,7 +65,6 @@ /* Begin PBXFileReference section */ 3430F66D1C45C930007473A6 /* Sample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Sample.app; sourceTree = BUILT_PRODUCTS_DIR; }; 3430F6701C45C930007473A6 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; - 3430F6721C45C930007473A6 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 3430F6751C45C930007473A6 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 3430F6771C45C930007473A6 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 3430F67A1C45C930007473A6 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; @@ -75,7 +73,7 @@ 3430F6851C45C930007473A6 /* SampleTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SampleTests.swift; sourceTree = ""; }; 3430F6871C45C930007473A6 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 3430F6901C45C93F007473A6 /* Zip.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = Zip.xcodeproj; path = ../../Zip.xcodeproj; sourceTree = ""; }; - 3430F69E1C45C96A007473A6 /* master.zip */ = {isa = PBXFileReference; lastKnownFileType = archive.zip; path = master.zip; sourceTree = ""; }; + 3467DAEC1C4BADB700BA3DB8 /* FileBrowser.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FileBrowser.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -120,8 +118,7 @@ isa = PBXGroup; children = ( 3430F6701C45C930007473A6 /* AppDelegate.swift */, - 3430F6721C45C930007473A6 /* ViewController.swift */, - 3430F69E1C45C96A007473A6 /* master.zip */, + 3467DAEC1C4BADB700BA3DB8 /* FileBrowser.swift */, 3430F6741C45C930007473A6 /* Main.storyboard */, 3430F6771C45C930007473A6 /* Assets.xcassets */, 3430F6791C45C930007473A6 /* LaunchScreen.storyboard */, @@ -257,7 +254,6 @@ 3430F67B1C45C930007473A6 /* LaunchScreen.storyboard in Resources */, 3430F6781C45C930007473A6 /* Assets.xcassets in Resources */, 3430F6761C45C930007473A6 /* Main.storyboard in Resources */, - 3430F69F1C45C96A007473A6 /* master.zip in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -275,7 +271,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 3430F6731C45C930007473A6 /* ViewController.swift in Sources */, + 3467DAED1C4BADB700BA3DB8 /* FileBrowser.swift in Sources */, 3430F6711C45C930007473A6 /* AppDelegate.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/examples/Sample/Sample/Assets.xcassets/Contents.json b/examples/Sample/Sample/Assets.xcassets/Contents.json new file mode 100644 index 0000000000000000000000000000000000000000..da4a164c918651cdd1e11dca5cc62c333f097601 --- /dev/null +++ b/examples/Sample/Sample/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/examples/Sample/Sample/Assets.xcassets/File.imageset/738-document-1.png b/examples/Sample/Sample/Assets.xcassets/File.imageset/738-document-1.png new file mode 100644 index 0000000000000000000000000000000000000000..b604d45eedb687f3c5ba340f9c0a110c5fd81ed8 Binary files /dev/null and b/examples/Sample/Sample/Assets.xcassets/File.imageset/738-document-1.png differ diff --git a/examples/Sample/Sample/Assets.xcassets/File.imageset/738-document-1@2x.png b/examples/Sample/Sample/Assets.xcassets/File.imageset/738-document-1@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..358af8b165fd3b6c9131221c3049291cd1bfefb9 Binary files /dev/null and b/examples/Sample/Sample/Assets.xcassets/File.imageset/738-document-1@2x.png differ diff --git a/examples/Sample/Sample/Assets.xcassets/File.imageset/Contents.json b/examples/Sample/Sample/Assets.xcassets/File.imageset/Contents.json new file mode 100644 index 0000000000000000000000000000000000000000..826f17f96cedca298b93fc757cf3a7b2f06f1d09 --- /dev/null +++ b/examples/Sample/Sample/Assets.xcassets/File.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "738-document-1.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "738-document-1@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/examples/Sample/Sample/Assets.xcassets/Folder.imageset/710-folder.png b/examples/Sample/Sample/Assets.xcassets/Folder.imageset/710-folder.png new file mode 100644 index 0000000000000000000000000000000000000000..b1a422b6a9a232d05feb4588ca4ec9b03b5e32cd Binary files /dev/null and b/examples/Sample/Sample/Assets.xcassets/Folder.imageset/710-folder.png differ diff --git a/examples/Sample/Sample/Assets.xcassets/Folder.imageset/710-folder@2x.png b/examples/Sample/Sample/Assets.xcassets/Folder.imageset/710-folder@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..f79e8b7bb564c09651348fd5ec98529abaaa0319 Binary files /dev/null and b/examples/Sample/Sample/Assets.xcassets/Folder.imageset/710-folder@2x.png differ diff --git a/examples/Sample/Sample/Assets.xcassets/Folder.imageset/Contents.json b/examples/Sample/Sample/Assets.xcassets/Folder.imageset/Contents.json new file mode 100644 index 0000000000000000000000000000000000000000..899935763187c8c7aeb748a0b4b6e300f553a167 --- /dev/null +++ b/examples/Sample/Sample/Assets.xcassets/Folder.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "710-folder.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "710-folder@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/examples/Sample/Sample/Base.lproj/Main.storyboard b/examples/Sample/Sample/Base.lproj/Main.storyboard index 3a2a49bad8c615d719f891998e537cd29a001ec0..e6136bb6d2ecfacd0ae47f724364147c29dd8044 100644 --- a/examples/Sample/Sample/Base.lproj/Main.storyboard +++ b/examples/Sample/Sample/Base.lproj/Main.storyboard @@ -1,25 +1,78 @@ - + - + + - - + + - + + + + + + + + + + + + + + + + + - - + + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + diff --git a/examples/Sample/Sample/FileBrowser.swift b/examples/Sample/Sample/FileBrowser.swift new file mode 100644 index 0000000000000000000000000000000000000000..4b0c319827bbbf771c5b6a46e6822b9c3ff8c260 --- /dev/null +++ b/examples/Sample/Sample/FileBrowser.swift @@ -0,0 +1,91 @@ +// +// FileBrowser.swift +// Sample +// +// Created by Roy Marmelstein on 17/01/2016. +// Copyright © 2016 Roy Marmelstein. All rights reserved. +// + +import UIKit + +class FileBrowser: UIViewController { + + @IBOutlet weak var tableView: UITableView! + + @IBOutlet weak var selectionCounter: UIBarButtonItem! + + let fileManager = NSFileManager.defaultManager() + + + var path: NSURL? { + didSet { + if let filePath = path { + var tempFiles = [String]() + do { + self.title = filePath.lastPathComponent + tempFiles = try self.fileManager.contentsOfDirectoryAtPath(filePath.path!) + } catch { + if path == "/System" { + tempFiles = ["Library"] + } + if path == "/Library" { + tempFiles = ["Preferences"] + } + if path == "/var" { + tempFiles = ["mobile"] + } + if path == "/usr" { + tempFiles = ["lib", "libexec", "bin"] + } + + } + self.files = tempFiles.sort(){$0 < $1} + } + } + } + + var files = [String]() + + override func viewDidLoad() { + if self.path == nil { + let documentsUrl = fileManager.URLsForDirectory(.DocumentDirectory, inDomains: .UserDomainMask)[0] as NSURL + self.path = documentsUrl + } + } + + func numberOfSectionsInTableView(tableView: UITableView) -> Int { + return 1 + } + + func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + return files.count + } + + func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { + let cellIdentifier = "FileCell" + var cell = UITableViewCell(style: .Subtitle, reuseIdentifier: cellIdentifier) + if let reuseCell = tableView.dequeueReusableCellWithIdentifier(cellIdentifier) { + cell = reuseCell + } + guard let path = path else { + return cell + } + let newPath = path.URLByAppendingPathComponent(files[indexPath.row]).path! + var isDirectory: ObjCBool = false + fileManager.fileExistsAtPath(newPath, isDirectory: &isDirectory) + cell.textLabel?.text = files[indexPath.row] + if isDirectory { + cell.imageView?.image = UIImage(named: "Folder") + } + else { + cell.imageView?.image = UIImage(named: "File") + } + return cell + } + + required init?(coder aDecoder: NSCoder) { + super.init(coder: aDecoder) + } + + +} diff --git a/examples/Sample/Sample/ViewController.swift b/examples/Sample/Sample/ViewController.swift deleted file mode 100644 index 41436acecc5ba61997b41bb525ca8bd1b5d13f76..0000000000000000000000000000000000000000 --- a/examples/Sample/Sample/ViewController.swift +++ /dev/null @@ -1,50 +0,0 @@ -// -// ViewController.swift -// Sample -// -// Created by Roy Marmelstein on 13/01/2016. -// Copyright © 2016 Roy Marmelstein. All rights reserved. -// - -import UIKit -import Zip - -class ViewController: UIViewController { - - override func viewDidLoad() { - super.viewDidLoad() - do { - let destinationPath = tempUnzipPath()! - let fileAbsolutePath = NSBundle.mainBundle().pathForResource("master", ofType: "zip") - let fileAbsoluteURL = NSURL(string: fileAbsolutePath!)! - print(destinationPath) - try Zip().quickUnzipFile(fileAbsoluteURL) - try Zip().quickZipFiles([fileAbsoluteURL], fileName: "zipTest") - - } - catch { - print("oops") - } - // Do any additional setup after loading the view, typically from a nib. - } - - override func didReceiveMemoryWarning() { - super.didReceiveMemoryWarning() - // Dispose of any resources that can be recreated. - } - - func tempUnzipPath() -> NSURL? { - var path = NSSearchPathForDirectoriesInDomains(.CachesDirectory, .UserDomainMask, true)[0] - path += "/\(NSUUID().UUIDString)" - let url = NSURL(fileURLWithPath: path) - - do { - try NSFileManager.defaultManager().createDirectoryAtURL(url, withIntermediateDirectories: true, attributes: nil) - } catch { - return nil - } - return url - } - -} - diff --git a/examples/Sample/Sample/master.zip b/examples/Sample/Sample/master.zip deleted file mode 100644 index 96e2d453dd67d621da39661bb46496df30a6db63..0000000000000000000000000000000000000000 Binary files a/examples/Sample/Sample/master.zip and /dev/null differ