FileIO.h
Go to the documentation of this file.
1 
8 #pragma once
9 // LIBOS LICENCE
10 //
11 // GNU Lesser General Public License Version 3.0
12 //
13 // Copyright Luke Shore (c) 2022, 2023
15 #include <libos/Defines.h>
20 typedef struct losFileHandle_T *losFileHandle;
24 typedef enum losFileBits
25 {
38 typedef struct losFileOpenInfo
39 {
40  uint8_t fileBits = 0;
42  const char *path;
44  size_t path_size = 0;
45 
74 EXPORT_DLL losResult losReadFile(_in_ losFileHandle handle, _out_ void **buffer, _out_ size_t *bytes_read);
83 EXPORT_DLL losResult losWriteFile(_in_ const losFileHandle handle, _in_ const void *buffer,
84  _in_ const size_t buffer_size);
91 EXPORT_DLL void *losGetFuncAddress(_in_ const losFileHandle handle, _in_ const char *name);
losResult
losResult enum is used to indicate the result of a LibOS function call that can fail instead of throw...
Definition: DataType.h:47
defines hold function & macros for the parts of the library to work
#define _out_
out macromatic suger to make headers easier to read
Definition: Defines.h:44
#define EXPORT_DLL
on windows some extra syntax is required for the dll to work properly so that is dose not affect the ...
Definition: Defines.h:33
#define _in_
in macromatic suger to make headers easier to read
Definition: Defines.h:40
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
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 wch...
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 e...
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 w...
losFileBits
losFileBits is used for file object flags
Definition: FileIO.h:25
@ LOS_FILE_BIT_DELETE_AFTER_CLOSE
Tells the library to delete the file after using it flag bit.
Definition: FileIO.h:31
@ LOS_FILE_BIT_WRITE
Write file flag bit.
Definition: FileIO.h:27
@ LOS_FILE_BIT_FLIP_ENDIAN
Flip the file's read bits from the original flag bit (NOT_IMPLEMENTED)
Definition: FileIO.h:32
@ LOS_FILE_BIT_UNICODE
Unicode file flag bit.
Definition: FileIO.h:29
@ LOS_FILE_BIT_BINARY
Binary aka library handle file flag bit (NOT_IMPLEMENTED)
Definition: FileIO.h:28
@ LOS_FILE_BIT_CREATE
Create file if does not exist flag bit.
Definition: FileIO.h:30
@ LOS_FILE_BIT_READ
Read file flag bit.
Definition: FileIO.h:26
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
EXPORT_DLL losResult losSetAssetPath(_in_ const char *path)
losSetAssetPath can be used to set the full data path for $[asset_base]
struct losFileOpenInfo losFileOpenInfo
losFileOpenInfo is the file creation struct we pass this into the creation function for the library t...
struct losFileHandle_T * losFileHandle
this is the Library object that is used to read and write files from the filesystem as the user only ...
Definition: FileIO.h:20
EXPORT_DLL losResult losCloseFile(_in_ losFileHandle handle)
losCloseFile is to close the library object and safely delete it
losFileOpenInfo is the file creation struct we pass this into the creation function for the library t...
Definition: FileIO.h:39
uint8_t fileBits
file (bits/flags) combination tells the library how to lock the file down to act like a sanity check
Definition: FileIO.h:40
size_t path_size
size of the path to the file
Definition: FileIO.h:44
const char * path
path to the file $[binary_base] and $[asset_base] can be used as relative path for internal program f...
Definition: FileIO.h:42