Snapdragon® Telematics Application Framework (TelAF) Interface Specification
le_fs.h File Reference

Go to the source code of this file.

Macros

#define LE_FS_ACCESS_MODE_MAX   127
 
#define LE_FS_RDONLY   0x1
 Read only. More...
 
#define LE_FS_WRONLY   0x2
 Write only. More...
 
#define LE_FS_RDWR   0x4
 Read/Write. More...
 
#define LE_FS_CREAT   0x8
 Create a new file. More...
 
#define LE_FS_TRUNC   0x10
 Truncate. More...
 
#define LE_FS_APPEND   0x20
 Append. More...
 
#define LE_FS_SYNC   0x40
 Synchronized. More...
 

Typedefs

typedef int le_fs_AccessMode_t
 
typedef struct le_fs_File * le_fs_FileRef_t
 

Enumerations

enum  le_fs_Position_t { LE_FS_SEEK_SET = 0, LE_FS_SEEK_CUR = 1, LE_FS_SEEK_END = 2 }
 

Functions

LE_API_FILESYSTEM le_result_t le_fs_Open (const char *filePath, le_fs_AccessMode_t accessMode, le_fs_FileRef_t *fileRefPtr)
 
LE_API_FILESYSTEM le_result_t le_fs_Close (le_fs_FileRef_t fileRef)
 
LE_API_FILESYSTEM le_result_t le_fs_Read (le_fs_FileRef_t fileRef, uint8_t *bufPtr, size_t *bufSizePtr)
 
LE_API_FILESYSTEM le_result_t le_fs_Write (le_fs_FileRef_t fileRef, const uint8_t *bufPtr, size_t bufSize)
 
LE_API_FILESYSTEM le_result_t le_fs_Seek (le_fs_FileRef_t fileRef, int32_t offset, le_fs_Position_t position, int32_t *currentOffsetPtr)
 
LE_API_FILESYSTEM le_result_t le_fs_GetSize (const char *filePath, size_t *sizePtr)
 
LE_API_FILESYSTEM le_result_t le_fs_Delete (const char *filePath)
 
LE_API_FILESYSTEM le_result_t le_fs_Move (const char *srcPath, const char *destPath)
 
LE_API_FILESYSTEM le_result_t le_fs_RemoveDirRecursive (const char *dirPathPtr)
 
LE_API_FILESYSTEM bool le_fs_Exists (const char *filePathPtr)
 
LE_FULL_API LE_API_FILESYSTEM le_result_t le_fs_GetExecutablePath (char *dirPathPtr, size_t dirPathSize, char *exeNamePtr, size_t exeNameSize)
 

Macro Definition Documentation

◆ LE_FS_ACCESS_MODE_MAX

#define LE_FS_ACCESS_MODE_MAX   127

Define the maximal bit mask for file access mode.

Note
This maximal value should be coherent with le_fs_AccessMode_t

◆ LE_FS_RDONLY

#define LE_FS_RDONLY   0x1

Read only.

◆ LE_FS_WRONLY

#define LE_FS_WRONLY   0x2

Write only.

◆ LE_FS_RDWR

#define LE_FS_RDWR   0x4

Read/Write.

◆ LE_FS_CREAT

#define LE_FS_CREAT   0x8

Create a new file.

◆ LE_FS_TRUNC

#define LE_FS_TRUNC   0x10

Truncate.

◆ LE_FS_APPEND

#define LE_FS_APPEND   0x20

Append.

◆ LE_FS_SYNC

#define LE_FS_SYNC   0x40

Synchronized.

Typedef Documentation

◆ le_fs_AccessMode_t

typedef int le_fs_AccessMode_t

File access modes used when opening a file.

◆ le_fs_FileRef_t

typedef struct le_fs_File* le_fs_FileRef_t

Reference of a file

Enumeration Type Documentation

◆ le_fs_Position_t

Offset position used when seeking in a file.

Enumerator
LE_FS_SEEK_SET 

From the current position.

LE_FS_SEEK_CUR 

From the beginning of the file.

LE_FS_SEEK_END 

From the end of the file.

Function Documentation

◆ le_fs_Open()

LE_API_FILESYSTEM le_result_t le_fs_Open ( const char *  filePath,
le_fs_AccessMode_t  accessMode,
le_fs_FileRef_t fileRefPtr 
)

This function is called to create or open an existing file.

Returns
  • LE_OK The function succeeded.
  • LE_BAD_PARAMETER A parameter is invalid.
  • LE_OVERFLOW The file path is too long.
  • LE_NOT_FOUND The file does not exists or a directory in the path does not exist
  • LE_NOT_PERMITTED Access denied to the file or to a directory in the path
  • LE_UNSUPPORTED The prefix cannot be added and the function is unusable
  • LE_FAULT The function failed.
Parameters
[in]filePathFile path
[in]accessModeAccess mode for the file
[out]fileRefPtrFile reference (if successful)

◆ le_fs_Close()

LE_API_FILESYSTEM le_result_t le_fs_Close ( le_fs_FileRef_t  fileRef)

This function is called to close an opened file.

Returns
  • LE_OK The function succeeded.
  • LE_FAULT The function failed.
Parameters
[in]fileRefFile reference

◆ le_fs_Read()

LE_API_FILESYSTEM le_result_t le_fs_Read ( le_fs_FileRef_t  fileRef,
uint8_t *  bufPtr,
size_t *  bufSizePtr 
)

This function is called to read the requested data length from an opened file. The data is read at the current file position.

Returns
  • LE_OK The function succeeded.
  • LE_BAD_PARAMETER A parameter is invalid.
  • LE_FAULT The function failed.
Parameters
[in]fileRefFile reference
[out]bufPtrBuffer to store the data read in the file
[in,out]bufSizePtrSize to read and size really read on file

◆ le_fs_Write()

LE_API_FILESYSTEM le_result_t le_fs_Write ( le_fs_FileRef_t  fileRef,
const uint8_t *  bufPtr,
size_t  bufSize 
)

This function is called to write the requested data length to an opened file. The data is written at the current file position.

Returns
  • LE_OK The function succeeded.
  • LE_BAD_PARAMETER A parameter is invalid.
  • LE_UNDERFLOW The write succeed but was not able to write all bytes
  • LE_FAULT The function failed.
Parameters
[in]fileRefFile reference
[in]bufPtrBuffer to write in the file
[in]bufSizeSize of the buffer to write

◆ le_fs_Seek()

LE_API_FILESYSTEM le_result_t le_fs_Seek ( le_fs_FileRef_t  fileRef,
int32_t  offset,
le_fs_Position_t  position,
int32_t *  currentOffsetPtr 
)

This function is called to change the file position of an opened file.

Returns
  • LE_OK The function succeeded.
  • LE_BAD_PARAMETER A parameter is invalid.
  • LE_FAULT The function failed.
Parameters
[in]fileRefFile reference
[in]offsetOffset to apply
[in]positionOffset is relative to this position
[out]currentOffsetPtrOffset from the beginning after the seek operation

◆ le_fs_GetSize()

LE_API_FILESYSTEM le_result_t le_fs_GetSize ( const char *  filePath,
size_t *  sizePtr 
)

This function is called to get the size of a file.

Returns
  • LE_OK The function succeeded.
  • LE_BAD_PARAMETER A parameter is invalid.
  • LE_OVERFLOW The file path is too long.
  • LE_UNSUPPORTED The prefix cannot be added and the function is unusable
  • LE_FAULT The function failed.
Parameters
[in]filePathFile path
[out]sizePtrFile size (if successful)

◆ le_fs_Delete()

LE_API_FILESYSTEM le_result_t le_fs_Delete ( const char *  filePath)

This function is called to delete a file.

Returns
  • LE_OK The function succeeded.
  • LE_BAD_PARAMETER A parameter is invalid.
  • LE_OVERFLOW The file path is too long.
  • LE_NOT_FOUND The file does not exist or a directory in the path does not exist
  • LE_NOT_PERMITTED The access right fails to delete the file or access is not granted to a a directory in the path
  • LE_UNSUPPORTED The prefix cannot be added and the function is unusable
  • LE_FAULT The function failed.
Parameters
[in]filePathFile path

◆ le_fs_Move()

LE_API_FILESYSTEM le_result_t le_fs_Move ( const char *  srcPath,
const char *  destPath 
)

This function is called to rename an existing file. If rename fails, the file will keep its original name.

Returns
  • LE_OK The function succeeded.
  • LE_BAD_PARAMETER A parameter is invalid.
  • LE_OVERFLOW A file path is too long.
  • LE_FAULT The function failed.
Parameters
[in]srcPathPath to file to rename
[in]destPathNew path to file

◆ le_fs_RemoveDirRecursive()

LE_API_FILESYSTEM le_result_t le_fs_RemoveDirRecursive ( const char *  dirPathPtr)

Removes a directory located at storage managed by file system service by first recursively removing sub-directories, files, symlinks, hardlinks, devices, etc. Symlinks are not followed, only the links themselves are deleted.

A file or device may not be able to be removed if it is busy, in which case an error message is logged and LE_FAULT is returned.

Returns
  • LE_OK The function succeeded.
  • LE_BAD_PARAMETER A parameter is invalid.
  • LE_UNSUPPORTED The prefix cannot be added and the function is unusable
  • LE_FAULT There is an error.
Parameters
[in]dirPathPtrDirectory path

◆ le_fs_Exists()

LE_API_FILESYSTEM bool le_fs_Exists ( const char *  filePathPtr)

This function checks whether a regular file exists at the provided path under file system service storage.

Returns
  • true If file exists and it is a regular file.
  • false Otherwise.
Parameters
[in]filePathPtrFile path

◆ le_fs_GetExecutablePath()

LE_FULL_API LE_API_FILESYSTEM le_result_t le_fs_GetExecutablePath ( char *  dirPathPtr,
size_t  dirPathSize,
char *  exeNamePtr,
size_t  exeNameSize 
)

Obtain the absolute directory containing the running executable and the name of the executable.

Returns
LE_OK on success or an appropriate error on failure.
Parameters
[out]dirPathPtrBuffer to put executable's directory path in.
[in]dirPathSizeSize of the directory path buffer.
[out]exeNamePtrBuffer to put the executable's name in.
[in]exeNameSizeSize of the executable name buffer.