Utilities

DataToolkitCore.FilePathType
FilePath <: SystemPath

Crude stand in for a file path type, which is strangely absent from Base.

This allows for load/write method dispatch, and the distinguishing of file content (as a String) from file paths.

See also: DirPath.

Examples

julia> string(FilePath("some/path"))
"some/path"
source
DataToolkitCore.DirPathType
DirPath <: SystemPath

Signifies that a given string is in fact a path to a directory.

This allows for load/write method dispatch, and the distinguishing of file content (as a String) from file paths.

See also: FilePath.

Examples

julia> string(DirPath("some/path"))
"some/path"
source
DataToolkitCore.@log_doMacro
@log_do category message [expr]

Return the result of expr, logging message with category if appropriate to do so.

source
DataToolkitCore.atomic_writeFunction
atomic_write(f::Function, dest::AbstractString; temp::AbstractString = dest * "_XXXX.part")

Atomically write to dest with f, via temp.

Calls the function f that writes to temp, with temp given as an IO handle or a String depending on as. Upon completion, temp is renamed to dest.

The file dest is not touched until the write is complete, and if the write to dest is interrupted or fails for any reason, no data is written to temp.

Limitations

It is impossible to gauntree truly atomic writes on hardware without power loss protection (PLP), even with copy-on-write (CoW) filesystems. This function makes a best effort, calling fdatasync before renaming a file. In most situations this will be sufficient, but it is not a guarantee.

source