Explore API

IXPAND

FILE SYSTEM APIS

1. getFATtype

Function

-(FATTYPE)getFATType

 

Description

Returns the file system type of iFDisk. Possible iXpand file system types are FAT32 and exFAT.

Note: Maximum file size that can be written over FAT32 is 4GB, whereas exFAT supports very larger file theoretically up to 16EB

 

Returns

Value
Description
FAT32 FAT32 format
EXFAT EXFAT format

2. setLabel

Function

-(BOOL)setLabel:(NSString *)labelName

 

Description

Sets the volume label of iXpand device.

Note that label name can’t be more than 11 words, and FAT32 type only supports the name of ASCII code.

 

Parameters

Value
Description
labelName Specifies the label name.

 

Returns

Value
Description
true Operation successful.
false Operation failed.

3. getLabel

Function

-(NSString *)getLabel

 

Description

Gets the volume label of iXpand device.

 

Returns

Value
Description
NSString volume label name

4. findFirst

Function

-(BYTE)findFirst:(NSData *)shortFileName findFirstStruct:(FFBLK *)aFFBLK

findFirstExact:(BOOL)isExact

 

Description

Starts a search of files that match the specified pattern (in the current directory).

 

Parameters

Value
Description
shortFileName Specifies the file name pattern to search for.
aFFBLK Points to a FFBLK structure to contain the file information.
isExact

0:returns true if shortFileName is contained within the file

name

1:returns true if shortFileName is an exact match with the

file name

 

FFBLK has the following structure:

Parameters
Description
BYTE sFileName[13] Found file name
BYTE bAttributes Attributes of the file
WORD ff_time File time (last modified time)
WORD ff_date File date (last modified date)
DWORD dwFileSize File size

 

bAttributescan have the following values (note that some attributes may be combined):

Parameters
Description
FA_NORMAL Normal file
FA_RDONLY Read only file
FA_HIDDEN Hidden file
FA_SYSTEM System file
FA_LABEL Volume label
FA_DIREC Directory name

 

FA_ARCH
Archive file
FA_LONGFILENAME Long file name entry

 

ff_time and ff_date are 16-bit structures divided into bit fields for referring to the current time and date.

Parameters
Description
ff_time bit15 ~ bit11:hours bit10 ~ bit5:minutes bit4 ~ bit 0:seconds/2
ff_date bit15 ~ bit9:years since 1980 bit8 ~ bit5:month bit4 ~ bit0:day

 

Returns

Value
Description
1 Match found.
0 No match found.

5. deleteFileAbsolutePath

Function

-(int)deleteFileAbsolutePath:(NSString *)filePath

 

Description

Deletes the specified file. The file must not be open when this function is called.

 

Parameters

Value
Description
filePath Specifies the file in absolute path to be deleted.

 

Returns

Value
Description
0 Operation successful
-1 Operation failed.

 

6. openFileAbsolutePath

Function

-(int)openFileAbsolutePath:(NSString *)filePath openMode:(BYTE)mode

 

Description

Opens (or creates) a file for reading or writing.

Maximum of ten files can be opened simultaneously.

 

Parameters

Value
Description
filePath Specifies the absolute file path.
mode Specifies the mode of operation

 

byMode can have the following values:

Parameters
Description
OF_CREATE Creates a new file
OF_READ Opens a file for reading
OF_WRITE Opens a file for writing
OF_EXIST Checks the file exists

 

Returns

Value
Description
Number File handle .
-1 Operation failed.

7. closeFile

Function

-(int)closeFile:(int)handle

 

Description

Closes a file and releases the file handle for future use.

 

Parameters

Parameters
Description
handle Specifies the handle of the file to be closed.

 

Returns

Value
Description
0 Operation successful.
-1 Operation failed.

7. flushData

Function

-(int)flushData:(int)handle;

 

Description

Force to write the buffer data in the handle.

 

Parameters

Value
Description
handle Specifies the handle of the file.

 

Returns

Value
Description
0 Operation successful.
-1 Operation failed.

8. getFileSize

Function

-(QWORD)getFileSize:(long)handle

 

Description

Return the file size of the file represented by the handle

 

Parameters

Value
Description
handle Specifies the handle of the file.

  Returns

Value
Description
Number File size.

 

9. writeFile

 Function

-(DWORD)writeFile:(int)handle writeBuf:(NSData *)data writeSize:(DWORD)length

 

Description

Writes the data from the specified buffer into the file.

 

Parameters

Value
Description

handle

Specifies the handle of the file.

data

Points to a memory block that contains the file data.

length

Specifies the number of bytes to write to the file.

*data, *length: Data size must be a multiple of 512 bytes.

 

 

Returns

Value
Description

Number

The actual number of bytes written to the file.

-1

Operation failed.

 

10. readFile

Function

-(DWORD)readFile:(int)handle readBuf:(NSData *)data readSize:(DWORD)length

 

Description

Reads data from the specified buffer into the file.

 

 

Parameters

Value
Description

handle

Specifies the handle of the file.

data

Points to a memory block that contains the file data.

length

Specifies the number of bytes to read to the file.

*data, *length: Data size must be a multiple of 512 bytes.

 

 

Returns

Value
Description

Number

The actual number of bytes read to the file.

-1

Operation failed.

11. seekFile

Function

-(QWORD)seekFile:(int)handle seekPosition:(QWORD)position

 

Description

Sets the current position of this file to the given value.

 

Parameters

Value
Description

handle

Specifies the handle of the file.

position

Specifies the number of file position.

 

 

Returns

Value
Description

Number

File position.

-1

Operation failed.

12. getTotalAvailableSpace

Function

-(QWORD)seekFile:(int)handle seekPosition:(QWORD)position

 

Description

Sets the current position of this file to the given value.

 

Parameters

Value
Description

handle

Specifies the handle of the file.

position

Specifies the number of file position.

 

 

Returns

Value
Description

Number

File position.

-1

Operation failed.

13. getAvailableSpace

Function

-(QWORD)getAvailableSpace

 

Description

Returns the available iXpand storage capacity in bytes.

 

Returns

Value
Description

Number

External available space (byte).

14. setFileAttribute

Function

- (BOOL)setFileAttribute:(NSString *)filename fileAttribute: (FILE_ATTRIBUTE)fileAttribute

 

Description

Sets the file attributes for file (in the current directory).

When using this function, the file must not be open.

 

Parameters

Value
Description

fileName

Specifies the file.

fileAttribute

Specifies the file attribute

 

FILE_ATTRIBUTE has the following structure:

Parameters
Description

BOOL enableAttr

Enable change attribute

uint16_t attributes

Attributes of the file

BOOL enableCDate

Enable change creation date and time

uint16_t creationDate

Creation date

uint16_t creationTime

Creation Time

uint8_t creationTimeCS

Creation time in centiseconds (exFAT only)

BOOL enableMDate

Enable change modification date and time

uint16_t modificationDate

Modification date

uint16_t modificationTime

Modification time

uint8_t

modificationTimeCS

Modification time in centiseconds (exFAT only)

BOOL enableADate

Enable change access date and time

uint16_t accessDate

Access date

uint16_t accessTime

Access time

 

attributes can have the following values (note that some attributes may be combined):

Parameters
Description

FA_NORMAL

Normal file

FA_RDONLY

Read only file

FA_HIDDEN

Hidden file

FA_SYSTEM

System file

FA_LABEL

Volume label

FA_DIREC

Directory name

FA_ARCH

Archive file

 

CreationDate, creationTime, modificationDate, modificationTime, accessDate and

accessTime are 16-bit structures divided into bit fields for referring to the the current time and date.

Parameters
Description

time

bit15 ~ bit11:hours

bit10 ~ bit5:minutes bit4 ~ bit 0:seconds/2

date

bit15 ~ bit9:years since 1980

bit8 ~ bit5:month bit4 ~ bit0:day

 

Returns

Value
Description

true

Operation successful.

false

Operation failed.

 

15. getFileAttribute

Function

- (BOOL)getFileAttribute:(NSString *)fileName fileAttribute: (FILE_ATTRIBUTE

*)fileAttribute

 

Description

Gets the file attributes for the file specified (in the current directory).

 

Parameters

Value
Description

fileName

Specifies the file.

fileAttribute

Specifies the pointer to get the file attribute

 

FILE_ATTRIBUTE has the following structure:

Parameters Description

BOOL enableAttr

Enable change attribute

uint16_t attributes

Attributes of the file

BOOL enableCDate

Enable change creation date and time

uint16_t creationDate

Creation date

uint16_t creationTime

Creation Time

uint8_t creationTimeCS

Creation time in centiseconds (exFAT only)

BOOL enableMDate

Enable change modification date and time

uint16_t modificationDate

Modification date

uint16_t modificationTime

Modification time

uint8_t

modificationTimeCS

Modification time in centiseconds (exFAT only)

BOOL enableADate

Enable change access date and time

 

uint16_t accessDate Access date

uint16_t accessTime

Access time

 

attributes can have the following values (note that some attributes may be combined):

Parameters
Description

FA_NORMAL

Normal file

FA_RDONLY

Read only file

FA_HIDDEN

Hidden file

FA_SYSTEM

System file

FA_LABEL

Volume label

FA_DIREC

Directory name

FA_ARCH

Archive file

 

creationDate、creationTime、modificationDate、modificationTime、accessDate and

accessTime are 16-bit structures divided into bit fields for referring to the current time and date.

Parameters
Description

time

bit15 ~ bit11:hours

bit10 ~ bit5:minutes bit4 ~ bit 0:seconds/2

date

bit15 ~ bit9:years since 1980

bit8 ~ bit5:month bit4 ~ bit0:day

 

Returns

Value
Description

true

Operation successful.

false

Operation failed.

16. renameFile

Function

-(int)renameFile:(NSString *)fileName toName:(NSString *)newFileName

 

Description

Rename the file or directory (in the current directory).

When using this function, the file must not be open.

 

Parameters

Value
Description

fileName

Specifies the file to be renamed.

newFileName

Specifies the new file name.

 

Returns

Value
Description

-1

Operation failed.

0

Operation successful.

17. searchFile

Function

1. -(BOOL)searchFile:(NSString *)fileName

2. -(NSArray *)searchFile:(NSString *)fileName isExact:(BOOL)isExact

 

Description

1. Search current directory by file name.

2. Search iXpand storage by file name.

 

Parameters

Value
Description

fileName

Specifies the file name to search for.

 

 

 

isExact

NO (0):returns true if fileName is contained within the file

name.

YES (1):returns true if fileName is an exact match with

the file name.

 

Returns

Value
Description

BOOL

File exists or not.

NSArray

Return all files that match the search criteria

18. movePath

Function

- (BOOL)movePath:(NSString*)source destination:(NSString*)destination;

 

Description

Move the file or directory from source path to destination path.

When using this function, the files must not be open

 

Parameters

Value
Description

Source

Specifies the absolute path of the source file/directory.

destination Specifies the absolute path of the destination directory.

 

Returns

Value
Description
NO Operation failed.
YES Operation successful.

19. getFilePosition

Function

-(QWORD)getFilePosition:(long)handle

 

Description

Gets the position of the file.

 

Parameters

Value
Description
handle

Specifies the handle of the file.

 

Returns

Value
Description
Number File position.
-1 Operation failed.

20. getFileOpenMode

Function

-(BYTE)getFileOpenMode:(long)handle

 

Description

Gets the mode the file was opened with.

 

Parameters

Value
Description

Handle

Specifies the handle of the file.

 

Returns

Value
Description

OF_CREATE

Creates a new file

OF_READ

Opens a file for reading

OF_WRITE Opens a file for writing

21. getCurrentDirectory

Function

-(NSString *)getCurrentDirectory

 

Description

Gets the current directory.

 

Returns

Value
Description

NSString

The absolute path of the current directory.

22. changeDirectoryAbsolutePath

Function

-(BOOL)changeDirectoryAbsolutePath:(NSString *)directoryPath

 

Description

Change the current directory to the absolute path specified.

 

Parameters

Value
Description

directoryPath

Specifies the absolute path to change current directory.

 

Returns

Value
Description

true

Operation successful.

false

Operation failed.

SYSTEM API

iXpand™ System Methods

1. initDrive

Function

-(BOOL) initDrive

Description

Initialize the drive, including the file system. Allocate appropriate resources, threads etc.

Returns

Value
Description
true Operation successful.
false Operation failed.

2. checkAccessoryUseFlag

Function

-(void) checkAccessoryUseFlag: (void(^)(NSUInteger * accessoryStatus))accessoryAvailabilityCallback

Description

Checks if the accessory is already in use by another application.

Block is passed as parameter to receive callback based on accessory availability. Callback will notify accessory states based on accessory occupancy by other applications. This API is intended to be called before initDrive API is called. Other iXpand SDK APIs have to be called only when accessory status is updated as ‘ACCESSORY_FREE’.

Parameters

Value
Description
(void(^)(NSUInteger * accessoryStatus))accessoryAvailabilityCallback

Block is passed as parameter to receive callback based on accessory availability.

Possible values of ‘accessoryStatus’ are the below

ACCESSORY_FREE = 0

ACCESSORY_WAIT = 1

ACCESSORY_BUSY = 2

APP_IN_BACKGROUND = 3

 

‘ACCESSORY_FREE’ implies accessory is available to use.

‘ACCESSORY_WAIT’ implies that accessory is occupied by an application & no application is waiting for accessory.

‘ACCESSORY_BUSY’ implies that accessory is occupied by an application & another application is waiting for accessory.

‘APP_IN_BACKGROUND’ implies that API is called when application is in background. Application is not intended to call accessoryCallback API in background

3. openSession

Function

-(BOOL) openSession

Description

This API is to be used to open a session with an external accessory after the external accessory controller is set up by the initDrive method.

Returns

Value
Description
true Open session success
false Open session failed

4. closeSession

Function

- closeSession

Description

This API is used to close the session when iXpand needs to be disconnected.

Returns

Value
Description
true Close session success
false Close session failed

5. wasDriveWrittenFromPC

Function

-( NSUInteger) wasDriveWrittenFromPC

Description

This function returns time stamp when the PC was last connected.

Returns

Value
Description
NSUInteger Time stamp when PC was last connected.

6. clearWrittenByPC

Function

-(NSUInteger) clearWrittenByPC

Description

This function Clear the flag used by wasDriveWrittenFromPC.

Returns

Value
Description
True Operation successful
False Operation failed

7. GetSDKVersion

Function

-(NSString)GetSDKVersion

Description

Returns the current SDK version.

Returns

Value
Description
‘x.x’ SDK version number

8. GetDeviceFwVersion

Function

- getDeviceFwVersion

Description

Returns the device Firmware version.

Returns

Value
Description
‘x.x.x.x’ Device Firmware version number

9. isDriveConnected

Function

-(BOOL)isDriveConnected

Description

This function returns true if iXpand is connected.

Returns

Value
Description
true Drive is connected.
false Drive is not connected.

10. getDeviceType

Function

-(NSString)getDeviceType

Description

Returns the device type connected.

Returns

Value
Description
NSString Device Type Connected. Ex: “iFDv1” for ‘iXpand Flash Drive’.

11. unregisterAccessoryCheck

Function

-(void)unregisterAccessoryCheck
 

Description

Unregisters accessory check callback registered in ‘checkAccessoryUseFlag’ API. This function has to be called after ‘closeSession’ API in normal accessory release operation.

There are situation in which application that occupying accessory can get killed. To ensure proper clean-up, ‘unregisterAccessoryCheck’ API can be called in appDelegate’s API ‘applicationWillTerminate’.

There are scenarios where application is moved to background when data transfer is in progress. In such scenario when data transfer is completed, ‘unregisterAccessoryCheck’ API has to be called immediately before application is moved to suspended state.

Do more with the
iXpand SDK

Click the buttons below to visit the iXpand Developer Home & Workflow pages

 

Developer
Home

Get started, access the SDK, build your apps, & learn more


View Home

Developer
Workflow

Register & submit your app for review and contact support


View Workflow