Mobile API Reference  MicroStrategy 2019
<FileManager> Protocol Reference

#import <FileManager.h>

Instance Methods

(BOOL- createDirectoryAtPath:withIntermediateDirectories:attributes:error:
 
(NSArray *) - contentsOfDirectoryAtPath:error:
 
(NSArray *) - subpathsAtPath:
 
(BOOL- fileExistsAtPath:
 
(BOOL- fileExistsAtPath:isDirectory:
 
(BOOL- setAttributes:ofItemAtPath:error:
 
(NSDictionary *) - attributesOfItemAtPath:error:
 
(NSData *) - readDataAtPath:error:
 
(NSData *) - readDataWithoutEncryptionAtPath:error:
 
(size_t) - readData:atPath:offset:length:error:
 
(size_t) - readDataInBuffer:atPath:offset:length:error:
 
(NSInteger) - writeData:atPath:error:
 
(NSInteger) - appendData:atPath:error:
 
(NSInteger) - writeDataWithoutEncryption:atPath:error:
 
(BOOL- createFileAtPath:contents:attributes:
 
(void) - writeDictionary:toFileAtPath:
 
(NSDictionary *) - dictionaryAtFilePath:
 
(NSData *) - readDataWithNoProtectionAtPath:error:encrypt:
 
(NSInteger) - writeDataWithNoProtection:atPath:error:encrypt:
 
(NSInteger) - appendDataWithNoProtection:atPath:error:encrypt:
 
(NSOutputStream *) - newOutputStreamToFileAtPath:append:
 
(NSInputStream *) - newInputStreamWithFileAtPath:
 
(NSInteger) - moveItemAtPath:toPath:error:
 
(NSInteger) - copyItemAtPath:toPath:error:
 
(NSInteger) - deleteDataAtPath:error:
 
(BOOL- removeItemAtPath:error:
 
(void) - clearTmpDirectory
 
(NSString *) - documentDirectory
 
(NSString *) - cachesDirectory
 
(NSString *) - libraryDirectory
 
(NSString *) - tempDirectory
 
(void) - waitUntilUnlockOperationIsFinished
 
(BOOL- isMappedFileSupported
 
(long long) - decryptDataAtPath:
 
(size_t) - incrementalDecryptSoftwareEncryptedDataAtPath:error:
 
(NSString *) - decryptedExternalFileForFileAtPath:
 
(void) - removeDecryptedFileForFile:
 

Class Methods

(id< FileManager >) + fileManager
 

Method Documentation

◆ appendData:atPath:error:()

- (NSInteger) appendData: (NSData *)  data
atPath: (NSString *)  path
error: (NSError **)  error 

◆ appendDataWithNoProtection:atPath:error:encrypt:()

- (NSInteger) appendDataWithNoProtection: (NSData *)  data
atPath: (NSString *)  path
error: (NSError **)  error
encrypt: (bool)  encrypt 

◆ attributesOfItemAtPath:error:()

- (NSDictionary *) attributesOfItemAtPath: (NSString *)  path
error: (NSError **)  error 

Get the attributes for a specific file.

Parameters
paththe path of the file.
errorout-parameter to tell whether there is any error occurred.
Returns
attributes of the file.

◆ cachesDirectory()

- (NSString*) cachesDirectory

◆ clearTmpDirectory()

- (void) clearTmpDirectory

Clear the Tmp directory.

◆ contentsOfDirectoryAtPath:error:()

- (NSArray*) contentsOfDirectoryAtPath: (NSString *)  path
error: (NSError **)  error 

Returns the contents of a directory at path.

Parameters
paththe path of the directory.
errorthe error occurred while creating directory.
Returns
an array of the contents of the directory.

◆ copyItemAtPath:toPath:error:()

- (NSInteger) copyItemAtPath: (NSString *)  path
toPath: (NSString *)  toPath
error: (NSError **)  error 

◆ createDirectoryAtPath:withIntermediateDirectories:attributes:error:()

- (BOOL) createDirectoryAtPath: (NSString *)  path
withIntermediateDirectories: (BOOL createIntermediates
attributes: (NSDictionary *)  attributes
error: (NSError **)  error 

Create a directory at specific path with attributes.

Parameters
paththe path of the directory.
createIntermediateswhether to create the parent directories to the destination directory.
attributesattriutes of the directory.
errorthe error occurred while creating directory.

◆ createFileAtPath:contents:attributes:()

- (BOOL) createFileAtPath: (NSString *)  path
contents: (NSData *)  contents
attributes: (NSDictionary *)  attributes 

Create file with provided content at path.

Parameters
paththe path of the destination file.
contentsthe data to be written into the file.
attributesthe attributes of the file.
Returns
YES if the writing operation succeeds; NO otherwise.

◆ decryptDataAtPath:()

- (long long) decryptDataAtPath: (NSString *)  path

Decrypt the content of file at path and write to the same path. The file reading/writing process is done without any protection.

Parameters
thepath of the file.
Returns
the length of the decrypted data.

◆ decryptedExternalFileForFileAtPath:()

- (NSString *) decryptedExternalFileForFileAtPath: (NSString *)  encryptedFilePath

Decrypt the file that will be opened in 3rd party app and save it to temperary location if necessary. The file has to be decrypted because 3rd party app could not decrypt the file encrypted by security framework.

Parameters
thepath of the file to decrypt.
Returns
the location of the temperary file.

◆ deleteDataAtPath:error:()

- (NSInteger) deleteDataAtPath: (NSString *)  path
error: (NSError **)  error 

APIs to remove file at a specific path.

Parameters
paththe path of the file to delete.
errorout-parameter to tell whether there is error occurred.
Returns
status of the operation. Do not use the return value to determine whether the operation is successful, use the error.

◆ dictionaryAtFilePath:()

- (NSDictionary*) dictionaryAtFilePath: (NSString *)  filePath

Read the content of file into a dictionary. It has to work with writeDictionary:toFileAtPath

Parameters
filePaththe path of the file to be read from.
Returns
a dictionary that contains the content of file.

◆ documentDirectory()

- (NSString*) documentDirectory

Utility APIs to get regular directories in file system sandbox.

◆ fileExistsAtPath:()

- (BOOL) fileExistsAtPath: (NSString *)  path

APIs to tell whether a file/directory exists in the file system.

Parameters
paththe path of file to check.
isDirectoryout-parameter to tell whether the file is a directory.
Returns
YES if the file exist; No if the file does not exist.

◆ fileExistsAtPath:isDirectory:()

- (BOOL) fileExistsAtPath: (NSString *)  path
isDirectory: (BOOL *)  isDirectory 

◆ fileManager()

+ (id<FileManager>) fileManager

Return a file manager singleton instance, create one if it does not exist.

Returns
a reference to the file manager singleton

◆ incrementalDecryptSoftwareEncryptedDataAtPath:error:()

- (size_t) incrementalDecryptSoftwareEncryptedDataAtPath: (NSString *)  path
error: (NSError **)  error 

Decrypt the data downloaded from Newsstand and write to the file system. This method is only called by Newsstand feature. The file writing process is done without any protection.

Parameters
thepath of the file.
errorout-parameter to tell whether there is error occurred.
Returns
the size of the decrypted data.

◆ isMappedFileSupported()

- (BOOL) isMappedFileSupported

The API to tell AE whether the mapped file is supported.

◆ libraryDirectory()

- (NSString*) libraryDirectory

◆ moveItemAtPath:toPath:error:()

- (NSInteger) moveItemAtPath: (NSString *)  path
toPath: (NSString *)  toPath
error: (NSError **)  error 

APIs to copy/move a file to another destination.

Parameters
pathfile path of the source file.
toPathfile path of the destination file.
errorout-parameter to tell whether there is error occurred.
Returns
status of the operation. Do not use the return value to determine whether the operation is successful, use the error.

◆ newInputStreamWithFileAtPath:()

- (NSInputStream*) newInputStreamWithFileAtPath: (NSString *)  filePath

Create and open an input stream for file at path.

Parameters
filePaththe path of the file.
Returns
input stream of the file.

◆ newOutputStreamToFileAtPath:append:()

- (NSOutputStream*) newOutputStreamToFileAtPath: (NSString *)  filePath
append: (BOOL append 

Create and open an output stream for file at path.

Parameters
filePaththe path of the file.
appendwhether to append data or not.
Returns
output stream of the file.

◆ readData:atPath:offset:length:error:()

- (size_t) readData: (void *)  dataBuf
atPath: (NSString *)  path
offset: (long)  offset
length: (size_t)  length
error: (NSError **)  error 

Read data from a specific file into a data buffer.

Parameters
dataBufthe buffer to which the data is read.
paththe path of the file.
offsetthe offset of the start point of reading.
lengthlength of data to read.
errorout-parameter to tell whether there is any error occurred.
Returns
the length of data returned.

◆ readDataAtPath:error:()

- (NSData*) readDataAtPath: (NSString *)  path
error: (NSError **)  error 

Read data from a specific file in an encrypted format.

Parameters
paththe path of the file.
errorout-parameter to tell whether there is any error occurred.
Returns
data object that contains the content of file.

◆ readDataInBuffer:atPath:offset:length:error:()

- (size_t) readDataInBuffer: (void **)  dataBuf
atPath: (NSString *)  path
offset: (long)  offset
length: (size_t)  length
error: (NSError **)  error 

◆ readDataWithNoProtectionAtPath:error:encrypt:()

- (NSData*) readDataWithNoProtectionAtPath: (NSString *)  path
error: (NSError **)  error
encrypt: (bool)  encrypt 
Parameters
paththe path of the file.
errorout-parameter to indicate whether there is error occurred.
encryptwhether we need to encrypt data.
Returns
the data read from the file.

◆ readDataWithoutEncryptionAtPath:error:()

- (NSData*) readDataWithoutEncryptionAtPath: (NSString *)  path
error: (NSError **)  error 

◆ removeDecryptedFileForFile:()

- (void) removeDecryptedFileForFile: (NSString *)  file

Remove the temperary files generated for 3rd party app.

Parameters
thepath for the encrypted file.

◆ removeItemAtPath:error:()

- (BOOL) removeItemAtPath: (NSString *)  path
error: (NSError **)  error 

◆ setAttributes:ofItemAtPath:error:()

- (BOOL) setAttributes: (NSDictionary *)  attributes
ofItemAtPath: (NSString *)  path
error: (NSError **)  error 

Set the attributes for a specific file.

Parameters
attributesthe attributes to get/set.
paththe path of the file.
errorout-parameter to tell whether there is any error occurred.
Returns
YES if set attributes successfully; NO otherwise.

◆ subpathsAtPath:()

- (NSArray*) subpathsAtPath: (NSString *)  path

Returns the sub paths of a directory.

Parameters
paththe path of the directory.
Returns
the sub paths of the directory.

◆ tempDirectory()

- (NSString*) tempDirectory

◆ waitUntilUnlockOperationIsFinished()

- (void) waitUntilUnlockOperationIsFinished

Block the file operation while the device is locked.

◆ writeData:atPath:error:()

- (NSInteger) writeData: (NSData *)  data
atPath: (NSString *)  path
error: (NSError **)  error 

Write/Append data to a file at path.

Parameters
datathe data to write.
paththe path of the destination file.
errorout-parameter to tell whether there is any error occurred.
Returns
1 if data or path is invalid; 0 otherwize. Use error to tell whether the writing is successful.

◆ writeDataWithNoProtection:atPath:error:encrypt:()

- (NSInteger) writeDataWithNoProtection: (NSData *)  data
atPath: (NSString *)  path
error: (NSError **)  error
encrypt: (bool)  encrypt 
Parameters
thedata to write/append to the file.
paththe path of the file.
errorout-parameter to indicate whether there is error occurred.
encryptwhether we need to encrypt data.

◆ writeDataWithoutEncryption:atPath:error:()

- (NSInteger) writeDataWithoutEncryption: (NSData *)  data
atPath: (NSString *)  path
error: (NSError **)  error 

◆ writeDictionary:toFileAtPath:()

- (void) writeDictionary: (NSDictionary *)  dictionary
toFileAtPath: (NSString *)  filePath 

Write a dictionary into a file.

Parameters
dictionarythe dictionary to write.
filePaththe path of the destination file.