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.c File Reference

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

#include "stdio.h"
#include "errno.h"
#include "Platform.h"
#include "FileIo.h"

Go to the source code of this file.

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)
 
char * FileIO_Read_Line ()
 
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.
 

Variables

static long int curPos = 0
 
static long int filesz = 0
 
static int isFOpenning = 0
 
FILE * fp
 

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.c.

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_E_FOPEN_WRITE
Definition FileIo.h:40

◆ 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_E_FOPEN_READ
Definition FileIo.h:40

◆ 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; };

Variable Documentation

◆ curPos

long int curPos = 0
static

Definition at line 48 of file FileIo.c.

◆ filesz

long int filesz = 0
static

Definition at line 49 of file FileIo.c.

◆ fp

FILE* fp

Definition at line 56 of file FileIo.c.

◆ isFOpenning

int isFOpenning = 0
static

Definition at line 50 of file FileIo.c.