FileUtils#

This module provides utilities for file management used by various IO modules.

See also

ClearMap.IO

abspath(filename)[source]#

Returns the filename using the full path specification.

Arguments

filenamestr

The file name.

Returns

filenamestr

The full file name.

copy_file(source, sink)[source]#

Copy a file.

Arguments

sourcestr

Filename of the file to copy.

sinkstr

File or directory name to copy the file to.

Returns

sinkstr

The name of the copied file.

create_directory(filename, split=True)[source]#

Creates the directory of the file name if it does not exists.

Arguments

filenamestr

The name to create the directory from.

splitbool

If True, split the filename first.

Returns

directorystr

The directory name.

delete_directory(filename, split=False)[source]#

Deletes a directory of the filename if it exists.

Arguments

filenamestr

The name to create the directory from.

splitbool

If True, split the filename first.

Returns

directorystr

The directory name.

delete_file(filename)[source]#

Deletes a file.

Arguments

filenamestr

Filename to delete.

file_extension(filename)[source]#

Returns the file extension of a file

Arguments

filenamestr

The file name.

Returns

extensionstr

The file extension or None if it does not exists.

is_directory(dirname)[source]#

Checks if a directory exists.

Arguments

dirnamestr

The directory name.

Returns

is_directorybool

True if source is a real file.

is_file(filename)[source]#

Checks if a file exists.

Arguments

filenamestr

The file name to check if it exists.

Returns

is_filebool

True if filename exists on disk and is not a directory.

join(path, filename)[source]#

Joins a path to a file name.

Arguments

pathstr

The path to append a file name to.

filenamestr

The file name.

Returns

filenamestr

The full file name.

split(filename)[source]#

Splits a file name into it’s path and name.

Arguments

filenamestr

The file name.

Returns

pathstr

The path of the file.

filenamestr

The file name.