dir_other.go
dir_other.go - Overview
This file provides directory locking mechanisms for systems other than Windows and Plan 9 (specifically targets Javascript and WASM), where standard file locking may not be available or applicable.
directoryLockGuard
- Purpose: Holds a lock on a directory.
- Fields:
- f:
*os.File
- File handle on the directory, which we've flocked. - path:
string
- The absolute path to our pid file. - readOnly:
bool
- Indicates if this is a shared lock for a read-only database.
- f:
acquireDirectoryLock
- Purpose: Gets a lock on the directory (using flock, which is skipped in this implementation).
- Parameters:
- dirPath:
string
- The path to the directory to lock. - pidFileName:
string
- The name of the PID file. - readOnly:
bool
- Indicates whether to acquire a read-only lock.
- dirPath:
- Returns:
*directoryLockGuard
- A pointer to the directoryLockGuard struct on success.error
- An error if the lock could not be acquired.
directoryLockGuard.release
- Purpose: Deletes the pid file and releases our lock on the directory.
- Parameters: None
- Returns:
error
- An error, if any.
openDir
- Purpose: Opens a directory for syncing.
- Parameters:
- path:
string
- The path to the directory.
- path:
- Returns:
*os.File
- A pointer to the opened file.error
- An error, if any.
syncDir
- Purpose: Ensures the directory entry for the file is synced.
- Parameters:
- dir:
string
- The directory to sync.
- dir:
- Returns:
error
- An error, if any.