668,7 → 668,7 |
/* specified by origin (SEEK_SET, SEEK_CUR, SEEK_END) */ |
/* Returnvalue: Is 1 if seek was successful */ |
/****************************************************************************************************************************************************/ |
int16_t fseek_(File_t *file, int32_t offset, int16_t origin) |
int16_t fseek_(File_t * const file, int32_t offset, int16_t origin) |
{ |
int32_t fposition = 0; |
int16_t retvalue = 1; |
1257,7 → 1257,7 |
/* */ |
/* Returnvalue: The filepointer to the file or 0 if faild. */ |
/********************************************************************************************************************************************/ |
File_t * fopen_(const int8_t *filename, const int8_t mode) |
File_t * fopen_(int8_t * const filename, const int8_t mode) |
{ |
File_t *file = 0; |
|
1363,7 → 1363,7 |
/* */ |
/* Returnvalue: 0 on success EOF on error */ |
/****************************************************************************************************************************************************/ |
int16_t fflush_(File_t *file) |
int16_t fflush_(File_t * const file) |
{ |
DirEntry_t *dir; |
|
1432,7 → 1432,7 |
/* */ |
/* Returnvalue: The function returns the character read from the specified memorylocation as u8 casted to s16 or EOF. */ |
/********************************************************************************************************************************************/ |
int16_t fgetc_(File_t *file) |
int16_t fgetc_(File_t * const file) |
{ |
int16_t c = EOF; |
uint32_t curr_sector; |
1486,7 → 1486,7 |
/* */ |
/* Returnvalue: The function returns the character written to the stream or EOF on error. */ |
/********************************************************************************************************************************************/ |
int16_t fputc_(const int8_t c, File_t *file) |
int16_t fputc_(const int8_t c, File_t * const file) |
{ |
uint32_t curr_sector = 0; |
|
1554,7 → 1554,7 |
/* */ |
/* Returnvalue: The function returns the number of objects (not bytes) read from the file. */ |
/****************************************************************************************************************************************/ |
uint32_t fread_(void *buffer, uint32_t size, uint32_t count, File_t *file) |
uint32_t fread_(void * const buffer, uint32_t size, uint32_t count, File_t * const file) |
{ |
uint32_t object_cnt = 0; // count the number of objects read from the file. |
uint32_t object_size = 0; // count the number of bytes read from the actual object. |
1597,7 → 1597,7 |
/* */ |
/* Returnvalue: The function returns the number of objects (not bytes) read from the file. */ |
/****************************************************************************************************************************************/ |
uint32_t fwrite_(void *buffer, uint32_t size, uint32_t count, File_t *file) |
uint32_t fwrite_(void * const buffer, uint32_t size, uint32_t count, File_t * const file) |
{ |
uint32_t object_cnt = 0; // count the number of objects written to the file. |
uint32_t object_size = 0; // count the number of bytes written from the actual object. |
1639,7 → 1639,7 |
/* */ |
/* Returnvalue: The function returns a no negative value or EOF on error. */ |
/****************************************************************************************************************************************/ |
int16_t fputs_(const int8_t *string, File_t *file) |
int16_t fputs_(int8_t * const string, File_t * const file) |
{ |
uint8_t i=0; |
int16_t c = 0; |
1661,32 → 1661,34 |
/* */ |
/* Returnvalue: A pointer to the string read from the file or 0 on error. */ |
/****************************************************************************************************************************************/ |
uint8_t * fgets_(int8_t *string, int16_t length, File_t *file) |
int8_t * fgets_(int8_t * const string, int16_t length, File_t * const file) |
{ |
uint8_t *pbuff; |
int16_t c = 0; |
int8_t *pbuff; |
int16_t c = 0, bytecount; |
|
if((!Partition.IsValid) || (file == NULL) || (string == NULL) || (length = 0)) return (0); |
if((!Partition.IsValid) || (file == NULL) || (string == NULL) || (length > 1)) return (0); |
pbuff = string; |
while(length > 1) // read the count-1 characters from the file to the string. |
bytecount = length; |
while(bytecount > 1) // read the count-1 characters from the file to the string. |
{ |
c = fgetc_(file); // read a character from the opened file. |
c = fgetc_(file); // read a character from the opened file. |
switch(c) |
{ |
case 0x0A: |
c = 0; // set string terminator |
length = 1; // stop loop |
*pbuff = 0; // set string terminator |
return(string); // stop loop |
break; |
|
case EOF: |
c = 0; // set string terminator |
length = 1; // stop loop |
*pbuff = 0; // set string terminator |
return(0); |
default: |
*pbuff++ = (int8_t)c; // copy byte to string |
bytecount--; |
break; |
} |
*pbuff = (uint8_t)c; // copy byte to string |
length--; |
pbuff++; |
} |
*pbuff = 0; |
return(string); |
} |
|