le_fs_interface.h File Reference

#include "legato.h"

Go to the source code of this file.

Macros

#define LE_FS_ACCESS_MODE_MAX   127
 
#define LE_FS_PATH_MAX_LEN   128
 
#define LE_FS_DATA_MAX_SIZE   8192
 

Typedefs

typedef struct le_fs_File * le_fs_FileRef_t
 

Enumerations

enum  le_fs_AccessMode_t {
  LE_FS_RDONLY = 0x1, LE_FS_WRONLY = 0x2, LE_FS_RDWR = 0x4, LE_FS_CREAT = 0x8,
  LE_FS_TRUNC = 0x10, LE_FS_APPEND = 0x20, LE_FS_SYNC = 0x40
}
 
enum  le_fs_Position_t { LE_FS_SEEK_SET = 0, LE_FS_SEEK_CUR = 1, LE_FS_SEEK_END = 2 }
 

Functions

void le_fs_ConnectService (void)
 
le_result_t le_fs_TryConnectService (void)
 
void le_fs_DisconnectService (void)
 
le_result_t le_fs_Open (const char *filePath, le_fs_AccessMode_t accessMode, le_fs_FileRef_t *fileRefPtr)
 
le_result_t le_fs_Close (le_fs_FileRef_t fileRef)
 
le_result_t le_fs_Read (le_fs_FileRef_t fileRef, uint8_t *bufPtr, size_t *bufNumElementsPtr)
 
le_result_t le_fs_Write (le_fs_FileRef_t fileRef, const uint8_t *bufPtr, size_t bufNumElements)
 
le_result_t le_fs_Seek (le_fs_FileRef_t fileRef, int32_t offset, le_fs_Position_t position, int32_t *currentOffsetPtr)
 
le_result_t le_fs_GetSize (const char *filePath, size_t *sizePtr)
 
le_result_t le_fs_Delete (const char *filePath)
 
le_result_t le_fs_Move (const char *srcPath, const char *destPath)
 

Detailed Description

Legato File System service API.


Macro Definition Documentation

#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
#define LE_FS_DATA_MAX_SIZE   8192

Maximum number of bytes to read/write in one API call.

#define LE_FS_PATH_MAX_LEN   128

Maximum number of characters permitted for a file path.

Typedef Documentation

typedef struct le_fs_File* le_fs_FileRef_t

Reference of a file

Enumeration Type Documentation

File access modes used when opening a file.

Enumerator
LE_FS_RDONLY 

Read only.

LE_FS_WRONLY 

Write only.

LE_FS_RDWR 

Read/Write.

LE_FS_CREAT 

Create a new file.

LE_FS_TRUNC 

Truncate.

LE_FS_APPEND 

Append.

LE_FS_SYNC 

Synchronized.

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_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
void le_fs_ConnectService ( void  )

Connect the current client thread to the service providing this API. Block until the service is available.

For each thread that wants to use this API, either ConnectService or TryConnectService must be called before any other functions in this API. Normally, ConnectService is automatically called for the main thread, but not for any other thread. For details, see Client-specific Functions.

This function is created automatically.

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
void le_fs_DisconnectService ( void  )

Disconnect the current client thread from the service providing this API.

Normally, this function doesn't need to be called. After this function is called, there's no longer a connection to the service, and the functions in this API can't be used. For details, see Client-specific Functions.

This function is created automatically.

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_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_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_result_t le_fs_Read ( le_fs_FileRef_t  fileRef,
uint8_t *  bufPtr,
size_t *  bufNumElementsPtr 
)

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]bufNumElementsPtr
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_result_t le_fs_TryConnectService ( void  )

Try to connect the current client thread to the service providing this API. Return with an error if the service is not available.

For each thread that wants to use this API, either ConnectService or TryConnectService must be called before any other functions in this API. Normally, ConnectService is automatically called for the main thread, but not for any other thread. For details, see Client-specific Functions.

This function is created automatically.

Returns
  • LE_OK if the client connected successfully to the service.
  • LE_UNAVAILABLE if the server is not currently offering the service to which the client is bound.
  • LE_NOT_PERMITTED if the client interface is not bound to any service (doesn't have a binding).
  • LE_COMM_ERROR if the Service Directory cannot be reached.
le_result_t le_fs_Write ( le_fs_FileRef_t  fileRef,
const uint8_t *  bufPtr,
size_t  bufNumElements 
)

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]bufNumElements