FileIO.h File Reference

FileIO is a simple cross-platform API for reading and writing files from the filesystem. More...

#include <libos/Defines.h>
Include dependency graph for FileIO.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  losFileOpenInfo
 losFileOpenInfo is the file creation struct we pass this into the creation function for the library to create a file object More...
 

Typedefs

typedef struct losFileHandle_T * losFileHandle
 this is the Library object that is used to read and write files from the filesystem as the user only holds a pointer to the library object that is controlled by the library. More...
 
typedef enum losFileBits losFileBits
 losFileBits is used for file object flags
 
typedef struct losFileOpenInfo losFileOpenInfo
 losFileOpenInfo is the file creation struct we pass this into the creation function for the library to create a file object
 

Enumerations

enum  losFileBits {
  LOS_FILE_BIT_READ = 0x01 , LOS_FILE_BIT_WRITE = 0x02 , LOS_FILE_BIT_BINARY = 0x04 , LOS_FILE_BIT_UNICODE = 0x08 ,
  LOS_FILE_BIT_CREATE = 0x10 , LOS_FILE_BIT_DELETE_AFTER_CLOSE = 0x20 , LOS_FILE_BIT_FLIP_ENDIAN = 0x40
}
 losFileBits is used for file object flags More...
 

Functions

EXPORT_DLL losResult losSetAssetPath (_in_ const char *path)
 losSetAssetPath can be used to set the full data path for $[asset_base] More...
 
EXPORT_DLL losResult losDoseFileExist (_in_ const char *path)
 losDoseFileExist can be used to check if the file exists will return LOS_SUCCESS if the file exists else it will return LOS_ERROR_MALFORMED_DATA More...
 
EXPORT_DLL losResult losOpenFile (_out_ losFileHandle *handle, _in_ const losFileOpenInfo file_info)
 losOpenFile is to create the library object but dose not release the object to the library user More...
 
EXPORT_DLL losResult losReadFile (_in_ losFileHandle handle, _out_ void **buffer, _out_ size_t *bytes_read)
 losReadFile read data to native file held by the library object when in unicode mode it will return wchar_t data encoding from the read More...
 
EXPORT_DLL losResult losWriteFile (_in_ const losFileHandle handle, _in_ const void *buffer, _in_ const size_t buffer_size)
 losWriteFile write data to native file held by the library object when in unicode mode it expects wchar_t data encoding to write More...
 
EXPORT_DLL void * losGetFuncAddress (_in_ const losFileHandle handle, _in_ const char *name)
 losGetFuncAddress extracts the function memory address loaded when the LOS_FILE_BIT_BINARY is set More...
 
EXPORT_DLL losResult losCloseFile (_in_ losFileHandle handle)
 losCloseFile is to close the library object and safely delete it More...
 

Detailed Description

FileIO is a simple cross-platform API for reading and writing files from the filesystem.

Author
Luke Shore luket.nosp@m.hemo.nosp@m.dded@.nosp@m.gmai.nosp@m.l.com
Version
1.2
Date
05/6/2022

Typedef Documentation

◆ losFileHandle

typedef struct losFileHandle_T* losFileHandle

this is the Library object that is used to read and write files from the filesystem as the user only holds a pointer to the library object that is controlled by the library.

Importation of libraries

Enumeration Type Documentation

◆ losFileBits

losFileBits is used for file object flags

Enumerator
LOS_FILE_BIT_READ 

Read file flag bit.

LOS_FILE_BIT_WRITE 

Write file flag bit.

LOS_FILE_BIT_BINARY 

Binary aka library handle file flag bit (NOT_IMPLEMENTED)

LOS_FILE_BIT_UNICODE 

Unicode file flag bit.

LOS_FILE_BIT_CREATE 

Create file if does not exist flag bit.

LOS_FILE_BIT_DELETE_AFTER_CLOSE 

Tells the library to delete the file after using it flag bit.

LOS_FILE_BIT_FLIP_ENDIAN 

Flip the file's read bits from the original flag bit (NOT_IMPLEMENTED)

Function Documentation

◆ losCloseFile()

EXPORT_DLL losResult losCloseFile ( _in_ losFileHandle  handle)

losCloseFile is to close the library object and safely delete it

Parameters
[in]handle
Returns
losResult

◆ losDoseFileExist()

EXPORT_DLL losResult losDoseFileExist ( _in_ const char *  path)

losDoseFileExist can be used to check if the file exists will return LOS_SUCCESS if the file exists else it will return LOS_ERROR_MALFORMED_DATA

Parameters
[in]path
Returns
losResult

◆ losGetFuncAddress()

EXPORT_DLL void* losGetFuncAddress ( _in_ const losFileHandle  handle,
_in_ const char *  name 
)

losGetFuncAddress extracts the function memory address loaded when the LOS_FILE_BIT_BINARY is set

Parameters
[in]handle
[in]name
Returns
address

◆ losOpenFile()

EXPORT_DLL losResult losOpenFile ( _out_ losFileHandle handle,
_in_ const losFileOpenInfo  file_info 
)

losOpenFile is to create the library object but dose not release the object to the library user

Parameters
[out]handle
[in]file_info
Returns
losResult

◆ losReadFile()

EXPORT_DLL losResult losReadFile ( _in_ losFileHandle  handle,
_out_ void **  buffer,
_out_ size_t *  bytes_read 
)

losReadFile read data to native file held by the library object when in unicode mode it will return wchar_t data encoding from the read

Parameters
[in]handle
[out]buffer
[out]bytes_read
Returns
losResult

◆ losSetAssetPath()

EXPORT_DLL losResult losSetAssetPath ( _in_ const char *  path)

losSetAssetPath can be used to set the full data path for $[asset_base]

Parameters
[in]path
Returns
losResult

◆ losWriteFile()

EXPORT_DLL losResult losWriteFile ( _in_ const losFileHandle  handle,
_in_ const void *  buffer,
_in_ const size_t  buffer_size 
)

losWriteFile write data to native file held by the library object when in unicode mode it expects wchar_t data encoding to write

Parameters
[in]handle
[in]buffer
[in]buffer_size
Returns
losResult