man Bric::Util::Trans::FS () - Utility class for handling files, paths and filenames.

NAME

Bric::Util::Trans::FS - Utility class for handling files, paths and filenames.

VERSION

$LastChangedRevision$

DATE

$LastChangedDate: 2005-03-02 15:08:13 -0800 (Wed, 02 Mar 2005) $

SYNOPSIS

  use Bric::Util::Trans::FS;

  # Constructors.
  my $fs = Bric::Util::Trans::FS->new;

  # Class methods.
  Bric::Util::Trans->put_res($res, @sts);
  Bric::Util::Trans->del_res($res, @sts);

  # Instance methods.
  $fs->copy($src, $loc);
  $fs->move($src, $loc);
  $fs->mk_path($path);
  $fs->del(@files);
  my $dir  = $fs->cat_dir(@dir_parts);
  my $file = $fs->cat_file(@file_parts);
  my $dir  = $fs->trunc_dir($dir);
  my $uri  = $fs->cat_uri(@uri_parts);
  my $uri  = $fs->trunc_uri($dir);
  my $uri  = $fs->dir_to_uri($dir);
  my $dir  = $fs->uri_to_dir($uri);

DESCRIPTION

This class provides a thin abstraction around a number of File::* modules (Copy, Spec, Basename, Find, etc.). Use it for all your portable file-system access needs.

INTERFACE

Constructors

Instantiates a Bric::Util::Trans::FS object. Throws:

*
Incorrect number of args to Bric::_set().
*
Bric::set() - Problems setting fields. Side Effects: NONE. Notes: NONE.

Destructors

$org->DESTROY
Dummy method to prevent wasting time trying to AUTOLOAD DESTROY. Throws: NONE. Side Effects: NONE. Notes: NONE.

Public Class Methods

Copies the resources in the CW$resources anonymous array to each of the file system document roots specified by the servers associated with the CW$st server type. Throws:

*
Bric::_get() - Problems retrieving fields.
*
Incorrect number of args to Bric::_set().
*
Bric::set() - Problems setting fields.
*
Unable to connect to database.
*
Unable to prepare SQL statement.
*
Unable to select column into arrayref.
*
Unable to execute SQL statement.
*
Unable to bind to columns to statement handle.
*
Unable to fetch row from statement handle.
*
Bad AUTOLOAD method format.
*
Cannot AUTOLOAD private methods.
*
Access denied: READ access for field 'uri' required.
*
No AUTOLOAD method.
*
Error copying CW$src to CW$dst.
*
Error creating path.
*
Error deleting path.
*
Error opening directory. Side Effects: NONE. Notes: NONE. Deletes the resources in the CW$resources anonymous array from each of the file system document roots specified by the servers associated with the CW$st server type. Throws:
*
Bric::_get() - Problems retrieving fields.
*
Incorrect number of args to Bric::_set().
*
Bric::set() - Problems setting fields.
*
Unable to connect to database.
*
Unable to prepare SQL statement.
*
Unable to select column into arrayref.
*
Unable to execute SQL statement.
*
Unable to bind to columns to statement handle.
*
Unable to fetch row from statement handle.
*
Bad AUTOLOAD method format.
*
Cannot AUTOLOAD private methods.
*
No AUTOLOAD method.
*
Error deleting path.
*
Error opening directory. Side Effects: NONE. Notes: NONE.

Public Instance Methods

Copies CW$src to CW$dest. If the directory hierarchy for CW$dst does not exist, it will be created. If CW$src is a file and CW$dst doesn't exist, CW$dst will be created as a copy of CW$src. If CW$srcs is a file and CW$dst exists as a directory, then CW$src will be copied into CW$dst. If CW$src is a file and CW$dst is a file, then CW$dst will be replaced with a copy of CW$src. If CW$src is a directory, then only the immediate contents of CW$src will be copied unless CW$recurse is true. If CW$src is a directory and CW$dst doesn't exist, then CW$dst will be created as a copy of CW$src. If CW$src is a directory and CW$dst is a directory, then CW$src will be copied into CW$dst. If CW$src is a directory and CW$dst is a file, then CW$dst will be wiped out and replaced with a copy of CW$src. Throws:

*
Error copying CW$src to CW$dst.
*
Error creating path.
*
Error deleting path.
*
Error opening directory. Side Effects: NONE. Notes: NONE. Moves CW$src to CW$dest. If the directory hierarchy for CW$dst does not exist, it will be created. If CW$src is a file and CW$dest is a file or doesn't exist, CW$src will be moved to (become) CW$dst. If CW$src is a file and CW$dst is a directory, CW$src will be moved into CW$dst. If CW$src is a directory and CW$dst doesn't exist, then CW$src will be moved to (become) CW$dst, including all of its contents. If CW$src is a directory and CW$dsts is a directory, then CW$src will be moved, with all of its contents, into CW$dst. If CW$src is a directory and CW$dst is a file, CW$dst will be blown away and then CW$src will be moved to (become) CW$dst. Throws:
*
Error creating path.
*
Error deleting path.
*
Error moving CW$src to CW$dst. Side Effects: NONE. Notes: NONE. Creates a directory path. Throws:
*
Error creating path. Side Effects: NONE. Notes: Uses File::Path::mkpath() internally. Deletes a an entire directory tree from the file system. If any path in CW@paths is a simple file, it will be deleted. Throws:
*
Error deleting path. Side Effects: NONE. Notes: Uses File::Path::rmtree() internally. Takes a list of directory parts and concatenates them for the local file system. Throws: NONE. Side Effects: NONE. Notes: Uses File::Spec::Functions::catdir() internally. Takes a list of directory parts and a filename and concatenates them for the local file system. Throws: NONE. Side Effects: NONE. Notes: Uses File::Spec::Functions::catfile() internally. Takes a URI and returns its directory parts. Throws: NONE. Side Effects: NONE. Notes: Uses File::Spec::Unix->catdir() internally. Takes a local filesystem directory name and and returns its directory parts. Throws: NONE. Side Effects: NONE. Notes: Uses File::Spec::Functions::splitdir() internally. Takes a URI and and returns its directory parts. Throws: NONE. Side Effects: NONE. Notes: Uses File::Spec::Unix->splitdir() internally.
  my $dir = '/here/there/every/where';
  $dir = $fs->trunc_dir($dir);
  print $dir; # Prints "/here/there/every" on Unix.
Takes a directory name, chops off the last directory specification, and returns the truncated directory. Returns undef when the directory passed in is the root directory (e.g., '/'). Throws: NONE. Side Effects: NONE. Notes: Uses File::Spec::Functions::catdir() and File::Spec::Functions::splitdir() internally. Takes a URI name, chops off the last URI specification, and returns the truncated URI. Returns undef when the URI passed in is the root URI (e.g., '/'). Throws: NONE. Side Effects: NONE. Notes: Uses File::Spec::Unix->catdir() and File::Spec::Unix->splitdir() internally. Takes a platform-specific directory name and changes it to a URI. Throws: NONE. Side Effects: NONE. Notes: Uses File::Spec::Unix->catdir() and File::Spec::Unix->splitdir() internally. Takes a URI and changes it to a directory name for the local platform. Throws: NONE. Side Effects: NONE. Notes: Uses File::Spec::Unix->catdir() and File::Spec::Unix->splitdir() internally. Takes a complete file path name and extracts just the file name. The CW$OS argument may be any one of the following:
Unix
SomeNix
Windows NT
Windows 95
Windows 98
Windows XP
Windows ME
MacOS
Mac
VMS
DOS
MSDOS
Amiga
AmigaOS
If it's not included, the CW$OS argument is assumed to be 'Unix'. Throws: NONE. Side Effects: NONE. Notes: Uses File::Basename::basename() and File::Basename::fileparse_set_fstype() internally. Takes a URI as an argument and returns just the base name of the file at the end of the URI. Throws: NONE. Side Effects: NONE. Notes: Uses File::Basename::basename() and File::Basename::fileparse_set_fstype() internally. Takes a complete file path name and extracts just the file name. The CW$OS argument may be any one of the options listed in base_name() above. Throws: NONE. Side Effects: NONE. Notes: Uses File::Basename::dirname() and File::Basename::fileparse_set_fstype() internally. Takes a URI as an argument and returns just the directory name, minus the filename at the end of the URI. Throws: NONE. Side Effects: NONE. Notes: Uses File::Basename::basename() and File::Basename::fileparse_set_fstype() internally.

PRIVATE

Private Class Methods

NONE.

Private Instance Methods

NONE.

Private Functions

Copies a source file to a destination file. Throws:

*
Error copying CW$src to CW$dst. Side Effects: NONE. Notes: Uses File::Copy::copy() internally. Moves a source file or directory to a destination file or directory. Throws:
*
Error moving CW$src to CW$dst. Side Effects: NONE. Notes: Uses File::Copy::move() internally. Copies the contents of CW$src into CW$dst. If CW$recurse is true, it will copy all the subdirectories of CW$src, too. Otherwise, it'll just copy the immediate contents of CW$src. Throws:
*
Error opening directory.
*
Error copying CW$src to CW$dst. Side Effects: NONE. Notes: Uses &$glob() and &$glob_rec() internally. Copies the immediate contents of CW$src_dir into CW$dst_dir. Does not recursively copy the subdirectories of CW$src. Throws:
*
Error opening directory.
*
Error copying CW$src to CW$dst. Side Effects: NONE. Notes: Uses &$cp() internally. Recursively copies the contents of CW$src to CW$dst. Throws: NONE. Side Effects: NONE. Notes: Uses File::Find::find() internally. Not yet implemented.

NOTES

NONE.

AUTHOR

David Wheeler <david@wheeler.net>

SEE ALSO

Bric, File::Copy, File::Path, File::Basename, File::Find, File::Spec