VFBuffering(W)

C Specification


#include <revolution/vf.h>

typedef s32	VFErr;

extern VFErr VFBuffering( const char* drive, s32 mode );
extern VFErr VFBufferingW( const VFWchar* drive, s32 mode );

Arguments

drive Drive name to set the write mode.
mode Write or Write Back Mode

Set to VF_WRITE_BACK_ON_SIGNIF_API by default when VF starts.
When a drive is formatted, the target drive is set to the default setting, VF_WRITE_BACK_ON_SIGNIF_API.

VF_EJECT_SAFE_WITH_WRITE_THRU Data is written immediately to the media if even 1 byte has been updated.
VF_EJECT_SAFE_WITH_WRITE_BACK Data is written immediately to the media if a write to FAT has been issued. Conversely, directory entries and file data are buffered to the data buffer and written back to the media during the file close process.
VF_WRITE_BACK_ON_SIGNIF_API All data is buffered and written back to the media during the file close process.
VF_WRITE_BACK_CACHE All data is buffered, but the data is not written back to the media during the file close process. To write back the data, call VFFileSync or VFSync.

Return Values

Returns 0 when successful
Otherwise, returns VFErr other than 0

Description

Sets the write mode and write-back mode for the FAT buffer and data buffer.

The FAT buffer is the region used internally by VF for caching the data of the FAT region when reading from or writing to FAT. The data buffer is the region used internally by VF for caching the file data and directory entry regions when reading from or writing to the file data and directory entry regions.
You can select whether to write data that has been updated when an API is issued immediately to the media when a directory entry has been updated with VFCreateFile or VFOpenFile, or when data has been updated with VFReadFile or VFWriteFile.

Note

Depending on the VF internal processing, the FAT buffer and the data buffer may sometimes be swapped.
When this happens, write-back to the FAT buffer or data buffer will occur, regardless of the write-back setting.

When a drive that has been set to a write mode other than VF_EJECT_SAFE_WITH_WRITE_THRU is set to VF_EJECT_SAFE_WITH_WRITE_THRU, the data cached in the FAT buffer or the data buffer is written back. If the write-back process fails at this time, the write mode is not changed.
In addition, the state of the cache buffer is undefined because the write-back process has been interrupted.
If the write-back process fails, set the write mode to VF_EJECT_SAFE_WITH_WRITE_THRU again, and call VFBuffering.
If data cannot be written back because of some problem with the media, the write mode cannot be changed.

If a file is open in the drive specified with drive, do not call VFBuffering to change the write mode or the write-back method.
Operation cannot be guaranteed if you make these changes.

See Also

VFSync, VFFileSync

Revision History

2006/11/13 Cleaned things up
2006/09/29 Initial version.


CONFIDENTIAL