├── ELFileManagerDemo.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ ├── easylink.xcuserdatad │ │ └── UserInterfaceState.xcuserstate │ │ └── yuqi.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ ├── easylink.xcuserdatad │ ├── xcdebugger │ │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ │ └── xcschememanagement.plist │ └── yuqi.xcuserdatad │ ├── xcdebugger │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ └── xcschememanagement.plist ├── ELFileManagerDemo ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ ├── Contents.json │ ├── file_avi.imageset │ │ ├── Contents.json │ │ ├── 视频-文件详情@2x.png │ │ └── 视频-文件详情@3x.png │ ├── file_excel.imageset │ │ ├── Contents.json │ │ ├── file_excel@2x.png │ │ └── file_excel@3x.png │ ├── file_floder.imageset │ │ ├── Contents.json │ │ ├── file_floder@2x.png │ │ └── file_floder@3x.png │ ├── file_ipa.imageset │ │ ├── Contents.json │ │ ├── 未知应用-文件详情@2x.png │ │ └── 未知应用-文件详情@3x.png │ ├── file_mp3.imageset │ │ ├── Contents.json │ │ ├── 音乐-文件详情@2x.png │ │ └── 音乐-文件详情@3x.png │ ├── file_pdf.imageset │ │ ├── Contents.json │ │ ├── file_pdf@2x.png │ │ └── file_pdf@3x.png │ ├── file_ppt.imageset │ │ ├── Contents.json │ │ ├── file_ppt@2x.png │ │ └── file_ppt@3x.png │ ├── file_qita.imageset │ │ ├── Contents.json │ │ ├── file_qita@2x.png │ │ └── file_qita@3x.png │ ├── file_txt.imageset │ │ ├── Contents.json │ │ ├── file_txt@2x.png │ │ └── file_txt@3x.png │ ├── file_webView_error.imageset │ │ ├── Contents.json │ │ ├── file_webView_error@2x.png │ │ └── file_webView_error@3x.png │ ├── file_word.imageset │ │ ├── Contents.json │ │ ├── file_word@2x.png │ │ └── file_word@3x.png │ ├── filemanager_cell_selected.imageset │ │ ├── Contents.json │ │ ├── filemanager_cell_selected@2x.png │ │ └── filemanager_cell_selected@3x.png │ └── filemanager_cell_unselected.imageset │ │ ├── Contents.json │ │ ├── filemanager_cell_unselected@2x.png │ │ └── filemanager_cell_unselected@3x.png ├── Base.lproj │ └── LaunchScreen.storyboard ├── ELFileBrowseViewController.h ├── ELFileBrowseViewController.m ├── ELFileDetailViewController.h ├── ELFileDetailViewController.m ├── ELFileManager │ ├── ELFileManager.h │ ├── ELFileManager.m │ ├── ELFileModel.h │ └── ELFileModel.m ├── ELGetAlllFileInDeepSearchViewController.h ├── ELGetAlllFileInDeepSearchViewController.m ├── ELMoreViewController.h ├── ELMoreViewController.m ├── ELUploadFileViewController.h ├── ELUploadFileViewController.m ├── Info.plist ├── MainViewController.h ├── MainViewController.m └── main.m ├── ELFileManagerDemoTests ├── ELFileManagerDemoTests.m └── Info.plist ├── ELFileManagerDemoUITests ├── ELFileManagerDemoUITests.m └── Info.plist └── README.md /ELFileManagerDemo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 48; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | DE6EC0D71F905B68001FFBA3 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = DE6EC0D61F905B68001FFBA3 /* AppDelegate.m */; }; 11 | DE6EC0DF1F905B68001FFBA3 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = DE6EC0DE1F905B68001FFBA3 /* Assets.xcassets */; }; 12 | DE6EC0E21F905B68001FFBA3 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = DE6EC0E01F905B68001FFBA3 /* LaunchScreen.storyboard */; }; 13 | DE6EC0E51F905B68001FFBA3 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = DE6EC0E41F905B68001FFBA3 /* main.m */; }; 14 | DE6EC0EF1F905B68001FFBA3 /* ELFileManagerDemoTests.m in Sources */ = {isa = PBXBuildFile; fileRef = DE6EC0EE1F905B68001FFBA3 /* ELFileManagerDemoTests.m */; }; 15 | DE6EC0FA1F905B68001FFBA3 /* ELFileManagerDemoUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = DE6EC0F91F905B68001FFBA3 /* ELFileManagerDemoUITests.m */; }; 16 | DED1CCA31F905E5300AD8BB5 /* ELFileManager.m in Sources */ = {isa = PBXBuildFile; fileRef = DED1CC9F1F905E4600AD8BB5 /* ELFileManager.m */; }; 17 | DED1CCA41F905E5900AD8BB5 /* ELFileModel.m in Sources */ = {isa = PBXBuildFile; fileRef = DED1CCA11F905E4600AD8BB5 /* ELFileModel.m */; }; 18 | F334C4FC1FC6B45300FFEFD3 /* ELMoreViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = F334C4F71FC6B45200FFEFD3 /* ELMoreViewController.m */; }; 19 | F334C4FD1FC6B45300FFEFD3 /* MainViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = F334C4F81FC6B45200FFEFD3 /* MainViewController.m */; }; 20 | F334C4FE1FC6B45300FFEFD3 /* ELFileDetailViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = F334C4F91FC6B45300FFEFD3 /* ELFileDetailViewController.m */; }; 21 | F334C4FF1FC6B45300FFEFD3 /* ELFileBrowseViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = F334C4FA1FC6B45300FFEFD3 /* ELFileBrowseViewController.m */; }; 22 | F334C5001FC6B45300FFEFD3 /* ELUploadFileViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = F334C4FB1FC6B45300FFEFD3 /* ELUploadFileViewController.m */; }; 23 | F334C50A1FC8117C00FFEFD3 /* ELGetAlllFileInDeepSearchViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = F334C5091FC8117C00FFEFD3 /* ELGetAlllFileInDeepSearchViewController.m */; }; 24 | /* End PBXBuildFile section */ 25 | 26 | /* Begin PBXContainerItemProxy section */ 27 | DE6EC0EB1F905B68001FFBA3 /* PBXContainerItemProxy */ = { 28 | isa = PBXContainerItemProxy; 29 | containerPortal = DE6EC0CA1F905B68001FFBA3 /* Project object */; 30 | proxyType = 1; 31 | remoteGlobalIDString = DE6EC0D11F905B68001FFBA3; 32 | remoteInfo = ELFileManagerDemo; 33 | }; 34 | DE6EC0F61F905B68001FFBA3 /* PBXContainerItemProxy */ = { 35 | isa = PBXContainerItemProxy; 36 | containerPortal = DE6EC0CA1F905B68001FFBA3 /* Project object */; 37 | proxyType = 1; 38 | remoteGlobalIDString = DE6EC0D11F905B68001FFBA3; 39 | remoteInfo = ELFileManagerDemo; 40 | }; 41 | /* End PBXContainerItemProxy section */ 42 | 43 | /* Begin PBXFileReference section */ 44 | DE6EC0D21F905B68001FFBA3 /* ELFileManagerDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ELFileManagerDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 45 | DE6EC0D51F905B68001FFBA3 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 46 | DE6EC0D61F905B68001FFBA3 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 47 | DE6EC0DE1F905B68001FFBA3 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 48 | DE6EC0E11F905B68001FFBA3 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 49 | DE6EC0E31F905B68001FFBA3 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 50 | DE6EC0E41F905B68001FFBA3 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 51 | DE6EC0EA1F905B68001FFBA3 /* ELFileManagerDemoTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ELFileManagerDemoTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 52 | DE6EC0EE1F905B68001FFBA3 /* ELFileManagerDemoTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ELFileManagerDemoTests.m; sourceTree = ""; }; 53 | DE6EC0F01F905B68001FFBA3 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 54 | DE6EC0F51F905B68001FFBA3 /* ELFileManagerDemoUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ELFileManagerDemoUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 55 | DE6EC0F91F905B68001FFBA3 /* ELFileManagerDemoUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ELFileManagerDemoUITests.m; sourceTree = ""; }; 56 | DE6EC0FB1F905B68001FFBA3 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 57 | DED1CC9E1F905E4600AD8BB5 /* ELFileManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ELFileManager.h; sourceTree = ""; }; 58 | DED1CC9F1F905E4600AD8BB5 /* ELFileManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ELFileManager.m; sourceTree = ""; }; 59 | DED1CCA01F905E4600AD8BB5 /* ELFileModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ELFileModel.h; sourceTree = ""; }; 60 | DED1CCA11F905E4600AD8BB5 /* ELFileModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ELFileModel.m; sourceTree = ""; }; 61 | F334C4F21FC6B45200FFEFD3 /* ELMoreViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ELMoreViewController.h; sourceTree = ""; }; 62 | F334C4F31FC6B45200FFEFD3 /* ELUploadFileViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ELUploadFileViewController.h; sourceTree = ""; }; 63 | F334C4F41FC6B45200FFEFD3 /* ELFileDetailViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ELFileDetailViewController.h; sourceTree = ""; }; 64 | F334C4F51FC6B45200FFEFD3 /* ELFileBrowseViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ELFileBrowseViewController.h; sourceTree = ""; }; 65 | F334C4F61FC6B45200FFEFD3 /* MainViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MainViewController.h; sourceTree = ""; }; 66 | F334C4F71FC6B45200FFEFD3 /* ELMoreViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ELMoreViewController.m; sourceTree = ""; }; 67 | F334C4F81FC6B45200FFEFD3 /* MainViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MainViewController.m; sourceTree = ""; }; 68 | F334C4F91FC6B45300FFEFD3 /* ELFileDetailViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ELFileDetailViewController.m; sourceTree = ""; }; 69 | F334C4FA1FC6B45300FFEFD3 /* ELFileBrowseViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ELFileBrowseViewController.m; sourceTree = ""; }; 70 | F334C4FB1FC6B45300FFEFD3 /* ELUploadFileViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ELUploadFileViewController.m; sourceTree = ""; }; 71 | F334C5081FC8117C00FFEFD3 /* ELGetAlllFileInDeepSearchViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ELGetAlllFileInDeepSearchViewController.h; sourceTree = ""; }; 72 | F334C5091FC8117C00FFEFD3 /* ELGetAlllFileInDeepSearchViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ELGetAlllFileInDeepSearchViewController.m; sourceTree = ""; }; 73 | /* End PBXFileReference section */ 74 | 75 | /* Begin PBXFrameworksBuildPhase section */ 76 | DE6EC0CF1F905B68001FFBA3 /* Frameworks */ = { 77 | isa = PBXFrameworksBuildPhase; 78 | buildActionMask = 2147483647; 79 | files = ( 80 | ); 81 | runOnlyForDeploymentPostprocessing = 0; 82 | }; 83 | DE6EC0E71F905B68001FFBA3 /* Frameworks */ = { 84 | isa = PBXFrameworksBuildPhase; 85 | buildActionMask = 2147483647; 86 | files = ( 87 | ); 88 | runOnlyForDeploymentPostprocessing = 0; 89 | }; 90 | DE6EC0F21F905B68001FFBA3 /* Frameworks */ = { 91 | isa = PBXFrameworksBuildPhase; 92 | buildActionMask = 2147483647; 93 | files = ( 94 | ); 95 | runOnlyForDeploymentPostprocessing = 0; 96 | }; 97 | /* End PBXFrameworksBuildPhase section */ 98 | 99 | /* Begin PBXGroup section */ 100 | DE6EC0C91F905B68001FFBA3 = { 101 | isa = PBXGroup; 102 | children = ( 103 | DE6EC0D41F905B68001FFBA3 /* ELFileManagerDemo */, 104 | DE6EC0ED1F905B68001FFBA3 /* ELFileManagerDemoTests */, 105 | DE6EC0F81F905B68001FFBA3 /* ELFileManagerDemoUITests */, 106 | DE6EC0D31F905B68001FFBA3 /* Products */, 107 | ); 108 | sourceTree = ""; 109 | }; 110 | DE6EC0D31F905B68001FFBA3 /* Products */ = { 111 | isa = PBXGroup; 112 | children = ( 113 | DE6EC0D21F905B68001FFBA3 /* ELFileManagerDemo.app */, 114 | DE6EC0EA1F905B68001FFBA3 /* ELFileManagerDemoTests.xctest */, 115 | DE6EC0F51F905B68001FFBA3 /* ELFileManagerDemoUITests.xctest */, 116 | ); 117 | name = Products; 118 | sourceTree = ""; 119 | }; 120 | DE6EC0D41F905B68001FFBA3 /* ELFileManagerDemo */ = { 121 | isa = PBXGroup; 122 | children = ( 123 | DE6EC0D51F905B68001FFBA3 /* AppDelegate.h */, 124 | DE6EC0D61F905B68001FFBA3 /* AppDelegate.m */, 125 | F334C4F61FC6B45200FFEFD3 /* MainViewController.h */, 126 | F334C4F81FC6B45200FFEFD3 /* MainViewController.m */, 127 | F334C4F51FC6B45200FFEFD3 /* ELFileBrowseViewController.h */, 128 | F334C4FA1FC6B45300FFEFD3 /* ELFileBrowseViewController.m */, 129 | F334C4F41FC6B45200FFEFD3 /* ELFileDetailViewController.h */, 130 | F334C4F91FC6B45300FFEFD3 /* ELFileDetailViewController.m */, 131 | F334C4F31FC6B45200FFEFD3 /* ELUploadFileViewController.h */, 132 | F334C4FB1FC6B45300FFEFD3 /* ELUploadFileViewController.m */, 133 | F334C5081FC8117C00FFEFD3 /* ELGetAlllFileInDeepSearchViewController.h */, 134 | F334C5091FC8117C00FFEFD3 /* ELGetAlllFileInDeepSearchViewController.m */, 135 | F334C4F21FC6B45200FFEFD3 /* ELMoreViewController.h */, 136 | F334C4F71FC6B45200FFEFD3 /* ELMoreViewController.m */, 137 | DED1CC9D1F905E4600AD8BB5 /* ELFileManager */, 138 | DE6EC0DE1F905B68001FFBA3 /* Assets.xcassets */, 139 | DE6EC0E01F905B68001FFBA3 /* LaunchScreen.storyboard */, 140 | DE6EC0E31F905B68001FFBA3 /* Info.plist */, 141 | DE6EC0E41F905B68001FFBA3 /* main.m */, 142 | ); 143 | path = ELFileManagerDemo; 144 | sourceTree = ""; 145 | }; 146 | DE6EC0ED1F905B68001FFBA3 /* ELFileManagerDemoTests */ = { 147 | isa = PBXGroup; 148 | children = ( 149 | DE6EC0EE1F905B68001FFBA3 /* ELFileManagerDemoTests.m */, 150 | DE6EC0F01F905B68001FFBA3 /* Info.plist */, 151 | ); 152 | path = ELFileManagerDemoTests; 153 | sourceTree = ""; 154 | }; 155 | DE6EC0F81F905B68001FFBA3 /* ELFileManagerDemoUITests */ = { 156 | isa = PBXGroup; 157 | children = ( 158 | DE6EC0F91F905B68001FFBA3 /* ELFileManagerDemoUITests.m */, 159 | DE6EC0FB1F905B68001FFBA3 /* Info.plist */, 160 | ); 161 | path = ELFileManagerDemoUITests; 162 | sourceTree = ""; 163 | }; 164 | DED1CC9D1F905E4600AD8BB5 /* ELFileManager */ = { 165 | isa = PBXGroup; 166 | children = ( 167 | DED1CC9E1F905E4600AD8BB5 /* ELFileManager.h */, 168 | DED1CC9F1F905E4600AD8BB5 /* ELFileManager.m */, 169 | DED1CCA01F905E4600AD8BB5 /* ELFileModel.h */, 170 | DED1CCA11F905E4600AD8BB5 /* ELFileModel.m */, 171 | ); 172 | path = ELFileManager; 173 | sourceTree = ""; 174 | }; 175 | /* End PBXGroup section */ 176 | 177 | /* Begin PBXNativeTarget section */ 178 | DE6EC0D11F905B68001FFBA3 /* ELFileManagerDemo */ = { 179 | isa = PBXNativeTarget; 180 | buildConfigurationList = DE6EC0FE1F905B68001FFBA3 /* Build configuration list for PBXNativeTarget "ELFileManagerDemo" */; 181 | buildPhases = ( 182 | DE6EC0CE1F905B68001FFBA3 /* Sources */, 183 | DE6EC0CF1F905B68001FFBA3 /* Frameworks */, 184 | DE6EC0D01F905B68001FFBA3 /* Resources */, 185 | ); 186 | buildRules = ( 187 | ); 188 | dependencies = ( 189 | ); 190 | name = ELFileManagerDemo; 191 | productName = ELFileManagerDemo; 192 | productReference = DE6EC0D21F905B68001FFBA3 /* ELFileManagerDemo.app */; 193 | productType = "com.apple.product-type.application"; 194 | }; 195 | DE6EC0E91F905B68001FFBA3 /* ELFileManagerDemoTests */ = { 196 | isa = PBXNativeTarget; 197 | buildConfigurationList = DE6EC1011F905B68001FFBA3 /* Build configuration list for PBXNativeTarget "ELFileManagerDemoTests" */; 198 | buildPhases = ( 199 | DE6EC0E61F905B68001FFBA3 /* Sources */, 200 | DE6EC0E71F905B68001FFBA3 /* Frameworks */, 201 | DE6EC0E81F905B68001FFBA3 /* Resources */, 202 | ); 203 | buildRules = ( 204 | ); 205 | dependencies = ( 206 | DE6EC0EC1F905B68001FFBA3 /* PBXTargetDependency */, 207 | ); 208 | name = ELFileManagerDemoTests; 209 | productName = ELFileManagerDemoTests; 210 | productReference = DE6EC0EA1F905B68001FFBA3 /* ELFileManagerDemoTests.xctest */; 211 | productType = "com.apple.product-type.bundle.unit-test"; 212 | }; 213 | DE6EC0F41F905B68001FFBA3 /* ELFileManagerDemoUITests */ = { 214 | isa = PBXNativeTarget; 215 | buildConfigurationList = DE6EC1041F905B68001FFBA3 /* Build configuration list for PBXNativeTarget "ELFileManagerDemoUITests" */; 216 | buildPhases = ( 217 | DE6EC0F11F905B68001FFBA3 /* Sources */, 218 | DE6EC0F21F905B68001FFBA3 /* Frameworks */, 219 | DE6EC0F31F905B68001FFBA3 /* Resources */, 220 | ); 221 | buildRules = ( 222 | ); 223 | dependencies = ( 224 | DE6EC0F71F905B68001FFBA3 /* PBXTargetDependency */, 225 | ); 226 | name = ELFileManagerDemoUITests; 227 | productName = ELFileManagerDemoUITests; 228 | productReference = DE6EC0F51F905B68001FFBA3 /* ELFileManagerDemoUITests.xctest */; 229 | productType = "com.apple.product-type.bundle.ui-testing"; 230 | }; 231 | /* End PBXNativeTarget section */ 232 | 233 | /* Begin PBXProject section */ 234 | DE6EC0CA1F905B68001FFBA3 /* Project object */ = { 235 | isa = PBXProject; 236 | attributes = { 237 | LastUpgradeCheck = 0900; 238 | ORGANIZATIONNAME = "俞琦"; 239 | TargetAttributes = { 240 | DE6EC0D11F905B68001FFBA3 = { 241 | CreatedOnToolsVersion = 9.0; 242 | ProvisioningStyle = Automatic; 243 | }; 244 | DE6EC0E91F905B68001FFBA3 = { 245 | CreatedOnToolsVersion = 9.0; 246 | ProvisioningStyle = Automatic; 247 | TestTargetID = DE6EC0D11F905B68001FFBA3; 248 | }; 249 | DE6EC0F41F905B68001FFBA3 = { 250 | CreatedOnToolsVersion = 9.0; 251 | ProvisioningStyle = Automatic; 252 | TestTargetID = DE6EC0D11F905B68001FFBA3; 253 | }; 254 | }; 255 | }; 256 | buildConfigurationList = DE6EC0CD1F905B68001FFBA3 /* Build configuration list for PBXProject "ELFileManagerDemo" */; 257 | compatibilityVersion = "Xcode 8.0"; 258 | developmentRegion = en; 259 | hasScannedForEncodings = 0; 260 | knownRegions = ( 261 | en, 262 | Base, 263 | ); 264 | mainGroup = DE6EC0C91F905B68001FFBA3; 265 | productRefGroup = DE6EC0D31F905B68001FFBA3 /* Products */; 266 | projectDirPath = ""; 267 | projectRoot = ""; 268 | targets = ( 269 | DE6EC0D11F905B68001FFBA3 /* ELFileManagerDemo */, 270 | DE6EC0E91F905B68001FFBA3 /* ELFileManagerDemoTests */, 271 | DE6EC0F41F905B68001FFBA3 /* ELFileManagerDemoUITests */, 272 | ); 273 | }; 274 | /* End PBXProject section */ 275 | 276 | /* Begin PBXResourcesBuildPhase section */ 277 | DE6EC0D01F905B68001FFBA3 /* Resources */ = { 278 | isa = PBXResourcesBuildPhase; 279 | buildActionMask = 2147483647; 280 | files = ( 281 | DE6EC0E21F905B68001FFBA3 /* LaunchScreen.storyboard in Resources */, 282 | DE6EC0DF1F905B68001FFBA3 /* Assets.xcassets in Resources */, 283 | ); 284 | runOnlyForDeploymentPostprocessing = 0; 285 | }; 286 | DE6EC0E81F905B68001FFBA3 /* Resources */ = { 287 | isa = PBXResourcesBuildPhase; 288 | buildActionMask = 2147483647; 289 | files = ( 290 | ); 291 | runOnlyForDeploymentPostprocessing = 0; 292 | }; 293 | DE6EC0F31F905B68001FFBA3 /* Resources */ = { 294 | isa = PBXResourcesBuildPhase; 295 | buildActionMask = 2147483647; 296 | files = ( 297 | ); 298 | runOnlyForDeploymentPostprocessing = 0; 299 | }; 300 | /* End PBXResourcesBuildPhase section */ 301 | 302 | /* Begin PBXSourcesBuildPhase section */ 303 | DE6EC0CE1F905B68001FFBA3 /* Sources */ = { 304 | isa = PBXSourcesBuildPhase; 305 | buildActionMask = 2147483647; 306 | files = ( 307 | DED1CCA41F905E5900AD8BB5 /* ELFileModel.m in Sources */, 308 | F334C4FF1FC6B45300FFEFD3 /* ELFileBrowseViewController.m in Sources */, 309 | F334C4FD1FC6B45300FFEFD3 /* MainViewController.m in Sources */, 310 | DED1CCA31F905E5300AD8BB5 /* ELFileManager.m in Sources */, 311 | DE6EC0E51F905B68001FFBA3 /* main.m in Sources */, 312 | DE6EC0D71F905B68001FFBA3 /* AppDelegate.m in Sources */, 313 | F334C50A1FC8117C00FFEFD3 /* ELGetAlllFileInDeepSearchViewController.m in Sources */, 314 | F334C4FE1FC6B45300FFEFD3 /* ELFileDetailViewController.m in Sources */, 315 | F334C4FC1FC6B45300FFEFD3 /* ELMoreViewController.m in Sources */, 316 | F334C5001FC6B45300FFEFD3 /* ELUploadFileViewController.m in Sources */, 317 | ); 318 | runOnlyForDeploymentPostprocessing = 0; 319 | }; 320 | DE6EC0E61F905B68001FFBA3 /* Sources */ = { 321 | isa = PBXSourcesBuildPhase; 322 | buildActionMask = 2147483647; 323 | files = ( 324 | DE6EC0EF1F905B68001FFBA3 /* ELFileManagerDemoTests.m in Sources */, 325 | ); 326 | runOnlyForDeploymentPostprocessing = 0; 327 | }; 328 | DE6EC0F11F905B68001FFBA3 /* Sources */ = { 329 | isa = PBXSourcesBuildPhase; 330 | buildActionMask = 2147483647; 331 | files = ( 332 | DE6EC0FA1F905B68001FFBA3 /* ELFileManagerDemoUITests.m in Sources */, 333 | ); 334 | runOnlyForDeploymentPostprocessing = 0; 335 | }; 336 | /* End PBXSourcesBuildPhase section */ 337 | 338 | /* Begin PBXTargetDependency section */ 339 | DE6EC0EC1F905B68001FFBA3 /* PBXTargetDependency */ = { 340 | isa = PBXTargetDependency; 341 | target = DE6EC0D11F905B68001FFBA3 /* ELFileManagerDemo */; 342 | targetProxy = DE6EC0EB1F905B68001FFBA3 /* PBXContainerItemProxy */; 343 | }; 344 | DE6EC0F71F905B68001FFBA3 /* PBXTargetDependency */ = { 345 | isa = PBXTargetDependency; 346 | target = DE6EC0D11F905B68001FFBA3 /* ELFileManagerDemo */; 347 | targetProxy = DE6EC0F61F905B68001FFBA3 /* PBXContainerItemProxy */; 348 | }; 349 | /* End PBXTargetDependency section */ 350 | 351 | /* Begin PBXVariantGroup section */ 352 | DE6EC0E01F905B68001FFBA3 /* LaunchScreen.storyboard */ = { 353 | isa = PBXVariantGroup; 354 | children = ( 355 | DE6EC0E11F905B68001FFBA3 /* Base */, 356 | ); 357 | name = LaunchScreen.storyboard; 358 | sourceTree = ""; 359 | }; 360 | /* End PBXVariantGroup section */ 361 | 362 | /* Begin XCBuildConfiguration section */ 363 | DE6EC0FC1F905B68001FFBA3 /* Debug */ = { 364 | isa = XCBuildConfiguration; 365 | buildSettings = { 366 | ALWAYS_SEARCH_USER_PATHS = NO; 367 | CLANG_ANALYZER_NONNULL = YES; 368 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 369 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 370 | CLANG_CXX_LIBRARY = "libc++"; 371 | CLANG_ENABLE_MODULES = YES; 372 | CLANG_ENABLE_OBJC_ARC = YES; 373 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 374 | CLANG_WARN_BOOL_CONVERSION = YES; 375 | CLANG_WARN_COMMA = YES; 376 | CLANG_WARN_CONSTANT_CONVERSION = YES; 377 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 378 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 379 | CLANG_WARN_EMPTY_BODY = YES; 380 | CLANG_WARN_ENUM_CONVERSION = YES; 381 | CLANG_WARN_INFINITE_RECURSION = YES; 382 | CLANG_WARN_INT_CONVERSION = YES; 383 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 384 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 385 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 386 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 387 | CLANG_WARN_STRICT_PROTOTYPES = YES; 388 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 389 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 390 | CLANG_WARN_UNREACHABLE_CODE = YES; 391 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 392 | CODE_SIGN_IDENTITY = "iPhone Developer"; 393 | COPY_PHASE_STRIP = NO; 394 | DEBUG_INFORMATION_FORMAT = dwarf; 395 | ENABLE_STRICT_OBJC_MSGSEND = YES; 396 | ENABLE_TESTABILITY = YES; 397 | GCC_C_LANGUAGE_STANDARD = gnu11; 398 | GCC_DYNAMIC_NO_PIC = NO; 399 | GCC_NO_COMMON_BLOCKS = YES; 400 | GCC_OPTIMIZATION_LEVEL = 0; 401 | GCC_PREPROCESSOR_DEFINITIONS = ( 402 | "DEBUG=1", 403 | "$(inherited)", 404 | ); 405 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 406 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 407 | GCC_WARN_UNDECLARED_SELECTOR = YES; 408 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 409 | GCC_WARN_UNUSED_FUNCTION = YES; 410 | GCC_WARN_UNUSED_VARIABLE = YES; 411 | IPHONEOS_DEPLOYMENT_TARGET = 11.0; 412 | MTL_ENABLE_DEBUG_INFO = YES; 413 | ONLY_ACTIVE_ARCH = YES; 414 | SDKROOT = iphoneos; 415 | }; 416 | name = Debug; 417 | }; 418 | DE6EC0FD1F905B68001FFBA3 /* Release */ = { 419 | isa = XCBuildConfiguration; 420 | buildSettings = { 421 | ALWAYS_SEARCH_USER_PATHS = NO; 422 | CLANG_ANALYZER_NONNULL = YES; 423 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 424 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 425 | CLANG_CXX_LIBRARY = "libc++"; 426 | CLANG_ENABLE_MODULES = YES; 427 | CLANG_ENABLE_OBJC_ARC = YES; 428 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 429 | CLANG_WARN_BOOL_CONVERSION = YES; 430 | CLANG_WARN_COMMA = YES; 431 | CLANG_WARN_CONSTANT_CONVERSION = YES; 432 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 433 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 434 | CLANG_WARN_EMPTY_BODY = YES; 435 | CLANG_WARN_ENUM_CONVERSION = YES; 436 | CLANG_WARN_INFINITE_RECURSION = YES; 437 | CLANG_WARN_INT_CONVERSION = YES; 438 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 439 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 440 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 441 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 442 | CLANG_WARN_STRICT_PROTOTYPES = YES; 443 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 444 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 445 | CLANG_WARN_UNREACHABLE_CODE = YES; 446 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 447 | CODE_SIGN_IDENTITY = "iPhone Developer"; 448 | COPY_PHASE_STRIP = NO; 449 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 450 | ENABLE_NS_ASSERTIONS = NO; 451 | ENABLE_STRICT_OBJC_MSGSEND = YES; 452 | GCC_C_LANGUAGE_STANDARD = gnu11; 453 | GCC_NO_COMMON_BLOCKS = YES; 454 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 455 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 456 | GCC_WARN_UNDECLARED_SELECTOR = YES; 457 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 458 | GCC_WARN_UNUSED_FUNCTION = YES; 459 | GCC_WARN_UNUSED_VARIABLE = YES; 460 | IPHONEOS_DEPLOYMENT_TARGET = 11.0; 461 | MTL_ENABLE_DEBUG_INFO = NO; 462 | SDKROOT = iphoneos; 463 | VALIDATE_PRODUCT = YES; 464 | }; 465 | name = Release; 466 | }; 467 | DE6EC0FF1F905B68001FFBA3 /* Debug */ = { 468 | isa = XCBuildConfiguration; 469 | buildSettings = { 470 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 471 | CODE_SIGN_STYLE = Automatic; 472 | DEVELOPMENT_TEAM = E7HPM4L27W; 473 | INFOPLIST_FILE = ELFileManagerDemo/Info.plist; 474 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 475 | PRODUCT_BUNDLE_IDENTIFIER = com.YuQi.ELFileManagerDemo; 476 | PRODUCT_NAME = "$(TARGET_NAME)"; 477 | TARGETED_DEVICE_FAMILY = "1,2"; 478 | }; 479 | name = Debug; 480 | }; 481 | DE6EC1001F905B68001FFBA3 /* Release */ = { 482 | isa = XCBuildConfiguration; 483 | buildSettings = { 484 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 485 | CODE_SIGN_STYLE = Automatic; 486 | DEVELOPMENT_TEAM = E7HPM4L27W; 487 | INFOPLIST_FILE = ELFileManagerDemo/Info.plist; 488 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 489 | PRODUCT_BUNDLE_IDENTIFIER = com.YuQi.ELFileManagerDemo; 490 | PRODUCT_NAME = "$(TARGET_NAME)"; 491 | TARGETED_DEVICE_FAMILY = "1,2"; 492 | }; 493 | name = Release; 494 | }; 495 | DE6EC1021F905B68001FFBA3 /* Debug */ = { 496 | isa = XCBuildConfiguration; 497 | buildSettings = { 498 | BUNDLE_LOADER = "$(TEST_HOST)"; 499 | CODE_SIGN_STYLE = Automatic; 500 | DEVELOPMENT_TEAM = E7HPM4L27W; 501 | INFOPLIST_FILE = ELFileManagerDemoTests/Info.plist; 502 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 503 | PRODUCT_BUNDLE_IDENTIFIER = com.YuQi.ELFileManagerDemoTests; 504 | PRODUCT_NAME = "$(TARGET_NAME)"; 505 | TARGETED_DEVICE_FAMILY = "1,2"; 506 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/ELFileManagerDemo.app/ELFileManagerDemo"; 507 | }; 508 | name = Debug; 509 | }; 510 | DE6EC1031F905B68001FFBA3 /* Release */ = { 511 | isa = XCBuildConfiguration; 512 | buildSettings = { 513 | BUNDLE_LOADER = "$(TEST_HOST)"; 514 | CODE_SIGN_STYLE = Automatic; 515 | DEVELOPMENT_TEAM = E7HPM4L27W; 516 | INFOPLIST_FILE = ELFileManagerDemoTests/Info.plist; 517 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 518 | PRODUCT_BUNDLE_IDENTIFIER = com.YuQi.ELFileManagerDemoTests; 519 | PRODUCT_NAME = "$(TARGET_NAME)"; 520 | TARGETED_DEVICE_FAMILY = "1,2"; 521 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/ELFileManagerDemo.app/ELFileManagerDemo"; 522 | }; 523 | name = Release; 524 | }; 525 | DE6EC1051F905B68001FFBA3 /* Debug */ = { 526 | isa = XCBuildConfiguration; 527 | buildSettings = { 528 | CODE_SIGN_STYLE = Automatic; 529 | DEVELOPMENT_TEAM = E7HPM4L27W; 530 | INFOPLIST_FILE = ELFileManagerDemoUITests/Info.plist; 531 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 532 | PRODUCT_BUNDLE_IDENTIFIER = com.YuQi.ELFileManagerDemoUITests; 533 | PRODUCT_NAME = "$(TARGET_NAME)"; 534 | TARGETED_DEVICE_FAMILY = "1,2"; 535 | TEST_TARGET_NAME = ELFileManagerDemo; 536 | }; 537 | name = Debug; 538 | }; 539 | DE6EC1061F905B68001FFBA3 /* Release */ = { 540 | isa = XCBuildConfiguration; 541 | buildSettings = { 542 | CODE_SIGN_STYLE = Automatic; 543 | DEVELOPMENT_TEAM = E7HPM4L27W; 544 | INFOPLIST_FILE = ELFileManagerDemoUITests/Info.plist; 545 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 546 | PRODUCT_BUNDLE_IDENTIFIER = com.YuQi.ELFileManagerDemoUITests; 547 | PRODUCT_NAME = "$(TARGET_NAME)"; 548 | TARGETED_DEVICE_FAMILY = "1,2"; 549 | TEST_TARGET_NAME = ELFileManagerDemo; 550 | }; 551 | name = Release; 552 | }; 553 | /* End XCBuildConfiguration section */ 554 | 555 | /* Begin XCConfigurationList section */ 556 | DE6EC0CD1F905B68001FFBA3 /* Build configuration list for PBXProject "ELFileManagerDemo" */ = { 557 | isa = XCConfigurationList; 558 | buildConfigurations = ( 559 | DE6EC0FC1F905B68001FFBA3 /* Debug */, 560 | DE6EC0FD1F905B68001FFBA3 /* Release */, 561 | ); 562 | defaultConfigurationIsVisible = 0; 563 | defaultConfigurationName = Release; 564 | }; 565 | DE6EC0FE1F905B68001FFBA3 /* Build configuration list for PBXNativeTarget "ELFileManagerDemo" */ = { 566 | isa = XCConfigurationList; 567 | buildConfigurations = ( 568 | DE6EC0FF1F905B68001FFBA3 /* Debug */, 569 | DE6EC1001F905B68001FFBA3 /* Release */, 570 | ); 571 | defaultConfigurationIsVisible = 0; 572 | defaultConfigurationName = Release; 573 | }; 574 | DE6EC1011F905B68001FFBA3 /* Build configuration list for PBXNativeTarget "ELFileManagerDemoTests" */ = { 575 | isa = XCConfigurationList; 576 | buildConfigurations = ( 577 | DE6EC1021F905B68001FFBA3 /* Debug */, 578 | DE6EC1031F905B68001FFBA3 /* Release */, 579 | ); 580 | defaultConfigurationIsVisible = 0; 581 | defaultConfigurationName = Release; 582 | }; 583 | DE6EC1041F905B68001FFBA3 /* Build configuration list for PBXNativeTarget "ELFileManagerDemoUITests" */ = { 584 | isa = XCConfigurationList; 585 | buildConfigurations = ( 586 | DE6EC1051F905B68001FFBA3 /* Debug */, 587 | DE6EC1061F905B68001FFBA3 /* Release */, 588 | ); 589 | defaultConfigurationIsVisible = 0; 590 | defaultConfigurationName = Release; 591 | }; 592 | /* End XCConfigurationList section */ 593 | }; 594 | rootObject = DE6EC0CA1F905B68001FFBA3 /* Project object */; 595 | } 596 | -------------------------------------------------------------------------------- /ELFileManagerDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ELFileManagerDemo.xcodeproj/project.xcworkspace/xcuserdata/easylink.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JabberYQ/ELFileManager/0dba00ab5914ade278098bcbb6c1383757920208/ELFileManagerDemo.xcodeproj/project.xcworkspace/xcuserdata/easylink.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /ELFileManagerDemo.xcodeproj/project.xcworkspace/xcuserdata/yuqi.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JabberYQ/ELFileManager/0dba00ab5914ade278098bcbb6c1383757920208/ELFileManagerDemo.xcodeproj/project.xcworkspace/xcuserdata/yuqi.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /ELFileManagerDemo.xcodeproj/xcuserdata/easylink.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /ELFileManagerDemo.xcodeproj/xcuserdata/easylink.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | ELFileManagerDemo.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /ELFileManagerDemo.xcodeproj/xcuserdata/yuqi.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /ELFileManagerDemo.xcodeproj/xcuserdata/yuqi.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | ELFileManagerDemo.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /ELFileManagerDemo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // ELFileManagerDemo 4 | // 5 | // Created by 俞琦 on 2017/10/13. 6 | // Copyright © 2017年 俞琦. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /ELFileManagerDemo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // ELFileManagerDemo 4 | // 5 | // Created by 俞琦 on 2017/10/13. 6 | // Copyright © 2017年 俞琦. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | #import "MainViewController.h" 11 | 12 | @interface AppDelegate () 13 | 14 | @end 15 | 16 | @implementation AppDelegate 17 | 18 | 19 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 20 | self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; 21 | self.window.backgroundColor = [UIColor grayColor]; 22 | self.window.rootViewController = [[UINavigationController alloc] initWithRootViewController:[[MainViewController alloc] init]]; 23 | [self.window makeKeyAndVisible]; 24 | return YES; 25 | } 26 | 27 | 28 | - (void)applicationWillResignActive:(UIApplication *)application { 29 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 30 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 31 | } 32 | 33 | 34 | - (void)applicationDidEnterBackground:(UIApplication *)application { 35 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 36 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 37 | } 38 | 39 | 40 | - (void)applicationWillEnterForeground:(UIApplication *)application { 41 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 42 | } 43 | 44 | 45 | - (void)applicationDidBecomeActive:(UIApplication *)application { 46 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 47 | } 48 | 49 | 50 | - (void)applicationWillTerminate:(UIApplication *)application { 51 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 52 | } 53 | 54 | 55 | @end 56 | -------------------------------------------------------------------------------- /ELFileManagerDemo/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /ELFileManagerDemo/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /ELFileManagerDemo/Assets.xcassets/file_avi.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "视频-文件详情@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "视频-文件详情@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /ELFileManagerDemo/Assets.xcassets/file_avi.imageset/视频-文件详情@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JabberYQ/ELFileManager/0dba00ab5914ade278098bcbb6c1383757920208/ELFileManagerDemo/Assets.xcassets/file_avi.imageset/视频-文件详情@2x.png -------------------------------------------------------------------------------- /ELFileManagerDemo/Assets.xcassets/file_avi.imageset/视频-文件详情@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JabberYQ/ELFileManager/0dba00ab5914ade278098bcbb6c1383757920208/ELFileManagerDemo/Assets.xcassets/file_avi.imageset/视频-文件详情@3x.png -------------------------------------------------------------------------------- /ELFileManagerDemo/Assets.xcassets/file_excel.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "file_excel@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "file_excel@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /ELFileManagerDemo/Assets.xcassets/file_excel.imageset/file_excel@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JabberYQ/ELFileManager/0dba00ab5914ade278098bcbb6c1383757920208/ELFileManagerDemo/Assets.xcassets/file_excel.imageset/file_excel@2x.png -------------------------------------------------------------------------------- /ELFileManagerDemo/Assets.xcassets/file_excel.imageset/file_excel@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JabberYQ/ELFileManager/0dba00ab5914ade278098bcbb6c1383757920208/ELFileManagerDemo/Assets.xcassets/file_excel.imageset/file_excel@3x.png -------------------------------------------------------------------------------- /ELFileManagerDemo/Assets.xcassets/file_floder.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "file_floder@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "file_floder@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /ELFileManagerDemo/Assets.xcassets/file_floder.imageset/file_floder@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JabberYQ/ELFileManager/0dba00ab5914ade278098bcbb6c1383757920208/ELFileManagerDemo/Assets.xcassets/file_floder.imageset/file_floder@2x.png -------------------------------------------------------------------------------- /ELFileManagerDemo/Assets.xcassets/file_floder.imageset/file_floder@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JabberYQ/ELFileManager/0dba00ab5914ade278098bcbb6c1383757920208/ELFileManagerDemo/Assets.xcassets/file_floder.imageset/file_floder@3x.png -------------------------------------------------------------------------------- /ELFileManagerDemo/Assets.xcassets/file_ipa.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "未知应用-文件详情@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "未知应用-文件详情@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /ELFileManagerDemo/Assets.xcassets/file_ipa.imageset/未知应用-文件详情@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JabberYQ/ELFileManager/0dba00ab5914ade278098bcbb6c1383757920208/ELFileManagerDemo/Assets.xcassets/file_ipa.imageset/未知应用-文件详情@2x.png -------------------------------------------------------------------------------- /ELFileManagerDemo/Assets.xcassets/file_ipa.imageset/未知应用-文件详情@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JabberYQ/ELFileManager/0dba00ab5914ade278098bcbb6c1383757920208/ELFileManagerDemo/Assets.xcassets/file_ipa.imageset/未知应用-文件详情@3x.png -------------------------------------------------------------------------------- /ELFileManagerDemo/Assets.xcassets/file_mp3.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "音乐-文件详情@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "音乐-文件详情@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /ELFileManagerDemo/Assets.xcassets/file_mp3.imageset/音乐-文件详情@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JabberYQ/ELFileManager/0dba00ab5914ade278098bcbb6c1383757920208/ELFileManagerDemo/Assets.xcassets/file_mp3.imageset/音乐-文件详情@2x.png -------------------------------------------------------------------------------- /ELFileManagerDemo/Assets.xcassets/file_mp3.imageset/音乐-文件详情@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JabberYQ/ELFileManager/0dba00ab5914ade278098bcbb6c1383757920208/ELFileManagerDemo/Assets.xcassets/file_mp3.imageset/音乐-文件详情@3x.png -------------------------------------------------------------------------------- /ELFileManagerDemo/Assets.xcassets/file_pdf.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "file_pdf@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "file_pdf@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /ELFileManagerDemo/Assets.xcassets/file_pdf.imageset/file_pdf@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JabberYQ/ELFileManager/0dba00ab5914ade278098bcbb6c1383757920208/ELFileManagerDemo/Assets.xcassets/file_pdf.imageset/file_pdf@2x.png -------------------------------------------------------------------------------- /ELFileManagerDemo/Assets.xcassets/file_pdf.imageset/file_pdf@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JabberYQ/ELFileManager/0dba00ab5914ade278098bcbb6c1383757920208/ELFileManagerDemo/Assets.xcassets/file_pdf.imageset/file_pdf@3x.png -------------------------------------------------------------------------------- /ELFileManagerDemo/Assets.xcassets/file_ppt.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "file_ppt@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "file_ppt@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /ELFileManagerDemo/Assets.xcassets/file_ppt.imageset/file_ppt@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JabberYQ/ELFileManager/0dba00ab5914ade278098bcbb6c1383757920208/ELFileManagerDemo/Assets.xcassets/file_ppt.imageset/file_ppt@2x.png -------------------------------------------------------------------------------- /ELFileManagerDemo/Assets.xcassets/file_ppt.imageset/file_ppt@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JabberYQ/ELFileManager/0dba00ab5914ade278098bcbb6c1383757920208/ELFileManagerDemo/Assets.xcassets/file_ppt.imageset/file_ppt@3x.png -------------------------------------------------------------------------------- /ELFileManagerDemo/Assets.xcassets/file_qita.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "file_qita@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "file_qita@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /ELFileManagerDemo/Assets.xcassets/file_qita.imageset/file_qita@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JabberYQ/ELFileManager/0dba00ab5914ade278098bcbb6c1383757920208/ELFileManagerDemo/Assets.xcassets/file_qita.imageset/file_qita@2x.png -------------------------------------------------------------------------------- /ELFileManagerDemo/Assets.xcassets/file_qita.imageset/file_qita@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JabberYQ/ELFileManager/0dba00ab5914ade278098bcbb6c1383757920208/ELFileManagerDemo/Assets.xcassets/file_qita.imageset/file_qita@3x.png -------------------------------------------------------------------------------- /ELFileManagerDemo/Assets.xcassets/file_txt.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "file_txt@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "file_txt@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /ELFileManagerDemo/Assets.xcassets/file_txt.imageset/file_txt@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JabberYQ/ELFileManager/0dba00ab5914ade278098bcbb6c1383757920208/ELFileManagerDemo/Assets.xcassets/file_txt.imageset/file_txt@2x.png -------------------------------------------------------------------------------- /ELFileManagerDemo/Assets.xcassets/file_txt.imageset/file_txt@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JabberYQ/ELFileManager/0dba00ab5914ade278098bcbb6c1383757920208/ELFileManagerDemo/Assets.xcassets/file_txt.imageset/file_txt@3x.png -------------------------------------------------------------------------------- /ELFileManagerDemo/Assets.xcassets/file_webView_error.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "file_webView_error@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "file_webView_error@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /ELFileManagerDemo/Assets.xcassets/file_webView_error.imageset/file_webView_error@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JabberYQ/ELFileManager/0dba00ab5914ade278098bcbb6c1383757920208/ELFileManagerDemo/Assets.xcassets/file_webView_error.imageset/file_webView_error@2x.png -------------------------------------------------------------------------------- /ELFileManagerDemo/Assets.xcassets/file_webView_error.imageset/file_webView_error@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JabberYQ/ELFileManager/0dba00ab5914ade278098bcbb6c1383757920208/ELFileManagerDemo/Assets.xcassets/file_webView_error.imageset/file_webView_error@3x.png -------------------------------------------------------------------------------- /ELFileManagerDemo/Assets.xcassets/file_word.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "file_word@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "file_word@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /ELFileManagerDemo/Assets.xcassets/file_word.imageset/file_word@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JabberYQ/ELFileManager/0dba00ab5914ade278098bcbb6c1383757920208/ELFileManagerDemo/Assets.xcassets/file_word.imageset/file_word@2x.png -------------------------------------------------------------------------------- /ELFileManagerDemo/Assets.xcassets/file_word.imageset/file_word@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JabberYQ/ELFileManager/0dba00ab5914ade278098bcbb6c1383757920208/ELFileManagerDemo/Assets.xcassets/file_word.imageset/file_word@3x.png -------------------------------------------------------------------------------- /ELFileManagerDemo/Assets.xcassets/filemanager_cell_selected.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "filemanager_cell_selected@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "filemanager_cell_selected@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /ELFileManagerDemo/Assets.xcassets/filemanager_cell_selected.imageset/filemanager_cell_selected@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JabberYQ/ELFileManager/0dba00ab5914ade278098bcbb6c1383757920208/ELFileManagerDemo/Assets.xcassets/filemanager_cell_selected.imageset/filemanager_cell_selected@2x.png -------------------------------------------------------------------------------- /ELFileManagerDemo/Assets.xcassets/filemanager_cell_selected.imageset/filemanager_cell_selected@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JabberYQ/ELFileManager/0dba00ab5914ade278098bcbb6c1383757920208/ELFileManagerDemo/Assets.xcassets/filemanager_cell_selected.imageset/filemanager_cell_selected@3x.png -------------------------------------------------------------------------------- /ELFileManagerDemo/Assets.xcassets/filemanager_cell_unselected.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "filemanager_cell_unselected@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "filemanager_cell_unselected@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /ELFileManagerDemo/Assets.xcassets/filemanager_cell_unselected.imageset/filemanager_cell_unselected@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JabberYQ/ELFileManager/0dba00ab5914ade278098bcbb6c1383757920208/ELFileManagerDemo/Assets.xcassets/filemanager_cell_unselected.imageset/filemanager_cell_unselected@2x.png -------------------------------------------------------------------------------- /ELFileManagerDemo/Assets.xcassets/filemanager_cell_unselected.imageset/filemanager_cell_unselected@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JabberYQ/ELFileManager/0dba00ab5914ade278098bcbb6c1383757920208/ELFileManagerDemo/Assets.xcassets/filemanager_cell_unselected.imageset/filemanager_cell_unselected@3x.png -------------------------------------------------------------------------------- /ELFileManagerDemo/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /ELFileManagerDemo/ELFileBrowseViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ELFileBrowseViewController.h 3 | // ELMoblieProject 4 | // 5 | // Created by easylink on 2017/11/20. 6 | // Copyright © 2017年 俞琦. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ELFileBrowseViewController : UIViewController 12 | - (instancetype)initWithPath:(NSString *)path; 13 | @end 14 | -------------------------------------------------------------------------------- /ELFileManagerDemo/ELFileBrowseViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ELFileBrowseViewController.m 3 | // ELMoblieProject 4 | // 5 | // Created by easylink on 2017/11/20. 6 | // Copyright © 2017年 俞琦. All rights reserved. 7 | // 8 | 9 | #import "ELFileBrowseViewController.h" 10 | #import "ELFileManager.h" 11 | #import "ELFileModel.h" 12 | #import "ELFileDetailViewController.h" 13 | 14 | @interface ELFileBrowseViewController () 15 | @property (nonatomic, strong) ELFileManager * fileManager; 16 | @property (nonatomic, weak) UITableView * tableView; 17 | @property (nonatomic, copy) NSString * homePath; 18 | @property (nonatomic, strong) NSMutableArray *files; 19 | @end 20 | 21 | @implementation ELFileBrowseViewController 22 | 23 | - (instancetype)initWithPath:(NSString *)path 24 | { 25 | if (self = [super init]) { 26 | self.homePath = path; 27 | } 28 | return self; 29 | } 30 | 31 | - (void)viewDidLoad 32 | { 33 | [super viewDidLoad]; 34 | 35 | if (![self.fileManager fileExistsAtPath:self.homePath]) { 36 | [self.fileManager createFolderToFullPath:self.homePath]; 37 | } 38 | ELFileModel *floder = [self.fileManager getFileWithPath:self.homePath]; 39 | self.title = floder.name; 40 | 41 | [self initViews]; 42 | } 43 | 44 | - (void)initViews 45 | { 46 | UITableView *tv = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStyleGrouped]; 47 | tv.delegate = self; 48 | tv.dataSource = self; 49 | [self.view addSubview:tv]; 50 | self.tableView = tv; 51 | } 52 | 53 | #pragma mark - UITableViewDelegate, UITableViewDataSource 54 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 55 | { 56 | return self.files.count; 57 | } 58 | 59 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 60 | { 61 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"]; 62 | if (!cell) { 63 | cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"cell"]; 64 | } 65 | ELFileModel *file = self.files[indexPath.row]; 66 | cell.textLabel.text = file.name; 67 | cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; 68 | UIImage *cellImage; 69 | if (file.fileType == ELFileTypeDirectory) { // 文件夹 70 | cell.detailTextLabel.text = [NSString stringWithFormat:@"文件夹: %@ %@", file.creatTime, file.fileSize]; 71 | cellImage = [UIImage imageNamed:@"file_floder"]; 72 | } else { 73 | 74 | switch (file.fileType) { 75 | case ELFileTypeImage: 76 | { 77 | cell.detailTextLabel.text = [NSString stringWithFormat:@"图片: %@ %@", file.creatTime, file.fileSize]; 78 | cellImage = [UIImage imageWithContentsOfFile:file.filePath]; 79 | } 80 | break; 81 | case ELFileTypeTxt: 82 | { 83 | cell.detailTextLabel.text = [NSString stringWithFormat:@"文档: %@ %@", file.creatTime, file.fileSize]; 84 | cellImage = [UIImage imageNamed:@"file_txt"]; 85 | } 86 | break; 87 | case ELFileTypeVoice: 88 | { 89 | cell.detailTextLabel.text = [NSString stringWithFormat:@"音乐: %@ %@", file.creatTime, file.fileSize]; 90 | cellImage = [UIImage imageNamed:@"file_mp3"]; 91 | } 92 | break; 93 | case ELFileTypeAudioVidio: 94 | { 95 | cell.detailTextLabel.text = [NSString stringWithFormat:@"视频: %@ %@", file.creatTime, file.fileSize]; 96 | cellImage = [UIImage imageNamed:@"file_avi"]; 97 | } 98 | break; 99 | case ELFileTypeApplication: 100 | { 101 | cell.detailTextLabel.text = [NSString stringWithFormat:@"应用: %@ %@", file.creatTime, file.fileSize]; 102 | cellImage = [UIImage imageNamed:@"file_ipa"]; 103 | } 104 | break; 105 | case ELFileTypeUnknown: 106 | { 107 | cell.detailTextLabel.text = [NSString stringWithFormat:@"未知文件: %@ %@", file.creatTime, file.fileSize]; 108 | cellImage = [UIImage imageNamed:@"file_webView_error"]; 109 | } 110 | break; 111 | case ELFileTypeWord: 112 | { 113 | cell.detailTextLabel.text = [NSString stringWithFormat:@"word: %@ %@", file.creatTime, file.fileSize]; 114 | cellImage = [UIImage imageNamed:@"file_word"]; 115 | } 116 | break; 117 | case ELFileTypePDF: 118 | { 119 | cell.detailTextLabel.text = [NSString stringWithFormat:@"pdf: %@ %@", file.creatTime, file.fileSize]; 120 | cellImage = [UIImage imageNamed:@"file_pdf"]; 121 | } 122 | break; 123 | case ELFileTypePPT: 124 | { 125 | cell.detailTextLabel.text = [NSString stringWithFormat:@"ppt: %@ %@", file.creatTime, file.fileSize]; 126 | cellImage = [UIImage imageNamed:@"file_ppt"]; 127 | } 128 | break; 129 | case ELFileTypeXLS: 130 | { 131 | cell.detailTextLabel.text = [NSString stringWithFormat:@"xls: %@ %@", file.creatTime, file.fileSize]; 132 | cellImage = [UIImage imageNamed:@"file_excel"]; 133 | } 134 | break; 135 | default: 136 | break; 137 | } 138 | 139 | } 140 | 141 | // 设置cell图片大小 142 | CGSize imageSize = CGSizeMake(40, 40); 143 | UIGraphicsBeginImageContextWithOptions(imageSize, NO, 0.0); 144 | CGRect imageRect = CGRectMake(0.0, 0.0, imageSize.width, imageSize.height); 145 | [cellImage drawInRect:imageRect]; 146 | cell.imageView.image = UIGraphicsGetImageFromCurrentImageContext(); 147 | UIGraphicsEndImageContext(); 148 | 149 | return cell; 150 | } 151 | 152 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 153 | { 154 | ELFileModel *file = self.files[indexPath.row]; 155 | if (file.fileType == ELFileTypeDirectory) { // 文件夹 156 | ELFileBrowseViewController *vc = [[ELFileBrowseViewController alloc] initWithPath:file.filePath]; 157 | [self.navigationController pushViewController:vc animated:YES]; 158 | } else { 159 | ELFileDetailViewController *fileDetail = [[ELFileDetailViewController alloc] initWithFileModel:file]; 160 | [self.navigationController pushViewController:fileDetail animated:YES]; 161 | } 162 | 163 | } 164 | 165 | - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath 166 | { 167 | return 50; 168 | } 169 | 170 | - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section 171 | { 172 | return [[UIView alloc] init]; 173 | } 174 | 175 | - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section 176 | { 177 | return 0.01; 178 | } 179 | 180 | - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section 181 | { 182 | return [[UIView alloc] init]; 183 | } 184 | 185 | - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section 186 | { 187 | return 0.01; 188 | } 189 | 190 | 191 | #pragma mark - lazy 192 | - (ELFileManager *)fileManager 193 | { 194 | if (!_fileManager) { 195 | _fileManager = [ELFileManager shareManager]; 196 | } 197 | return _fileManager; 198 | } 199 | 200 | - (NSMutableArray *)files 201 | { 202 | if (!_files) { 203 | _files = [NSMutableArray arrayWithArray:[self.fileManager getAllFileWithPath:self.homePath]]; 204 | } 205 | return _files; 206 | } 207 | @end 208 | -------------------------------------------------------------------------------- /ELFileManagerDemo/ELFileDetailViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ELFileDetailViewController.h 3 | // FileManagerDemo 4 | // 5 | // Created by easylink on 2017/11/17. 6 | // Copyright © 2017年 YuQi. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @class ELFileModel; 12 | 13 | @interface ELFileDetailViewController : UIViewController 14 | - (instancetype)initWithFileModel:(ELFileModel *)file; 15 | @end 16 | -------------------------------------------------------------------------------- /ELFileManagerDemo/ELFileDetailViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ELFileDetailViewController.m 3 | // FileManagerDemo 4 | // 5 | // Created by easylink on 2017/11/17. 6 | // Copyright © 2017年 YuQi. All rights reserved. 7 | // 8 | 9 | #import "ELFileDetailViewController.h" 10 | #import "ELFileModel.h" 11 | #import 12 | 13 | @interface ELFileDetailViewController () 14 | @property (nonatomic, strong) ELFileModel * file; 15 | @property (nonatomic, strong) UIDocumentInteractionController * documentInteraction; 16 | @property (nonatomic, weak) UIWebView * webView; 17 | @end 18 | 19 | @implementation ELFileDetailViewController 20 | 21 | - (instancetype)initWithFileModel:(ELFileModel *)file 22 | { 23 | if (self = [super init]) { 24 | self.file = file; 25 | } 26 | return self; 27 | } 28 | 29 | - (void)viewDidLoad 30 | { 31 | [super viewDidLoad]; 32 | self.navigationItem.title = @"文件详情"; 33 | self.view.backgroundColor = [UIColor whiteColor]; 34 | 35 | NSString *urlStr = self.file.filePath; 36 | NSURL *url = [NSURL fileURLWithPath:urlStr]; 37 | 38 | UIDocumentInteractionController *documentVc = [UIDocumentInteractionController interactionControllerWithURL:url]; 39 | documentVc.delegate = self; 40 | 41 | UIView *remindView = [[UIView alloc] initWithFrame:self.view.bounds]; 42 | remindView.backgroundColor = [UIColor colorWithRed:247/255.0 green:247/255.0 blue:247/255.0 alpha:1.0]; 43 | remindView.hidden = YES; 44 | [self.view addSubview:remindView]; 45 | 46 | UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, self.view.bounds.size.height * 0.4, self.view.bounds.size.width, 60)]; 47 | label.numberOfLines = 0; 48 | label.font = [UIFont systemFontOfSize:18]; 49 | label.textAlignment = NSTextAlignmentCenter; 50 | label.text = @"文件暂不支持本地打开\n请用其他应用打开"; 51 | label.textColor = [UIColor colorWithRed:47/255.0 green:47/255.0 blue:47/255.0 alpha:1.0]; 52 | [remindView addSubview:label]; 53 | 54 | UIButton *btn = [[UIButton alloc] init]; 55 | [btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; 56 | [btn setTitle:@"用其他应用打开" forState:UIControlStateNormal]; 57 | btn.frame = CGRectMake((self.view.bounds.size.width-200)/2, self.view.bounds.size.height * 0.55, 200, 45); 58 | btn.titleLabel.font = [UIFont systemFontOfSize:18]; 59 | btn.layer.cornerRadius = 5; 60 | btn.backgroundColor = [UIColor colorWithRed:43/255.0 green:173/255.0 blue:158/255.0 alpha:1.0]; 61 | [btn addTarget:self action:@selector(openInOtherApp) forControlEvents:UIControlEventTouchUpInside]; 62 | [remindView addSubview:btn]; 63 | 64 | 65 | BOOL canOpen = [documentVc presentPreviewAnimated:YES]; 66 | if (!canOpen) { 67 | remindView.hidden = NO; 68 | } 69 | } 70 | 71 | - (void)openInOtherApp 72 | { 73 | NSString *urlStr = self.file.filePath; 74 | NSURL *url = [NSURL fileURLWithPath:urlStr]; 75 | //创建实例 76 | UIDocumentInteractionController *documentController = [UIDocumentInteractionController interactionControllerWithURL:url]; 77 | 78 | //设置代理 79 | documentController.delegate = self; 80 | BOOL canOpen = [documentController presentOpenInMenuFromRect:CGRectZero 81 | inView:self.view 82 | animated:YES]; 83 | if (!canOpen) { 84 | 85 | } 86 | } 87 | 88 | #pragma mark - UIDocumentInteractionController 代理方法 89 | - (UIViewController *)documentInteractionControllerViewControllerForPreview:(UIDocumentInteractionController *)controller 90 | { 91 | return self; 92 | } 93 | 94 | - (UIView *)documentInteractionControllerViewForPreview:(UIDocumentInteractionController *)controller 95 | { 96 | return self.view; 97 | } 98 | 99 | - (CGRect)documentInteractionControllerRectForPreview:(UIDocumentInteractionController *)controller 100 | { 101 | return self.view.bounds; 102 | } 103 | 104 | - (void)documentInteractionControllerDidEndPreview:(UIDocumentInteractionController *)controller 105 | { 106 | [self.navigationController popViewControllerAnimated:YES]; 107 | } 108 | @end 109 | -------------------------------------------------------------------------------- /ELFileManagerDemo/ELFileManager/ELFileManager.h: -------------------------------------------------------------------------------- 1 | // 2 | // ELFileManager.h 3 | // ELFileManager 4 | // 5 | // Created by 俞琦 on 2017/10/12. 6 | // Copyright © 2017年 俞琦. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @class ELFileModel; 12 | 13 | @interface ELFileManager : NSObject 14 | 15 | /** 16 | 初始化单例 17 | 18 | @return 自身对象 19 | */ 20 | + (instancetype)shareManager; 21 | 22 | 23 | /** 24 | 获得一个文件 25 | 26 | @param path 文件路径 27 | @return ELFileModel 对象 28 | */ 29 | - (ELFileModel *)getFileWithPath:(NSString *)path; 30 | 31 | 32 | /** 33 | 获取到当前路径下的所有文件(返回包括文件夹)(表面!!!) 34 | 35 | @param path 文件夹路径 36 | @return 返回 ELFileModel 对象数组 37 | */ 38 | - (NSArray *)getAllFileWithPath:(NSString *)path; 39 | 40 | 41 | 42 | /** 43 | 表面获取当前文件夹下的所有文件(返回不包括文件夹,全是文件)(表面!!!) 44 | 45 | @param path 文件夹路径 46 | @return 返回 ELFileModel 对象数组 47 | */ 48 | - (NSArray *)getAllFileInPathWithSurfaceSearch:(NSString *)path; 49 | 50 | 51 | /** 52 | 深度获取当前文件夹下的所有文件(返回不包括文件夹,全是文件)(深度!!!) 53 | 54 | @param path 文件夹路径 55 | @return 返回 ELFileModel 对象数组 56 | */ 57 | - (NSArray *)getAllFileInPathWithDeepSearch:(NSString *)path; 58 | 59 | 60 | 61 | /** 62 | 文件是否存在 63 | 64 | @param path 文件路径 65 | @return 是否存在 66 | */ 67 | - (BOOL)fileExistsAtPath:(NSString *)path; 68 | 69 | /** 70 | 新建一个文件夹-1 71 | 72 | @param path 文件所在的文件夹路径 73 | @param name 文件夹名称 74 | @return 返回 成功与否 75 | */ 76 | - (BOOL)createFolderToPath:(NSString *)path folderName:(NSString *)name; 77 | 78 | 79 | /** 80 | 新建一个文件夹-2 81 | 82 | @param fullPath 文件夹的全路径 83 | @return 成功与否 84 | */ 85 | - (BOOL)createFolderToFullPath:(NSString *)fullPath; 86 | 87 | /** 88 | 新建一个文件到指定目录-1 89 | 90 | @param path 文件所在的文件夹路径 91 | @param name 文件名称 92 | @return 返回 成功与否 93 | */ 94 | - (BOOL)createFileToPath:(NSString *)path fileName:(NSString *)name; 95 | 96 | 97 | /** 98 | 新建一个文件到指定目录-2 99 | 100 | @param fullPath 文件的全路径 101 | @return 成功与否 102 | */ 103 | - (BOOL)createFileToFullPath:(NSString *)fullPath; 104 | 105 | /** 106 | 添加文件到指定目录 107 | 108 | @param file 需要写入的文件 109 | @param path 文件所在的文件夹路径 110 | @param name 文件名称 111 | @return 返回 成功与否 112 | */ 113 | - (BOOL)addFile:(id)file toPath:(NSString *)path fileName:(NSString *)name; 114 | 115 | /** 116 | 删除文件 117 | 118 | @param path 文件路径(全路径) 119 | @return 返回 成功与否 120 | */ 121 | - (BOOL)deleteFileWithPath:(NSString *)path; 122 | 123 | 124 | /** 125 | 移动文件 126 | 127 | @param oldPath 原本的文件全路径 128 | @param newPath 新的文件所在的文件夹路径 129 | @return 成功与否 130 | */ 131 | - (BOOL)moveFile:(NSString *)oldPath toNewPath:(NSString *)newPath; 132 | 133 | /** 134 | 复制文件 135 | 136 | @param oldPath 原本的文件全路径 137 | @param newPath 新的文件所在的文件夹路径 138 | @return 成功与否 139 | */ 140 | - (BOOL)copyFile:(NSString *)oldPath toNewPath:(NSString *)newPath; 141 | 142 | /** 143 | 重命名 144 | 145 | @param path 文件所在的文件夹路径 146 | @param oldName 老名字 147 | @param newName 新名字 148 | @return 返回 成功与否 149 | */ 150 | - (BOOL)renameFileWithPath:(NSString *)path oldName:(NSString *)oldName newName:(NSString *)newName; 151 | 152 | 153 | 154 | /** 155 | 搜索表面的文件(不会搜索当前文件夹里的文件夹内文件。。) 156 | 157 | @param searchText 搜索的文字 158 | @param folderPath 搜索的文件夹路径 159 | @return 返回 ELFileModel 对象数组 160 | */ 161 | - (NSArray *)searchSurfaceFile:(NSString *)searchText folderPath:(NSString *)folderPath; 162 | 163 | 164 | 165 | /** 166 | 搜索深度的文件 (会把当前文件夹里的所有文件都查一遍 包括文件夹里的文件夹) 167 | 168 | @param searchText 搜索的文字 169 | @param folderPath 搜索的文件夹路径 170 | @return 返回 ELFileModel 对象数组 171 | */ 172 | - (NSArray *)searchDeepFile:(NSString *)searchText folderPath:(NSString *)folderPath; 173 | 174 | /** 175 | 读取文件的内容 176 | 177 | @param filePath 文件的路径 178 | @return 返回 NSData类型对象 179 | */ 180 | - (NSData *)readDataFromFilePath:(NSString *)filePath; 181 | 182 | 183 | /** 184 | 往文件里追加内容 185 | 186 | @param contentData 追加的内容 187 | @param filePath 文件路径 188 | */ 189 | - (void)seriesWriteContent:(NSData *)contentData intoHandleFile:(NSString *)filePath; 190 | @end 191 | 192 | 193 | -------------------------------------------------------------------------------- /ELFileManagerDemo/ELFileManager/ELFileManager.m: -------------------------------------------------------------------------------- 1 | // 2 | // ELFileManager.m 3 | // ELFileManager 4 | // 5 | // Created by 俞琦 on 2017/10/12. 6 | // Copyright © 2017年 俞琦. All rights reserved. 7 | // 8 | 9 | #import "ELFileManager.h" 10 | #import "ELFileModel.h" 11 | 12 | @interface ELFileManager() 13 | @property (nonatomic, strong) NSFileManager *fileManager; 14 | @end 15 | 16 | @implementation ELFileManager 17 | static id instance = nil; 18 | + (instancetype)shareManager 19 | { 20 | @synchronized(self) { 21 | if (!instance) { 22 | instance = [[self alloc] init]; 23 | } 24 | return instance; 25 | } 26 | } 27 | 28 | + (instancetype)allocWithZone:(struct _NSZone *)zone 29 | { 30 | @synchronized(self) { 31 | if (!instance) { 32 | instance = [super allocWithZone:zone]; 33 | } 34 | return instance; 35 | } 36 | } 37 | 38 | - (instancetype)copyWithZone:(NSZone *)zone 39 | { 40 | return self; 41 | } 42 | 43 | - (ELFileModel *)getFileWithPath:(NSString *)path 44 | { 45 | ELFileModel *file = [[ELFileModel alloc] initWithFilePath:path]; 46 | return file; 47 | } 48 | 49 | - (NSArray *)getAllFileWithPath:(NSString *)path 50 | { 51 | NSMutableArray *files = [NSMutableArray array]; 52 | NSArray *subPathsArray = [self.fileManager contentsOfDirectoryAtPath:path error: NULL]; 53 | for(NSString *str in subPathsArray){ 54 | ELFileModel *file = [[ELFileModel alloc] initWithFilePath: [NSString stringWithFormat:@"%@/%@",path, str]]; 55 | [files addObject:file]; 56 | } 57 | return files; 58 | } 59 | 60 | - (NSArray *)getAllFileInPathWithSurfaceSearch:(NSString *)path 61 | { 62 | NSMutableArray *files = [NSMutableArray array]; 63 | NSArray *subPathsArray = [self.fileManager contentsOfDirectoryAtPath:path error: NULL]; 64 | for(NSString *str in subPathsArray){ 65 | ELFileModel *file = [[ELFileModel alloc] initWithFilePath: [NSString stringWithFormat:@"%@/%@",path, str]]; 66 | if (file.fileType != ELFileTypeDirectory) 67 | [files addObject:file]; 68 | } 69 | return files; 70 | } 71 | 72 | - (NSArray *)getAllFileInPathWithDeepSearch:(NSString *)path 73 | { 74 | NSMutableArray *files = [NSMutableArray array]; 75 | NSArray *subPathsArray = [self.fileManager contentsOfDirectoryAtPath:path error: NULL]; 76 | for(NSString *str in subPathsArray){ 77 | ELFileModel *file = [[ELFileModel alloc] initWithFilePath: [NSString stringWithFormat:@"%@/%@",path, str]]; 78 | if (file.fileType == ELFileTypeDirectory) { 79 | [files addObjectsFromArray: [self getAllFileInPathWithDeepSearch:file.filePath]]; 80 | } else { 81 | [files addObject:file]; 82 | } 83 | } 84 | return files; 85 | } 86 | 87 | - (BOOL)fileExistsAtPath:(NSString *)path 88 | { 89 | return [[NSFileManager defaultManager] fileExistsAtPath:path]; 90 | } 91 | 92 | - (BOOL)createFolderToPath:(NSString *)path folderName:(NSString *)name 93 | { 94 | path = [NSString stringWithFormat:@"%@/%@", path, name]; 95 | return [self createFolderToFullPath:path]; 96 | } 97 | 98 | - (BOOL)createFolderToFullPath:(NSString *)fullPath 99 | { 100 | NSError *error; 101 | return [self.fileManager createDirectoryAtPath:fullPath withIntermediateDirectories:YES attributes:nil error:&error]; 102 | } 103 | 104 | - (BOOL)createFileToPath:(NSString *)path fileName:(NSString *)name 105 | { 106 | path = [NSString stringWithFormat:@"%@/%@", path, name]; 107 | return [self createFileToFullPath:path]; 108 | } 109 | 110 | - (BOOL)createFileToFullPath:(NSString *)fullPath 111 | { 112 | return [self.fileManager createFileAtPath:fullPath contents:nil attributes:nil]; 113 | } 114 | 115 | - (BOOL)addFile:(id)file toPath:(NSString *)path fileName:(NSString *)name 116 | { 117 | path = [NSString stringWithFormat:@"%@/%@", path, name]; 118 | return [file writeToFile:path atomically:YES]; 119 | } 120 | 121 | - (BOOL)deleteFileWithPath:(NSString *)path 122 | { 123 | return [self.fileManager removeItemAtPath:path error:nil]; 124 | } 125 | 126 | - (BOOL)moveFile:(NSString *)oldPath toNewPath:(NSString *)newPath 127 | { 128 | newPath = [NSString stringWithFormat:@"%@/%@", newPath, [oldPath lastPathComponent]]; 129 | return [self.fileManager moveItemAtPath:oldPath toPath:newPath error:nil]; 130 | } 131 | 132 | - (BOOL)copyFile:(NSString *)oldPath toNewPath:(NSString *)newPath 133 | { 134 | NSError *error; 135 | newPath = [NSString stringWithFormat:@"%@/%@", newPath, [oldPath lastPathComponent]]; 136 | BOOL succeed = [self.fileManager copyItemAtPath:oldPath toPath:newPath error:&error]; 137 | return succeed; 138 | } 139 | 140 | - (BOOL)renameFileWithPath:(NSString *)path oldName:(NSString *)oldName newName:(NSString *)newName 141 | { 142 | NSString *oldPath = [NSString stringWithFormat:@"%@/%@", path, oldName]; 143 | NSString *newPath = [NSString stringWithFormat:@"%@/%@", path, newName]; 144 | return [self.fileManager moveItemAtPath:oldPath toPath:newPath error:nil]; 145 | } 146 | 147 | - (NSArray *)searchSurfaceFile:(NSString *)searchText folderPath:(NSString *)folderPath 148 | { 149 | NSArray *files = [self getAllFileWithPath:folderPath]; 150 | 151 | NSMutableArray *returnArr = [NSMutableArray array]; 152 | for (ELFileModel *file in files) { 153 | if ([file.name rangeOfString:searchText].location != NSNotFound) { 154 | [returnArr addObject:file]; 155 | } 156 | } 157 | return returnArr; 158 | } 159 | 160 | - (NSArray *)searchDeepFile:(NSString *)searchText folderPath:(NSString *)folderPath 161 | { 162 | NSArray *files = [self getAllFileWithPath:folderPath]; 163 | 164 | NSMutableArray *returnArr = [NSMutableArray array]; 165 | for (ELFileModel *file in files) { 166 | if ([file.name rangeOfString:searchText].location != NSNotFound) { // 找到文件 167 | if (file.fileType == ELFileTypeDirectory) { // 文件夹 168 | [returnArr addObjectsFromArray:[self searchDeepFile:searchText folderPath:file.filePath]]; // 递归去找 169 | } 170 | [returnArr addObject:file]; 171 | } 172 | } 173 | return returnArr; 174 | } 175 | 176 | - (NSData *)readDataFromFilePath:(NSString *)filePath 177 | { 178 | NSFileHandle *fileHandle = [NSFileHandle fileHandleForUpdatingAtPath:filePath]; 179 | NSData *data = [fileHandle readDataToEndOfFile]; 180 | [fileHandle closeFile]; 181 | return data; 182 | } 183 | 184 | - (void)seriesWriteContent:(NSData *)contentData intoHandleFile:(NSString *)filePath 185 | { 186 | NSFileHandle *fileHandle = [NSFileHandle fileHandleForUpdatingAtPath:filePath]; 187 | [fileHandle seekToEndOfFile]; 188 | [fileHandle writeData:contentData]; 189 | [fileHandle closeFile]; 190 | } 191 | 192 | #pragma mark - lazy 193 | - (NSFileManager *)fileManager 194 | { 195 | if (!_fileManager) { 196 | _fileManager = [NSFileManager defaultManager]; 197 | } 198 | return _fileManager; 199 | } 200 | 201 | @end 202 | 203 | 204 | -------------------------------------------------------------------------------- /ELFileManagerDemo/ELFileManager/ELFileModel.h: -------------------------------------------------------------------------------- 1 | // 2 | // ELFileModel.h 3 | // ELFileManager 4 | // 5 | // Created by 俞琦 on 2017/10/12. 6 | // Copyright © 2017年 俞琦. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | typedef NS_ENUM(NSInteger, ELFileType) { 12 | 13 | ELFileTypeUnknown = -1, //其他 14 | 15 | ELFileTypeAll = 0, //所有 16 | 17 | ELFileTypeImage = 1, //图片 18 | 19 | ELFileTypeTxt = 2, //文档 20 | 21 | ELFileTypeVoice = 3, //音乐 22 | 23 | ELFileTypeAudioVidio = 4, //视频 24 | 25 | ELFileTypeApplication = 5, //应用 26 | 27 | ELFileTypeDirectory = 6, //目录 28 | 29 | ELFileTypePDF = 7, //PDF 30 | 31 | ELFileTypePPT = 8, //PPT 32 | 33 | ELFileTypeWord = 9, //Word 34 | 35 | ELFileTypeXLS = 10, //XLS 36 | }; 37 | 38 | @interface ELFileModel : NSObject 39 | //文件路径 40 | @property (copy, nonatomic) NSString *filePath; ///< 全路径 41 | //文件URL 42 | @property (copy, nonatomic) NSString *fileUrl; 43 | 44 | @property (copy, nonatomic) NSString *name; ///< 文件名称 45 | 46 | @property (copy, nonatomic) NSString *fileSize; ///< 大小用字符表述 47 | 48 | @property (nonatomic, assign) float fileSizefloat; ///< 大小用float 49 | 50 | @property (copy, nonatomic) NSString *modTime; ///< 修改时间 51 | 52 | @property (copy, nonatomic) NSString *creatTime; ///< 修改时间 53 | 54 | @property (assign, nonatomic) ELFileType fileType; 55 | 56 | @property (nonatomic, strong) NSDictionary *attributes; ///<文件属性 57 | 58 | 59 | 60 | /** 61 | 初始化方法 62 | 63 | @param filePath 全路径 64 | @return 自身对象 65 | */ 66 | - (instancetype)initWithFilePath:(NSString *)filePath; 67 | @end 68 | -------------------------------------------------------------------------------- /ELFileManagerDemo/ELFileManager/ELFileModel.m: -------------------------------------------------------------------------------- 1 | // 2 | // ELFileModel.m 3 | // ELFileManager 4 | // 5 | // Created by 俞琦 on 2017/10/12. 6 | // Copyright © 2017年 俞琦. All rights reserved. 7 | // 8 | 9 | #import "ELFileModel.h" 10 | 11 | static const UInt8 IMAGES_TYPES_COUNT = 8; 12 | static const UInt8 TEXT_TYPES_COUNT = 2; 13 | static const UInt8 VIOCEVIDIO_COUNT = 14; 14 | static const UInt8 Application_count = 4; 15 | static const UInt8 AV_COUNT = 14; 16 | static const UInt8 DOC_TYPES_COUNT = 4; 17 | static const UInt8 XLS_TYPES_COUNT = 4; 18 | static const UInt8 PPT_TYPES_COUNT = 2; 19 | static const UInt8 PDF_TYPES_COUNT = 2; 20 | 21 | static const NSString *IMAGES_TYPES[IMAGES_TYPES_COUNT] = {@"png", @"PNG", @"jpg",@",JPG", @"jpeg", @"JPEG" ,@"gif", @"GIF"}; 22 | static const NSString *TEXT_TYPES[TEXT_TYPES_COUNT] = {@"txt", @"TXT"}; 23 | static const NSString *VIOCEVIDIO_TYPES[VIOCEVIDIO_COUNT] = {@"mp3",@"MP3",@"wav",@"WAV",@"CD",@"cd",@"ogg",@"OGG",@"midi",@"MIDE",@"vqf",@"VQF",@"amr",@"AMR"}; 24 | static const NSString *AV_TYPES[AV_COUNT] = {@"asf",@"ASF",@"wma",@"WMA",@"rm",@"RM",@"rmvb",@"RMVB",@"avi",@"AVI",@"mkv",@"MKV",@"mp4",@"MP4"}; 25 | static const NSString *Application_types[Application_count] = {@"apk",@"APK",@"ipa",@"IPA"}; 26 | static const NSString *DOC_TYPES[DOC_TYPES_COUNT] = {@"doc",@"DOC",@"docx",@"DOCX"}; 27 | static const NSString *XLS_TYPES[XLS_TYPES_COUNT] = {@"xls",@"XLS", @"xlsx",@"XLSX"}; 28 | static const NSString *PPT_TYPES[PPT_TYPES_COUNT] = {@"ppt",@"PPT"}; 29 | static const NSString *PDF_TYPES[PDF_TYPES_COUNT] = {@"pdf",@"PDF"}; 30 | 31 | //@interface ELFileModel() 32 | //@end 33 | 34 | @implementation ELFileModel 35 | { 36 | NSFileManager *fileMgr; 37 | } 38 | 39 | - (instancetype)init 40 | { 41 | if(self = [super init]) { 42 | fileMgr = [NSFileManager defaultManager]; 43 | } 44 | return self; 45 | } 46 | 47 | - (instancetype)initWithFilePath:(NSString *)filePath 48 | { 49 | if(self = [self init]){ 50 | self.filePath = filePath; 51 | } 52 | return self; 53 | } 54 | 55 | 56 | - (void)setFilePath:(NSString *)filePath 57 | { 58 | _filePath = filePath; 59 | self.name = [filePath lastPathComponent]; 60 | self.fileType = ELFileTypeUnknown; // 暂时先设置为未知 61 | 62 | BOOL isDirectory = true; 63 | [fileMgr fileExistsAtPath:filePath isDirectory:&isDirectory]; 64 | if (isDirectory) { // 存在文件夹,说明这个文件是文件夹 65 | self.fileType = ELFileTypeDirectory; 66 | } else { 67 | self.fileType = [self judgeType:[filePath pathExtension]]; // 设置类型 68 | } 69 | 70 | NSError *error = nil; 71 | NSDictionary *fileAttributes = [fileMgr attributesOfItemAtPath:filePath error:&error]; 72 | if (fileAttributes != nil) { 73 | 74 | self.attributes = fileAttributes; 75 | 76 | // 下面把一些常用的获取到 77 | NSDate *fileModDate = [fileAttributes objectForKey:NSFileModificationDate]; 78 | if (fileModDate) { // 修改时间 79 | //用于格式化NSDate对象 80 | NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; 81 | //设置格式:zzz表示时区 82 | [dateFormatter setDateFormat:@"MM-dd HH:mm:ss"]; 83 | //NSDate转NSString 84 | self.modTime = [dateFormatter stringFromDate:fileModDate]; 85 | } 86 | 87 | NSDate *fileCreateDate = [fileAttributes objectForKey:NSFileCreationDate]; 88 | if (fileCreateDate) { // 创建时间 89 | NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; 90 | //设置格式:zzz表示时区 91 | [dateFormatter setDateFormat:@"MM-dd HH:mm:ss"]; 92 | //NSDate转NSString 93 | self.creatTime = [dateFormatter stringFromDate:fileCreateDate]; 94 | } 95 | 96 | // 获得大小 97 | self.fileSizefloat = [self calculateSize]; 98 | 99 | // 大小的字符 100 | if (self.fileSizefloat) { 101 | NSNumber *fileSize = [NSNumber numberWithUnsignedLongLong:self.fileSizefloat]; 102 | NSString *sizestr = [NSString stringWithFormat:@"%qi",[fileSize unsignedLongLongValue]]; 103 | if (sizestr.length <=3) { 104 | self.fileSize = [NSString stringWithFormat:@"%.1f B",self.fileSizefloat]; 105 | } else if(sizestr.length>3 && sizestr.length<7){ 106 | self.fileSize = [NSString stringWithFormat:@"%.1f KB",self.fileSizefloat/1000.0]; 107 | }else{ 108 | self.fileSize = [NSString stringWithFormat:@"%.1f M",self.fileSizefloat/(1000.0 * 1000)]; 109 | } 110 | } else { 111 | self.fileSize = @"0 B"; 112 | } 113 | } 114 | } 115 | 116 | 117 | 118 | #pragma mark - 私有 119 | // 计算大小 120 | - (float)calculateSize 121 | { 122 | if (self.fileType != ELFileTypeDirectory) { // 文件 123 | NSNumber *fileSize = [self.attributes objectForKey:NSFileSize]; 124 | return [fileSize unsignedLongLongValue]; 125 | } else { // 文件夹 126 | //遍历文件夹中的所有内容 127 | NSArray *subpaths = [fileMgr subpathsAtPath:_filePath]; 128 | //计算文件夹大小 129 | float totalByteSize = 0; 130 | for (NSString *subpath in subpaths){ 131 | //拼接全路径 132 | NSString *fullSubPath = [_filePath stringByAppendingPathComponent:subpath]; 133 | //判断是否为文件 134 | BOOL dir = NO; 135 | [fileMgr fileExistsAtPath:fullSubPath isDirectory:&dir]; 136 | if (dir == NO){//是文件 137 | NSDictionary *attr = [fileMgr attributesOfItemAtPath:fullSubPath error:nil]; 138 | totalByteSize += [attr[NSFileSize] integerValue]; 139 | } 140 | } 141 | return totalByteSize; 142 | } 143 | } 144 | 145 | // 通过后缀获得类型 146 | - (ELFileType)judgeType:(NSString *)pathExtension 147 | { 148 | NSArray *imageTypesArray = [NSArray arrayWithObjects: IMAGES_TYPES count: IMAGES_TYPES_COUNT]; 149 | if ([imageTypesArray containsObject:pathExtension]) { 150 | return ELFileTypeImage; 151 | } 152 | 153 | NSArray *textTypesArray = [NSArray arrayWithObjects: TEXT_TYPES count: TEXT_TYPES_COUNT]; 154 | if ([textTypesArray containsObject:pathExtension]) { 155 | return ELFileTypeTxt; 156 | } 157 | 158 | NSArray *viceViodeArray = [NSArray arrayWithObjects: VIOCEVIDIO_TYPES count: VIOCEVIDIO_COUNT]; 159 | if ([viceViodeArray containsObject:pathExtension]) { 160 | return ELFileTypeVoice; 161 | } 162 | 163 | NSArray *appViodeArray = [NSArray arrayWithObjects: Application_types count: Application_count]; 164 | if ([appViodeArray containsObject:pathExtension]) { 165 | return ELFileTypeApplication; 166 | } 167 | 168 | NSArray *AVArray = [NSArray arrayWithObjects: AV_TYPES count: AV_COUNT]; 169 | if ([AVArray containsObject:pathExtension]) { 170 | return ELFileTypeAudioVidio; 171 | } 172 | 173 | NSArray *DOCArray = [NSArray arrayWithObjects: DOC_TYPES count: DOC_TYPES_COUNT]; 174 | if ([DOCArray containsObject:pathExtension]) { 175 | return ELFileTypeWord; 176 | } 177 | 178 | NSArray *XLSArray = [NSArray arrayWithObjects: XLS_TYPES count: XLS_TYPES_COUNT]; 179 | if ([XLSArray containsObject:pathExtension]) { 180 | return ELFileTypeXLS; 181 | } 182 | 183 | NSArray *PDFArray = [NSArray arrayWithObjects: PDF_TYPES count: PDF_TYPES_COUNT]; 184 | if ([PDFArray containsObject:pathExtension]) { 185 | return ELFileTypePDF; 186 | } 187 | 188 | NSArray *PPTArray = [NSArray arrayWithObjects: PPT_TYPES count: PPT_TYPES_COUNT]; 189 | if ([PPTArray containsObject:pathExtension]) { 190 | return ELFileTypePPT; 191 | } 192 | 193 | return ELFileTypeUnknown; 194 | } 195 | @end 196 | -------------------------------------------------------------------------------- /ELFileManagerDemo/ELGetAlllFileInDeepSearchViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ELGetAlllFileInDeepSearchViewController.h 3 | // ELFileManagerDemo 4 | // 5 | // Created by easylink on 2017/11/24. 6 | // Copyright © 2017年 俞琦. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ELGetAlllFileInDeepSearchViewController : UIViewController 12 | - (instancetype)initWithPath:(NSString *)path; 13 | @end 14 | -------------------------------------------------------------------------------- /ELFileManagerDemo/ELGetAlllFileInDeepSearchViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ELGetAlllFileInDeepSearchViewController.m 3 | // ELFileManagerDemo 4 | // 5 | // Created by easylink on 2017/11/24. 6 | // Copyright © 2017年 俞琦. All rights reserved. 7 | // 8 | 9 | #import "ELGetAlllFileInDeepSearchViewController.h" 10 | #import "ELFileManager.h" 11 | #import "ELFileModel.h" 12 | #import "ELFileDetailViewController.h" 13 | 14 | @interface ELGetAlllFileInDeepSearchViewController () 15 | @property (nonatomic, strong) ELFileManager * fileManager; 16 | @property (nonatomic, weak) UITableView * tableView; 17 | @property (nonatomic, copy) NSString * homePath; 18 | @property (nonatomic, strong) NSMutableArray *files; 19 | @end 20 | 21 | @implementation ELGetAlllFileInDeepSearchViewController 22 | 23 | - (instancetype)initWithPath:(NSString *)path 24 | { 25 | if (self = [super init]) { 26 | self.homePath = path; 27 | } 28 | return self; 29 | } 30 | 31 | - (void)viewDidLoad 32 | { 33 | [super viewDidLoad]; 34 | 35 | if (![self.fileManager fileExistsAtPath:self.homePath]) { 36 | [self.fileManager createFolderToFullPath:self.homePath]; 37 | } 38 | 39 | [self initViews]; 40 | } 41 | 42 | - (void)initViews 43 | { 44 | UITableView *tv = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStyleGrouped]; 45 | tv.delegate = self; 46 | tv.dataSource = self; 47 | [self.view addSubview:tv]; 48 | self.tableView = tv; 49 | } 50 | 51 | #pragma mark - UITableViewDelegate, UITableViewDataSource 52 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 53 | { 54 | return self.files.count; 55 | } 56 | 57 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 58 | { 59 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"]; 60 | if (!cell) { 61 | cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"cell"]; 62 | } 63 | ELFileModel *file = self.files[indexPath.row]; 64 | cell.textLabel.text = file.name; 65 | cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; 66 | UIImage *cellImage; 67 | if (file.fileType == ELFileTypeDirectory) { // 文件夹 68 | cell.detailTextLabel.text = [NSString stringWithFormat:@"文件夹: %@ %@", file.creatTime, file.fileSize]; 69 | cellImage = [UIImage imageNamed:@"file_floder"]; 70 | } else { 71 | 72 | switch (file.fileType) { 73 | case ELFileTypeImage: 74 | { 75 | cell.detailTextLabel.text = [NSString stringWithFormat:@"图片: %@ %@", file.creatTime, file.fileSize]; 76 | cellImage = [UIImage imageWithContentsOfFile:file.filePath]; 77 | } 78 | break; 79 | case ELFileTypeTxt: 80 | { 81 | cell.detailTextLabel.text = [NSString stringWithFormat:@"文档: %@ %@", file.creatTime, file.fileSize]; 82 | cellImage = [UIImage imageNamed:@"file_txt"]; 83 | } 84 | break; 85 | case ELFileTypeVoice: 86 | { 87 | cell.detailTextLabel.text = [NSString stringWithFormat:@"音乐: %@ %@", file.creatTime, file.fileSize]; 88 | cellImage = [UIImage imageNamed:@"file_mp3"]; 89 | } 90 | break; 91 | case ELFileTypeAudioVidio: 92 | { 93 | cell.detailTextLabel.text = [NSString stringWithFormat:@"视频: %@ %@", file.creatTime, file.fileSize]; 94 | cellImage = [UIImage imageNamed:@"file_avi"]; 95 | } 96 | break; 97 | case ELFileTypeApplication: 98 | { 99 | cell.detailTextLabel.text = [NSString stringWithFormat:@"应用: %@ %@", file.creatTime, file.fileSize]; 100 | cellImage = [UIImage imageNamed:@"file_ipa"]; 101 | } 102 | break; 103 | case ELFileTypeUnknown: 104 | { 105 | cell.detailTextLabel.text = [NSString stringWithFormat:@"未知文件: %@ %@", file.creatTime, file.fileSize]; 106 | cellImage = [UIImage imageNamed:@"file_webView_error"]; 107 | } 108 | break; 109 | case ELFileTypeWord: 110 | { 111 | cell.detailTextLabel.text = [NSString stringWithFormat:@"word: %@ %@", file.creatTime, file.fileSize]; 112 | cellImage = [UIImage imageNamed:@"file_word"]; 113 | } 114 | break; 115 | case ELFileTypePDF: 116 | { 117 | cell.detailTextLabel.text = [NSString stringWithFormat:@"pdf: %@ %@", file.creatTime, file.fileSize]; 118 | cellImage = [UIImage imageNamed:@"file_pdf"]; 119 | } 120 | break; 121 | case ELFileTypePPT: 122 | { 123 | cell.detailTextLabel.text = [NSString stringWithFormat:@"ppt: %@ %@", file.creatTime, file.fileSize]; 124 | cellImage = [UIImage imageNamed:@"file_ppt"]; 125 | } 126 | break; 127 | case ELFileTypeXLS: 128 | { 129 | cell.detailTextLabel.text = [NSString stringWithFormat:@"xls: %@ %@", file.creatTime, file.fileSize]; 130 | cellImage = [UIImage imageNamed:@"file_excel"]; 131 | } 132 | break; 133 | default: 134 | break; 135 | } 136 | 137 | } 138 | 139 | // 设置cell图片大小 140 | CGSize imageSize = CGSizeMake(40, 40); 141 | UIGraphicsBeginImageContextWithOptions(imageSize, NO, 0.0); 142 | CGRect imageRect = CGRectMake(0.0, 0.0, imageSize.width, imageSize.height); 143 | [cellImage drawInRect:imageRect]; 144 | cell.imageView.image = UIGraphicsGetImageFromCurrentImageContext(); 145 | UIGraphicsEndImageContext(); 146 | 147 | return cell; 148 | } 149 | 150 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 151 | { 152 | ELFileModel *file = self.files[indexPath.row]; 153 | 154 | ELFileDetailViewController *fileDetail = [[ELFileDetailViewController alloc] initWithFileModel:file]; 155 | [self.navigationController pushViewController:fileDetail animated:YES]; 156 | } 157 | 158 | - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath 159 | { 160 | return 50; 161 | } 162 | 163 | - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section 164 | { 165 | return [[UIView alloc] init]; 166 | } 167 | 168 | - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section 169 | { 170 | return 0.01; 171 | } 172 | 173 | - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section 174 | { 175 | return [[UIView alloc] init]; 176 | } 177 | 178 | - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section 179 | { 180 | return 0.01; 181 | } 182 | 183 | 184 | #pragma mark - lazy 185 | - (ELFileManager *)fileManager 186 | { 187 | if (!_fileManager) { 188 | _fileManager = [ELFileManager shareManager]; 189 | } 190 | return _fileManager; 191 | } 192 | 193 | - (NSMutableArray *)files 194 | { 195 | if (!_files) { 196 | _files = [NSMutableArray arrayWithArray:[self.fileManager getAllFileInPathWithDeepSearch:self.homePath]]; 197 | } 198 | return _files; 199 | } 200 | 201 | @end 202 | -------------------------------------------------------------------------------- /ELFileManagerDemo/ELMoreViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // ELFileManagerDemo 4 | // 5 | // Created by 俞琦 on 2017/10/13. 6 | // Copyright © 2017年 俞琦. All rights reserved. 7 | // 8 | 9 | #import 10 | @class ELFileModel; 11 | 12 | @interface ELMoreViewController : UIViewController 13 | @property (nonatomic, strong) ELFileModel *fileModel; 14 | 15 | @end 16 | 17 | -------------------------------------------------------------------------------- /ELFileManagerDemo/ELMoreViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // ELFileManagerDemo 4 | // 5 | // Created by 俞琦 on 2017/10/13. 6 | // Copyright © 2017年 俞琦. All rights reserved. 7 | // http://5.fjdx1.crsky.com/software1/VC_CN-v6.0.zip 8 | 9 | #import "ELMoreViewController.h" 10 | #import "ELFileModel.h" 11 | #import "ELFileManager.h" 12 | 13 | @interface YQProgress : UIView 14 | @property (nonatomic, assign) float progress; 15 | @property (nonatomic, weak) UIView *blackView; 16 | @end 17 | @implementation YQProgress 18 | - (instancetype)initWithFrame:(CGRect)frame 19 | { 20 | if (self = [super initWithFrame:frame]) { 21 | self.backgroundColor = [UIColor whiteColor]; 22 | self.progress = 0; 23 | self.layer.borderWidth = 1; 24 | self.layer.borderColor = [UIColor blackColor].CGColor; 25 | 26 | UIView *blackView = [UIView new]; 27 | blackView.backgroundColor = [UIColor blackColor]; 28 | blackView.frame = CGRectMake(2, 2, self.bounds.size.width * self.progress - 4, self.bounds.size.height - 4); 29 | [self addSubview:blackView]; 30 | self.blackView = blackView; 31 | } 32 | return self; 33 | } 34 | 35 | - (void)setProgress:(float)progress 36 | { 37 | _progress = progress; 38 | self.blackView.frame = CGRectMake(2, 2, self.bounds.size.width * self.progress - 4, self.bounds.size.height - 4); 39 | if (_progress <= 0 || _progress >= 1) { 40 | self.hidden = YES; 41 | } else { 42 | self.hidden = NO; 43 | } 44 | } 45 | @end 46 | 47 | @interface ELMoreViewController () 48 | @property (nonatomic, strong) NSMutableArray *files; 49 | @property (nonatomic, strong) ELFileManager *fileManager; 50 | @property (nonatomic, weak) UITableView *tv; 51 | @property (nonatomic, copy) NSString *homePath; 52 | 53 | // 下载相关 54 | @property (nonatomic, weak) YQProgress *progress; 55 | @end 56 | 57 | @implementation ELMoreViewController 58 | { 59 | ELFileModel *_longPressFile; // 记录长按的文件 60 | NSIndexPath *_longPressIndexPath; // 记录长按的indexpath 61 | NSString *_downloadFileName; // 下载的文件名 62 | NSUInteger _totolLen; // 总长度 63 | NSUInteger _currentLen; // 当前长度 64 | } 65 | 66 | - (void)viewDidLoad 67 | { 68 | [super viewDidLoad]; 69 | 70 | self.fileManager = [ELFileManager shareManager]; 71 | 72 | if (self.fileModel == nil) { // 总目录 73 | self.homePath = [[NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:@"ELFileCache"]; 74 | // 创建一个目录 75 | [self.fileManager createFolderToFullPath:self.homePath]; 76 | self.title = @"总目录"; 77 | } else { 78 | self.title = self.fileModel.name; 79 | self.homePath = self.fileModel.filePath; 80 | } 81 | 82 | 83 | // init视图 84 | [self initViews]; 85 | 86 | // 获得路径下的所以文件 87 | [self getAllFile]; 88 | } 89 | 90 | #pragma mark - tableView 代理数据源 91 | - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView 92 | { 93 | return 1; 94 | } 95 | 96 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 97 | { 98 | return self.files.count; 99 | } 100 | 101 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 102 | { 103 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"]; 104 | if (!cell) { 105 | cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"cell"]; 106 | //添加长按手势 107 | UILongPressGestureRecognizer * longPressGesture =[[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(cellLongPress:)]; 108 | longPressGesture.minimumPressDuration = 1.0f; 109 | [cell addGestureRecognizer:longPressGesture]; 110 | } 111 | ELFileModel *file = self.files[indexPath.row]; 112 | cell.textLabel.text = file.name; 113 | if (file.fileType == ELFileTypeDirectory) { // 文件夹 114 | cell.detailTextLabel.text = [NSString stringWithFormat:@"文件夹: %@ %@", file.creatTime, file.fileSize]; 115 | cell.imageView.image = [UIImage imageNamed:@"file_floder"]; 116 | cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; 117 | } else { 118 | cell.accessoryType = UITableViewCellAccessoryNone; 119 | switch (file.fileType) { 120 | case ELFileTypeImage: 121 | { 122 | cell.detailTextLabel.text = [NSString stringWithFormat:@"图片: %@ %@", file.creatTime, file.fileSize]; 123 | cell.imageView.image = [UIImage imageWithContentsOfFile:file.filePath]; 124 | } 125 | break; 126 | case ELFileTypeTxt: 127 | { 128 | cell.detailTextLabel.text = [NSString stringWithFormat:@"文档: %@ %@", file.creatTime, file.fileSize]; 129 | cell.imageView.image = [UIImage imageNamed:@"file_txt"]; 130 | } 131 | break; 132 | case ELFileTypeVoice: 133 | { 134 | cell.detailTextLabel.text = [NSString stringWithFormat:@"音乐: %@ %@", file.creatTime, file.fileSize]; 135 | cell.imageView.image = [UIImage imageNamed:@"file_mp3"]; 136 | } 137 | break; 138 | case ELFileTypeAudioVidio: 139 | { 140 | cell.detailTextLabel.text = [NSString stringWithFormat:@"视频: %@ %@", file.creatTime, file.fileSize]; 141 | cell.imageView.image = [UIImage imageNamed:@"file_avi"]; 142 | } 143 | break; 144 | case ELFileTypeApplication: 145 | { 146 | cell.detailTextLabel.text = [NSString stringWithFormat:@"应用: %@ %@", file.creatTime, file.fileSize]; 147 | cell.imageView.image = [UIImage imageNamed:@"file_ipa"]; 148 | } 149 | break; 150 | case ELFileTypeUnknown: 151 | { 152 | cell.detailTextLabel.text = [NSString stringWithFormat:@"未知文件: %@ %@", file.creatTime, file.fileSize]; 153 | cell.imageView.image = [UIImage imageNamed:@"file_webView_error"]; 154 | } 155 | break; 156 | case ELFileTypeWord: 157 | { 158 | cell.detailTextLabel.text = [NSString stringWithFormat:@"word: %@ %@", file.creatTime, file.fileSize]; 159 | cell.imageView.image = [UIImage imageNamed:@"file_word"]; 160 | } 161 | break; 162 | case ELFileTypePDF: 163 | { 164 | cell.detailTextLabel.text = [NSString stringWithFormat:@"pdf: %@ %@", file.creatTime, file.fileSize]; 165 | cell.imageView.image = [UIImage imageNamed:@"file_pdf"]; 166 | } 167 | break; 168 | case ELFileTypePPT: 169 | { 170 | cell.detailTextLabel.text = [NSString stringWithFormat:@"ppt: %@ %@", file.creatTime, file.fileSize]; 171 | cell.imageView.image = [UIImage imageNamed:@"file_ppt"]; 172 | } 173 | break; 174 | case ELFileTypeXLS: 175 | { 176 | cell.detailTextLabel.text = [NSString stringWithFormat:@"xls: %@ %@", file.creatTime, file.fileSize]; 177 | cell.imageView.image = [UIImage imageNamed:@"file_excel"]; 178 | } 179 | break; 180 | default: 181 | break; 182 | } 183 | } 184 | 185 | return cell; 186 | } 187 | 188 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 189 | { 190 | ELFileModel *file = self.files[indexPath.row]; 191 | if (file.fileType == ELFileTypeDirectory) { 192 | ELMoreViewController *vc = [[ELMoreViewController alloc] init]; 193 | vc.fileModel = file; 194 | vc.homePath = file.filePath; 195 | [self.navigationController pushViewController:vc animated:YES]; 196 | } else { 197 | NSData *data = [self.fileManager readDataFromFilePath:file.filePath]; 198 | [self.fileManager seriesWriteContent:data intoHandleFile:file.filePath]; 199 | } 200 | } 201 | 202 | - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath 203 | { 204 | return YES; 205 | } 206 | 207 | - (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath 208 | { 209 | return UITableViewCellEditingStyleDelete; 210 | } 211 | 212 | - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath 213 | { 214 | ELFileModel *file = self.files[indexPath.row]; 215 | if ([self.fileManager deleteFileWithPath:file.filePath]) { 216 | [self.files removeObjectAtIndex:indexPath.row]; 217 | [self.tv deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationLeft]; 218 | } 219 | } 220 | 221 | #pragma mark - 对控件权限进行设置 222 | - (BOOL)canBecomeFirstResponder 223 | { 224 | return YES; 225 | } 226 | 227 | - (BOOL)canPerformAction:(SEL)action withSender:(id)sender 228 | { 229 | if(action == @selector(rename:) || action == @selector(moveFile) || action == @selector(copyFile)) 230 | return YES; 231 | return NO; 232 | } 233 | 234 | #pragma mark - 下载代理 235 | 236 | - (void)URLSession:(NSURLSession *)session dataTask:(NSURLSessionDataTask *)dataTask didReceiveResponse:(NSURLResponse *)response completionHandler:(void (^)(NSURLSessionResponseDisposition disposition))completionHandler 237 | { 238 | // 接收到数据时,创建文件 239 | _downloadFileName = response.suggestedFilename; 240 | [self.fileManager createFileToPath:self.homePath fileName:response.suggestedFilename]; 241 | _totolLen = response.expectedContentLength; 242 | completionHandler(NSURLSessionResponseAllow); 243 | } 244 | 245 | - (void)URLSession:(NSURLSession *)session dataTask:(NSURLSessionDataTask *)dataTask didReceiveData:(NSData *)data 246 | { 247 | 248 | NSString* filePath = [self.homePath stringByAppendingPathComponent:_downloadFileName]; 249 | [self.fileManager seriesWriteContent:data intoHandleFile:filePath]; // 写入 250 | _currentLen += data.length; 251 | double progress = (double)_currentLen / _totolLen; 252 | dispatch_async(dispatch_get_main_queue(), ^{ 253 | self.progress.progress = progress; 254 | }); 255 | } 256 | 257 | - (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didCompleteWithError:(NSError *)error 258 | { 259 | [self getAllFile]; 260 | } 261 | 262 | #pragma mark - 私有 263 | - (void)initViews 264 | { 265 | UITableView *tv = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStyleGrouped]; 266 | tv.delegate = self; 267 | tv.dataSource = self; 268 | [self.view addSubview:tv]; 269 | self.tv = tv; 270 | 271 | self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemEdit target:self action:@selector(addAction)]; 272 | 273 | YQProgress* progress = [[YQProgress alloc] initWithFrame:CGRectMake(10, self.view.bounds.size.height - 30, self.view.bounds.size.width - 20, 20)]; 274 | progress.progress = 0; 275 | [self.view addSubview:progress]; 276 | self.progress = progress; 277 | } 278 | 279 | - (void)getAllFile 280 | { 281 | self.files = [NSMutableArray arrayWithArray:[self.fileManager getAllFileWithPath:self.homePath]]; 282 | dispatch_async(dispatch_get_main_queue(), ^{ 283 | [self.tv reloadData]; 284 | }); 285 | } 286 | 287 | - (void)addAction 288 | { 289 | UIAlertController *actionSheetController = [UIAlertController alertControllerWithTitle:nil message:@"操作" preferredStyle:UIAlertControllerStyleActionSheet]; 290 | UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil]; 291 | UIAlertAction *createFolderAction = [UIAlertAction actionWithTitle:@"添加一个文件夹" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { 292 | 293 | int num = arc4random() % 100; 294 | NSString *name = [NSString stringWithFormat:@"新建的文件夹--%d", num]; 295 | if ([self.fileManager createFolderToPath:self.homePath folderName:name]) { 296 | [self getAllFile]; 297 | } else { 298 | NSLog(@"创建失败"); 299 | } 300 | 301 | }]; 302 | UIAlertAction *createFileAction = [UIAlertAction actionWithTitle:@"新建一个文件" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { 303 | 304 | if ([self.fileManager createFileToPath:self.homePath fileName:@"hello.api"]) { 305 | [self getAllFile]; 306 | } else { 307 | NSLog(@"创建失败"); 308 | } 309 | }]; 310 | UIAlertAction *addFileAction = [UIAlertAction actionWithTitle:@"添加一个文件" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { 311 | 312 | int num = arc4random() % 100; 313 | NSDictionary *dic = @{@"name" : @"YYQQ"}; 314 | if ([self.fileManager addFile:dic toPath:self.homePath fileName:[NSString stringWithFormat:@"添加的字典--%d.txt", num]]) { 315 | [self getAllFile]; 316 | } else { 317 | NSLog(@"添加失败"); 318 | } 319 | }]; 320 | UIAlertAction *downloadFileAction = [UIAlertAction actionWithTitle:@"下载一个大文件" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { 321 | 322 | NSURLSession *session = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration] delegate:self delegateQueue:[[NSOperationQueue alloc] init]]; 323 | NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:[NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://120.25.226.186:32812/resources/videos/minion_02.mp4"]]]; 324 | [dataTask resume]; 325 | }]; 326 | UIAlertAction *searchAction = [UIAlertAction actionWithTitle:@"搜索“的”字文件" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { 327 | 328 | NSArray *resFiles = [self.fileManager searchDeepFile:@"的" folderPath:self.homePath]; 329 | for (ELFileModel *file in resFiles) { 330 | NSLog(@"%@", file.name); 331 | } 332 | 333 | }]; 334 | 335 | // 添加响应方式 336 | [actionSheetController addAction:createFolderAction]; 337 | [actionSheetController addAction:createFileAction]; 338 | [actionSheetController addAction:addFileAction]; 339 | [actionSheetController addAction:downloadFileAction]; 340 | [actionSheetController addAction:searchAction]; 341 | [actionSheetController addAction:cancelAction]; 342 | 343 | // 显示 344 | [self presentViewController:actionSheetController animated:YES completion:nil]; 345 | } 346 | 347 | - (void)cellLongPress:(UILongPressGestureRecognizer *)longRecognizer 348 | { 349 | if (longRecognizer.state == UIGestureRecognizerStateBegan) { 350 | 351 | CGPoint location = [longRecognizer locationInView:self.tv]; 352 | _longPressIndexPath = [self.tv indexPathForRowAtPoint:location]; 353 | UITableViewCell *cell = [self.tv cellForRowAtIndexPath:_longPressIndexPath]; 354 | _longPressFile = self.files[_longPressIndexPath.row]; 355 | 356 | 357 | [self becomeFirstResponder]; 358 | UIMenuController *menuController = [UIMenuController sharedMenuController]; 359 | //控制箭头方向 360 | menuController.arrowDirection = UIMenuControllerArrowDefault; 361 | //自定义事件 362 | UIMenuItem *renameItem = [[UIMenuItem alloc] initWithTitle:@"重命名" action:@selector(rename:)]; 363 | UIMenuItem *moveItem = [[UIMenuItem alloc] initWithTitle:@"移动" action:@selector(moveFile)]; 364 | UIMenuItem *copyItem = [[UIMenuItem alloc] initWithTitle:@"复制" action:@selector(copyFile)]; 365 | 366 | NSArray *menuItemArray = [NSArray arrayWithObjects:renameItem, moveItem, copyItem, nil]; 367 | [menuController setMenuItems:menuItemArray]; 368 | [menuController setTargetRect:cell.frame inView:self.tv]; 369 | [menuController setMenuVisible:YES animated:YES]; 370 | 371 | 372 | 373 | } 374 | } 375 | 376 | // 重命名 377 | - (void)rename:(UIMenuController *)menu 378 | { 379 | UIAlertController *actionAlertController = [UIAlertController alertControllerWithTitle:@"重命名" message:nil preferredStyle:UIAlertControllerStyleAlert]; 380 | 381 | UIAlertAction *cancleAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil]; 382 | 383 | UIAlertAction *defaultAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { 384 | if ([self.fileManager renameFileWithPath:self.homePath oldName:_longPressFile.name newName:[[[actionAlertController textFields] firstObject] text]]) { // 成功 385 | [self getAllFile]; // 获取数据 386 | } else { 387 | NSLog(@"失败"); 388 | } 389 | }]; 390 | 391 | [actionAlertController addAction:cancleAction]; 392 | [actionAlertController addAction:defaultAction]; 393 | 394 | [actionAlertController addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) { 395 | textField.text = _longPressFile.name; 396 | }]; 397 | 398 | [self presentViewController:actionAlertController animated:YES completion:nil]; 399 | } 400 | 401 | // 复制 402 | - (void)copyFile 403 | { 404 | ELFileModel *directoryFile; 405 | for (ELFileModel *file in self.files) { // 获取一个临时的最前的文件夹 406 | if (file.fileType == ELFileTypeDirectory) { 407 | directoryFile = file; 408 | } 409 | } 410 | if ([self.fileManager copyFile:_longPressFile.filePath toNewPath:directoryFile.filePath]) { 411 | [self getAllFile]; 412 | NSLog(@"复制成功"); 413 | } else { 414 | NSLog(@"复制失败"); 415 | } 416 | } 417 | 418 | // 移动 419 | - (void)moveFile 420 | { 421 | ELFileModel *directoryFile; 422 | for (ELFileModel *file in self.files) { // 获取一个临时的最前的文件夹 423 | if (file.fileType == ELFileTypeDirectory) { 424 | directoryFile = file; 425 | } 426 | } 427 | if ([self.fileManager moveFile:_longPressFile.filePath toNewPath:directoryFile.filePath]) { 428 | [self getAllFile]; 429 | NSLog(@"移动成功"); 430 | } else { 431 | NSLog(@"移动失败"); 432 | } 433 | } 434 | 435 | #pragma mark - lazy 436 | - (NSMutableArray *)files 437 | { 438 | if (!_files) { 439 | _files = [NSMutableArray array]; 440 | } 441 | return _files; 442 | } 443 | @end 444 | 445 | -------------------------------------------------------------------------------- /ELFileManagerDemo/ELUploadFileViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ELUploadFileViewController.h 3 | // FileManagerDemo 4 | // 5 | // Created by easylink on 2017/11/16. 6 | // Copyright © 2017年 YuQi. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | typedef void (^UploadFileBlock)(NSArray *fileArray); 12 | 13 | @interface ELUploadFileViewController : UIViewController 14 | - (instancetype)initWithPath:(NSString *)path maxCount:(NSInteger)maxCount uploadBlock:(UploadFileBlock)uploadBlock; 15 | @end 16 | 17 | -------------------------------------------------------------------------------- /ELFileManagerDemo/ELUploadFileViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ELFileChooserViewController.m 3 | // ELMoblieProject 4 | // 5 | // Created by easylink on 2017/11/16. 6 | // Copyright © 2017年 俞琦. All rights reserved. 7 | // 8 | 9 | #import "ELUploadFileViewController.h" 10 | #import "ELFileManager.h" 11 | #import "ELFileModel.h" 12 | #import "ELFileDetailViewController.h" 13 | 14 | @interface ELSelectedFileManager : NSObject 15 | @property (nonatomic, strong) NSMutableArray * selectedFileArray; 16 | @property (nonatomic, assign) NSInteger maxCount; 17 | @property (nonatomic, assign) NSInteger selectedFileCount; 18 | @end 19 | 20 | @implementation ELSelectedFileManager 21 | static id instance = nil; 22 | + (instancetype)shareManager 23 | { 24 | @synchronized(self) { 25 | if (!instance) { 26 | instance = [[self alloc] init]; 27 | } 28 | return instance; 29 | } 30 | } 31 | 32 | + (instancetype)allocWithZone:(struct _NSZone *)zone 33 | { 34 | @synchronized(self) { 35 | if (!instance) { 36 | instance = [super allocWithZone:zone]; 37 | } 38 | return instance; 39 | } 40 | } 41 | 42 | - (instancetype)copyWithZone:(NSZone *)zone 43 | { 44 | return self; 45 | } 46 | 47 | // 添加文件 成功返回YES 48 | - (BOOL)addFile:(ELFileModel *)file 49 | { 50 | if ([self isFileContain:file]) { // 51 | return NO; 52 | } else { 53 | [self.selectedFileArray addObject:file]; 54 | return YES; 55 | } 56 | } 57 | 58 | - (BOOL)removeFile:(ELFileModel *)file 59 | { 60 | BOOL isRemove = NO; 61 | for (int i = 0; i < self.selectedFileArray.count; i ++) { 62 | ELFileModel *aFile = self.selectedFileArray[i]; 63 | if ([aFile.filePath isEqualToString:file.filePath]) { // 存在 64 | [self.selectedFileArray removeObject:aFile]; 65 | isRemove = YES; 66 | break; 67 | } 68 | } 69 | return isRemove; 70 | } 71 | 72 | - (BOOL)isFileContain:(ELFileModel *)file 73 | { 74 | BOOL isExists = NO; 75 | for (int i = 0; i < self.selectedFileArray.count; i ++) { 76 | ELFileModel *aFile = self.selectedFileArray[i]; 77 | if ([aFile.filePath isEqualToString:file.filePath]) { // 存在 78 | isExists = YES; 79 | break; 80 | } 81 | } 82 | return isExists; 83 | } 84 | 85 | - (BOOL)isFull 86 | { 87 | if (self.selectedFileArray.count >= self.maxCount) { 88 | return YES; 89 | } else { 90 | return NO; 91 | } 92 | } 93 | 94 | - (NSInteger)selectedFileCount 95 | { 96 | return self.selectedFileArray.count; 97 | } 98 | 99 | - (NSMutableArray *)selectedFileArray 100 | { 101 | if (!_selectedFileArray) { 102 | _selectedFileArray = [NSMutableArray array]; 103 | } 104 | return _selectedFileArray; 105 | } 106 | 107 | - (void)emptySelectedArray 108 | { 109 | [self.selectedFileArray removeAllObjects]; 110 | } 111 | @end 112 | 113 | 114 | 115 | @interface ELUploadFileViewController () 116 | @property (nonatomic, copy) UploadFileBlock uploadBlock; 117 | @property (nonatomic, assign) NSInteger maxCount; 118 | 119 | @property (nonatomic, strong) ELFileManager * fileManager; 120 | @property (nonatomic, weak) UITableView * tableView; 121 | @property (nonatomic, copy) NSString * homePath; 122 | @property (nonatomic, strong) NSMutableArray *files; 123 | @property (nonatomic, weak) UIButton *uploadBtn; 124 | @end 125 | 126 | @implementation ELUploadFileViewController 127 | - (instancetype)initWithPath:(NSString *)path maxCount:(NSInteger)maxCount uploadBlock:(UploadFileBlock)uploadBlock 128 | { 129 | if (self = [super init]) { 130 | self.homePath = path; 131 | if ([ELSelectedFileManager shareManager].maxCount == 0) { 132 | [ELSelectedFileManager shareManager].maxCount = maxCount; 133 | } 134 | self.maxCount = maxCount; 135 | self.uploadBlock = uploadBlock; 136 | } 137 | return self; 138 | } 139 | 140 | - (void)viewDidLoad 141 | { 142 | [super viewDidLoad]; 143 | 144 | if (![self.fileManager fileExistsAtPath:self.homePath]) { 145 | [self.fileManager createFolderToFullPath:self.homePath]; 146 | } 147 | ELFileModel *floder = [self.fileManager getFileWithPath:self.homePath]; 148 | self.title = floder.name; 149 | 150 | [self initViews]; 151 | } 152 | 153 | #pragma mark - 私有方法 154 | - (void)initViews 155 | { 156 | self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"取消" style:UIBarButtonItemStyleDone target:self action:@selector(cancel)]; 157 | 158 | UITableView *tv = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height - 50) style:UITableViewStyleGrouped]; 159 | tv.delegate = self; 160 | tv.dataSource = self; 161 | [self.view addSubview:tv]; 162 | self.tableView = tv; 163 | 164 | // 添加上传按钮 165 | UIButton *uploadBtn = [[UIButton alloc] init]; 166 | uploadBtn.frame = CGRectMake(0, self.view.bounds.size.height - 50, self.view.bounds.size.width, 50); 167 | uploadBtn.backgroundColor = [UIColor colorWithRed:43/255.0 green:173/255.0 blue:158/255.0 alpha:1.0]; 168 | [uploadBtn setTitle:@"上 传" forState:UIControlStateNormal]; 169 | [uploadBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; 170 | uploadBtn.titleLabel.font = [UIFont boldSystemFontOfSize:19]; 171 | [uploadBtn addTarget:self action:@selector(uploadBtnDidClick:) forControlEvents:UIControlEventTouchUpInside]; 172 | [self.view addSubview:uploadBtn]; 173 | self.uploadBtn = uploadBtn; 174 | 175 | [self reloadUploadBtnStr]; 176 | } 177 | 178 | - (void)alertWithString:(NSString *)str 179 | { 180 | UIAlertController *alertC = [UIAlertController alertControllerWithTitle:@"温馨提示" message:str preferredStyle:UIAlertControllerStyleAlert]; 181 | UIAlertAction *action = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:nil]; 182 | [alertC addAction:action]; 183 | [self presentViewController:alertC animated:YES completion:nil]; 184 | } 185 | 186 | - (void)uploadBtnDidClick:(UIButton *)sender 187 | { 188 | NSArray *selectedFileArray = [ELSelectedFileManager shareManager].selectedFileArray; 189 | if (self.uploadBlock) { 190 | self.uploadBlock(selectedFileArray); 191 | } 192 | [[ELSelectedFileManager shareManager] emptySelectedArray]; 193 | [self dismissViewControllerAnimated:YES completion:nil]; 194 | } 195 | 196 | - (void)reloadUploadBtnStr 197 | { 198 | NSString *uploadBtnStr; 199 | if ([ELSelectedFileManager shareManager].selectedFileCount == 0) { 200 | uploadBtnStr = @"上传"; 201 | self.uploadBtn.backgroundColor = [UIColor grayColor]; 202 | self.uploadBtn.enabled = NO; 203 | } else { 204 | uploadBtnStr = [NSString stringWithFormat:@"上传(%ld)", [ELSelectedFileManager shareManager].selectedFileCount]; 205 | self.uploadBtn.backgroundColor = [UIColor colorWithRed:43/255.0 green:173/255.0 blue:158/255.0 alpha:1.0]; 206 | self.uploadBtn.enabled = YES; 207 | } 208 | [self.uploadBtn setTitle:uploadBtnStr forState:UIControlStateNormal]; 209 | } 210 | 211 | - (void)seleteBtnDidClick:(UIButton *)sender 212 | { 213 | int index = sender.tag%1000; 214 | ELFileModel *file = self.files[index]; 215 | if (sender.selected == YES) { // 已经选中 216 | [[ELSelectedFileManager shareManager] removeFile:file]; 217 | } else { 218 | if ([[ELSelectedFileManager shareManager] isFull]) { 219 | [self alertWithString:[NSString stringWithFormat:@"最多只能选择%ld个文件", [ELSelectedFileManager shareManager].maxCount]]; 220 | return; 221 | } 222 | [[ELSelectedFileManager shareManager] addFile:file]; 223 | } 224 | 225 | [self reloadUploadBtnStr]; 226 | 227 | sender.selected = !sender.selected; 228 | } 229 | 230 | - (void)cancel 231 | { 232 | [self dismissViewControllerAnimated:YES completion:^{ 233 | 234 | }]; 235 | } 236 | 237 | #pragma mark - UITableViewDelegate, UITableViewDataSource 238 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 239 | { 240 | return self.files.count; 241 | } 242 | 243 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 244 | { 245 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"]; 246 | if (!cell) { 247 | cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"cell"]; 248 | } 249 | ELFileModel *file = self.files[indexPath.row]; 250 | cell.textLabel.text = file.name; 251 | UIImage *cellImage; 252 | if (file.fileType == ELFileTypeDirectory) { // 文件夹 253 | cell.detailTextLabel.text = [NSString stringWithFormat:@"文件夹: %@ %@", file.creatTime, file.fileSize]; 254 | cellImage = [UIImage imageNamed:@"file_floder"]; 255 | cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; 256 | cell.accessoryView = nil; 257 | } else { 258 | 259 | switch (file.fileType) { 260 | case ELFileTypeImage: 261 | { 262 | cell.detailTextLabel.text = [NSString stringWithFormat:@"图片: %@ %@", file.creatTime, file.fileSize]; 263 | cellImage = [UIImage imageWithContentsOfFile:file.filePath]; 264 | } 265 | break; 266 | case ELFileTypeTxt: 267 | { 268 | cell.detailTextLabel.text = [NSString stringWithFormat:@"文档: %@ %@", file.creatTime, file.fileSize]; 269 | cellImage = [UIImage imageNamed:@"file_txt"]; 270 | } 271 | break; 272 | case ELFileTypeVoice: 273 | { 274 | cell.detailTextLabel.text = [NSString stringWithFormat:@"音乐: %@ %@", file.creatTime, file.fileSize]; 275 | cellImage = [UIImage imageNamed:@"file_mp3"]; 276 | } 277 | break; 278 | case ELFileTypeAudioVidio: 279 | { 280 | cell.detailTextLabel.text = [NSString stringWithFormat:@"视频: %@ %@", file.creatTime, file.fileSize]; 281 | cellImage = [UIImage imageNamed:@"file_avi"]; 282 | } 283 | break; 284 | case ELFileTypeApplication: 285 | { 286 | cell.detailTextLabel.text = [NSString stringWithFormat:@"应用: %@ %@", file.creatTime, file.fileSize]; 287 | cellImage = [UIImage imageNamed:@"file_ipa"]; 288 | } 289 | break; 290 | case ELFileTypeUnknown: 291 | { 292 | cell.detailTextLabel.text = [NSString stringWithFormat:@"未知文件: %@ %@", file.creatTime, file.fileSize]; 293 | cellImage = [UIImage imageNamed:@"file_webView_error"]; 294 | } 295 | break; 296 | case ELFileTypeWord: 297 | { 298 | cell.detailTextLabel.text = [NSString stringWithFormat:@"word: %@ %@", file.creatTime, file.fileSize]; 299 | cellImage = [UIImage imageNamed:@"file_word"]; 300 | } 301 | break; 302 | case ELFileTypePDF: 303 | { 304 | cell.detailTextLabel.text = [NSString stringWithFormat:@"pdf: %@ %@", file.creatTime, file.fileSize]; 305 | cellImage = [UIImage imageNamed:@"file_pdf"]; 306 | } 307 | break; 308 | case ELFileTypePPT: 309 | { 310 | cell.detailTextLabel.text = [NSString stringWithFormat:@"ppt: %@ %@", file.creatTime, file.fileSize]; 311 | cellImage = [UIImage imageNamed:@"file_ppt"]; 312 | } 313 | break; 314 | case ELFileTypeXLS: 315 | { 316 | cell.detailTextLabel.text = [NSString stringWithFormat:@"xls: %@ %@", file.creatTime, file.fileSize]; 317 | cellImage = [UIImage imageNamed:@"file_excel"]; 318 | } 319 | break; 320 | default: 321 | break; 322 | } 323 | 324 | // 除了文件夹,其他设置选择按钮 325 | UIButton *seleteBtn = [[UIButton alloc] init]; 326 | seleteBtn.tag = [NSString stringWithFormat:@"1000%ld", indexPath.row].intValue; 327 | [seleteBtn setImage:[UIImage imageNamed:@"filemanager_cell_unselected"] forState:UIControlStateNormal]; 328 | [seleteBtn setImage:[UIImage imageNamed:@"filemanager_cell_selected"] forState:UIControlStateSelected]; 329 | seleteBtn.frame = CGRectMake(0, 0, 40, 40); 330 | [seleteBtn addTarget:self action:@selector(seleteBtnDidClick:) forControlEvents:UIControlEventTouchUpInside]; 331 | cell.accessoryView = seleteBtn; 332 | 333 | if ([[ELSelectedFileManager shareManager] isFileContain:file]) { 334 | seleteBtn.selected = YES; 335 | } else { 336 | seleteBtn.selected = NO; 337 | } 338 | 339 | } 340 | 341 | // 设置cell图片大小 342 | CGSize imageSize = CGSizeMake(40, 40); 343 | UIGraphicsBeginImageContextWithOptions(imageSize, NO, 0.0); 344 | CGRect imageRect = CGRectMake(0.0, 0.0, imageSize.width, imageSize.height); 345 | [cellImage drawInRect:imageRect]; 346 | cell.imageView.image = UIGraphicsGetImageFromCurrentImageContext(); 347 | UIGraphicsEndImageContext(); 348 | 349 | return cell; 350 | } 351 | 352 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 353 | { 354 | ELFileModel *file = self.files[indexPath.row]; 355 | if (file.fileType == ELFileTypeDirectory) { // 文件夹 356 | ELUploadFileViewController *vc = [[ELUploadFileViewController alloc] initWithPath:file.filePath maxCount:[ELSelectedFileManager shareManager].maxCount - [ELSelectedFileManager shareManager].selectedFileCount uploadBlock:self.uploadBlock]; 357 | [self.navigationController pushViewController:vc animated:YES]; 358 | } else { 359 | ELFileDetailViewController *fileDetail = [[ELFileDetailViewController alloc] initWithFileModel:file]; 360 | [self.navigationController pushViewController:fileDetail animated:YES]; 361 | } 362 | 363 | } 364 | 365 | - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath 366 | { 367 | return 50; 368 | } 369 | 370 | - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section 371 | { 372 | return [[UIView alloc] init]; 373 | } 374 | 375 | - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section 376 | { 377 | return 0.01; 378 | } 379 | 380 | - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section 381 | { 382 | return [[UIView alloc] init]; 383 | } 384 | 385 | - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section 386 | { 387 | return 0.01; 388 | } 389 | 390 | #pragma mark - lazy 391 | - (ELFileManager *)fileManager 392 | { 393 | if (!_fileManager) { 394 | _fileManager = [ELFileManager shareManager]; 395 | } 396 | return _fileManager; 397 | } 398 | 399 | - (NSMutableArray *)files 400 | { 401 | if (!_files) { 402 | _files = [NSMutableArray arrayWithArray:[self.fileManager getAllFileWithPath:self.homePath]]; 403 | } 404 | return _files; 405 | } 406 | 407 | @end 408 | 409 | -------------------------------------------------------------------------------- /ELFileManagerDemo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIRequiredDeviceCapabilities 26 | 27 | armv7 28 | 29 | UISupportedInterfaceOrientations 30 | 31 | UIInterfaceOrientationPortrait 32 | UIInterfaceOrientationLandscapeLeft 33 | UIInterfaceOrientationLandscapeRight 34 | 35 | UISupportedInterfaceOrientations~ipad 36 | 37 | UIInterfaceOrientationPortrait 38 | UIInterfaceOrientationPortraitUpsideDown 39 | UIInterfaceOrientationLandscapeLeft 40 | UIInterfaceOrientationLandscapeRight 41 | 42 | NSAppTransportSecurity 43 | 44 | NSAllowsArbitraryLoads 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /ELFileManagerDemo/MainViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // MainViewController.h 3 | // ELFileManagerDemo 4 | // 5 | // Created by easylink on 2017/11/23. 6 | // Copyright © 2017年 俞琦. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface MainViewController : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /ELFileManagerDemo/MainViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // MainViewController.m 3 | // ELFileManagerDemo 4 | // 5 | // Created by easylink on 2017/11/23. 6 | // Copyright © 2017年 俞琦. All rights reserved. 7 | // 8 | 9 | #import "MainViewController.h" 10 | #import "ELMoreViewController.h" 11 | #import "ELUploadFileViewController.h" 12 | #import "ELFileModel.h" 13 | #import "ELFileBrowseViewController.h" 14 | #import "ELGetAlllFileInDeepSearchViewController.h" 15 | 16 | @interface MainViewController () 17 | @property (nonatomic, strong) NSArray * lists; 18 | @end 19 | 20 | @implementation MainViewController 21 | 22 | - (void)viewDidLoad { 23 | [super viewDidLoad]; 24 | // Do any additional setup after loading the view. 25 | self.title = @"Mian"; 26 | self.lists = @[@"上传控制器 路径:document/2333", @"文件浏览器 路径:document/2333", @"获取所有文件(没有文件夹)路径:document/2333", @"更多操作 路径:cache/ELFileCache"]; 27 | 28 | UITableView *tv = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain]; 29 | tv.delegate = self; 30 | tv.dataSource = self; 31 | [self.view addSubview:tv]; 32 | 33 | } 34 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 35 | { 36 | return self.lists.count; 37 | } 38 | 39 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 40 | { 41 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"]; 42 | if (!cell) { 43 | cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"cell"]; 44 | } 45 | cell.textLabel.text = self.lists[indexPath.row]; 46 | return cell; 47 | } 48 | 49 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 50 | { 51 | NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 52 | NSString *docDir = [paths objectAtIndex:0]; 53 | NSString *path = [docDir stringByAppendingPathComponent:@"2333"]; 54 | 55 | if (indexPath.row == 0) { 56 | ELUploadFileViewController *upload = [[ELUploadFileViewController alloc] initWithPath:path maxCount:1 uploadBlock:^(NSArray *fileArray) { 57 | for (ELFileModel *model in fileArray) { 58 | NSLog(@"%@", model.name); 59 | } 60 | }]; 61 | [self.navigationController pushViewController:upload animated:YES]; 62 | } else if (indexPath.row == 1) { 63 | ELFileBrowseViewController *fileBrowse = [[ELFileBrowseViewController alloc] initWithPath:path]; 64 | [self.navigationController pushViewController:fileBrowse animated:YES]; 65 | } else if (indexPath.row == 2) { 66 | ELGetAlllFileInDeepSearchViewController *allfile = [[ELGetAlllFileInDeepSearchViewController alloc] initWithPath:path]; 67 | [self.navigationController pushViewController:allfile animated:YES]; 68 | } else if (indexPath.row == 3) { 69 | ELMoreViewController *vc = [[ELMoreViewController alloc] init]; 70 | [self.navigationController pushViewController:vc animated:YES]; 71 | } 72 | } 73 | 74 | @end 75 | -------------------------------------------------------------------------------- /ELFileManagerDemo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // ELFileManagerDemo 4 | // 5 | // Created by 俞琦 on 2017/10/13. 6 | // Copyright © 2017年 俞琦. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /ELFileManagerDemoTests/ELFileManagerDemoTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // ELFileManagerDemoTests.m 3 | // ELFileManagerDemoTests 4 | // 5 | // Created by 俞琦 on 2017/10/13. 6 | // Copyright © 2017年 俞琦. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ELFileManagerDemoTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation ELFileManagerDemoTests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | // Put setup code here. This method is called before the invocation of each test method in the class. 20 | } 21 | 22 | - (void)tearDown { 23 | // Put teardown code here. This method is called after the invocation of each test method in the class. 24 | [super tearDown]; 25 | } 26 | 27 | - (void)testExample { 28 | // This is an example of a functional test case. 29 | // Use XCTAssert and related functions to verify your tests produce the correct results. 30 | } 31 | 32 | - (void)testPerformanceExample { 33 | // This is an example of a performance test case. 34 | [self measureBlock:^{ 35 | // Put the code you want to measure the time of here. 36 | }]; 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /ELFileManagerDemoTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /ELFileManagerDemoUITests/ELFileManagerDemoUITests.m: -------------------------------------------------------------------------------- 1 | // 2 | // ELFileManagerDemoUITests.m 3 | // ELFileManagerDemoUITests 4 | // 5 | // Created by 俞琦 on 2017/10/13. 6 | // Copyright © 2017年 俞琦. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ELFileManagerDemoUITests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation ELFileManagerDemoUITests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | 22 | // In UI tests it is usually best to stop immediately when a failure occurs. 23 | self.continueAfterFailure = NO; 24 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 25 | [[[XCUIApplication alloc] init] launch]; 26 | 27 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 28 | } 29 | 30 | - (void)tearDown { 31 | // Put teardown code here. This method is called after the invocation of each test method in the class. 32 | [super tearDown]; 33 | } 34 | 35 | - (void)testExample { 36 | // Use recording to get started writing UI tests. 37 | // Use XCTAssert and related functions to verify your tests produce the correct results. 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /ELFileManagerDemoUITests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ELFileManager 2 | 文件管理器以及UI层使用浏览器 3 | 4 | # 文章地址 5 | [自造小轮子:文件管理工具及UI层文件浏览器](http://www.jianshu.com/p/3894413a5bd6) 6 | 7 | # 正文 8 | ### 总目录界面 9 | ![总目录UI对应文件示例.png](http://upload-images.jianshu.io/upload_images/2312304-8d07fe509054cd1f.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 10 | 11 | 大致说一下思路,在``Cache``目录下找到``ELFileCache``文件夹,如果没有就创建一个,然后接下来的文件处理都会放在这个文件夹中。 12 | 13 | ### a.获取所有文件 14 | 封装方法: 15 | ``` 16 | /** 17 | 获取到当前路径下的所有文件(包括文件夹) 18 | 19 | @param path 文件夹路径 20 | @return 返回 ELFileModel 对象数组 21 | */ 22 | - (NSArray *)getAllFileWithPath:(NSString *)path; 23 | ``` 24 | 使用方法: 25 | ``` 26 | - (void)getAllFile 27 | { 28 | self.fileManager = [ELFileManager shareManager]; 29 | self.files = [NSMutableArray arrayWithArray:[self.fileManager getAllFileWithPath:self.homePath]]; 30 | dispatch_async(dispatch_get_main_queue(), ^{ 31 | [self.tv reloadData]; 32 | }); 33 | } 34 | ``` 35 | ### b.新建文件夹 36 | 37 | ![新建文件夹.gif](http://upload-images.jianshu.io/upload_images/2312304-e5461db7d52f8435.gif?imageMogr2/auto-orient/strip) 38 | ``` 39 | /** 40 | 新建一个文件夹 41 | 42 | @param path 文件所在的文件夹路径 43 | @param name 文件夹名称 44 | @return 返回 成功与否 45 | */ 46 | - (BOOL)createFolderToPath:(NSString *)path folderName:(NSString *)name; 47 | ``` 48 | ``` 49 | int num = arc4random() % 100; 50 | NSString *name = [NSString stringWithFormat:@"新建的文件夹--%d", num]; 51 | if ([self.fileManager createFolderToPath:self.homePath folderName:name]) { 52 | [self getAllFile]; 53 | } else { 54 | NSLog(@"创建失败"); 55 | } 56 | ``` 57 | ### c.新建文件 58 | 59 | ![新建文件.gif](http://upload-images.jianshu.io/upload_images/2312304-9e6164d1a4cf366c.gif?imageMogr2/auto-orient/strip) 60 | 61 | ``` 62 | /** 63 | 新建一个文件到指定目录 64 | 65 | @param path 文件所在的文件夹路径 66 | @param name 文件名称 67 | @return 返回 成功与否 68 | */ 69 | - (BOOL)createFileToPath:(NSString *)path fileName:(NSString *)name; 70 | ``` 71 | ``` 72 | if ([self.fileManager createFileToPath:self.homePath fileName:@"hello.api"]) { 73 | [self getAllFile]; 74 | } else { 75 | NSLog(@"创建失败"); 76 | } 77 | ``` 78 | 79 | ### d.下载文件(边下边写) 80 | 81 | ![下载文件.gif](http://upload-images.jianshu.io/upload_images/2312304-e7be11a13a225fcb.gif?imageMogr2/auto-orient/strip) 82 | 83 | 内部使用的是``NSFileHandle``类实现。 84 | 封装方法: 85 | ``` 86 | /** 87 | 往文件里追加内容 88 | 89 | @param contentData 追加的内容 90 | @param filePath 文件路径 91 | */ 92 | - (void)seriesWriteContent:(NSData *)contentData intoHandleFile:(NSString *)filePath; 93 | ``` 94 | 使用方法: 95 | ``` 96 | // 下载任务开启 97 | NSURLSession *session = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration] delegate:self delegateQueue:[[NSOperationQueue alloc] init]]; 98 | NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:[NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://120.25.226.186:32812/resources/videos/minion_02.mp4"]]]; 99 | [dataTask resume]; 100 | 101 | // 在代理方法中使用 102 | - (void)URLSession:(NSURLSession *)session dataTask:(NSURLSessionDataTask *)dataTask didReceiveData:(NSData *)data 103 | { 104 | 105 | NSString* filePath = [self.homePath stringByAppendingPathComponent:_downloadFileName]; 106 | [self.fileManager seriesWriteContent:data intoHandleFile:filePath]; // 写入 107 | _currentLen += data.length; 108 | double progress = (double)_currentLen / _totolLen; 109 | dispatch_async(dispatch_get_main_queue(), ^{ 110 | self.progress.progress = progress; 111 | }); 112 | } 113 | ``` 114 | ### d.搜索 115 | ![搜索.gif](http://upload-images.jianshu.io/upload_images/2312304-3826b0b07f577191.gif?imageMogr2/auto-orient/strip) 116 | 117 | ``` 118 | /** 119 | 搜索表面的文件(不会搜索当前文件夹里的文件夹内文件。。) 120 | 121 | @param searchText 搜索的文字 122 | @param folderPath 搜索的文件夹路径 123 | @return 返回 ELFileModel 对象数组 124 | */ 125 | - (NSArray *)searchSurfaceFile:(NSString *)searchText folderPath:(NSString *)folderPath; 126 | 127 | 128 | 129 | /** 130 | 搜索深度的文件 (会把当前文件夹里的所有文件都查一遍 包括文件夹里的文件夹) 131 | 132 | @param searchText 搜索的文字 133 | @param folderPath 搜索的文件夹路径 134 | @return 返回 ELFileModel 对象数组 135 | */ 136 | - (NSArray *)searchDeepFile:(NSString *)searchText folderPath:(NSString *)folderPath; 137 | ``` 138 | ``` 139 | NSArray *resFiles = [self.fileManager searchDeepFile:@"的" folderPath:self.homePath]; 140 | for (ELFileModel *file in resFiles) { 141 | NSLog(@"%@", file.name); 142 | } 143 | ``` 144 | 搜索功能分了深度搜索和表面搜索。深度搜索能搜索到文件夹内部的内容。 145 | ### e.更多功能 146 | 147 | ![更多功能.gif](http://upload-images.jianshu.io/upload_images/2312304-4c645b26ff103360.gif?imageMogr2/auto-orient/strip) 148 | 149 | ## ``ELFileModel``类 150 | ``` 151 | typedef NS_ENUM(NSInteger, ELFileType) { 152 | 153 | ELFileTypeUnknown = -1, //其他 154 | 155 | ELFileTypeAll = 0, //所有 156 | 157 | ELFileTypeImage = 1, //图片 158 | 159 | ELFileTypeTxt = 2, //文档 160 | 161 | ELFileTypeVoice = 3, //音乐 162 | 163 | ELFileTypeAudioVidio = 4, //视频 164 | 165 | ELFileTypeApplication = 5, //应用 166 | 167 | ELFileTypeDirectory = 6, //目录 168 | 169 | ELFileTypePDF = 7, //PDF 170 | 171 | ELFileTypePPT = 8, //PPT 172 | 173 | ELFileTypeWord = 9, //Word 174 | 175 | ELFileTypeXLS = 10, //XLS 176 | }; 177 | 178 | @interface ELFileModel : NSObject 179 | //文件路径 180 | @property (copy, nonatomic) NSString *filePath; ///< 全路径 181 | //文件URL 182 | @property (copy, nonatomic) NSString *fileUrl; 183 | 184 | @property (copy, nonatomic) NSString *name; ///< 文件名称 185 | 186 | @property (copy, nonatomic) NSString *fileSize; ///< 大小用字符表述 187 | 188 | @property (nonatomic, assign) float fileSizefloat; ///< 大小用float 189 | 190 | @property (copy, nonatomic) NSString *modTime; ///< 修改时间 191 | 192 | @property (copy, nonatomic) NSString *creatTime; ///< 修改时间 193 | 194 | @property (assign, nonatomic) ELFileType fileType; 195 | 196 | @property (nonatomic, strong) NSDictionary *attributes; ///<文件属性 197 | 198 | 199 | 200 | /** 201 | 初始化方法 202 | 203 | @param filePath 全路径 204 | @return 自身对象 205 | */ 206 | - (instancetype)initWithFilePath:(NSString *)filePath; 207 | ``` 208 | 文件类的所有属性如上,通过``- (instancetype)initWithFilePath:(NSString *)filePath;``方法初始化,就可获得完整的对象。其中文件类型的判断方法如下:(以图片类型为例子) 209 | ``` 210 | static const UInt8 IMAGES_TYPES_COUNT = 8; 211 | static const NSString *IMAGES_TYPES[IMAGES_TYPES_COUNT] = {@"png", @"PNG", @"jpg",@",JPG", @"jpeg", @"JPEG" ,@"gif", @"GIF"}; 212 | 213 | NSArray *imageTypesArray = [NSArray arrayWithObjects: IMAGES_TYPES count: IMAGES_TYPES_COUNT]; 214 | if ([imageTypesArray containsObject:pathExtension]) { 215 | return ELFileTypeImage; 216 | } 217 | ``` 218 | --------------------------------------------------------------------------------