Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork135
📱 📂 iOS file manager on top of NSFileManager for simplifying files management.
License
fabiocaccamo/FCFileManager
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
iOS File Manager on top of NSFileManager for simplifying files management. It provides many static methods for executing most common operations with few lines of code. It works by default in the Documents directory to allow use of relative paths, but it's possible to work easily on any other directory.
- iOS >= 5.0
- ARC enabled
pod 'FCFileManager'
CopyFCFileManager.h andFCFileManager.m to your project.
- Build paths relative to absolute directories(FCFileManager works by default in the Documents directory, so you must build absolute paths only if you need to work outside of the Documents directory)
- Copy files/directories
- Create files/directories
- Check if files/directoryexists
- Get files/directoriesattributes(creation date, size, ...)
- List files/directories
- Move files/directories
- Read/Write files content in different formats(arrays, custom models, data, dictionaries, images, json, strings, ... )
- Read/Write xattr(Extended File Attributes)
- Read images metadata,EXIF data,TIFF data
- Remove files/directories
- Rename files/directories
- Directories are created on the fly
- Error handling as using NSFileManager
SeeFCFileManager.h for all of the methods.
Build path:
//my file path, this will be automatically used as it's relative to the Documents directoryNSString *testPath =@"test.txt";//my file path relative to the temporary directory pathNSString *testPathTemp = [FCFileManagerpathForTemporaryDirectoryWithPath:testPath];/*All shortcuts suppported:pathForApplicationSupportDirectory;pathForCachesDirectory;pathForDocumentsDirectory;pathForLibraryDirectory;pathForMainBundleDirectory;pathForPlistNamed:(NSString *)name; //look for {{ name }}.plist in the main bundle directorypathForTemporaryDirectory;*/
Copy file:
//copy file from Documents directory (public) to ApplicationSupport directory (private)NSString *testPath = [FCFileManagerpathForApplicationSupportDirectoryWithPath:@"test-copy.txt"];[FCFileManagercopyItemAtPath:@"test.txt"toPath:testPath];
Create file:
//create file and write content to it (if it doesn't exist)[FCFileManagercreateFileAtPath:@"test.txt"withContent:@"File management has never been so easy!!!"];
Create directories:
//create directories tree for the given path (in this case in the Documents directory)[FCFileManagercreateDirectoriesForPath:@"/a/b/c/d/"];
Check if file exists:
//check if file exist and returns YES or NOBOOL testFileExists = [FCFileManagerexistsItemAtPath:@"test.txt"];
Move file:
//move file from a path to another and returns YES or NO[FCFileManagermoveItemAtPath:@"test.txt"toPath:@"tests/test.txt"];
Read file:
//read file from path and returns its content (NSString in this case)NSString *test = [FCFileManagerreadFileAtPath:@"test.txt"];
Read/Write xattr (Extended File Attributes):
//returns the string-value stored for the specified key, if the key doesn't exist returns nilNSString *value = [FCFileManagerxattrOfItemAtPath:@"test.txt"getValueForKey:"uploaded"];//set the specified string-value and returns a BOOL result of the operationBOOL success = [FCFileManagerxattrOfItemAtPath:@"test.txt"setValue:@"1"forKey:@"uploaded"];
Read image EXIF data:
//read image file from path and returns its EXIF dataNSDictionary *exifData = [FCFileManagerexifDataOfImageAtPath:@"test.jpg"];
Remove file:
//remove file at the specified path[FCFileManagerremoveItemAtPath:@"test.txt"];
Rename file:
//rename file at the specified path with the new name[FCFileManagerrenameItemAtPath:@"test.txt"withName:@"test-renamed.txt"];
Write file:
NSArray *testContent = [NSArrayarrayWithObjects:@"t",@"e",@"s",@"t",nil];//write file at the specified path with content[FCFileManagerwriteFileAtPath:@"test.txt"content:testContent];
Get file/directory size:
//get the file size in bytesNSNumber *fileSize = [FCFileManagersizeOfFileAtPath:@"test.txt"];//get the directory size in bytes (including all subdirectories and files inside it)NSNumber *directorySize = [FCFileManagersizeOfDirectoryAtPath:@"/a/"];
Get file/directory size formatted:
//returns a human-readable file size formatted with the necessary suffix: bytes, KB, MB, GB, TBNSString *fileSizeFormatted = [FCFileManagersizeFormattedOfFileAtPath:@"test.txt"];
Released underMIT License.
About
📱 📂 iOS file manager on top of NSFileManager for simplifying files management.
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Sponsor this project
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Contributors7
Uh oh!
There was an error while loading.Please reload this page.
