Loading...
Searching...
No Matches
BD_FILE_H Struct Reference

File access. More...

## Data Fields

void * | internal
| Reserved for BD_FILE_H implementation use.
void(* | close )(BD_FILE_H *file)
| Close file.
int64_t(* | seek )(BD_FILE_H *file, int64_t offset, int32_t origin)
| Reposition file offset.
int64_t(* | tell )(BD_FILE_H *file)
| Get current read or write position.
int(* | eof )(BD_FILE_H *file)
| Check for end of file.
int64_t(* | read )(BD_FILE_H *file, uint8_t *buf, int64_t size)
| Read from file.
int64_t(* | write )(BD_FILE_H *file, const uint8_t *buf, int64_t size)
| Write to file.

## Detailed Description

File access.

## Field Documentation

## close

void(* BD_FILE_H::close) (BD_FILE_H *file)

Close file.

Parameters

  file | BD_FILE_H object

## eof

int(* BD_FILE_H::eof) (BD_FILE_H *file)

Check for end of file.

- optional, currently not used

Parameters

  file | BD_FILE_H object

Returns
  1 on EOF, < 0 on error, 0 if not EOF

## internal

void* BD_FILE_H::internal

Reserved for BD_FILE_H implementation use.

Implementation can store here ex. file handle, FILE*, ...

## read

int64_t(* BD_FILE_H::read) (BD_FILE_H *file, uint8_t *buf, int64_t size)

Read from file.

Parameters

  file | BD_FILE_H object
  buf | buffer where to store the data
  size | bytes to read

Returns
  number of bytes read, 0 on EOF, < 0 on error

## seek

int64_t(* BD_FILE_H::seek) (BD_FILE_H *file, int64_t offset, int32_t origin)

Reposition file offset.

- SEEK_SET: seek to 'offset' bytes from file start
- SEEK_CUR: seek 'offset' bytes from current position
- SEEK_END: seek 'offset' bytes from file end

Parameters

  file | BD_FILE_H object
  offset | byte offset
  origin | SEEK_SET, SEEK_CUR or SEEK_END

Returns
  current file offset, < 0 on error

## tell

int64_t(* BD_FILE_H::tell) (BD_FILE_H *file)

Get current read or write position.

Parameters

  file | BD_FILE_H object

Returns
  current file offset, < 0 on error

## write

int64_t(* BD_FILE_H::write) (BD_FILE_H *file, const uint8_t *buf, int64_t size)

Write to file.

Writing 0 bytes can be used to flush previous writes and check for errors.

Parameters

  file | BD_FILE_H object
  buf | data to be written
  size | bytes to write

Returns
  number of bytes written, < 0 on error

The documentation for this struct was generated from the following file:

- filesystem.h