Documentation
¶
Index ¶
- func AcquireLock(path string, exclusive bool) (*os.File, error)
- func ComputeShaFile(filename string) ([]byte, error)
- func CopyDir(src string, dst string) (err error)
- func CopyFile(src, dst string) (err error)
- func DirExists(log *base.LogObject, dirname string) bool
- func DirSync(dirName string) error
- func EnsureDir(dirname string) error
- func FileExists(log *base.LogObject, filename string) bool
- func MoveDir(log *base.LogObject, src string, dst string) error
- func ReadSavedCounter(log *base.LogObject, fileName string) (uint32, bool)
- func ReadWithMaxSize(log *base.LogObject, filename string, maxReadSize int) ([]byte, error)
- func StatAndRead(log *base.LogObject, filename string, maxReadSize int) (string, time.Time, error)
- func Writable(dir string) bool
- func WriteRename(fileName string, b []byte) error
- func WriteRenameJSON(path, tmpPath string, v any) error
- func WriteRenameWithBackup(fileName string, b []byte) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AcquireLock ¶
AcquireLock acquires a file lock on the given path (appends .lock). It returns the locked file handle which must be closed by the caller to release the lock.
func ComputeShaFile ¶
ComputeShaFile computes the sha256 for the content of a file
func CopyDir ¶
CopyDir recursively copies a directory tree, attempting to preserve permissions. Source directory must exist, destination directory must *not* exist. Symlinks are ignored and skipped.
func CopyFile ¶
CopyFile copies the contents of the file named src to the file named by dst. The file will be created if it does not already exist. If the destination file exists, all it's contents will be replaced by the contents of the source file. The file mode will be copied from the source and the copied data is synced/flushed to stable storage.
func EnsureDir ¶
EnsureDir checks if the specified directory exists, and if not, creates it along with any necessary parent directories with permission 0755.
func FileExists ¶
FileExists checks file existence.
func MoveDir ¶
MoveDir recursively move a directory tree, attempting to preserve permissions. if file exists in dst (sub)directory it will be replaced
func ReadSavedCounter ¶
ReadSavedCounter returns counter value from provided file If the file doesn't exist or doesn't contain an integer it returns false
func ReadWithMaxSize ¶
ReadWithMaxSize returns the content but limits the size to maxReadSize and truncates if longer
func StatAndRead ¶
StatAndRead returns the content and Modtime We limit the size we read maxReadSize and truncate if longer
func WriteRename ¶
WriteRename write data to a tmpfile and then rename it to a desired name
func WriteRenameJSON ¶
WriteRenameJSON marshals the provided value 'v' into indented JSON format, appends a newline, and writes it atomically to the specified file path. The write operation is performed using an atomic write-rename strategy with fsync and directory sync to ensure data integrity. No backup of the previous file is created. Returns an error if marshalling or writing fails.
func WriteRenameWithBackup ¶
WriteRenameWithBackup : just like WriteRename but additionally it creates a backup of the original file at the same path but with the ".bak" extension added.
Types ¶
This section is empty.