static void _block_out (rle_out *rle, unsigned char c) { rle->oblock[(rle->oblen)++] = c; if (rle->oblen >= 255) _write_block (rle); }
int fl_fputc(int c, FL_FILE *file) { BYTE Buffer[1]; // If first call to library, initialise CHECK_FL_INIT(); if (file==NULL) return -1; // Check if file open if (file->inUse==FALSE) return -1; // Append writes to end of file if (file->Append) file->bytenum = file->filelength; // Else write to current position // Write single byte Buffer[0] = (BYTE)c; if (_write_block(file, Buffer, 1)) return c; else return -1; }
int fl_fputs(const char * str, FL_FILE *file) { // If first call to library, initialise CHECK_FL_INIT(); if (file==NULL) return -1; // Check if file open if (file->inUse==FALSE) return -1; // Append writes to end of file if (file->Append) file->bytenum = file->filelength; // Else write to current position if (_write_block(file, (BYTE*)str, (UINT32)strlen(str))) return (int)strlen(str); else return -1; }
int fl_fwrite(const void * data, int size, int count, FL_FILE *file ) { // If first call to library, initialise CHECK_FL_INIT(); if (file==NULL) return -1; // Check if file open if (file->inUse==FALSE) return -1; // Append writes to end of file if (file->Append) file->bytenum = file->filelength; // Else write to current position if (_write_block(file, (BYTE*)data, (size*count) )) return count; else return -1; }
static void _block_flush (rle_out *rle) { if (rle->oblen > 0) _write_block (rle); }