Packages

Virtfs allows mock-FS operations, that can be applied on a real FS folder

Current section

Files

Jump to
virtfs lib virtfs file.ex
Raw

lib/virtfs/file.ex

defmodule Virtfs.File do
@type kind :: :file | :dir
use TypedStruct
typedstruct do
@typedoc "A File"
field(:kind, kind, default: :file)
field(:content, String.t(), default: "")
field(:path, String.t(), enforce: true)
end
def new_file(path, content) do
%Virtfs.File{
kind: :file,
path: path,
content: content
}
end
def new_dir(path) do
%Virtfs.File{
kind: :dir,
path: path
}
end
end