image/svg+xml
Brteve's API for EveApps
Version 0.0.1
The reference document for common folder of EveApps project.
 
Loading...
Searching...
No Matches
FileIo.h File Reference

File read-write library for Eve application, support a unique interface for every platform. More...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

Go to the source code of this file.

Macros

#define FileIO_Append(M, ...)
 

Enumerations

enum  _FILEIO_E_FOPEN { FILEIO_E_FOPEN_READ , FILEIO_E_FOPEN_WRITE , FILEIO_E_FOPEN_APPEND }
 
enum  _FILEIO_E_FRESULT { FILEIO_E_FRESULT_OK , FILEIO_E_FRESULT_FAIL , FILEIO_E_FRESULT_EOF }
 

Functions

int FileIO_File_Close ()
 
int FileIO_File_Seek (unsigned long offset)
 
int FileIO_File_Tell ()
 
int FileIO_File_Open (const char *filePath, enum _FILEIO_E_FOPEN e)
 
int FileIO_File_Read (char *buffer, long bytes)
 
int FileIO_File_Write (const char *buffer, long buffersize)
 
int FileIO_File_List (char *path)
 
int FileIO_File_To_Buffer (const char *file, char *buff, long offset, int size, int *ByteCount)
 Read a whole file to a buffer.
 
void FileIO_Buffer_To_File (const char *txt, const char *buffer, unsigned long buffersize)
 Write a buffer to file.
 
char * FileIO_Read_Line ()
 

Detailed Description

File read-write library for Eve application, support a unique interface for every platform.

Author
Tuan Nguyen tuan..nosp@m.nguy.nosp@m.en@br.nosp@m.tchi.nosp@m.p.com
Date
2019

MIT License

Copyright (c) [2019] [Bridgetek Pte Ltd (BRTChip)]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Definition in file FileIo.h.

Macro Definition Documentation

◆ FileIO_Append

#define FileIO_Append (   M,
  ... 
)
Value:
{ \
int num = sprintf(msg, M, ##__VA_ARGS__); \
FileIO_File_Write(msg, num); \
}

Definition at line 45 of file FileIo.h.

46{ \
47 int num = sprintf(msg, M, ##__VA_ARGS__); \
48 FileIO_File_Write(msg, num); \
49}

Enumeration Type Documentation

◆ _FILEIO_E_FOPEN

Enumerator
FILEIO_E_FOPEN_READ 
FILEIO_E_FOPEN_WRITE 
FILEIO_E_FOPEN_APPEND 

Definition at line 39 of file FileIo.h.

39 {
41};
@ FILEIO_E_FOPEN_APPEND
Definition FileIo.h:40
@ FILEIO_E_FOPEN_READ
Definition FileIo.h:40
@ FILEIO_E_FOPEN_WRITE
Definition FileIo.h:40

◆ _FILEIO_E_FRESULT

Enumerator
FILEIO_E_FRESULT_OK 
FILEIO_E_FRESULT_FAIL 
FILEIO_E_FRESULT_EOF 

Definition at line 42 of file FileIo.h.

42 {
44};
@ FILEIO_E_FRESULT_FAIL
Definition FileIo.h:43
@ FILEIO_E_FRESULT_OK
Definition FileIo.h:43
@ FILEIO_E_FRESULT_EOF
Definition FileIo.h:43

Function Documentation

◆ FileIO_Buffer_To_File()

void FileIO_Buffer_To_File ( const char *  txt,
const char *  buffer,
unsigned long  buffersize 
)

Write a buffer to file.

Parameters
txtFile to write
bufferBuffer to write
buffersizeBuffer size
Note
File open mode: FILEIO_E_FOPEN_READ | FILEIO_E_FOPEN_WRITE | FILEIO_E_FOPEN_APPEND

Definition at line 566 of file FileIo.c.

566 {
567 if (-1 == FileIO_File_Open(txt, FILEIO_E_FOPEN_WRITE)) {
568 printf("Error open file\n");
569 return;
570 }
571 FileIO_File_Write(buffer, buffersize);
573}
static ft_uint32_t ft_uint8_t * buffer
Definition FT_Gpu_Hal.h:139
int FileIO_File_Write(const char *buffer, long buffersize)
Definition FileIo.c:510
int FileIO_File_Open(const char *filePath, enum _FILEIO_E_FOPEN e)
Definition FileIo.c:508
int FileIO_File_Close()
Definition FileIo.c:505

◆ FileIO_File_Close()

int FileIO_File_Close ( )

Definition at line 505 of file FileIo.c.

505{ return 0; };

◆ FileIO_File_List()

int FileIO_File_List ( char *  path)

Definition at line 511 of file FileIo.c.

511{ return 0; };

◆ FileIO_File_Open()

int FileIO_File_Open ( const char *  filePath,
enum _FILEIO_E_FOPEN  e 
)

Definition at line 508 of file FileIo.c.

508{ return 0; };

◆ FileIO_File_Read()

int FileIO_File_Read ( char *  buffer,
long  bytes 
)

Definition at line 509 of file FileIo.c.

509{ return 0; };

◆ FileIO_File_Seek()

int FileIO_File_Seek ( unsigned long  offset)

Definition at line 506 of file FileIo.c.

506{ return 0; };

◆ FileIO_File_Tell()

int FileIO_File_Tell ( )

Definition at line 507 of file FileIo.c.

507{ return 0; };

◆ FileIO_File_To_Buffer()

int FileIO_File_To_Buffer ( const char *  file,
char *  buff,
long  offset,
int  size,
int *  byteCount 
)

Read a whole file to a buffer.

Parameters
fileFile to read
buffResult buffer
offsetOffset where to read
sizeNumber of byte to read
byteCountResult of number of byte read
Returns
int 1 on successful

Definition at line 525 of file FileIo.c.

525 {
526 int fileSize = 0;
527 int numRead = 0;
528
529 fileSize = FileIO_File_Open(file, FILEIO_E_FOPEN_READ);
530 numRead = fileSize - offset;
531
532 if (offset >= fileSize) {
533 return 0;
534 }
535
536 if (0 >= fileSize) {
537 return 0;
538 }
539
540 if (size > 0 && size < numRead) {
541 numRead = size;
542 }
543
544 // seek file pointer to offset
545 FileIO_File_Seek(offset);
546
547 FileIO_File_Read(buff, numRead);
548
550
551 if (byteCount) {
552 *byteCount = numRead;
553 }
554
555 return 1;
556}
int FileIO_File_Read(char *buffer, long bytes)
Definition FileIo.c:509
int FileIO_File_Seek(unsigned long offset)
Definition FileIo.c:506

◆ FileIO_File_Write()

int FileIO_File_Write ( const char *  buffer,
long  buffersize 
)

Definition at line 510 of file FileIo.c.

510{ return 0; };

◆ FileIO_Read_Line()

char * FileIO_Read_Line ( )

Definition at line 512 of file FileIo.c.

512{ return 0; };