Giter VIP home page Giter VIP logo

janak-nirmal / fcfilemanager Goto Github PK

View Code? Open in Web Editor NEW

This project forked from fabiocaccamo/fcfilemanager

0.0 2.0 0.0 72 KB

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.

License: The Unlicense

fcfilemanager's Introduction

FCFileManager

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.

#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
  • Create files
  • Check if files exist
  • List files (filtered by extension) or directory content
  • Move files
  • Read files content as: NSArray, NSData, NSDictionary, NSString...
  • Remove files or directory content
  • Rename files
  • Write files
  • Directories are created on the fly
  • Error handling as using NSFileManager

#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];

Copy file:

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

Create file:

//create file and write content to it (if it doesn't exixt)
[FCFileManager createFileAtPath:@"test.txt" withContent:@"File management has never been so easy!!!"];

Check if file exist:

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

List directory content or files (filtered by extension):

//list content (files and directories) of the specified path
[FCFileManager listContentOfPath:[FCFileManager pathForMainBundleDirectory]];

//list files at the specified path filtered by extension, in this case list all PNGs in the MainBundleDirectory
[FCFileManager listFilesAtPath:[FCFileManager pathForMainBundleDirectory] withExtension:@"png"];

Move file:

//move file from a path to another and returns YES or NO
[FCFileManager moveFileAtPath:@"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"];

Remove files or directory content:

//remove all files and directories in the Temporary directory
[FCFileManager removeContentOfPath:[FCFileManager pathForTemporaryDirectory]];

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

Rename file:

//rename file at the specified path with the new name
[FCFileManager renameFileAtPath:@"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];

#TODO

  • documentation

fcfilemanager's People

Contributors

fabiocaccamo avatar

Watchers

James Cloos avatar Janak Nirmal avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.