Badger

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

    calling context and to handle false but defined values.

    Cleaned up and generalised the Badger::Hub module. The Badger-specific
    data has now been moved into Badger::Hub::Badger. The "configure()"
    method is now called construct().

  Version 0.06
    Added copy_file() and move_file() to Badger::Filesystem and copy() and
    move() methods to Badger::Filesystem::File.

    Added chmod_path() to Badger::Filesystem and chmod() to
    Badger::Filesystem::Path.

    Added Bin() to Badger::Filesystem.

    Added the encoding() method to Badger::Filesystem::File for specifying
    the encoding of a file, along with the utf8(), bytes(), crlf() and raw()
    methods for enabling different encoding layers.

    Added the codec() method to Badger::Filesystem::File for specifying a
    serialisation codec to use in conjunction with the new data() method.

lib/Badger/Filesystem.pm  view on Meta::CPAN

    my @stats = (stat($path), -r _, -w _, -x _, -o _, $path);

    return $self->error_msg( bad_stat => $self->{ path } )
        unless @stats;

    return wantarray
        ?  @stats
        : \@stats;
}

sub chmod_path {
    my $self = shift;
    my $path = $self->definitive_write(shift);
    chmod(shift, $path);
}


#-----------------------------------------------------------------------
# file manipulation methods
#-----------------------------------------------------------------------

sub create_file {
    my ($self, $path) = @_;
    unless (-e $self->definitive_write($path)) {

lib/Badger/Filesystem.pm  view on Meta::CPAN

            }
        }
    }

    $code->($src, $dest)
        || return $self->error_msg( copy_failed => $action, $from, $to, $! );

    my $mode = $params->{ file_mode };
       $mode = $params->{ mode } unless defined $mode;

    $file->chmod($mode) 
        if $file && defined $mode;

    return $file || $dest;
}


#-----------------------------------------------------------------------
# directory manipulation methods
#-----------------------------------------------------------------------

lib/Badger/Filesystem.pm  view on Meta::CPAN

      8     last access time in seconds since the epoch
      9     last modify time in seconds since the epoch
     10     inode change time in seconds since the epoch (*)
     11     preferred block size for file system I/O
     12     actual number of blocks allocated
     13     file is readable by current process
     14     file is writeable by current process
     15     file is executable by current process
     16     file is owned by current process

=head2 chmod_path($path)

Changes the file permissions on a path.

    $fs->chmod_path('/path/to/file', 0755);

=head1 FILE MANIPULATION METHODS

=head2 create_file($path)

Creates an empty file if it doesn't already exist.  Returns a true value
if the file is created and a false value if it already exists.  Errors are
thrown as exceptions.

    $fs->create_file('/path/to/file');

lib/Badger/Filesystem/Path.pm  view on Meta::CPAN

    my $self = shift;
    delete $self->{ stats };
    delete @$self{ keys %$TS_FIELD }; # timestamps for created, modified, etc.
    return $self->stats;
}

sub permissions {
    shift->mode & 0777;
}

sub chmod {
    my $self = shift;
    $self->filesystem->chmod_path($self->{ path }, @_);
    return $self;
}

sub basename {
    my $self = shift;
    my $name = $self->name;
    $name = $self->{ path } unless defined $name;
    $name =~ s/$MATCH_EXT//g;
    return $name;
}

lib/Badger/Filesystem/Path.pm  view on Meta::CPAN

In the base class this will method will throw an error. You can't physically
create an abstract path unless you know what kind of concrete entity (e.g.
file or directory) it maps onto. In other words, the L<create()> method will
only work for the L<Badger::Filesystem::File> and
L<Badger::Filesystem::Directory> subclasses.

    $path->create;                          # FAIL
    $dir->create;                           # OK
    $file->create;                          # OK

=head2 chmod($perms)

This method changes the file permissions on a file or directory.

    $file->chmod(0775);

=head2 stat()

Performs a filesystem C<stat> on the path and returns a list (in list
context), or a reference to a list (in scalar context) containing the 13
information elements.

    @list = $path->stat;                    # list context
    $list = $path->stat;                    # scalar context

pod/Badger/Changes.pod  view on Meta::CPAN

data has now been moved into L<Badger::Hub::Badger>.  The C<configure()>
method is now called L<construct()|Badger::Hub/construct()>.

=head2 Version 0.06

Added L<copy_file()|Badger::Filesystem/copy_file()> and
L<move_file()|Badger::Filesystem/move_file()> to L<Badger::Filesystem> and
L<copy()|Badger::Filesystem/copy()> and L<move()|Badger::Filesystem/move()>
methods to L<Badger::Filesystem::File>.

Added L<chmod_path()|Badger::Filesystem/chmod_path()> to L<Badger::Filesystem>
and L<chmod()|Badger::Filesystem::Path/chmod()> to L<Badger::Filesystem::Path>.

Added L<Bin()|Badger::Filesystem/Bin()> to L<Badger::Filesystem>.

Added the L<encoding()|Badger::Filesystem::File/encoding()> method to
L<Badger::Filesystem::File> for specifying the encoding of a file, along
with the L<utf8()|Badger::Filesystem::File/utf8()>,
L<bytes()|Badger::Filesystem::File/bytes()>,
L<crlf()|Badger::Filesystem::File/crlf()> and
L<raw()|Badger::Filesystem::File/raw()> methods for enabling different
encoding layers.



( run in 0.635 second using v1.01-cache-2.11-cpan-496ff517765 )