Commit 48ac645c authored by Ronan's avatar Ronan

fix(vfs): remove define of posix functions like read

parent 530ebd52
Pipeline #15 failed with stage
in 0 seconds
......@@ -38,7 +38,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include <unistd.h>
#endif
#ifdef _WIN32
#ifdef _WIN32
#ifndef S_IRUSR
#define S_IRUSR S_IREAD
......@@ -48,12 +48,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#define S_IWUSR S_IWRITE
#endif
#define open _open
#define read _read
#define write _write
#define close _close
#define lseek _lseek
#endif /*!_WIN32*/
#define BCTBX_VFS_OK 0 /* Successful result */
......@@ -91,7 +85,7 @@ struct bctbx_io_methods_t {
int (*pFuncClose)(bctbx_vfs_file_t *pFile);
ssize_t (*pFuncRead)(bctbx_vfs_file_t *pFile, void* buf, size_t count, off_t offset);
ssize_t (*pFuncWrite)(bctbx_vfs_file_t *pFile, const void* buf, size_t count, off_t offset);
int (*pFuncTruncate)(bctbx_vfs_file_t *pFile, int64_t size);
int (*pFuncTruncate)(bctbx_vfs_file_t *pFile, int64_t size);
int64_t (*pFuncFileSize)(bctbx_vfs_file_t *pFile);
int (*pFuncGetLineFromFd)(bctbx_vfs_file_t *pFile, char* s, int count);
off_t (*pFuncSeek)(bctbx_vfs_file_t *pFile, off_t offset, int whence);
......@@ -116,21 +110,21 @@ BCTBX_PUBLIC bctbx_vfs_t *bc_create_vfs(void);
/**
* Attempts to read count bytes from the open file given by pFile, at the position starting at offset
* Attempts to read count bytes from the open file given by pFile, at the position starting at offset
* in the file and and puts them in the buffer pointed by buf.
* @param pFile bctbx_vfs_file_t File handle pointer.
* @param buf Buffer holding the read bytes.
* @param count Number of bytes to read.
* @param count Number of bytes to read.
* @param offset Where to start reading in the file (in bytes).
* @return Number of bytes read on success, BCTBX_VFS_ERROR otherwise.
* @return Number of bytes read on success, BCTBX_VFS_ERROR otherwise.
*/
BCTBX_PUBLIC ssize_t bctbx_file_read(bctbx_vfs_file_t *pFile, void *buf, size_t count, off_t offset);
/**
* Close the file from its descriptor pointed by thw bctbx_vfs_file_t handle.
* Close the file from its descriptor pointed by thw bctbx_vfs_file_t handle.
* @param pFile File handle pointer.
* @return return value from the pFuncClose VFS Close function on success,
* BCTBX_VFS_ERROR otherwise.
* @return return value from the pFuncClose VFS Close function on success,
* BCTBX_VFS_ERROR otherwise.
*/
BCTBX_PUBLIC int bctbx_file_close(bctbx_vfs_file_t *pFile);
......@@ -140,7 +134,7 @@ BCTBX_PUBLIC int bctbx_file_close(bctbx_vfs_file_t *pFile);
* @param pVfs Pointer to the vfs instance in use.
* @param fName Absolute file path.
* @param mode File access mode (char*).
* @return pointer to bctbx_vfs_file_t on success, NULL otherwise.
* @return pointer to bctbx_vfs_file_t on success, NULL otherwise.
*/
BCTBX_PUBLIC bctbx_vfs_file_t* bctbx_file_open(bctbx_vfs_t *pVfs, const char *fName, const char *mode);
......@@ -151,7 +145,7 @@ BCTBX_PUBLIC bctbx_vfs_file_t* bctbx_file_open(bctbx_vfs_t *pVfs, const char *fN
* @param pVfs Pointer to the vfs instance in use.
* @param fName Absolute file path.
* @param openFlags File access flags(integer).
* @return pointer to bctbx_vfs_file_t on success, NULL otherwise.
* @return pointer to bctbx_vfs_file_t on success, NULL otherwise.
*/
BCTBX_PUBLIC bctbx_vfs_file_t* bctbx_file_open2(bctbx_vfs_t *pVfs, const char *fName, const int openFlags);
......@@ -159,7 +153,7 @@ BCTBX_PUBLIC bctbx_vfs_file_t* bctbx_file_open2(bctbx_vfs_t *pVfs, const char *f
/**
* Returns the file size.
* @param pFile bctbx_vfs_file_t File handle pointer.
* @return BCTBX_VFS_ERROR if an error occured, file size otherwise.
* @return BCTBX_VFS_ERROR if an error occured, file size otherwise.
*/
BCTBX_PUBLIC int64_t bctbx_file_size(bctbx_vfs_file_t *pFile);
......@@ -167,7 +161,7 @@ BCTBX_PUBLIC int64_t bctbx_file_size(bctbx_vfs_file_t *pFile);
* Truncates/ Extends a file.
* @param pFile bctbx_vfs_file_t File handle pointer.
* @param size New size of the file.
* @return BCTBX_VFS_ERROR if an error occured, 0 otherwise.
* @return BCTBX_VFS_ERROR if an error occured, 0 otherwise.
*/
BCTBX_PUBLIC int bctbx_file_truncate(bctbx_vfs_file_t *pFile, int64_t size);
......@@ -177,13 +171,13 @@ BCTBX_PUBLIC int bctbx_file_truncate(bctbx_vfs_file_t *pFile, int64_t size);
* @param pFile File handle pointer.
* @param buf Buffer hodling the values to write.
* @param count Number of bytes to write to the file.
* @param offset Position in the file where to start writing.
* @param offset Position in the file where to start writing.
* @return Number of bytes written on success, BCTBX_VFS_ERROR if an error occurred.
*/
BCTBX_PUBLIC ssize_t bctbx_file_write(bctbx_vfs_file_t *pFile, const void *buf, size_t count, off_t offset);
/**
* Writes to file.
* Writes to file.
* @param pFile File handle pointer.
* @param offset where to write in the file
* @param fmt format argument, similar to that of printf
......@@ -192,12 +186,12 @@ BCTBX_PUBLIC ssize_t bctbx_file_write(bctbx_vfs_file_t *pFile, const void *buf,
BCTBX_PUBLIC ssize_t bctbx_file_fprintf(bctbx_vfs_file_t *pFile, off_t offset, const char *fmt, ...);
/**
* Wrapper to pFuncGetNxtLine. Returns a line with at most maxlen characters
* Wrapper to pFuncGetNxtLine. Returns a line with at most maxlen characters
* from the file associated to pFile and writes it into s.
* @param pFile File handle pointer.
* @param s Buffer where to store the read line.
* @param maxlen Number of characters to read to find a line in the file.
* @return BCTBX_VFS_ERROR if an error occurred, size of line read otherwise.
* @param maxlen Number of characters to read to find a line in the file.
* @return BCTBX_VFS_ERROR if an error occurred, size of line read otherwise.
*/
BCTBX_PUBLIC int bctbx_file_get_nxtline(bctbx_vfs_file_t *pFile, char *s, int maxlen);
......@@ -205,16 +199,16 @@ BCTBX_PUBLIC int bctbx_file_get_nxtline(bctbx_vfs_file_t *pFile, char *s, int ma
* Wrapper to pFuncSeek VFS method call. Set the position to offset in the file.
* @param pFile File handle pointer.
* @param offset File offset where to set the position to.
* @param whence Either SEEK_SET, SEEK_CUR,SEEK_END
* @return BCTBX_VFS_ERROR on error, offset otherwise.
* @param whence Either SEEK_SET, SEEK_CUR,SEEK_END
* @return BCTBX_VFS_ERROR on error, offset otherwise.
*/
BCTBX_PUBLIC off_t bctbx_file_seek(bctbx_vfs_file_t *pFile, off_t offset, int whence);
/**
* Set default VFS pointer pDefault to my_vfs.
* By default, the global pointer is set to use VFS implemnted in vfs.c
* @param my_vfs Pointer to a bctbx_vfs_t structure.
* By default, the global pointer is set to use VFS implemnted in vfs.c
* @param my_vfs Pointer to a bctbx_vfs_t structure.
*/
BCTBX_PUBLIC void bctbx_vfs_set_default(bctbx_vfs_t *my_vfs);
......@@ -225,7 +219,7 @@ BCTBX_PUBLIC void bctbx_vfs_set_default(bctbx_vfs_t *my_vfs);
* @return Pointer to bctbx_vfs_t set to operate as default VFS.
*/
BCTBX_PUBLIC bctbx_vfs_t* bctbx_vfs_get_default(void);
/**
* Return pointer to standard VFS impletentation.
* @return pointer to bcVfs
......@@ -239,4 +233,3 @@ BCTBX_PUBLIC bctbx_vfs_t* bctbx_vfs_get_standard(void);
#endif /* BCTBX_VFS_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment