Andrew Sterling Hanenkamp > File-System-1.16 > File::System::Layered

Download:
File-System-1.16.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  2
Open  0
View/Report Bugs
Module Version: 1.16   Source  

NAME ^

File::System::Layered - A file system implementation with "layered" roots

SYNOPSIS ^

  use File::System;

  my $root = File::System->new('Layered',
      [ 'Real', root => '/usr/local' ],
      [ 'Real', root => '/usr' ],
      [ 'Real', root => '/cw/usr/local' ],
      [ 'Real', root => '/sw/usr/local' ],
  );

  my $dir = $root->lookup('/bin');
  print "All files:\n";
  print map({ " - $_\n" } $root->children_paths);

DESCRIPTION ^

This file system allows for the layering of other file systems. A layerd file system contains one or more other file systems such that the list of files available at a certain path in the tree is the union of the files available in all the contained file systems. When reading from or writing to file content, the file system with the highest priority is given preference.

The priority of the file systems is determined during construction, and may be modified later.

LAYERED API

The constructor of this module provides the initial layer prioritization. The File::System::Layered package also provides methods for altering the layers after the file system has been established.

$root = File::System->new('Layered', @file_systems)

The constructor establishes the initial layout of the file system. Each element of @file_systems is either a file system object or is a reference to an array that may be passed to File::System::new to construct a file system object.

The layers are prioritized by the order given in @file_systems. The file systems listed first are given the higher priority.

@layers = $obj->get_layers

Returns the list of the file system layers in descending order of priority. By using this method to get the list of layers, they can be reordered, removed, added to and then passed back to set_layers to alter the file system.

$obj->set_layers(@layers)

Reset the layers of the file system in descending order of priority. This effectively reinitializes the file system. The semantics are the same as that of the constructor.

BUGS ^

This list includes things that aren't always bugs, but eccentricities of the implementation forced by the the nature of the service provided. This provides an explanation for anything that might not be obvious. I've tried to make the implementations work in a simple and natural way, but a few decisions were arbitrary.

The copy, move, and rename methods are stuck within the file system they are in. That is, if you move, rename, or copy a file, the new file, location, or duplicate will be stored within the same layer as the original. If you attempt to move or copy to a location that exists in one layer, but not another, those methods will attempt to use create to create the needed directory in the other layer. Due to these kinds of complications, these methods haven't yet been fully tested.

Removing a file or directory might not have the expected effect. If there are two layers with the same file or directory, removal will just remove the version in the highest layer, so the file or directory will still appear to exist.

The is_creatable method returns true if any layer returns true. The create method uses the is_creatable of each layer to find out if the file can be created and will create the file on the first layer it finds where it is true.

The glob and find methods rely upon the slowish defaults. This situation could probably be improved with a little bit of effort.

SEE ALSO ^

File::System, File::System::Object, File::System::Real, File::System::Table

AUTHOR ^

Andrew Sterling Hanenkamp, <hanenkamp@users.sourceforge.net>

COPYRIGHT AND LICENSE ^

Copyright 2005 Andrew Sterling Hanenkamp. All Rights Reserved.

This library is distributed and licensed under the same terms as Perl itself.

syntax highlighting: