CatalystX::Usul::FileSystem - File system related methods
Describes v0.16.$Rev: 1 $
use Class::Usul; use CatalystX::Usul::FileSystem; my $usul = Class::Usul->new( config => {} ); my $filesys = CatalystX::Usul::FileSystem->new( builder => $usul ); my $table = $filesys->list_subdirectory( { dir => 'path_to_directory' } );
This model provides methods for manipulating files and directories
Defines the following attributes
compress_logs
Boolean defaults to true. Causes the "rotate_logs" methods to compress logs files after the first copy
config_path
A path to a file containing control data. Defaults to the misc file in the ctrldir directory
ctrldir
ctldata
Hash ref of control data loaded from file referenced by config_path attribute
fcopy_format
A non empty simple string which defaults to %{file}.%{copy}. Used by "rotate_logs" to insert the copy number into the file name. The %{file} symbol is replaced by the file name and the %{copy} symbol is replaced by the copy number. Literal text remains unaffected
%{file}.%{copy}
%{file}
%{copy}
fs_type
String which defaults to ext3. The default filesystem type
ext3
fuser
String which defaults to the value returned by the usul config object. The path to the external fuser command
postfix
String which defaults to A_. Prepended to filename when archived
A_
$output_messages = $self->archive( @paths );
Archives a files by prepending the $self-postfix>, which defaults to A_
$self-
$bool = $self->file_in_use( $path );
Uses the system fuser command if it is available to determine if a file is in use
$filesystem_responce_object = $self->file_systems( $filesysem );
Parses the output from the system mount command to produce a list of file systems. Includes details of the specified filesystem
mount
$permission_string = $self->get_perms( $mode );
Returns the -rw-rw-r-- style permission string for a given octal mode
-rw-rw-r--
$table_object = $self->list_subdirectory( $director_path );
Generates the table data for a directory listing. The data is used by the table subclass of HTML::FormWidgets
table
$output_messages = $self->purge_tree( $dir, $atime, $dtime );
Archive old files and delete even older ones from a given directory
$self->rotate( $logfile, $copies );
Issues a sequence a move commands to rename file to file.0, file.0 to file.1, file.1 to file.2 and so on. If the attribute compress_logs is true, then copies after the first one are compressed
move
file
file.0
file.1
file.2
$message = $self->rotate_log( logfile => $logfile_path, copies => $copies );
Calls "rotate". Will also touch a new logfile into existence and optionally signal a process
touch
$output_messages = $self->rotate_logs( $copies, $extension, $directory );
Calls "rotate_log" on all of the .log files in the given directory, which defaults to the logs directory. Defaults to keeping seven copies. Run this daily from cron
cron
$output_messages = $self->unarchive( @paths );
Reverse out the effect of calling "archive"
$output_messages = $self->wait_for( $opts, $key, $max_wait, $no_thrash );
Wait for a given file to exist. Polls at given intervals file a configurable period before throwing a time out error if the file does not show up
None
There are no known incompatibilities in this module
There are no known bugs in this module. Please report problems to the address below. Patches are welcome
Peter Flanigan, <Support at RoxSoft.co.uk>
<Support at RoxSoft.co.uk>
Copyright (c) 2014 Peter Flanigan. All rights reserved
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic
This program is distributed in the hope that it will be useful, but WITHOUT WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE
To install CatalystX::Usul, copy and paste the appropriate command in to your terminal.
cpanm
cpanm CatalystX::Usul
CPAN shell
perl -MCPAN -e shell install CatalystX::Usul
For more information on module installation, please visit the detailed CPAN module installation guide.