=head1 NAME VAdmind::Lib::FileSystem.pm - Proveds common file system functionality. =head1 DESCRIPTION Common functionality required from plugins will be provided through this module. =head1 USES TBD =cut package FileSystem; =head1 CONSTRUCTORS =head2 new Creates a new VAdmind::Lib::FileSystem object =cut sub new { my $type = shift; my $self = {@_}; return bless ($self, $type); } =head1 METHODS =head2 file_read FILE, SEPARATOR Read the content from FILE splitting content into an array based on SEPARATOR. =cut sub file_read { my $self = shift; my $file = shift; my @content = []; $/ = shift; if (!$/) { $/ = "\n"; } if (-f $file) { if (open (FH, "<" . $file)) { while () { push (@content, $_); } } } return @content; } =head2 file_write FILE, CONTENT Write the CONTENT into FILE. =cut sub file_write { my $self = shift; my $file = shift; my @content = @_; my $ret = 1; if (open (FH, ">" . $file)) { print FH @content; close (FH); } else { $ret = 0; } return $ret; } =head2 file_append FILE, CONTENT Append the CONTENT into FILE. =cut sub file_append { my $self = shift; my $file = shift; my @content = @_; my $ret = 1; if (open (FH, ">>" . $file)) { print FH @content; close (FH); } else { $ret = 0; } return $ret; } =head1 LICENSE This module has been released under a GPL license. =head1 AUTHOR Urivan Flores Saaib =head1 MODIFICATION HISTORY May 31 2007 - First version. =cut 1