Declared in NSFileManager+BFKit.h

Overview

This category adds some useful methods to NSFileManager

Tasks

Class Methods

deleteFile:fromDirectory:

+ (BOOL)deleteFile:(NSString *_Nonnull)fileName fromDirectory:(DirectoryType)directory
Discussion

Delete a file with the given filename

Parameters

origin

Directory of the file

filename

Filename to delete

Return Value

Returns YES if the operation was successful, otherwise NO

Declared In

NSFileManager+BFKit.h

duplicateFileAtPath:toNewPath:

+ (BOOL)duplicateFileAtPath:(NSString *_Nonnull)origin toNewPath:(NSString *_Nonnull)destination
Discussion

Duplicate a file into another directory

Parameters

origin

Origin path

destination

Destination path

Return Value

Returns YES if the operation was successful, otherwise NO

Declared In

NSFileManager+BFKit.h

fileSize:fromDirectory:

+ (NSNumber *_Nullable)fileSize:(NSString *_Nonnull)fileName fromDirectory:(DirectoryType)directory
Discussion

Returns the size of the file

Parameters

fileName

Filename

directory

Directory of the file

Return Value

Returns the file size

Declared In

NSFileManager+BFKit.h

getAppSettingsForObjectWithKey:

+ (id _Nullable)getAppSettingsForObjectWithKey:(NSString *_Nonnull)objKey
Discussion

Get the App settings for a given key

Parameters

objKey

Key to get the object

Return Value

Returns the object for the given key

Declared In

NSFileManager+BFKit.h

getBundlePathForFile:

+ (NSString *_Nonnull)getBundlePathForFile:(NSString *_Nonnull)fileName
Discussion

Get the Bundle path for a filename

Parameters

fileName

Filename

Return Value

Returns the path as a NSString

Declared In

NSFileManager+BFKit.h

getCacheDirectoryForFile:

+ (NSString *_Nonnull)getCacheDirectoryForFile:(NSString *_Nonnull)fileName
Discussion

Get the Cache directory for a filename

Parameters

fileName

Filename

Return Value

Returns the directory as a NSString

Declared In

NSFileManager+BFKit.h

getDocumentsDirectoryForFile:

+ (NSString *_Nonnull)getDocumentsDirectoryForFile:(NSString *_Nonnull)fileName
Discussion

Get the Documents directory for a filename

Parameters

fileName

Filename

Return Value

Returns the directory as a NSString

Declared In

NSFileManager+BFKit.h

getLibraryDirectoryForFile:

+ (NSString *_Nonnull)getLibraryDirectoryForFile:(NSString *_Nonnull)fileName
Discussion

Get the Library directory for a filename

Parameters

fileName

Filename

Return Value

Returns the directory as a NSString

Declared In

NSFileManager+BFKit.h

getSettings:objectForKey:

+ (id _Nullable)getSettings:(NSString *_Nonnull)settings objectForKey:(NSString *_Nonnull)objKey
Discussion

Get the given settings for a given key

Parameters

settings

Settings filename

objKey

Key to set the object

Return Value

Returns the object for the given key

Declared In

NSFileManager+BFKit.h

loadArrayFromPath:withFilename:

+ (NSArray *_Nullable)loadArrayFromPath:(DirectoryType)path withFilename:(NSString *_Nonnull)fileName
Discussion

Load array from a PLIST with the given filename

Parameters

path

Path of the PLIST

fileName

PLIST filename

Return Value

Returns the loaded array

Declared In

NSFileManager+BFKit.h

moveLocalFile:fromDirectory:toDirectory:

+ (BOOL)moveLocalFile:(NSString *_Nonnull)fileName fromDirectory:(DirectoryType)origin toDirectory:(DirectoryType)destination
Discussion

Move a file from a directory to another

Parameters

fileName

Filename to move

origin

Origin directory of the file

destination

Destination directory of the file

Return Value

Returns YES if the operation was successful, otherwise NO

Declared In

NSFileManager+BFKit.h

moveLocalFile:fromDirectory:toDirectory:withFolderName:

+ (BOOL)moveLocalFile:(NSString *_Nonnull)fileName fromDirectory:(DirectoryType)origin toDirectory:(DirectoryType)destination withFolderName:(NSString *_Nullable)folderName
Discussion

Move a file from a directory to another

Parameters

fileName

Filename to move

origin

Origin directory of the file

destination

Destination directory of the file

folderName

Folder name where to move the file. If folder not exist it will be created automatically

Return Value

Returns YES if the operation was successful, otherwise NO

Declared In

NSFileManager+BFKit.h

readTextFile:ofType:

+ (NSString *_Nullable)readTextFile:(NSString *_Nonnull)file ofType:(NSString *_Nonnull)type
Discussion

Read a file an returns the content as NSString

Parameters

file

File name

type

File type

Return Value

Returns the content of the file a NSString

Declared In

NSFileManager+BFKit.h

renameFileFromDirectory:atPath:withOldName:andNewName:

+ (BOOL)renameFileFromDirectory:(DirectoryType)origin atPath:(NSString *_Nonnull)path withOldName:(NSString *_Nonnull)oldName andNewName:(NSString *_Nonnull)newName
Discussion

Rename a file with another filename

Parameters

origin

Origin path

path

Subdirectory path

oldName

Old filename

newName

New filename

Return Value

Returns YES if the operation was successful, otherwise NO

Declared In

NSFileManager+BFKit.h

saveArrayToPath:withFilename:array:

+ (BOOL)saveArrayToPath:(DirectoryType)path withFilename:(NSString *_Nonnull)fileName array:(NSArray *_Nonnull)array
Discussion

Save a given array into a PLIST with the given filename

Parameters

path

Path of the PLIST

array

Array to save into PLIST

filename

PLIST filename

Return Value

Returns YES if the operation was successful, otherwise NO

Declared In

NSFileManager+BFKit.h

setAppSettingsForObject:forKey:

+ (BOOL)setAppSettingsForObject:(id _Nonnull)value forKey:(NSString *_Nonnull)objKey
Discussion

Set the App settings for a given object and key. The file will be saved in the Library directory

Parameters

value

Object to set

objKey

Key to set the object

Return Value

Returns YES if the operation was successful, otherwise NO

Declared In

NSFileManager+BFKit.h

setSettings:object:forKey:

+ (BOOL)setSettings:(NSString *_Nonnull)settings object:(id _Nonnull)value forKey:(NSString *_Nonnull)objKey
Discussion

Set the given settings for a given object and key. The file will be saved in the Library directory

Parameters

settings

Settings filename

value

Object to set

objKey

Key to set the object

Return Value

Returns YES if the operation was successful, otherwise NO

Declared In

NSFileManager+BFKit.h