Apps     Components     Interfaces     All Files     Source Tree     source: tos.lib.FS.Write.nc

Component: Write

Required Interfaces

Provided Interfaces

Variables

Function Index

Function Descriptions

FileWrite.open

command result_t FileWrite.open (uint8_t fd, const char *filename, uint8_t pflags)

open a file for sequential reads.

Parameters:

filename - Name of file to open. Must not be stack allocated.

create - TRUE if file should be created if it doesn't exist

truncate - TRUE if file should be truncated if it exists

Returns: SUCCESS: attempt proceeds, opened will be signaled
FAIL: filesystem is busy or another file is already open for writing

FileWrite.reserve

command result_t FileWrite.reserve (uint8_t fd, filesize_t newSize)

Reserve space for the currently open file to be newSize bytes long. appends that do not make the file take more than newSize bytes will not fail with FS_ERROR_NOSPACE. Note: you can find the reserved size of a file by requesting a reserve with a newSize of 0. The reserved event will indicate the space currently reserved.

Parameters:

newSize - Size file is expected to grow to

Returns: SUCCESS: attempt proceeds, reserved will be signaled
FAIL: no file was open for writing, or a close/append/reserve/sync is in progress

FileWrite.sync

command result_t FileWrite.sync (uint8_t fd)

Ensure data appended is comitted to stable storage.
Returns: SUCCESS: attempt proceeds, synced will be signaled
FAIL: no file was open for writing, or a close/append/reserve/sync is in progress

FileWrite.append

command result_t FileWrite.append (uint8_t fd, void *buffer, filesize_t n)

Write bytes sequentially to end of open file.

Parameters:

buffer - Data to write

n - Number of bytes to write

Returns: SUCCESS: attempt proceeds, appended will be signaled
FAIL: no file was open for writing, or a close/append/reserve/sync is in progress