NAME
Meta::Utils::Utils - misc utility library for many functions.
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: Utils.pm
PROJECT: meta
VERSION: 0.45
SYNOPSIS
package foo;
use Meta::Utils::Utils qw();
my($get_home_dir)=Meta::Utils::Utils::get_home_dir();
DESCRIPTION
This is a general utility module for either miscelleneous commands which are hard to calssify or for routines which are just starting to form a module and have not yet been given a module and moved there.
FUNCTIONS
bnot($)
minus($$)
get_temp_dir()
get_temp_dire()
get_temp_file()
replace_suffix($$)
remove_suffix($)
remove_suf($$)
is_prefix($$)
is_suffix($$)
cuid()
cuname()
cgid()
get_home_dir()
get_user_home_dir($)
remove_comments($)
cat($$$)
is_absolute($)
is_relative($)
to_absolute($)
TEST($)
FUNCTION DOCUMENTATION
- bnot($)
-
This does a binary "not" operation which (suprisingly) is not enough to do using the "!" operator.
- minus($$)
-
This subtracts one string from another under the assumbtions that the second is a prefix of the first. This is useful for paths (and hence the names of the local variables in this function).
- get_temp_dir()
-
This gives you a temporary directory where you can store temporary files to your hearts content. Currently this just returns "/tmp" which is ok for UNIX type systems.
- get_temp_dire()
-
This method will give you a directory it created in a temporary location. Currently it iterates on names until it manages to create the directory.
- get_temp_file()
-
This gives you a temporary file name using the POSIX tmpnam function.
- replace_suffix($$)
-
This replaces the strings suffix with another one.
- remove_suffix($)
-
This removes a suffix from the string argument given it. This just substitues the suffix of the string with nothing...:)
- remove_suf($$)
-
This method removes a suffix from a string. The suffix is an explicit string passed to it.
- is_prefix($$)
-
This routine receives a string and a prefix and returns whether the prefix is a prefix for that string
- is_suffix($$)
-
This routine receives a string and a suffix and returns whether the suffix is a suffix for that string
- cuid()
-
This routine returns the numerical value of the current user (uid).
- cuname()
-
This routine returns the current user name (uname).
- cgid()
-
This routine returns the numerical value of the current group (gid). I don't think there is a cleaner way to do this.
- get_home_dir()
-
This routine returns the current users home directory. The implementation used to work with the environment and getting the HOME variable but this is very unrobust and works for less platforms and situations. Currently this uses POSIX which is much more robust to find the uid of the current user and then the home directory from the password file using getpwuid. The reason that this does not use the get_user_home_dir method from this same module is that there is no convinient way to get the current user name (it would take another function to convert uid to uname). The implementation marked out using POSIX::getpwnam does not work.
- get_user_home_dir($)
-
This routine returns the home dir of the user that is given to it as the argument.
- remove_comments($)
-
This routine will receive a text and will remove all comments from it. The idea here is C/C++ style comments : /* sdfdaf */
- cat($$$)
-
This function receives the names of two files and write the content of the two fles into the third one. If one of the input files is the output file then this function will throw an exception. In the future the function may be able to deal with such cases by moving the info through an intermediate file.
- is_absolute($)
-
This function will return whether the file name it received is an absolute file name.
- is_relative($)
-
This function will return whether the file name it received is a relative file name.
- to_absolute($)
-
This function will convert a relative file name to an absolute one. It use Meta::Utils::Chdir::pwd to do it's thing.
- 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 bring databases on line
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 more perl code quality
0.09 MV put ALL tests back and light the tree
0.10 MV make options a lot better
0.11 MV introduce docbook into the baseline
0.12 MV make lilypond work
0.13 MV correct die usage
0.14 MV lilypond stuff
0.15 MV perl quality change
0.16 MV perl code quality
0.17 MV more perl quality
0.18 MV more perl quality
0.19 MV get basic Simul up and running
0.20 MV perl documentation
0.21 MV more perl quality
0.22 MV perl qulity code
0.23 MV more perl code quality
0.24 MV revision change
0.25 MV languages.pl test online
0.26 MV more on images
0.27 MV PDMT/SWIG support
0.28 MV perl packaging
0.29 MV perl packaging again
0.30 MV db inheritance
0.31 MV more database issues
0.32 MV md5 project
0.33 MV database
0.34 MV perl module versions in files
0.35 MV movies and small fixes
0.36 MV thumbnail user interface
0.37 MV more thumbnail issues
0.38 MV website construction
0.39 MV more web page stuff
0.40 MV web site automation
0.41 MV SEE ALSO section fix
0.42 MV move tests to modules
0.43 MV web site development
0.44 MV finish papers
0.45 MV md5 issues
SEE ALSO
Cwd(3), Error(3), File::Basename(3), Meta::IO::File(3), Meta::Utils::Chdir(3), Meta::Utils::Env(3), Meta::Utils::File::File(3), POSIX(3), strict(3)
TODO
-implement the get_temp_dir routine better... (is there a way of officialy getting such a directory ?).
-is there a better way to implement the get_temp_dire routine ?
-move the get_home_dir and related functions into some library.
-The is suffix routine and is prefix routines should be fixed for cases where the string they match has special (regexp type) characters in it. Watch the example in cook_touch.
-more routines should be moved to their own modules...
-the remove_suffix function is a little slow (uses replace suffix). Make it just do it's thing.
-do the basename more efficiently using regexps. (experimental code is there but doesnt work)
-improve the cat method to deal with the case where the one of the input files is also the output.
-improve the cat method to check for cannonical file names and not just the ones given.