NAME
IO::Easy - is easy to use class for operations with filesystem objects.
ABSTRACT
We wanted to provide Perl with the interface for file system objects with the simplicity similar to shell. The following operations can be used as an example: operations for recursive creation (mkdir -p) and removing (rm -rf), touching file.
IO::Easy transparently processes file system paths independently from operating system with help of File::Spec module and does not require a lot of additional modules from CPAN.
For better understanding of IO::Easy processing principles you should keep in mind that it operates with "Path Context". "Path Context" means that for any path in any file system IO::Easy takes path parts which are between path separators, but doesn't include path separators themselves, and tries to fetch the path in the current system from these path parts. This way it can substitute different path separators from system to system (as long as they may differ depending on operating system, this also includes drive specification e.g. for Windows) and doesn't depend on some system specifics of paths representation.
SYNOPSIS
use IO::Easy;
my $io = IO::Easy->new ('.');
# file object "./example.txt" for unix
my $file = $io->append ('example.txt')->as_file;
my $content = "Some text goes here!";
$file->store ($content);
METHODS
new
Creates new IO::Easy object, takes path as parameter. IO::Easy object for abstract file system path. For operating with typed objects there were 2 additional modules created: IO::Easy::File IO::Easy::Dir
You can use method attach_interface for automatic object conversion for existing filesystem object or force type by using methods as_file or as_dir.
path
return current filesystem object path, also available as overload of ""
name
return current filesystem object name, without path
base_name, extension
name part before last dot and after last dot
as_file, as_dir, attach_interface
re bless object with specified or autodetected interface
note: filesystem check for attach_interface
abs_path
absolute path
append, append_in_place
append filesystem objects to IO::Easy object
my $config = IO::Easy::Dir->current->append (qw(etc config.json));
produce …/etc/config.json on unix
stat, modified, dev, inode, mode, nlink, uid, gid, rdev, size, atime, mtime, ctime, blksize, blocks
complete stat array or this array accessors
note: filesystem check
up, parent
directory container for io object
my $config = IO::Easy::Dir->current->append (qw(etc config.json)); # '…/etc/config.json'
my $config_dir = $config->up; # '…/etc'
rel_path
relative path to specified directory
my $current = IO::Easy::Dir->current; # '…'
my $config = $current->append (qw(etc config.json)); # '…/etc/config.json'
my $config_rel = $config->rel_path ($current); # 'etc/config.json'
touch
constructor for IO::Easy::Dir object
my $current = IO::Easy::Dir->current; # '…'
my $config = $current->append (qw(etc config.json)); # '…/etc/config.json'
$config->touch; # file created
path_components
path, split by filesystem separators
AUTHOR
Ivan Baktsheev, <apla at the-singlers.us>
BUGS
Please report any bugs or feature requests to my email address, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=IO-Easy. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
SUPPORT
ACKNOWLEDGEMENTS
COPYRIGHT & LICENSE
Copyright 2007-2009 Ivan Baktsheev
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 310:
Non-ASCII character seen before =encoding in '…/etc/config.json'. Assuming UTF-8