Subversion Repositories Projects

Compare Revisions

Ignore whitespace Rev 316 → Rev 317

/FollowMe/fat16.c
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);
}
 
/FollowMe/fat16.h
47,18 → 47,18
extern uint8_t Fat16_Init(void);
extern uint8_t Fat16_Deinit(void);
 
extern File_t * fopen_(const int8_t *filename, const int8_t mode);
extern File_t * fopen_(int8_t * const filename, const int8_t mode);
extern int16_t fclose_(File_t *file);
extern uint8_t fexist_(const int8_t *filename);
extern int16_t fflush_(File_t *file);
extern int16_t fseek_(File_t *file, int32_t offset, int16_t origin);
extern int16_t fgetc_(File_t *file);
extern int16_t fputc_(int8_t c, File_t *file);
extern uint32_t fread_(void *buffer, uint32_t size, uint32_t count, File_t *file);
extern uint8_t fexist_(int8_t * const filename);
extern int16_t fflush_(File_t * const file);
extern int16_t fseek_(File_t * const file, int32_t offset, int16_t origin);
extern int16_t fgetc_(File_t * const file);
extern int16_t fputc_(const int8_t c, File_t * const file);
extern uint32_t fread_(void * const buffer, uint32_t size, uint32_t count, File_t * const file);
extern uint32_t fwrite_(void *buffer, uint32_t size, uint32_t count, File_t *file);
extern int16_t fputs_(const int8_t *string, File_t *file);
extern uint8_t * fgets_(int8_t *string, int16_t length, File_t *file);
extern uint8_t feof_(File_t *file);
extern int16_t fputs_(int8_t * const string, File_t * const file);
extern int8_t * fgets_(int8_t * const string, const int16_t length, File_t * const file);
extern uint8_t feof_(File_t * const file);