NAME
File::Access::Driver - Convenient File Access with "Batteries included"
DESCRIPTION
File::Access::Driver is a class for convenient file access designed to reduce the code needed to interact with files.
It has grown to a "Batteries included" solution covering the most file access use cases.
It will not produce exceptions but instead report the errors over the getErrorCode() and the getErrorString() methods.
SYNOPSIS
The File::Access::Driver can be used as seen in the "File Write" test:
use File::Access::Driver;
my $driver = File::Access::Driver->new( 'filepath' => $spath . 'files/out/testfile_out.txt' );
# Make sure the file does not exist
is( $driver->Delete(), 1, "File Delete: Delete operation 1 correct" );
is( $driver->Exists(), 0, "File Exist: File does not exist anymore" );
$driver->writeContent(q(This is the multi line content for the test file.
It will be written into the test file. The file should only contain this text. Also the file should be created. ));
printf(
"Test File Exists - File '%s': Write finished with [%d]\n",
$driver->getFileName(),
$driver->getErrorCode()
);
printf(
"Test File Exists - File '%s': Write Report:\n'%s'\n",
$driver->getFileName(),
${ $driver->getReportString() }
);
printf(
"Test File Exists - File '%s': Write Error:\n'%s'\n",
$driver->getFileName(),
${ $driver->getErrorString() }
);
is( $driver->getErrorCode(), 0, "Write Error Code: No errors have occurred" );
is( ${ $driver->getErrorString() }, '', "Write Error Message: No errors are reported" );
is( $driver->Exists(), 1, "File Exist: File does exist now" );
isnt( $driver->getFileSize(), 0, "File Size: File is not empty anymore" );
METHODS
Constructor
- new ( [ CONFIGURATIONS ] )
-
This is the constructor for a new
File::Access::Driverobject.Parameters:
CONFIGURATIONS-
Key and value pairs containing the configurations.
Recognized fields:
filedirectory- The directory where the file is located.filename- The base name of the file.filepath- The complete path with directory and file base name.
setFileDirectory ( DIRECTORY )
This method sets the directory where the file is located.
Parameters:
DIRECTORY-
The directory where the file is located.
If the directory does not end on a slash
/it will be appended.
setFileName ( NAME )
This method sets the base name of the file.
Parameters:
NAME-
The base name of the file.
This will also close open file handles and free in-memory cache.
setFilePath ( PATH )
This method sets the complete path of the file.
Parameters:
PATH-
The complete path of the file.
This will split the
PATHand callsetFileDirectory()with the directory andsetFileName()with the file base name.
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 183:
You forgot a '=back' before '=head3'