• Stars
    star
    899
  • Rank 50,796 (Top 1.0 %)
  • Language
    Objective-C
  • License
    MIT License
  • Created almost 11 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

๐Ÿ“ฑ ๐Ÿ“‚ iOS file manager on top of NSFileManager for simplifying files management.

FCFileManager Pod version Pod platforms Pod license

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.

Requirements

  • iOS >= 5.0
  • ARC enabled

Installation

CocoaPods:

pod 'FCFileManager'

Manual install:

Copy FCFileManager.h and FCFileManager.m to your project.

Features

  • 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/directory exists
  • Get files/directories attributes (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

See FCFileManager.h for all of the methods.

Usage examples

Build path:

//my file path, this will be automatically used as it's relative to the Documents directory
NSString *testPath = @"test.txt";
//my file path relative to the temporary directory path
NSString *testPathTemp = [FCFileManager pathForTemporaryDirectoryWithPath:testPath];

/*
All shortcuts suppported:

pathForApplicationSupportDirectory;
pathForCachesDirectory;
pathForDocumentsDirectory;
pathForLibraryDirectory;
pathForMainBundleDirectory;
pathForPlistNamed:(NSString *)name; //look for {{ name }}.plist in the main bundle directory
pathForTemporaryDirectory;
*/

Copy file:

//copy file from Documents directory (public) to ApplicationSupport directory (private)
NSString *testPath = [FCFileManager pathForApplicationSupportDirectoryWithPath:@"test-copy.txt"];
[FCFileManager copyItemAtPath:@"test.txt" toPath:testPath];

Create file:

//create file and write content to it (if it doesn't exist)
[FCFileManager createFileAtPath:@"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)
[FCFileManager createDirectoriesForPath:@"/a/b/c/d/"];

Check if file exists:

//check if file exist and returns YES or NO
BOOL testFileExists = [FCFileManager existsItemAtPath:@"test.txt"];

Move file:

//move file from a path to another and returns YES or NO
[FCFileManager moveItemAtPath:@"test.txt" toPath:@"tests/test.txt"];

Read file:

//read file from path and returns its content (NSString in this case)
NSString *test = [FCFileManager readFileAtPath:@"test.txt"];

Read/Write xattr (Extended File Attributes):

//returns the string-value stored for the specified key, if the key doesn't exist returns nil
NSString *value = [FCFileManager xattrOfItemAtPath:@"test.txt" getValueForKey:"uploaded"];

//set the specified string-value and returns a BOOL result of the operation
BOOL success = [FCFileManager xattrOfItemAtPath:@"test.txt" setValue:@"1" forKey:@"uploaded"];

Read image EXIF data:

//read image file from path and returns its EXIF data
NSDictionary *exifData = [FCFileManager exifDataOfImageAtPath:@"test.jpg"];

Remove file:

//remove file at the specified path
[FCFileManager removeItemAtPath:@"test.txt"];

Rename file:

//rename file at the specified path with the new name
[FCFileManager renameItemAtPath:@"test.txt" withName:@"test-renamed.txt"];

Write file:

NSArray *testContent = [NSArray arrayWithObjects:@"t", @"e", @"s", @"t", nil];

//write file at the specified path with content
[FCFileManager writeFileAtPath:@"test.txt" content:testContent];

Get file/directory size:

//get the file size in bytes
NSNumber *fileSize = [FCFileManager sizeOfFileAtPath:@"test.txt"];

//get the directory size in bytes (including all subdirectories and files inside it)
NSNumber *directorySize = [FCFileManager sizeOfDirectoryAtPath:@"/a/"];

Get file/directory size formatted:

//returns a human-readable file size formatted with the necessary suffix: bytes, KB, MB, GB, TB
NSString *fileSizeFormatted = [FCFileManager sizeFormattedOfFileAtPath:@"test.txt"];

Support development

Donate

License

Released under MIT License.

More Repositories

1

FCUUID

๐Ÿ“ฑ ๐Ÿ†” iOS UUID / Universally Unique Identifiers library as alternative to UDID and identifierForVendor.
Objective-C
1,574
star
2

django-admin-interface

๐Ÿฆธ โšก django's default admin interface with superpowers - customizable themes, popup windows replaced by modals and many other features.
CSS
1,546
star
3

python-benedict

๐Ÿ“˜ dict subclass with keylist/keypath support, built-in I/O operations (base64, csv, ini, json, pickle, plist, query-string, toml, xls, xml, yaml), s3 support and many utilities.
Python
1,111
star
4

django-colorfield

๐ŸŽจ color field for django models with a nice color-picker in the admin.
Python
519
star
5

django-treenode

๐ŸŒณ probably the best abstract model/admin for your tree based stuff.
Python
481
star
6

django-maintenance-mode

๐Ÿšง ๐Ÿ› ๏ธ shows a 503 error page when maintenance-mode is on.
Python
408
star
7

django-extra-settings

โš™๏ธ config and manage typed extra settings using just the django admin.
Python
359
star
8

FCCurrentLocationGeocoder

๐Ÿ“ฑ ๐Ÿ“ iOS geocoder for forward / reverse geocode user's current location using a block-based syntax.
Objective-C
262
star
9

python-fsutil

๐Ÿ’ป ๐Ÿ”ง high-level file-system operations for lazy devs.
Python
147
star
10

FCIPAddressGeocoder

๐Ÿ“ฑ ๐ŸŒ iOS geocoder for geocode device IP Address location using GeoIP service(s) and a block-based syntax.
Objective-C
114
star
11

django-freeze

๐ŸงŠ convert your dynamic django site to a static one with one line of code.
Python
89
star
12

python-codicefiscale

๐Ÿ‡ฎ๐Ÿ‡น ๐Ÿ’ณ italian fiscal codes encoding, decoding and validation - codifica, decodifica e validazione del Codice Fiscale italiano.
Python
62
star
13

django-redirects

โ†ช๏ธ โœ… redirects as they should be, with full control.
Python
55
star
14

python-fontbro

๐Ÿงข friendly font operations on top of fontTools.
Python
41
star
15

utils.js

๐Ÿ‘ท ๐Ÿ”ง zero dependencies vanilla JavaScript utils.
JavaScript
18
star
16

create-matrix-action

๐Ÿงช ๐Ÿ’ฅ GitHub action that creates a non-square matrix parsing a readable config.
Python
9
star
17

layers.css

๐Ÿ“‘ pure (s)css independent stacked layers, no js at all.
CSS
8
star
18

wall.css

๐Ÿงฑ pure (s)css block-grid implementation with extra features.
SCSS
8
star
19

FCMapsApp

๐Ÿ“ฑ ๐Ÿ—บ๏ธ iOS utility for launching external maps applications (Apple Maps, Google Maps, Waze, Yandex Maps), showing locations and getting directions.
Objective-C
7
star
20

FCUtils

๐Ÿ“ฑ ๐Ÿ”ง iOS utilities collection.
Objective-C
6
star
21

python-imageutil

๐ŸŽฉ ๐Ÿช„ high-level image operations, with a bit of magic. ๐Ÿฐ
Python
5
star
22

django-cache-cleaner

๐Ÿงนโœจ clear the entire cache or individual caches easily using the admin panel or management command.
Python
2
star
23

xhrm.js

JavaScript XMLHttpRequest manager built on top of jQuery $.ajax.
JavaScript
2
star
24

tabbo.js

๐Ÿซ โŒจ๏ธ enhanced keyboard tabbing usability on any website / webapp with one line of code.
JavaScript
1
star