Backwards compatibility brings in a lot of code and logic that we dont need from here on out.
It does a ton of chdir()s which could leave you somewhere youre not planning on being and requires much more overhead to do.
can croak not allowing you to detect and handle failure
Just let me handle errors how I want. Dont make my entire app die or have to wrap it in an eval
A well intentioned output system
Just let me do the output how I want. (Nothing, As HTML, print to a filehandle, etc...)
A well intentioned and experimental (IE subject to change) error handling system.
Just keep it simple and detect failure via a boolean check and do what I want with the error. See How can I make/remove multiple paths?
According to its POD, removing a tree is apparently not safe unless you tell it to be with the XsafeX or keep_root attributes.
Seems like that should just happen, I dont want to worry about accidentally removing / when I pass it /tmp
Nothing in exported or exportable, that helps keep it ::Tiny.
File::Path::Tiny::mk()Takes a single path (like mkdir()) to recursively create and, optionally, a mask (like mkdir()) for all subsequent mkdir() calls.
Mask defaults to 0700 (also like mkdir())
It is recursive in the sense that given Xfoo/bar/bazX as the path to create all 3 will be created if necessary.
File::Path::Tiny::rm()Takes a single path (like rmdir()) to recursively empty and remove.
It is recursive in the sense that given X/foo/bar/bazX as the path to remove it will recursively empty XbazX and then remove it from /foo/bar.
Throws no warnings or errors of its own
If the functions ever return false, $! will have been set either explicitly or by the mkdir(), rmdir(), unlink(), or opendir() that ultimately returned false.
For simplicity sake && ::Tiny status this module must be very very very simple.
That said it is also very simple to do multiple paths:
That also lets you keep going or short circuit it or handle errors however you like:
See Acme::Tiny for information on the ::Tiny suffix.
#3 is almost there (< 1/5th +/-), a bit more trimming and I think well have it! #8 is N/A since part of the "sub set" is to do single paths like their non-recursive core counterparts and there are so many ways to invoke it with different consequences [ -- RSS Memory -- ] Baseline perl 1168 File::Path 1808 (+640) File::Path::Tiny 1288 (+120)
Even though time isnt really a ::Tiny factor, it does improve loading a bit:
As time allows and more tests are added Ill try to include more comprehensive benchmark results.
Of course the answer depends on what you mean by safe.
This module makes no assumptions on interpreting the safeness of a path, just like mkdir() and rmdir().
Also like mkdir() and rmdir() typically youll find that filesystem permissions are a pretty reliable tool (of course if the code will be run as root you would want to setuid first...)
You might use Cwd::abs_path() to sanitize a path before sending it to be made or removed.
Even after that it might not be safe so youll need to discern what your particular definition of safe is and take appropriate action.
File::Spec of course but its only loaded if needed
Please report any bugs or feature requests (and a pull request for bonus points)
through the issue tracker at <https://github.com/drmuey/p5-File-Path-Tiny/issues>.
Daniel Muey <http://drmuey.com/cpan_contact.pl>
Copyright (c) 2008, Daniel Muey <http://drmuey.com/cpan_contact.pl>. All rights reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.
BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|perl v5.20.3||FILE::PATH::TINY (3)||2016-01-26|