GriffinSSG.Filesystem (Griffin v0.4.0)

View Source

Helper functions for handling basic file operations

Summary

Functions

Copies a list of files or directories into the destination directory. When successful, returns {:ok, count} where count is the number of copied files. if successful or {:errors, list(string())} when one or more copy operations failed. In case of error, the destination directory will be left in a dirty state, and only some of the files might have been copied.

Lists all files from a path or wildcard. If filepath is a path to a file, returns a list with only that filepath. If filepath points to a directory, returns a list of all files inside that directory and subdirectories. A list of ignored paths can be passed in to opts. The default value for opts is [".git", ".elixir_ls"]

Calculates the output path for a file. The filepath is a contained within input_dir, which means that to calculate the filepath in the output directory we need to see what is the filepath relative to the input_dir. The end result is a concatenation of the output_dir with this relative path.

Searches a given path for files that have the selected extensions

Functions

copy_all(files, destination)

Copies a list of files or directories into the destination directory. When successful, returns {:ok, count} where count is the number of copied files. if successful or {:errors, list(string())} when one or more copy operations failed. In case of error, the destination directory will be left in a dirty state, and only some of the files might have been copied.

git_ignores(path \\ ".gitignore")

list_all(filepath, opts \\ [".git", ".elixir_ls"])

Lists all files from a path or wildcard. If filepath is a path to a file, returns a list with only that filepath. If filepath points to a directory, returns a list of all files inside that directory and subdirectories. A list of ignored paths can be passed in to opts. The default value for opts is [".git", ".elixir_ls"]

output_filepath(filepath, input_dir, output_dir)

Calculates the output path for a file. The filepath is a contained within input_dir, which means that to calculate the filepath in the output directory we need to see what is the filepath relative to the input_dir. The end result is a concatenation of the output_dir with this relative path.

search_directory(path, extensions)

Searches a given path for files that have the selected extensions