2022-07-22 16:00:25 +00:00
|
|
|
#pragma once
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <storage/storage.h>
|
|
|
|
#include "stream.h"
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Allocate a file stream with buffered read operations
|
|
|
|
* @return Stream*
|
|
|
|
*/
|
|
|
|
Stream* buffered_file_stream_alloc(Storage* storage);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Opens an existing file or creates a new one.
|
|
|
|
* @param stream pointer to file stream object.
|
|
|
|
* @param path path to file
|
|
|
|
* @param access_mode access mode from FS_AccessMode
|
|
|
|
* @param open_mode open mode from FS_OpenMode
|
2022-08-03 16:43:14 +00:00
|
|
|
* @return True on success, False on failure. You need to close the file even if the open operation failed.
|
2022-07-22 16:00:25 +00:00
|
|
|
*/
|
|
|
|
bool buffered_file_stream_open(
|
|
|
|
Stream* stream,
|
|
|
|
const char* path,
|
|
|
|
FS_AccessMode access_mode,
|
|
|
|
FS_OpenMode open_mode);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Closes the file.
|
2022-08-03 16:43:14 +00:00
|
|
|
* @param stream pointer to file stream object.
|
|
|
|
* @return True on success, False on failure.
|
2022-07-22 16:00:25 +00:00
|
|
|
*/
|
|
|
|
bool buffered_file_stream_close(Stream* stream);
|
|
|
|
|
2022-08-03 16:43:14 +00:00
|
|
|
/**
|
|
|
|
* Forces write from cache to the underlying file.
|
|
|
|
* @param stream pointer to file stream object.
|
|
|
|
* @return True on success, False on failure.
|
|
|
|
*/
|
|
|
|
bool buffered_file_stream_sync(Stream* stream);
|
|
|
|
|
2022-07-22 16:00:25 +00:00
|
|
|
/**
|
|
|
|
* Retrieves the error id from the file object
|
|
|
|
* @param stream pointer to stream object.
|
|
|
|
* @return FS_Error error id
|
|
|
|
*/
|
|
|
|
FS_Error buffered_file_stream_get_error(Stream* stream);
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|