core/file

file and directory support library

Dependency Graph

core/file: Library Dependencies

View the full-size SVG (svg) or PDF (pdf) image or graphviz source (dot)

View color source code (raw) for this file

View reStructuredText (rst) source code for this page

Library Settings

$file_find_opts[]

Passed to find(1) when called by file_find.

$file_find_sort

If set to true, output from file_find() will be sorted.

$file_hashbin

Name of default hashing program

$file_hash_texts[]

Hashing algorithm output (see file_hash()).

$file_hash_name[]

Hashed file names (see file_hash()).

$file_hash_sizes[]

Hashed file sizes (see file_hash()).

$file_hash_modes[]

Hashed file modes (see file_hash()).

File I/O

file_read()

Reads file ($2) into an array variable ($1)

file_read_func()

Reads file ($1) and calls a command ($@) with lines as its arguments.

$1 - File name

$@ - Command to receive the file contents as arguments

file_capture_func()

Capture the output of a command ($@) to a temporary file, storing the name of the file in a named variable ($1).

$1 - Name of variable to receive the name of the temporary file.

$2 - Command to execute

$@ - Command arguments (optional)

file_capture()

Captures stdin to a temporary file, storing the name of the file in a named variable ($1).

$1 - Name of variable to receive the name of the temporary file.

File Variable I/O

file_var_func()

Captures the output of a command ($@) and assigns its output to the given variable ($1).

$1 - Name of variable to receive output from the command.

$2 - Command to execute

$@ - Command arguments (optional)

file_array_func()

Captures the output of a command ($@) and assigns its output to the given array variable ($1).

$1 - Name of array variable to receive lines from the command.

$2 - Command to execute

$@ - Command arguments (optional)

Directory and Path Functions

run_mkdir()

Wraps mkdir -p. This function should be used instead of the bare command in most cases.

run_pushd()

Wraps pushd to be silent or report a useful error

run_popd()

Wraps popd to be silent

run_in_dir()

Runs the command ($@) after changing a new directory ($1).

$1 - New directory

$@ - Command to run

file_readdir()

Prints list of files in the given directory ($1).

$1 - Directory to search

$@ - Optional arguments

file_mkdir()

Creates directory portion of file name ($1).

Finding Files

file_find

Fills an array with names of things found by find(1). The $file_find_opts[] variable controls the behavior of this function, allowing additional arguments to be passed to find.

$1 - Name of array variable

$@ - Path names to search

File Checking

file_size()

Prints the size of the given file(s)

$@ - File names

file_test()

Performs a existential test ($1) on the given files ($@) using the test shell command.

file_is_terminal()

Returns success if the named fd ($1) is a terminal.

File Hashing

file_hash_raw()

Runs the $file_hashbin program on the given files ($@).

file_hash_list()

Runs file_hash_raw() on the given files ($@) and reads the results in the named array variable ($1).

file_hash()

Loads the hash information for the given files ($@) into the file_hash_* arrays

_file_hash_split()

Splits apart the hash results ($1) for a single file and appends the various pieces to the respective $file_hash_*[] arrays.

remove mode from name

file_hash_print()

Prints the stored hash information. This function exists primarily for verification purposes.

_file_hash_print_index()

Prints stored hash information for a single file.

$1 - Index into $file_hash_*[] arrays

Duplicate Detection

file_duplicate_scan()

Scans the provided paths ($@) for duplicate files.

_file_duplicate_scan_index()

Checks an individual file for duplicity.

_file_duplicate_scan_check()

Prints the full list of duplicate files. The first of a group of duplicates files is prefixed with -; the remaining duplicates in the group are prefixed with +.

file_duplicate_scan_list()

Calls file_duplicate_scan "$@" and stores the results in an array variable ($1).

for_each_file_duplicate()

Iterates through a list of duplicates, as produced by file_duplicate_scan_list(). For each duplicate, a given function ($1) will be called with two arguments: the original and duplicate file names.

Duplicate Elimination

file_duplicate_delete()

Finds duplicates and deletes them.


View the Developer Guide Index

View the Reference Manual Index


Generated on Fri Jul 28 14:37:11 PDT 2017 by mcsh d14 v0.23.0.