cbmimage
Loading...
Searching...
No Matches
File handling functions

Functions

cbmimage_filecbmimage_file_open_by_name (const char *filename)
 open a file on the cbmimage where the name is known
 
cbmimage_filecbmimage_file_open_by_dir_entry (cbmimage_dir_entry *dir_entry)
 open a file on the cbmimage that has already een enumerated
 
void cbmimage_file_close (cbmimage_file *file)
 close a file
 
int cbmimage_file_read_next_block (cbmimage_file *file, uint8_t *buffer, size_t buffer_size)
 read a block from the file
 

Detailed Description

Function Documentation

◆ cbmimage_file_close()

void cbmimage_file_close ( cbmimage_file * file)

close a file

Parameters
[in]filepointer to a cbmimage_file that was obtained by a previous cbmimage_file_open_by_name() or cbmimage_file_open_by_dir_entry() call.
Remarks
  • Call this function after the proceessing of the file has finished.

◆ cbmimage_file_open_by_dir_entry()

cbmimage_file * cbmimage_file_open_by_dir_entry ( cbmimage_dir_entry * dir_entry)

open a file on the cbmimage that has already een enumerated

Parameters
[in]dir_entryptr to a directory entry for the file that should be opened.
That dir_entry must have been the result of a previous cbmimage_dir_get_first() or cbmimage_dir_get_next() call.
Returns
  • pointer to a cbmimage_file object than can be used to access the file
  • NULL if an error occurred
Remarks

◆ cbmimage_file_open_by_name()

cbmimage_file * cbmimage_file_open_by_name ( const char * filename)

open a file on the cbmimage where the name is known

Parameters
[in]filenamepointer to the file name of the file to open on the image.
Returns
  • pointer to a cbmimage_file object than can be used to access the file
  • NULL if an error occurred
Remarks
Todo
implement cbmimage_file_open_by_name()
Todo
Bug
cbmimage_file_open_by_name() not yet implemented

◆ cbmimage_file_read_next_block()

int cbmimage_file_read_next_block ( cbmimage_file * file,
uint8_t * buffer,
size_t buffer_size )

read a block from the file

Parameters
[in]filepointer to a cbmimage_file that was obtained by a previous cbmimage_file_open_by_name() or cbmimage_file_open_by_dir_entry() call.
[in,out]bufferthe buffer where the file contents are written to
[in]buffer_sizethe size of the buffer.
Returns
  • > 0: the number of valid byte in the buffer
  • = 0: EOF, no more byte are available
  • < 0: an error occurred
Remarks
  • If you want to read in the whole file, call this function repeatedly until the return value is 0.