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

NAME

Meta::Utils::File::Fs - object to encapsulate a file system.

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: Fs.pm
        PROJECT: meta
        VERSION: 0.14

SYNOPSIS

        package foo;
        use Meta::Utils::File::Fs qw();
        my($object)=Meta::Utils::File::Fs->new();
        my($result)=$object->method();

DESCRIPTION

This object provides the services of a file system. You can create files, remove files, create symlinks and query its condition. You may rightfuly ask: "why the fuck should I want such an object ?" Well, some processes, for example building software and updating a remote mirror/ftp site acquire a knowledge of a file heirarchy (a file system) when they start off, and then assume that no one alters the file system (or at least tell them when they do) and proceed to execute operations on the file system. They still want to remmember what the status of the file system is. This is where this object comes into play. Using this object to store the file system information they retrieve upon startup and updating this object whenever they perform operations on the file system enables them to have knowledge of the underlying file system without resorting to re-query the actual file system which is expensive when querying a disk but even more so when querying a remote ftp server or the like...

FUNCTIONS

        new($)
        get_type($)
        set_type($$)
        get_modi($)
        set_modi($$)
        get_md5x($)
        set_md5x($$)
        get_data($)
        set_data($$)
        is_file($)
        is_dire($)
        has_single_dir($$)
        has_dir($$)
        has_single_file($$)
        has_file($$)
        check_single_dir($$)
        check_dir($$)
        check_single_file($$)
        check_file($$)
        check_empty_single_dir($$)
        check_empty_dir($$)
        create_single_dir($$)
        create_dir($$)
        create_single_file($$)
        create_file($$)
        get_single_dir($$)
        get_dir($$)
        get_single_file($$)
        get_file($$)
        get_dir_of_file($$)
        remove_single_dir($$)
        remove_dir($$)
        remove_single_file($$)
        remove_file($$)
        remove_last_dir($$)
        get_all_files_list($$$)
        get_all_files_hash($$$)
        get_all_empty_dirs($$$)
        print($$)
        xml($$$)
        TEST($)

FUNCTION DOCUMENTATION

new($)

This is a constructor for the Meta::Utils::File::Fs object.

get_type($)

This method will return the type of this node.

set_type($$)

This method will set the type for the current node.

get_modi($)

This method will retrieve the modification time for the current node.

set_modi($$)

This method will set the modification time for the current node.

get_md5x($)

This method will retrieve the md5 sum of the current file.

set_md5x($$)

This method will set the md5 sum for the current file.

get_data($)

This method will retrieve the data for the current file.

set_data($$)

This method will set the data for the current file.

is_file($)

This method will return a boolean value which will be true if the current node is of type file.

is_dire($)

This method will return a boolean value which will be true if the current node is of type directory.

has_single_dir($$)

This method returns true if the Fs object given to it has a certain subdir.

has_dir($$)

This method returns true if the Fs object given to it has a certain directory (of any nesting level).

has_single_file($$)

This method returns true if the Fs object given to it has a certain file.

has_file($$)

This method returns true if the Fs object given to it has a certain file (of any nesting level).

check_single_dir($$)

This method receives an Fs type object and checks that the name given to it is indeed a directory in that filesystem. The method returns the directory involved. The reason that this method is using the !is_file method is because in the future we may support other things like sym links, hard links etc...

check_dir($$)

This method receives an Fs type object and checks that the name given to it is indeed a directory (of any depth) in that filesystem. It uses consecutive calls to check_single_dir. The method doesnt return anything.

check_single_file($$)

This method receives an Fs type object and checks that the name given to it is indeed a file in that filesystem. The method doesnt return anything. The reason that this method is using the !is_file method is because in the future we may support other things like sym links, hard links etc...

check_file($$)

This method receives an Fs type object and checks that the name given to it is indeed a file (of any depth) in that filesystem. The method doesnt return anything.

check_empty_single_dir($$)

This method receives an Fs type object and checks that the name given to it is indeed a directory in that file system and it is empty. The method returns the directory involved.

check_empty_dir($$)

This method receives an Fs type object and checks that the name given to it is indeed a directory in that file system and it is empty. The method returns the directory involved.

create_single_dir($$)

This method creates a single directory under the current one. The method returns the directory created.

create_dir($$)

This creates a new directory with parent directories. The method returns the directory created.

create_single_file($$)

This creates a single file under the current directory. The method returns the file type created.

create_file($$)

This method creates a file with parent directories. This method doesnt return anything.

remove_single_dir($$)

This method removes a single direcotry from the current fs. The method doesnt return anything.

remove_dir($$)

This method removes a directory with all of its ancestors from the current file system.

remove_single_file($$)

This method removes a single file from the current fs. The method doesnt return anything.

remove_file($$)

This method receives an Fs type object and removes a file named from it. The method returns the directory of the file.

remove_last_dir($$)

This method removes the last component of a directory. The method returns the directory handle of the directory from which it was removed.

get_single_dir($$)

This method returns a directory within the current fs.

get_dir($$)

This method returns a directory within the current fs (of any depth).

get_single_file($$)

This method returns a specific file within the current fs.

get_file($$)

This method returns a file within the current fs (of any depth).

get_dir_of_file($$)

This method receives an Fs type object and returns the directory entry in which the file given to it resides.

get_all_files_list($$$)

This method receives an fs object and a list pointer and fills the list with all the files under the current fs. All the files will be given the prefix that you specify. If you do not wish to have a prefix then "" will do.

get_all_files_hash($$$)

This method receives an fs object a hash pointer and fills the hash with all the files unders the current fs. All the files will be given the prefix that you specify. If you do not wish to have a prefix then "" will do.

get_all_empty_dirs($$$)

This method gets an fs object and a list and fills the list with all the empty directories it could find. The prefixe that is supplied will be given to all files ("" should do if you do not want any prefix). The method returns whether the current dir is empty or not.

get_name_of_file($)

This function receives a file name (with directory) and returns just the file name part. NOTE: this is not a method but a function (no object is neccessary).

print($$)

This method will print the current fs (mostly for debug purposes). You could put 0 in the indent parameter if you don't want the print indented.

xml($$$)

This method receives an XML writer object and writer the file system into the XML writer object.

TEST($)

Test suite for this module.

SUPER CLASSES

Meta::Ds::Ohash(3)

BUGS

None.

AUTHOR

        Name: Mark Veltzer
        Email: mailto:veltzer@cpan.org
        WWW: http://www.veltzer.org
        CPAN id: VELTZER

HISTORY

        0.00 MV upload system revamp
        0.01 MV do some book work
        0.02 MV perl packaging
        0.03 MV xml
        0.04 MV data sets
        0.05 MV md5 project
        0.06 MV database
        0.07 MV perl module versions in files
        0.08 MV movies and small fixes
        0.09 MV thumbnail user interface
        0.10 MV more thumbnail issues
        0.11 MV website construction
        0.12 MV web site automation
        0.13 MV SEE ALSO section fix
        0.14 MV md5 issues

SEE ALSO

Error(3), Meta::Ds::Ohash(3), Meta::Utils::Output(3), Meta::Utils::System(3), strict(3)

TODO

-there are no current checks that makes sure that files and directories are not created inside files!!!

-make the print routine have the same logic as the xml routine (it's better logic). That would require that routine to get 3 parameters too.