Getting the Default Env
Default
Env*
Returns a pointer to the default environment.
File Operations
NewSequentialFile
const std::string&
Path to the file to open.
std::unique_ptr<SequentialFile>*
Output parameter for the created file object.
const EnvOptions&
Options for opening the file (direct I/O, mmap, etc.).
Status
Returns OK on success, or an error status if the file cannot be opened.
NewRandomAccessFile
NewWritableFile
NewDirectory
File System Operations
FileExists
Status
Returns OK if the file exists, NotFound if it doesn’t exist.
GetChildren
DeleteFile
CreateDir
CreateDirIfMissing
DeleteDir
GetFileSize
RenameFile
LinkFile
File Locking
LockFile
const std::string&
Path to the file to lock. May be created if it doesn’t exist.
FileLock**
Output parameter for the lock object.
Status
Returns OK if the lock was acquired, or an error if another process holds the lock.
UnlockFile
Thread Management
Schedule
void (*)(void* arg)
Function to execute.
void*
Argument passed to the function.
Priority
Thread pool priority: BOTTOM, LOW, HIGH, USER.
StartThread
SetBackgroundThreads
GetBackgroundThreads
Time Functions
NowMicros
uint64_t
Current time in microseconds.
NowNanos
GetCurrentTime
SleepForMicroseconds
System Information
GetHostName
GetAbsolutePath
GetFreeSpace
EnvOptions
bool
Use O_DIRECT for reading data.
bool
Use O_DIRECT for writing data.
uint64_t
Incrementally sync files to disk while writing. 0 means no incremental sync.
Write Life Time Hints
Thread Priorities
Priority
Lowest priority for background operations.
Priority
Default priority for most background operations.
Priority
High priority for operations like flush.
Example
FileSystem API
For more fine-grained control, use the FileSystem interface:- IOOptions for per-request hints
- Temperature-aware file creation
- Async I/O support
- Better error reporting with IODebugContext