NAME
Meta::Utils::File::File - library to do operations on files.
COPYRIGHT
Copyright (C) 2001, 2002 Mark Veltzer; All rights reserved.
LICENSE
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
DETAILS
MANIFEST: File.pm
PROJECT: meta
VERSION: 0.31
SYNOPSIS
package foo;
use Meta::Utils::File::File qw();
my($file)="/etc/passwd";
if(Meta::Utils::File::File::exist($file)) {
# try to break into the system
} else {
# we are in windows, just remove the kernel.dll from c:\windows
}
DESCRIPTION
This is a library to help you do things with files with meaningful names. For instance: check if a file exists, compare two files etc...
FUNCTIONS
check_mult_regexp($$$)
check_sing_regexp($$$)
save_nodie($$)
save($$)
load_nodie($$)
old_load($)
load($)
load_deve($)
load_line($$)
cmp($$)
exist($)
notexist($)
check_exist($)
check_notexist($)
check_exec($)
create_new($)
subst($$$)
TEST($)
FUNCTION DOCUMENTATION
- check_mult_regexp($$$)
-
This routine does exactly the same as check_sing_regexp except it gets a list of regular expressions and matches any of them. This also receives a variable telling it whether to print the matched lines or not.
- check_sing_regexp($$$)
-
This routine checks whether a single regular expression given to it is present in the file given to it. This also receives a variable telling it whether to print the matched lines or not.
- save_nodie($$)
-
This does exactly the same as save but does not die if something goes wrong and instead returns a valid error bit.
- save($$)
-
This routine receives a file name and text to write into it. The routine assumes that it has permissions, and writes a new file (recreates it) and writes the string into it, and then closes the file. The routine dies if something goes wrong.
- load_nodie($$)
-
This routine receives a file name and a reference to a string. The routine loads the file into the string. If the routine fails somewhere then it return a valid error bit.
- old_load($)
-
This is the old implementation of the load routine which gulps the file down one line at a time.
- load($)
-
This routine loads up a files into a single string and gives it to you.
- load_deve($)
-
This method loads a file from a development framework.
- load_line($$)
-
This routine loads a specific text line from the source file given to it. You better make sure that the specified file has that line in it..!!!:)
- cmp($$)
-
This routines receives a file to compare a variable with. It returns a boolean value which is the result of the comparison. The implementation attemps to read length(input) characters from the file. If it fails it return false and else it just does a eq comparison...
- exist($)
-
This routine returns whether a cetain file is a regular file I cannot just return the result of "-f $file" since it will be nothing (which is not good for boolean arithmetic) if the file is not there.
- notexist($)
-
This routine returns whether a certain file not exist as a regular file I cannot just return the result of "-x $file" since it will be nothing (which is not good for boolean arithmetic) if the file is not there.
- check_exist($)
-
This routine checks if a file given to it exists and if indeed it is a regular file. If something fails it dies.
- check_notexist($)
-
This routine checks if a file given to it not exists. If something fails it dies.
- check_exec($)
-
This routine will check if a file given to it exists and is executable. If something fails it dies.
- create_new($)
-
This function receives a file name and creates that file (it supposes the file does not exist and if it does it fails...).
- subst($$$)
-
This function receives the following arguments: 1. File to be modifield. 2. Pattern to be searched for. 3. Pattern to be replaced with. And modifies the file by replacing the required pattern with the target pattern.
- TEST($)
-
Test suite for this module.
SUPER CLASSES
None.
BUGS
None.
AUTHOR
Name: Mark Veltzer
Email: mailto:veltzer@cpan.org
WWW: http://www.veltzer.org
CPAN id: VELTZER
HISTORY
0.00 MV initial code brought in
0.01 MV this time really make the databases work
0.02 MV make quality checks on perl code
0.03 MV more perl checks
0.04 MV make Meta::Utils::Opts object oriented
0.05 MV check that all uses have qw
0.06 MV fix todo items look in pod documentation
0.07 MV more on tests/more checks to perl
0.08 MV correct die usage
0.09 MV perl code quality
0.10 MV more perl quality
0.11 MV more perl quality
0.12 MV perl documentation
0.13 MV more perl quality
0.14 MV perl qulity code
0.15 MV more perl code quality
0.16 MV revision change
0.17 MV languages.pl test online
0.18 MV perl packaging
0.19 MV tree type organization in databases
0.20 MV md5 project
0.21 MV database
0.22 MV perl module versions in files
0.23 MV movies and small fixes
0.24 MV thumbnail user interface
0.25 MV more thumbnail issues
0.26 MV website construction
0.27 MV web site automation
0.28 MV SEE ALSO section fix
0.29 MV move tests to modules
0.30 MV download scripts
0.31 MV finish papers
SEE ALSO
Meta::Baseline::Aegis(3), Meta::Utils::Output(3), strict(3)
TODO
-Cant the load() fundtion return a reference to the data instead of the actual data ? (the return value may be long...). (The same goes for load_line...).
-Do the create_new function more effiently (isnt there a perl function for it?).
-make the load routine prototype be the same as the load_nodie prototype. (its cleaner that way...).
-stop using the hardcoded hexa value in ioctl (I only did it because of error in requiring the required ph files).
-cant the load method be nicer if implemented using file handles ?