The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

Name

CatalystX::Usul::FileSystem - File system related methods

Version

Describes v0.16.$Rev: 1 $

Synopsis

   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' } );

Description

This model provides methods for manipulating files and directories

Configuration and Environment

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

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

fs_type

String which defaults to ext3. The default filesystem type

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

Subroutines/Methods

archive

   $output_messages = $self->archive( @paths );

Archives a files by prepending the $self-postfix>, which defaults to A_

file_in_use

   $bool = $self->file_in_use( $path );

Uses the system fuser command if it is available to determine if a file is in use

file_systems

   $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

get_perms

   $permission_string = $self->get_perms( $mode );

Returns the -rw-rw-r-- style permission string for a given octal mode

list_subdirectory

   $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

purge_tree

   $output_messages = $self->purge_tree( $dir, $atime, $dtime );

Archive old files and delete even older ones from a given directory

rotate

   $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

rotate_log

   $message = $self->rotate_log( logfile => $logfile_path, copies => $copies );

Calls "rotate". Will also touch a new logfile into existence and optionally signal a process

rotate_logs

   $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

unarchive

   $output_messages = $self->unarchive( @paths );

Reverse out the effect of calling "archive"

wait_for

   $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

Diagnostics

None

Dependencies

CatalystX::Usul::Response::FileSystem
Class::Usul::File
Class::Usul::IPC
CatalystX::Usul::Moose
Class::Usul::Response::Table
Class::Usul::Time

Incompatibilities

There are no known incompatibilities in this module

Bugs and Limitations

There are no known bugs in this module. Please report problems to the address below. Patches are welcome

Author

Peter Flanigan, <Support at RoxSoft.co.uk>

License and Copyright

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