File.Behaviour behaviour (Raxol v0.4.0)
View SourceDefines the behaviour for file system operations. This is used for mocking in tests.
Summary
Callbacks
Checks if a file exists.
Creates a directory and its parent directories.
Reads file contents.
Removes a file.
Gets file statistics.
Writes content to a file.
Callbacks
Checks if a file exists.
@callback mkdir_p(path :: String.t()) :: :ok | {:error, File.posix()}
Creates a directory and its parent directories.
@callback read(path :: String.t()) :: {:ok, binary()} | {:error, File.posix()}
Reads file contents.
@callback rm(path :: String.t()) :: :ok | {:error, File.posix()}
Removes a file.
@callback stat(path :: String.t()) :: {:ok, File.Stat.t()} | {:error, File.posix()}
Gets file statistics.
@callback write(path :: String.t(), content :: binary()) :: :ok | {:error, File.posix()}
Writes content to a file.