File

Note

Each of these methods are forwarded to Dsl, e.g. you can use dsl.file_exists?(path) instead File.exists?(dsl, path).

class Hutte::File

Remote file utilities. The Unix notion of file is used here, where a directory is considered as a special kind of file.

This class is effectively a wrapper around the test utility.

classmethod File.exists?(dsl, path)

Return true if path exists.

classmethod File.is_dir?(dsl, path)

Return true if path is a directory.

classmethod File.has_content?(dsl, path)

Return true if path has a size greater than zero.

classmethod File.is_link?(dsl, path)

Return true if path is symbolic link.

classmethod File.is_readable?(dsl, path)

Return true if read permission is granted for path.

classmethod File.is_writable?(dsl, path)

Return true if write permission is granted for path.

classmethod File.is_executable?(dsl, path)

Return true if execute (or search) permission is granted for path.

classmethod File.is_socket?(dsl, path)

Return true if path is a socket.

classmethod File.test(dsl, test_flag, path)

Call the test utility on the remote server, passing test_flag (e.g. ‘-s’) and path as arguments.

Return the result of the evaluation. This may be somewhat confusing, as the test utility returns 0 if the expression evaluated to true. As an example, test(dsl, '-e', '/some/path') would return true if /some/path exists.

The other methods all call this one with the appropriate flag value. This method is intended as a way to use the less common flags.