Skip to main content
FileSystem is a modern interface for file system operations that provides more fine-grained control than the Env interface. It supports features like async I/O, temperature-aware storage, and detailed I/O options.

Getting a FileSystem

Default

Returns the default FileSystem for the current platform.
std::shared_ptr<FileSystem>
Shared pointer to the default FileSystem.

File Creation

NewSequentialFile

Creates a sequentially-readable file.
const std::string&
Path to the file.
const FileOptions&
File options including I/O options, temperature, and checksum settings.
std::unique_ptr<FSSequentialFile>*
Output parameter for the file object.
IODebugContext*
Debug context for troubleshooting.
IOStatus
Returns OK on success, with detailed error information on failure.

NewRandomAccessFile

Creates a random access read-only file.

NewWritableFile

Creates a writable file.

FileOptions

Temperature
Hint for storage media placement: kUnknown, kHot, kWarm, kCold.
ChecksumType
Checksum type for write verification.
WriteLifeTimeHint
Expected lifetime of the data for storage optimization.

IOOptions

std::chrono::microseconds
Timeout for the I/O operation.
Env::IOPriority
Priority for rate limiting.
IOType
Type of data: kData, kFilter, kIndex, kMetadata, kWAL, kManifest, kLog.
bool
Request stronger data integrity checking and correction on read.

Directory Operations

NewDirectory

Creates a directory object for fsync operations.

CreateDir

Creates a directory.

CreateDirIfMissing

Creates a directory if it doesn’t exist.

File Operations

DeleteFile

Deletes a file.

RenameFile

Renames a file.

GetFileSize

Gets file size.

LinkFile

Creates a hard link.

File System Query

FileExists

Checks if a file exists.

GetChildren

Lists directory contents.

GetFreeSpace

Gets free disk space.

IsDirectory

Checks if a path is a directory.

Async I/O Support

SupportedOps

Indicates which advanced operations are supported:
  • kAsyncIO: Async read operations
  • kFSBuffer: File system allocated buffers
  • kVerifyAndReconstructRead: Enhanced data integrity
  • kFSPrefetch: Prefetch operations

Poll

Polls for completion of async I/O requests.

AbortIO

Aborts async I/O requests.

IODebugContext

std::string
File path filled in by RocksDB.
std::map<std::string, uint64_t>
Performance counters set by the FileSystem.
std::string
Debug message from the FileSystem.
const std::string*
Optional request ID for tracing.

Temperature Awareness

Temperature hints help file systems place data on appropriate storage media:
  • kHot: Frequently accessed data, place on fast storage
  • kWarm: Moderately accessed data
  • kCold: Rarely accessed data, can use slower storage

Example: Basic File Operations

Example: Async I/O

FSRandomAccessFile

Read

Reads data at a specific offset.

MultiRead

Reads multiple blocks, potentially in parallel.

ReadAsync

Asynchronously reads data.

FSWritableFile

Append

Appends data to the file.

Append with Checksum

Appends data with checksum verification.

Sync

Syncs data to storage.

See Also