Path-Tiny-0.076/000755 000765 000024 00000000000 12622375237 013606 5ustar00davidstaff000000 000000 Path-Tiny-0.076/Changes000644 000765 000024 00000041230 12622375237 015101 0ustar00davidstaff000000 000000 Revision history for Path-Tiny 0.076 2015-11-16 10:47:24-05:00 America/New_York - no changes from 0.075 0.075 2015-11-15 21:02:18-05:00 America/New_York (TRIAL RELEASE) [FIXED] - Tilde expansion on Windows was resulting in backslashes. Now they are correctly normalized to forward slashes. [DOCS] - Typos fixed 0.073 2015-10-30 10:36:18-04:00 America/New_York (TRIAL RELEASE) [FIXED] - Fixed spewing to a symlink that crosses a filesystem boundary [PREREQS] - Add Test::MockRandom to META as an recommended test prerequisite. 0.072 2015-07-20 16:07:20-04:00 America/New_York - No changes from 0.071 0.071 2015-07-17 13:40:08-04:00 America/New_York (TRIAL RELEASE) [FIXED] - Fixed incorrect error argument for File::Path functions (mkpath and remove_tree) 0.070 2015-06-28 13:50:16-04:00 America/New_York - No changes from 0.069 0.069 2015-06-18 18:09:44-04:00 America/New_York (TRIAL RELEASE) [CHANGED] - The 'copy' method now returns the object for the copied file [FIXED] - The 'visit' method only dereferences the callback return value for scalar refs, avoiding some common bugs 0.068 2015-03-23 20:42:56-04:00 America/New_York [META] - Jumping to 0.068 to get to an even-version for a stable release [DOCUMENTED] - Noted that 0.66 changed the 'filehandle' method 0.066 2015-03-20 23:59:08-04:00 America/New_York (TRIAL RELEASE) [ADDED] - Added exclusive locking option to filehandle opens; spew now exclusively locks tempfile used for atomic writes 0.065 2015-03-06 05:59:56-05:00 America/New_York [ADDED] - Added 'assert' method - Added 'visit' method - Added support for a negative count for 'lines' to get the last lines of a file [FIXED] - Fixed tilde expansion if path has spaces - Make realpath non-fatal if the parent path exists and only the final path component does not. (Was fatal on Windows and some Unixes.) - Removed rendundant locking on tempfile use for spewing - Work around File::Temp bugs on older ActiveState Windows Perls https://bugs.activestate.com/show_bug.cgi?id=104767 [DOCUMENTED] - Fixed SYNOPSIS example 0.064 2015-03-05 03:58:42-05:00 America/New_York (TRIAL RELEASE) 0.063 2015-03-04 16:00:17-05:00 America/New_York (TRIAL RELEASE) 0.062 2015-03-04 13:59:31-05:00 America/New_York (TRIAL RELEASE) 0.061 2014-11-13 16:50:05-05:00 America/New_York [FIXED] - Fixed append_utf8 and append_raw with 'truncate' option. 0.060 2014-11-04 17:33:39-05:00 America/New_York [ADDED] - Added 'truncate' option to append for in-place replacement of file contents. 0.059 2014-10-14 12:45:46-04:00 America/New_York [FIXED] - Fixed precedence bug in the check for Unicode::UTF8 0.058 2014-09-23 11:00:24-04:00 America/New_York [ADDED] - Added a 'sibling' method as a more efficient form of calling $path->parent->child(...). [DOCUMENTED] - Every method annotated with the version number of the last API change. 0.057 2014-09-19 11:23:05-04:00 America/New_York [FIXED] - On AIX, reads that default to locking would fail without write permissions, because locking needs write permissions. The fix is only to lock reads if write permissions exist; otherwise locking is skipped. 0.056 2014-08-07 15:08:41-04:00 America/New_York [*** DEPRECATIONS ***] - The 'dirname' method is deprecated due to exposing File::Spec inconsistencies [ADDED] - The 'digest' method now takes a 'chunk_size' option to avoid slurping files entirely into memory. [FIXED] - Fixed problem throwing errors from 'remove' 0.055 2014-06-30 10:29:28-04:00 America/New_York [FIXED] - tempfile/tempdir won't warn if used as functions without arguments 0.054 2014-05-04 13:56:11-04:00 America/New_York [ADDED] - The 'basename' method now takes a list of suffixes to remove before returning the name - FREEZE/THAW/TO_JSON serialization helpers [CHANGED] - When constructing a Path::Tiny object from another, the original is returned unless it's a temp dir/file. This significantly speeds up calling path($path) if $path is already a Path::Tiny object. (Thanks to Michael Schwern for prompting such benchmarking.) [FIXED] - Constructing any path -- e.g. with child() -- with undef or zero-length parts throws an error instead of constructing an invalid path 0.053 2014-03-24 09:25:51-04:00 America/New_York (TRIAL RELEASE) [INCOMPATIBLE CHANGES] - The 'is_file' method now does -e && ! -d and not -f because -f is often more restrictive than people intend or expect. [ADDED] - Added 'chmod' method with symbolic chmod support ("a=r,u+rx") 0.052 2014-01-14 15:58:03-05:00 America/New_York [FIXED] - Backslash-to-slash conversion now only happens on Windows (since backslash is legal on Unix, we must allow it) 0.051 2013-12-20 07:34:14 America/New_York [FIXED] - Fixed file order bug in the new test file 0.050 2013-12-20 07:27:20 America/New_York [FIXED] - Recursive iteration won't throw an exception if a directory is removed or unreadable during iteration. 0.049 2013-12-12 00:48:01 America/New_York [FIXED] - Generates filename for atomic writes independent of thread-ID. Fixes crashing bug on Win32 when fork() is called. 0.048 2013-12-11 21:56:23 America/New_York [ADDED] - Added 'subsumes' method [CHANGED] - The 'chomp' option for 'lines' will remove any end-of-line sequences fully instead of just chomping the last character - The 'flock' package will no longer indexed by PAUSE [FIXED] - Hides warnings and fixes possible fatal errors from pure-perl Cwd, particularly on MSWin32 0.047 2013-11-26 15:11:13 America/New_York [FIXED] - Previous lock testing fixes broke on Windows (sigh); now fixed, I hope. 0.046 2013-11-22 17:07:24 America/New_York [FIXED] - Revised locking tests for portability again: locks are now tested from a separate process 0.045 2013-11-22 15:28:50 America/New_York [FIXED] - Fixed locking test on AIX 0.044 2013-10-17 17:00:41 America/New_York [FIXED] - Fixed child path construction against the root path. - Fixed path construction when a relative volume is provided as the first argument on Windows; e.g. path("C:", "lib") must be like path("C:lib"), not path("C:/lib"). - On AIX, shared locking is replaced by exclusive locking on a R/W filehandle, as locking read handles is not supported 0.043 2013-10-14 06:24:06 America/New_York [CHANGED] - Calling 'absolute' on Windows will add the volume if it is missing (E.g. "/foo" will become "C:/foo"). This matches the behavior of File::Spec->rel2abs. [FIXED] - Fixed t/00-report-prereqs.t for use with older versions of CPAN::Meta::Requirements 0.042 2013-10-13 11:02:02 America/New_York [FIXED] - When 'realpath' can't be resolved (because intermediate directories don't exist), the exception now explains the error clearly instead of complaining about path() needing a defined, positive-length argument. - On Windows, fixed resolution of relative paths with a volume. E.g. "C:foo" is now correctly translated into getdcwd on "C:" plus "foo". 0.041 2013-10-11 08:56:31 America/New_York [FIXES] - Removes duplicate test dependency on File::Spec that triggers a CPAN.pm bug 0.040 2013-10-08 22:01:50 America/New_York [FIXES] - Fixed broken locking test on *bsd - When using 'filehandle' to request a locked handle that truncates an existing file and has a binmode starting with ":unix", this fixes a bug where pseudo-layers weren't being cleared properly. 0.039 2013-10-08 16:39:23 America/New_York [ADDITIONS] - The 'filehandle' method now offers an option to return locked handles based on the file mode. Input-output methods now rely on this feature internally. Truncating file modes defer truncation until after an exclusive lock is acquired. [FIXES] - The 'filehandle' method now respects default encoding set by the caller's open pragma. 0.038 2013-10-01 18:20:05 America/New_York [ADDITIONS] - Added 'is_rootdir' method to simplify testing if a path is the root directory 0.037 2013-09-25 13:00:25 America/New_York [FIXES] - Fixed for v5.8 0.036 2013-09-25 09:34:28 America/New_York [PREREQS] - No longer lists 'threads' as a prerequisite. If you have a threaded perl, you have it and if you're not, Path::Tiny doesn't care. 0.035 2013-09-24 07:21:55 America/New_York [FIXED] - Fixed flock warning on BSD that was broken with the autodie removal; now also applies to all BSD flavors 0.034 2013-09-23 16:16:36 America/New_York [INCOMPATIBLE CHANGE] - Exceptions are now Path::Tiny::Error objects, not autodie exceptions; this removes the last dependency on autodie, which allows us to support Perls as far back as v5.8.1 [FIXED] - BSD/NFS flock fix was not backwards compatible before v5.14. This fixes it harder. [PREREQS] - dropped autodie - lowered ExtUtils::MakeMaker configure_requires version to 6.17 0.033 2013-09-12 08:54:30 America/New_York [FIXED] - Perl on BSD may not support locking on an NFS filesystem. If this is detected, Path::Tiny warns and continues in an unsafe mode. The 'flock' warning category may be fatalized to die instead. [DOCUMENTED] - Added 'iterator' example showing defaults 0.032 2013-09-06 17:52:48 America/New_York [PREREQS] - Removed several test dependencies. Path::Tiny now only needs core modules, though some must be upgraded on old Perls 0.031 2013-08-27 10:03:57 America/New_York [FIXED] - parent() on paths with internal double dots (e.g. /foo..bar.txt) now works correctly 0.030 2013-08-20 16:10:04 America/New_York [FIXED] - t/zzz-spec.t used getcwd() instead of getdcwd(), which breaks on Windows if the build directory isn't on the 'C' drive 0.029 2013-08-19 11:52:24 America/New_York [FIXED] - On Win32, "C:/" no longer is changed to "C:". Also, "C:" is converted to the absolute path of cwd on the "C:" volume. UNC paths ("//server/share/") now retain their trailing slash to correctly distinguish volume and directory paths when split 0.028 2013-08-14 13:12:49 America/New_York [ADDED] - The 'children()' method now takes an optional regular expression to filter the results 0.027 2013-07-25 19:38:44 America/New_York [ADDED] - Added the 'digest' method to produce a hexadecimal SHA-256 (or user-specified) digest of a file 0.026 2013-07-14 21:25:22 America/New_York [FIXED] - Fixed bug where lines() with a count longer than the file would return undef for the extra lines. Now returns only the lines in the file if the count is greater than the number of lines. 0.025 2013-07-10 09:32:13 America/New_York [FIXED] - Spew to an existing symlink now atomically replaces the resolved destination, not the symlink 0.024 2013-06-17 18:12:36 America/New_York [FIXED] - Win32 pseudo-forks don't load threads.pm, so we do that in CLONE to ensure we get the thread ID 0.023 2013-06-12 07:18:31 America/New_York [FIXED] - Removing dangling symlinks now works 0.022 2013-05-28 11:57:15 America/New_York [ADDED] - The 'touch' method can now take an epoch secs argument 0.021 2013-05-17 22:53:18 America/New_York [FIXED] - Fixed fatal bug with lines_utf8 using chomp [DOCS] - Pod typos fixed 0.020 2013-04-13 06:58:11 Europe/London [FIXED] - More descriptive error message if copy() fails 0.019 2013-04-12 06:58:18 Europe/London [FIXED] - Fixed warning about -l on dirhandle in iterator() 0.018 2013-04-08 12:44:31 America/New_York [ADDED] - cwd, rootdir, tempfile and tempdir can now be exported on request and used as functions instead of as methods [FIXED] - Fixed regression in lines() where it no longer returned count of lines in scalar context 0.017 2013-03-28 16:49:15 America/New_York [ADDED] - path() constructor now glob-expands tildes (~) [CHANGED] - Improved options validation; invalid options now throw errors 0.016 2013-03-26 14:59:36 America/New_York [ADDED] - The iterator now has an optional recursive mode [CHANGED] - We no longer use autodie directly, but we throw our own autodie::exceptions on error. This avoids the overhead of wrapping built-ins with function calls. - Most dependencies are now loaded on demand, reducing startup time. 0.015 2013-03-13 13:20:38 America/New_York [CHANGED] - touch and touchpath now return the object to allow easy chaining with spew 0.014 2013-03-09 08:54:26 America/New_York [ADDED] - parent now takes an optional argument to look upwards multiple times in one call. e.g. $path->parent(2) 0.013 2013-02-22 10:58:05 America/New_York [CHANGED] - remove_tree now defaults to safe mode and will not attempt to chmod and remove directories with insufficient permissions - Temporary files and directories are always created with an absolute path. [FIXED] - Failures from autodie are reported from our caller's location (as if we called croak()); bumped autodie prereq to 2.14 for this feature - Failures from mkpath and remove_tree are now trapped and thrown as exceptions. (Making an existing path or removing a non-existant path return false and are not errors); 0.012 2013-02-20 09:34:50 America/New_York [REMOVED] - The 'remove' function no longer works on directories. The new 'remove_tree' method should be used instead. [CHANGED] - path() now requires a defined, positive-length argument to keep you safe from subtle bugs in your code that pass an undef or empty argument to path suddenly having you operating in the current directory. [ADDED] - Added Path::Tiny->cwd as a constructor to give an absolute path to the current working directory - Added 'remove_tree' as a method for recursively removing a directory 0.011 2013-02-19 11:08:44 America/New_York [CHANGED] - slurp/spew/etc and openr/openw/etc now repect default layers set by -C or the open pragma - spew and append can now be given array references to output to avoid extra copying 0.010 2013-02-16 10:26:38 America/New_York [FIXED] - The 'tempdir' and 'tempfile' methods can now both take either leading templates or a TEMPLATE option, so you don't have to remember which one File::Temp wants 0.009 2013-02-15 16:05:39 America/New_York [CHANGED] - Dropped use of '//' to allow Path::Tiny to run on Perl 5.008 0.008 2013-02-15 13:49:54 America/New_York [ADDED] - Added 'touchpath' method combining 'mkpath' and 'touch' 0.007 2013-02-12 17:41:44 America/New_York [FIXED] - Unicode::UTF8 0.58 is necessary for optional faster Unicode processing 0.006 2013-02-11 13:22:18 America/New_York [FIXED] - t/parent.t is amended to work on Windows - new() now correctly takes multiple path arguments, like path() 0.005 2013-02-07 15:41:32 America/New_York [FIXED] - Fixed test for platforms with /sbin symlinked to /usr/sbin 0.004 2013-02-05 19:19:46 America/New_York [ADDED] - Added slurp_raw and other *_raw helper methods - Added realpath method (with thanks to ether) - Added canonpath method (with thanks to sjmiller) [FIXED] - slurp/lines/spew/append now do appropriate flocking - Fixed test that fails if run as root (bingos) - Fixed test that fails if cwd/getcwd don't agree [CHANGED] - internal optimizations 0.003 2013-01-31 06:59:50 America/New_York [FIXED] - lstat was calling the wrong stat [rt.cpan.org #83063] - make atomic writes thread-safe [rt.cpan.org #83064] [CHANGED] - updated bugtracker to point to github 0.002 2013-01-30 22:09:37 America/New_York [FIXED] - s/File::Stat/File::stat/; # OMG! I hate case insensitivity 0.001 2013-01-30 19:36:22 America/New_York - First release Path-Tiny-0.076/CONTRIBUTING.mkdn000644 000765 000024 00000005751 12622375237 016400 0ustar00davidstaff000000 000000 ## HOW TO CONTRIBUTE Thank you for considering contributing to this distribution. This file contains instructions that will help you work with the source code. The distribution is managed with Dist::Zilla. This means than many of the usual files you might expect are not in the repository, but are generated at release time, as is much of the documentation. Some generated files are kept in the repository as a convenience (e.g. Makefile.PL or cpanfile). Generally, **you do not need Dist::Zilla to contribute patches**. You do need Dist::Zilla to create a tarball. See below for guidance. ### Getting dependencies If you have App::cpanminus 1.6 or later installed, you can use `cpanm` to satisfy dependencies like this: $ cpanm --installdeps . Otherwise, look for either a `Makefile.PL` or `cpanfile` file for a list of dependencies to satisfy. ### Running tests You can run tests directly using the `prove` tool: $ prove -l $ prove -lv t/some_test_file.t For most of my distributions, `prove` is entirely sufficient for you to test any patches you have. I use `prove` for 99% of my testing during development. ### Code style and tidying Please try to match any existing coding style. If there is a `.perltidyrc` file, please install Perl::Tidy and use perltidy before submitting patches. If there is a `tidyall.ini` file, you can also install Code::TidyAll and run `tidyall` on a file or `tidyall -a` to tidy all files. ### Patching documentation Much of the documentation Pod is generated at release time. Some is generated boilerplate; other documentation is built from pseudo-POD directives in the source like C<=method> or C<=func>. If you would like to submit a documentation edit, please limit yourself to the documentation you see. If you see typos or documentation issues in the generated docs, please email or open a bug ticket instead of patching. ### Installing and using Dist::Zilla Dist::Zilla is a very powerful authoring tool, optimized for maintaining a large number of distributions with a high degree of automation, but it has a large dependency chain, a bit of a learning curve and requires a number of author-specific plugins. To install it from CPAN, I recommend one of the following approaches for the quickest installation: # using CPAN.pm, but bypassing non-functional pod tests $ cpan TAP::Harness::Restricted $ PERL_MM_USE_DEFAULT=1 HARNESS_CLASS=TAP::Harness::Restricted cpan Dist::Zilla # using cpanm, bypassing *all* tests $ cpanm -n Dist::Zilla In either case, it's probably going to take about 10 minutes. Go for a walk, go get a cup of your favorite beverage, take a bathroom break, or whatever. When you get back, Dist::Zilla should be ready for you. Then you need to install any plugins specific to this distribution: $ cpan `dzil authordeps` $ dzil authordeps | cpanm Once installed, here are some dzil commands you might try: $ dzil build $ dzil test $ dzil xtest You can learn more about Dist::Zilla at http://dzil.org/ Path-Tiny-0.076/cpanfile000644 000765 000024 00000004006 12622375237 015312 0ustar00davidstaff000000 000000 requires "Carp" => "0"; requires "Cwd" => "0"; requires "Digest" => "1.03"; requires "Digest::SHA" => "5.45"; requires "Exporter" => "5.57"; requires "Fcntl" => "0"; requires "File::Copy" => "0"; requires "File::Glob" => "0"; requires "File::Path" => "2.07"; requires "File::Spec" => "3.40"; requires "File::Temp" => "0.19"; requires "File::stat" => "0"; requires "constant" => "0"; requires "if" => "0"; requires "overload" => "0"; requires "perl" => "5.008001"; requires "strict" => "0"; requires "warnings" => "0"; recommends "Unicode::UTF8" => "0.58"; on 'test' => sub { requires "ExtUtils::MakeMaker" => "0"; requires "File::Basename" => "0"; requires "File::Spec" => "3.40"; requires "File::Spec::Functions" => "0"; requires "File::Spec::Unix" => "0"; requires "File::Temp" => "0.19"; requires "Test::More" => "0.96"; requires "lib" => "0"; requires "open" => "0"; requires "perl" => "5.008001"; }; on 'test' => sub { recommends "CPAN::Meta" => "2.120900"; recommends "Test::FailWarnings" => "0"; recommends "Test::MockRandom" => "0"; }; on 'configure' => sub { requires "ExtUtils::MakeMaker" => "6.17"; requires "perl" => "5.008001"; }; on 'develop' => sub { requires "Dist::Zilla" => "5"; requires "Dist::Zilla::Plugin::MinimumPerl" => "0"; requires "Dist::Zilla::Plugin::OnlyCorePrereqs" => "0"; requires "Dist::Zilla::Plugin::Prereqs" => "0"; requires "Dist::Zilla::Plugin::RemovePrereqs" => "0"; requires "Dist::Zilla::PluginBundle::DAGOLDEN" => "0.072"; requires "English" => "0"; requires "File::Spec" => "0"; requires "File::Temp" => "0"; requires "IO::Handle" => "0"; requires "IPC::Open3" => "0"; requires "Pod::Coverage::TrustPod" => "0"; requires "Pod::Wordlist" => "0"; requires "Software::License::Apache_2_0" => "0"; requires "Test::CPAN::Meta" => "0"; requires "Test::More" => "0"; requires "Test::Pod" => "1.41"; requires "Test::Pod::Coverage" => "1.08"; requires "Test::Spelling" => "0.12"; requires "Test::Version" => "1"; requires "blib" => "1.01"; }; Path-Tiny-0.076/dist.ini000644 000765 000024 00000002131 12622375237 015247 0ustar00davidstaff000000 000000 name = Path-Tiny author = David Golden license = Apache_2_0 copyright_holder = David Golden copyright_year = 2014 [@DAGOLDEN] :version = 0.072 -remove = MinimumPerlFast stopwords = AIX stopwords = BENCHMARKING stopwords = CRLF stopwords = SHA stopwords = NFS stopwords = canonpath stopwords = codepoints stopwords = cwd stopwords = dirname stopwords = fatalize stopwords = lstat stopwords = mkpath stopwords = opena stopwords = openr stopwords = openrw stopwords = openw stopwords = realpath stopwords = stringifying stopwords = subclasses stopwords = touchpath stopwords = UNC stopwords = unlinked stopwords = utf MetaNoIndex.package = flock [MinimumPerl] [RemovePrereqs] remove = Unicode::UTF8 remove = Path::Class remove = Test::FailWarnings remove = threads ; Digest/Digest::SHA are fine in 5.10.0+ [Prereqs] Digest = 1.03 Digest::SHA = 5.45 File::Path = 2.07 File::Temp = 0.19 ; newdir [Prereqs / Recommends] Unicode::UTF8 = 0.58 [Prereqs / TestRecommends] Test::FailWarnings = 0 Test::MockRandom = 0 [OnlyCorePrereqs] starting_version = current check_dual_life_versions = 0 Path-Tiny-0.076/lib/000755 000765 000024 00000000000 12622375237 014354 5ustar00davidstaff000000 000000 Path-Tiny-0.076/LICENSE000644 000765 000024 00000026354 12622375237 014625 0ustar00davidstaff000000 000000 This software is Copyright (c) 2014 by David Golden. This is free software, licensed under: The Apache License, Version 2.0, January 2004 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Path-Tiny-0.076/Makefile.PL000644 000765 000024 00000004035 12622375237 015562 0ustar00davidstaff000000 000000 # This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v5.041. use strict; use warnings; use 5.008001; use ExtUtils::MakeMaker 6.17; my %WriteMakefileArgs = ( "ABSTRACT" => "File path utility", "AUTHOR" => "David Golden ", "CONFIGURE_REQUIRES" => { "ExtUtils::MakeMaker" => "6.17" }, "DISTNAME" => "Path-Tiny", "LICENSE" => "apache", "MIN_PERL_VERSION" => "5.008001", "NAME" => "Path::Tiny", "PREREQ_PM" => { "Carp" => 0, "Cwd" => 0, "Digest" => "1.03", "Digest::SHA" => "5.45", "Exporter" => "5.57", "Fcntl" => 0, "File::Copy" => 0, "File::Glob" => 0, "File::Path" => "2.07", "File::Spec" => "3.40", "File::Temp" => "0.19", "File::stat" => 0, "constant" => 0, "if" => 0, "overload" => 0, "strict" => 0, "warnings" => 0 }, "TEST_REQUIRES" => { "ExtUtils::MakeMaker" => 0, "File::Basename" => 0, "File::Spec" => "3.40", "File::Spec::Functions" => 0, "File::Spec::Unix" => 0, "File::Temp" => "0.19", "Test::More" => "0.96", "lib" => 0, "open" => 0 }, "VERSION" => "0.076", "test" => { "TESTS" => "t/*.t" } ); my %FallbackPrereqs = ( "Carp" => 0, "Cwd" => 0, "Digest" => "1.03", "Digest::SHA" => "5.45", "Exporter" => "5.57", "ExtUtils::MakeMaker" => 0, "Fcntl" => 0, "File::Basename" => 0, "File::Copy" => 0, "File::Glob" => 0, "File::Path" => "2.07", "File::Spec" => "3.40", "File::Spec::Functions" => 0, "File::Spec::Unix" => 0, "File::Temp" => "0.19", "File::stat" => 0, "Test::More" => "0.96", "constant" => 0, "if" => 0, "lib" => 0, "open" => 0, "overload" => 0, "strict" => 0, "warnings" => 0 ); unless ( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ) { delete $WriteMakefileArgs{TEST_REQUIRES}; delete $WriteMakefileArgs{BUILD_REQUIRES}; $WriteMakefileArgs{PREREQ_PM} = \%FallbackPrereqs; } delete $WriteMakefileArgs{CONFIGURE_REQUIRES} unless eval { ExtUtils::MakeMaker->VERSION(6.52) }; WriteMakefile(%WriteMakefileArgs); Path-Tiny-0.076/MANIFEST000644 000765 000024 00000001514 12622375237 014740 0ustar00davidstaff000000 000000 # This file was automatically generated by Dist::Zilla::Plugin::Manifest v5.041. CONTRIBUTING.mkdn Changes LICENSE MANIFEST META.json META.yml Makefile.PL README cpanfile dist.ini lib/Path/Tiny.pm perlcritic.rc t/00-report-prereqs.dd t/00-report-prereqs.t t/README t/basename.t t/basic.t t/children.t t/chmod.t t/data/chmod.txt t/digest.t t/exception.t t/exports.t t/filesystem.t t/input_output.t t/input_output_no_UU.t t/lib/TestUtils.pm t/locking.t t/mkpath.t t/mutable_tree_while_iterating.t t/normalize.t t/overloading.t t/parent.t t/recurse.t t/rel-abs.t t/subsumes.t t/temp.t t/visit.t t/zz-atomic.t t/zzz-spec.t tidyall.ini xt/author/00-compile.t xt/author/critic.t xt/author/pod-coverage.t xt/author/pod-spell.t xt/author/pod-syntax.t xt/author/test-version.t xt/release/distmeta.t xt/release/minimum-version.t xt/release/portability.t Path-Tiny-0.076/META.json000644 000765 000024 00000011206 12622375237 015227 0ustar00davidstaff000000 000000 { "abstract" : "File path utility", "author" : [ "David Golden " ], "dynamic_config" : 0, "generated_by" : "Dist::Zilla version 5.041, CPAN::Meta::Converter version 2.150001", "license" : [ "apache_2_0" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : 2 }, "name" : "Path-Tiny", "no_index" : { "directory" : [ "corpus", "examples", "t", "xt" ], "package" : [ "DB", "flock" ] }, "prereqs" : { "configure" : { "requires" : { "ExtUtils::MakeMaker" : "6.17", "perl" : "5.008001" } }, "develop" : { "requires" : { "Dist::Zilla" : "5", "Dist::Zilla::Plugin::MinimumPerl" : "0", "Dist::Zilla::Plugin::OnlyCorePrereqs" : "0", "Dist::Zilla::Plugin::Prereqs" : "0", "Dist::Zilla::Plugin::RemovePrereqs" : "0", "Dist::Zilla::PluginBundle::DAGOLDEN" : "0.072", "English" : "0", "File::Spec" : "0", "File::Temp" : "0", "IO::Handle" : "0", "IPC::Open3" : "0", "Pod::Coverage::TrustPod" : "0", "Pod::Wordlist" : "0", "Software::License::Apache_2_0" : "0", "Test::CPAN::Meta" : "0", "Test::More" : "0", "Test::Pod" : "1.41", "Test::Pod::Coverage" : "1.08", "Test::Spelling" : "0.12", "Test::Version" : "1", "blib" : "1.01" } }, "runtime" : { "recommends" : { "Unicode::UTF8" : "0.58" }, "requires" : { "Carp" : "0", "Cwd" : "0", "Digest" : "1.03", "Digest::SHA" : "5.45", "Exporter" : "5.57", "Fcntl" : "0", "File::Copy" : "0", "File::Glob" : "0", "File::Path" : "2.07", "File::Spec" : "3.40", "File::Temp" : "0.19", "File::stat" : "0", "constant" : "0", "if" : "0", "overload" : "0", "perl" : "5.008001", "strict" : "0", "warnings" : "0" } }, "test" : { "recommends" : { "CPAN::Meta" : "2.120900", "Test::FailWarnings" : "0", "Test::MockRandom" : "0" }, "requires" : { "ExtUtils::MakeMaker" : "0", "File::Basename" : "0", "File::Spec" : "3.40", "File::Spec::Functions" : "0", "File::Spec::Unix" : "0", "File::Temp" : "0.19", "Test::More" : "0.96", "lib" : "0", "open" : "0", "perl" : "5.008001" } } }, "provides" : { "Path::Tiny" : { "file" : "lib/Path/Tiny.pm", "version" : "0.076" }, "Path::Tiny::Error" : { "file" : "lib/Path/Tiny.pm", "version" : "0.076" } }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "https://github.com/dagolden/Path-Tiny/issues" }, "homepage" : "https://github.com/dagolden/Path-Tiny", "repository" : { "type" : "git", "url" : "https://github.com/dagolden/Path-Tiny.git", "web" : "https://github.com/dagolden/Path-Tiny" } }, "version" : "0.076", "x_authority" : "cpan:DAGOLDEN", "x_contributors" : [ "Alex Efros ", "Chris Williams ", "David Golden ", "David Steinbrunner ", "Doug Bell ", "Gabor Szabo ", "Gabriel Andrade ", "George Hartzell ", "Geraud Continsouzas ", "Goro Fuji ", "Graham Knop ", "James Hunt ", "Karen Etheridge ", "Mark Ellis ", "Martin Kjeldsen ", "Michael G. Schwern ", "Philippe Bruhat (BooK) ", "Regina Verbae ", "Roy Ivy III ", "Shlomi Fish ", "Smylers ", "Tatsuhiko Miyagawa ", "Toby Inkster ", "Yanick Champoux ", "김도형 - Keedi Kim " ] } Path-Tiny-0.076/META.yml000644 000765 000024 00000004652 12622375237 015066 0ustar00davidstaff000000 000000 --- abstract: 'File path utility' author: - 'David Golden ' build_requires: ExtUtils::MakeMaker: '0' File::Basename: '0' File::Spec: '3.40' File::Spec::Functions: '0' File::Spec::Unix: '0' File::Temp: '0.19' Test::More: '0.96' lib: '0' open: '0' perl: '5.008001' configure_requires: ExtUtils::MakeMaker: '6.17' perl: '5.008001' dynamic_config: 0 generated_by: 'Dist::Zilla version 5.041, CPAN::Meta::Converter version 2.150001' license: apache meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: Path-Tiny no_index: directory: - corpus - examples - t - xt package: - DB - flock provides: Path::Tiny: file: lib/Path/Tiny.pm version: '0.076' Path::Tiny::Error: file: lib/Path/Tiny.pm version: '0.076' recommends: Unicode::UTF8: '0.58' requires: Carp: '0' Cwd: '0' Digest: '1.03' Digest::SHA: '5.45' Exporter: '5.57' Fcntl: '0' File::Copy: '0' File::Glob: '0' File::Path: '2.07' File::Spec: '3.40' File::Temp: '0.19' File::stat: '0' constant: '0' if: '0' overload: '0' perl: '5.008001' strict: '0' warnings: '0' resources: bugtracker: https://github.com/dagolden/Path-Tiny/issues homepage: https://github.com/dagolden/Path-Tiny repository: https://github.com/dagolden/Path-Tiny.git version: '0.076' x_authority: cpan:DAGOLDEN x_contributors: - 'Alex Efros ' - 'Chris Williams ' - 'David Golden ' - 'David Steinbrunner ' - 'Doug Bell ' - 'Gabor Szabo ' - 'Gabriel Andrade ' - 'George Hartzell ' - 'Geraud Continsouzas ' - 'Goro Fuji ' - 'Graham Knop ' - 'James Hunt ' - 'Karen Etheridge ' - 'Mark Ellis ' - 'Martin Kjeldsen ' - 'Michael G. Schwern ' - 'Philippe Bruhat (BooK) ' - 'Regina Verbae ' - 'Roy Ivy III ' - 'Shlomi Fish ' - 'Smylers ' - 'Tatsuhiko Miyagawa ' - 'Toby Inkster ' - 'Yanick Champoux ' - '김도형 - Keedi Kim ' Path-Tiny-0.076/perlcritic.rc000644 000765 000024 00000001166 12622375237 016300 0ustar00davidstaff000000 000000 severity = 5 verbose = 8 [Variables::ProhibitPunctuationVars] allow = $@ $! [TestingAndDebugging::ProhibitNoStrict] allow = refs [Variables::ProhibitEvilVariables] variables = $DB::single # Turn these off [-BuiltinFunctions::ProhibitStringyEval] [-ControlStructures::ProhibitPostfixControls] [-ControlStructures::ProhibitUnlessBlocks] [-Documentation::RequirePodSections] [-InputOutput::ProhibitInteractiveTest] [-References::ProhibitDoubleSigils] [-RegularExpressions::RequireExtendedFormatting] [-InputOutput::ProhibitTwoArgOpen] [-Modules::ProhibitEvilModules] # Turn this on [Lax::ProhibitStringyEval::ExceptForRequire] Path-Tiny-0.076/README000644 000765 000024 00000104320 12622375237 014466 0ustar00davidstaff000000 000000 NAME Path::Tiny - File path utility VERSION version 0.076 SYNOPSIS use Path::Tiny; # creating Path::Tiny objects $dir = path("/tmp"); $foo = path("foo.txt"); $subdir = $dir->child("foo"); $bar = $subdir->child("bar.txt"); # stringifies as cleaned up path $file = path("./foo.txt"); print $file; # "foo.txt" # reading files $guts = $file->slurp; $guts = $file->slurp_utf8; @lines = $file->lines; @lines = $file->lines_utf8; ($head) = $file->lines( {count => 1} ); ($tail) = $file->lines( {count => -1} ); # writing files $bar->spew( @data ); $bar->spew_utf8( @data ); # reading directories for ( $dir->children ) { ... } $iter = $dir->iterator; while ( my $next = $iter->() ) { ... } DESCRIPTION This module provides a small, fast utility for working with file paths. It is friendlier to use than File::Spec and provides easy access to functions from several other core file handling modules. It aims to be smaller and faster than many alternatives on CPAN, while helping people do many common things in consistent and less error-prone ways. Path::Tiny does not try to work for anything except Unix-like and Win32 platforms. Even then, it might break if you try something particularly obscure or tortuous. (Quick! What does this mean: "///../../..//./././a//b/.././c/././"? And how does it differ on Win32?) All paths are forced to have Unix-style forward slashes. Stringifying the object gives you back the path (after some clean up). File input/output methods "flock" handles before reading or writing, as appropriate (if supported by the platform). The *_utf8 methods ("slurp_utf8", "lines_utf8", etc.) operate in raw mode. On Windows, that means they will not have CRLF translation from the ":crlf" IO layer. Installing Unicode::UTF8 0.58 or later will speed up *_utf8 situations in many cases and is highly recommended. This module depends heavily on PerlIO layers for correct operation and thus requires Perl 5.008001 or later. CONSTRUCTORS path $path = path("foo/bar"); $path = path("/tmp", "file.txt"); # list $path = path("."); # cwd $path = path("~user/file.txt"); # tilde processing Constructs a "Path::Tiny" object. It doesn't matter if you give a file or directory path. It's still up to you to call directory-like methods only on directories and file-like methods only on files. This function is exported automatically by default. The first argument must be defined and have non-zero length or an exception will be thrown. This prevents subtle, dangerous errors with code like "path( maybe_undef() )->remove_tree". If the first component of the path is a tilde ('~') then the component will be replaced with the output of "glob('~')". If the first component of the path is a tilde followed by a user name then the component will be replaced with output of "glob('~username')". Behaviour for non-existent users depends on the output of "glob" on the system. On Windows, if the path consists of a drive identifier without a path component ("C:" or "D:"), it will be expanded to the absolute path of the current directory on that volume using "Cwd::getdcwd()". If called with a single "Path::Tiny" argument, the original is returned unless the original is holding a temporary file or directory reference in which case a stringified copy is made. $path = path("foo/bar"); $temp = Path::Tiny->tempfile; $p2 = path($path); # like $p2 = $path $t2 = path($temp); # like $t2 = path( "$temp" ) This optimizes copies without proliferating references unexpectedly if a copy is made by code outside your control. Current API available since 0.017. new $path = Path::Tiny->new("foo/bar"); This is just like "path", but with method call overhead. (Why would you do that?) Current API available since 0.001. cwd $path = Path::Tiny->cwd; # path( Cwd::getcwd ) $path = cwd; # optional export Gives you the absolute path to the current directory as a "Path::Tiny" object. This is slightly faster than "path(".")->absolute". "cwd" may be exported on request and used as a function instead of as a method. Current API available since 0.018. rootdir $path = Path::Tiny->rootdir; # / $path = rootdir; # optional export Gives you "File::Spec->rootdir" as a "Path::Tiny" object if you're too picky for "path("/")". "rootdir" may be exported on request and used as a function instead of as a method. Current API available since 0.018. tempfile, tempdir $temp = Path::Tiny->tempfile( @options ); $temp = Path::Tiny->tempdir( @options ); $temp = tempfile( @options ); # optional export $temp = tempdir( @options ); # optional export "tempfile" passes the options to "File::Temp->new" and returns a "Path::Tiny" object with the file name. The "TMPDIR" option is enabled by default. The resulting "File::Temp" object is cached. When the "Path::Tiny" object is destroyed, the "File::Temp" object will be as well. "File::Temp" annoyingly requires you to specify a custom template in slightly different ways depending on which function or method you call, but "Path::Tiny" lets you ignore that and can take either a leading template or a "TEMPLATE" option and does the right thing. $temp = Path::Tiny->tempfile( "customXXXXXXXX" ); # ok $temp = Path::Tiny->tempfile( TEMPLATE => "customXXXXXXXX" ); # ok The tempfile path object will be normalized to have an absolute path, even if created in a relative directory using "DIR". "tempdir" is just like "tempfile", except it calls "File::Temp->newdir" instead. Both "tempfile" and "tempdir" may be exported on request and used as functions instead of as methods. Note: for tempfiles, the filehandles from File::Temp are closed and not reused. This is not as secure as using File::Temp handles directly, but is less prone to deadlocks or access problems on some platforms. Think of what "Path::Tiny" gives you to be just a temporary file name that gets cleaned up. Current API available since 0.018. METHODS absolute $abs = path("foo/bar")->absolute; $abs = path("foo/bar")->absolute("/tmp"); Returns a new "Path::Tiny" object with an absolute path (or itself if already absolute). Unless an argument is given, the current directory is used as the absolute base path. The argument must be absolute or you won't get an absolute result. This will not resolve upward directories ("foo/../bar") unless "canonpath" in File::Spec would normally do so on your platform. If you need them resolved, you must call the more expensive "realpath" method instead. On Windows, an absolute path without a volume component will have it added based on the current drive. Current API available since 0.001. append, append_raw, append_utf8 path("foo.txt")->append(@data); path("foo.txt")->append(\@data); path("foo.txt")->append({binmode => ":raw"}, @data); path("foo.txt")->append_raw(@data); path("foo.txt")->append_utf8(@data); Appends data to a file. The file is locked with "flock" prior to writing. An optional hash reference may be used to pass options. Valid options are: * "binmode": passed to "binmode()" on the handle used for writing. * "truncate": truncates the file after locking and before appending The "truncate" option is a way to replace the contents of a file in place, unlike "spew" which writes to a temporary file and then replaces the original (if it exists). "append_raw" is like "append" with a "binmode" of ":unix" for fast, unbuffered, raw write. "append_utf8" is like "append" with a "binmode" of ":unix:encoding(UTF-8)". If Unicode::UTF8 0.58+ is installed, a raw append will be done instead on the data encoded with "Unicode::UTF8". Current API available since 0.060. assert $path = path("foo.txt")->assert( sub { $_->exists } ); Returns the invocant after asserting that a code reference argument returns true. When the assertion code reference runs, it will have the invocant object in the $_ variable. If it returns false, an exception will be thrown. The assertion code reference may also throw its own exception. If no assertion is provided, the invocant is returned without error. Current API available since 0.062. basename $name = path("foo/bar.txt")->basename; # bar.txt $name = path("foo.txt")->basename('.txt'); # foo $name = path("foo.txt")->basename(qr/.txt/); # foo $name = path("foo.txt")->basename(@suffixes); Returns the file portion or last directory portion of a path. Given a list of suffixes as strings or regular expressions, any that match at the end of the file portion or last directory portion will be removed before the result is returned. Current API available since 0.054. canonpath $canonical = path("foo/bar")->canonpath; # foo\bar on Windows Returns a string with the canonical format of the path name for the platform. In particular, this means directory separators will be "\" on Windows. Current API available since 0.001. child $file = path("/tmp")->child("foo.txt"); # "/tmp/foo.txt" $file = path("/tmp")->child(@parts); Returns a new "Path::Tiny" object relative to the original. Works like "catfile" or "catdir" from File::Spec, but without caring about file or directories. Current API available since 0.001. children @paths = path("/tmp")->children; @paths = path("/tmp")->children( qr/\.txt$/ ); Returns a list of "Path::Tiny" objects for all files and directories within a directory. Excludes "." and ".." automatically. If an optional "qr//" argument is provided, it only returns objects for child names that match the given regular expression. Only the base name is used for matching: @paths = path("/tmp")->children( qr/^foo/ ); # matches children like the glob foo* Current API available since 0.028. chmod path("foo.txt")->chmod(0777); path("foo.txt")->chmod("0755"); path("foo.txt")->chmod("go-w"); path("foo.txt")->chmod("a=r,u+wx"); Sets file or directory permissions. The argument can be a numeric mode, a octal string beginning with a "0" or a limited subset of the symbolic mode use by /bin/chmod. The symbolic mode must be a comma-delimited list of mode clauses. Clauses must match "qr/\A([augo]+)([=+-])([rwx]+)\z/", which defines "who", "op" and "perms" parameters for each clause. Unlike /bin/chmod, all three parameters are required for each clause, multiple ops are not allowed and permissions "stugoX" are not supported. (See File::chmod for more complex needs.) Current API available since 0.053. copy path("/tmp/foo.txt")->copy("/tmp/bar.txt"); Copies a file using File::Copy's "copy" function. Upon success, returns the "Path::Tiny" object for the newly copied file. Current API available since 0.070. digest $obj = path("/tmp/foo.txt")->digest; # SHA-256 $obj = path("/tmp/foo.txt")->digest("MD5"); # user-selected $obj = path("/tmp/foo.txt")->digest( { chunk_size => 1e6 }, "MD5" ); Returns a hexadecimal digest for a file. An optional hash reference of options may be given. The only option is "chunk_size". If "chunk_size" is given, that many bytes will be read at a time. If not provided, the entire file will be slurped into memory to compute the digest. Any subsequent arguments are passed to the constructor for Digest to select an algorithm. If no arguments are given, the default is SHA-256. Current API available since 0.056. dirname (deprecated) $name = path("/tmp/foo.txt")->dirname; # "/tmp/" Returns the directory portion you would get from calling "File::Spec->splitpath( $path->stringify )" or "." for a path without a parent directory portion. Because File::Spec is inconsistent, the result might or might not have a trailing slash. Because of this, this method is deprecated. A better, more consistently approach is likely "$path->parent->stringify", which will not have a trailing slash except for a root directory. Deprecated in 0.056. exists, is_file, is_dir if ( path("/tmp")->exists ) { ... } # -e if ( path("/tmp")->is_dir ) { ... } # -d if ( path("/tmp")->is_file ) { ... } # -e && ! -d Implements file test operations, this means the file or directory actually has to exist on the filesystem. Until then, it's just a path. Note: "is_file" is not "-f" because "-f" is not the opposite of "-d". "-f" means "plain file", excluding symlinks, devices, etc. that often can be read just like files. Use "-f" instead if you really mean to check for a plain file. Current API available since 0.053. filehandle $fh = path("/tmp/foo.txt")->filehandle($mode, $binmode); $fh = path("/tmp/foo.txt")->filehandle({ locked => 1 }, $mode, $binmode); $fh = path("/tmp/foo.txt")->filehandle({ exclusive => 1 }, $mode, $binmode); Returns an open file handle. The $mode argument must be a Perl-style read/write mode string ("<" ,">", "<<", etc.). If a $binmode is given, it is set during the "open" call. An optional hash reference may be used to pass options. The "locked" option governs file locking; if true, handles opened for writing, appending or read-write are locked with "LOCK_EX"; otherwise, they are locked with "LOCK_SH". When using "locked", ">" or "+>" modes will delay truncation until after the lock is acquired. The "exclusive" option causes the open() call to fail if the file already exists. This corresponds to the O_EXCL flag to sysopen / open(2). "exclusive" implies "locked" and will set it for you if you forget it. See "openr", "openw", "openrw", and "opena" for sugar. Current API available since 0.066. is_absolute, is_relative if ( path("/tmp")->is_absolute ) { ... } if ( path("/tmp")->is_relative ) { ... } Booleans for whether the path appears absolute or relative. Current API available since 0.001. is_rootdir while ( ! $path->is_rootdir ) { $path = $path->parent; ... } Boolean for whether the path is the root directory of the volume. I.e. the "dirname" is "q[/]" and the "basename" is "q[]". This works even on "MSWin32" with drives and UNC volumes: path("C:/")->is_rootdir; # true path("//server/share/")->is_rootdir; #true Current API available since 0.038. iterator $iter = path("/tmp")->iterator( \%options ); Returns a code reference that walks a directory lazily. Each invocation returns a "Path::Tiny" object or undef when the iterator is exhausted. $iter = path("/tmp")->iterator; while ( $path = $iter->() ) { ... } The current and parent directory entries ("." and "..") will not be included. If the "recurse" option is true, the iterator will walk the directory recursively, breadth-first. If the "follow_symlinks" option is also true, directory links will be followed recursively. There is no protection against loops when following links. If a directory is not readable, it will not be followed. The default is the same as: $iter = path("/tmp")->iterator( { recurse => 0, follow_symlinks => 0, } ); For a more powerful, recursive iterator with built-in loop avoidance, see Path::Iterator::Rule. See also "visit". Current API available since 0.016. lines, lines_raw, lines_utf8 @contents = path("/tmp/foo.txt")->lines; @contents = path("/tmp/foo.txt")->lines(\%options); @contents = path("/tmp/foo.txt")->lines_raw; @contents = path("/tmp/foo.txt")->lines_utf8; @contents = path("/tmp/foo.txt")->lines( { chomp => 1, count => 4 } ); Returns a list of lines from a file. Optionally takes a hash-reference of options. Valid options are "binmode", "count" and "chomp". If "binmode" is provided, it will be set on the handle prior to reading. If a positive "count" is provided, that many lines will be returned from the start of the file. If a negative "count" is provided, the entire file will be read, but only "abs(count)" will be kept and returned. If "abs(count)" exceeds the number of lines in the file, all lines will be returned. If "chomp" is set, any end-of-line character sequences ("CR", "CRLF", or "LF") will be removed from the lines returned. Because the return is a list, "lines" in scalar context will return the number of lines (and throw away the data). $number_of_lines = path("/tmp/foo.txt")->lines; "lines_raw" is like "lines" with a "binmode" of ":raw". We use ":raw" instead of ":unix" so PerlIO buffering can manage reading by line. "lines_utf8" is like "lines" with a "binmode" of ":raw:encoding(UTF-8)". If Unicode::UTF8 0.58+ is installed, a raw UTF-8 slurp will be done and then the lines will be split. This is actually faster than relying on ":encoding(UTF-8)", though a bit memory intensive. If memory use is a concern, consider "openr_utf8" and iterating directly on the handle. Current API available since 0.065. mkpath path("foo/bar/baz")->mkpath; path("foo/bar/baz")->mkpath( \%options ); Like calling "make_path" from File::Path. An optional hash reference is passed through to "make_path". Errors will be trapped and an exception thrown. Returns the list of directories created or an empty list if the directories already exist, just like "make_path". Current API available since 0.001. move path("foo.txt")->move("bar.txt"); Just like "rename". Current API available since 0.001. openr, openw, openrw, opena $fh = path("foo.txt")->openr($binmode); # read $fh = path("foo.txt")->openr_raw; $fh = path("foo.txt")->openr_utf8; $fh = path("foo.txt")->openw($binmode); # write $fh = path("foo.txt")->openw_raw; $fh = path("foo.txt")->openw_utf8; $fh = path("foo.txt")->opena($binmode); # append $fh = path("foo.txt")->opena_raw; $fh = path("foo.txt")->opena_utf8; $fh = path("foo.txt")->openrw($binmode); # read/write $fh = path("foo.txt")->openrw_raw; $fh = path("foo.txt")->openrw_utf8; Returns a file handle opened in the specified mode. The "openr" style methods take a single "binmode" argument. All of the "open*" methods have "open*_raw" and "open*_utf8" equivalents that use ":raw" and ":raw:encoding(UTF-8)", respectively. An optional hash reference may be used to pass options. The only option is "locked". If true, handles opened for writing, appending or read-write are locked with "LOCK_EX"; otherwise, they are locked for "LOCK_SH". $fh = path("foo.txt")->openrw_utf8( { locked => 1 } ); See "filehandle" for more on locking. Current API available since 0.011. parent $parent = path("foo/bar/baz")->parent; # foo/bar $parent = path("foo/wibble.txt")->parent; # foo $parent = path("foo/bar/baz")->parent(2); # foo Returns a "Path::Tiny" object corresponding to the parent directory of the original directory or file. An optional positive integer argument is the number of parent directories upwards to return. "parent" by itself is equivalent to parent(1). Current API available since 0.014. realpath $real = path("/baz/foo/../bar")->realpath; $real = path("foo/../bar")->realpath; Returns a new "Path::Tiny" object with all symbolic links and upward directory parts resolved using Cwd's "realpath". Compared to "absolute", this is more expensive as it must actually consult the filesystem. If the parent path can't be resolved (e.g. if it includes directories that don't exist), an exception will be thrown: $real = path("doesnt_exist/foo")->realpath; # dies However, if the parent path exists and only the last component (e.g. filename) doesn't exist, the realpath will be the realpath of the parent plus the non-existent last component: $real = path("./aasdlfasdlf")->realpath; # works The underlying Cwd module usually worked this way on Unix, but died on Windows (and some Unixes) if the full path didn't exist. As of version 0.064, it's safe to use anywhere. Current API available since 0.001. relative $rel = path("/tmp/foo/bar")->relative("/tmp"); # foo/bar Returns a "Path::Tiny" object with a relative path name. Given the trickiness of this, it's a thin wrapper around "File::Spec->abs2rel()". Current API available since 0.001. remove path("foo.txt")->remove; This is just like "unlink", except for its error handling: if the path does not exist, it returns false; if deleting the file fails, it throws an exception. Current API available since 0.012. remove_tree # directory path("foo/bar/baz")->remove_tree; path("foo/bar/baz")->remove_tree( \%options ); path("foo/bar/baz")->remove_tree( { safe => 0 } ); # force remove Like calling "remove_tree" from File::Path, but defaults to "safe" mode. An optional hash reference is passed through to "remove_tree". Errors will be trapped and an exception thrown. Returns the number of directories deleted, just like "remove_tree". If you want to remove a directory only if it is empty, use the built-in "rmdir" function instead. rmdir path("foo/bar/baz/"); Current API available since 0.013. sibling $foo = path("/tmp/foo.txt"); $sib = $foo->sibling("bar.txt"); # /tmp/bar.txt $sib = $foo->sibling("baz", "bam.txt"); # /tmp/baz/bam.txt Returns a new "Path::Tiny" object relative to the parent of the original. This is slightly more efficient than "$path->parent->child(...)". Current API available since 0.058. slurp, slurp_raw, slurp_utf8 $data = path("foo.txt")->slurp; $data = path("foo.txt")->slurp( {binmode => ":raw"} ); $data = path("foo.txt")->slurp_raw; $data = path("foo.txt")->slurp_utf8; Reads file contents into a scalar. Takes an optional hash reference may be used to pass options. The only option is "binmode", which is passed to "binmode()" on the handle used for reading. "slurp_raw" is like "slurp" with a "binmode" of ":unix" for a fast, unbuffered, raw read. "slurp_utf8" is like "slurp" with a "binmode" of ":unix:encoding(UTF-8)". If Unicode::UTF8 0.58+ is installed, a raw slurp will be done instead and the result decoded with "Unicode::UTF8". This is just as strict and is roughly an order of magnitude faster than using ":encoding(UTF-8)". Note: "slurp" and friends lock the filehandle before slurping. If you plan to slurp from a file created with File::Temp, be sure to close other handles or open without locking to avoid a deadlock: my $tempfile = File::Temp->new(EXLOCK => 0); my $guts = path($tempfile)->slurp; Current API available since 0.004. spew, spew_raw, spew_utf8 path("foo.txt")->spew(@data); path("foo.txt")->spew(\@data); path("foo.txt")->spew({binmode => ":raw"}, @data); path("foo.txt")->spew_raw(@data); path("foo.txt")->spew_utf8(@data); Writes data to a file atomically. The file is written to a temporary file in the same directory, then renamed over the original. An optional hash reference may be used to pass options. The only option is "binmode", which is passed to "binmode()" on the handle used for writing. "spew_raw" is like "spew" with a "binmode" of ":unix" for a fast, unbuffered, raw write. "spew_utf8" is like "spew" with a "binmode" of ":unix:encoding(UTF-8)". If Unicode::UTF8 0.58+ is installed, a raw spew will be done instead on the data encoded with "Unicode::UTF8". NOTE: because the file is written to a temporary file and then renamed, the new file will wind up with permissions based on your current umask. This is a feature to protect you from a race condition that would otherwise give different permissions than you might expect. If you really want to keep the original mode flags, use "append" with the "truncate" option. Current API available since 0.011. stat, lstat $stat = path("foo.txt")->stat; $stat = path("/some/symlink")->lstat; Like calling "stat" or "lstat" from File::stat. Current API available since 0.001. stringify $path = path("foo.txt"); say $path->stringify; # same as "$path" Returns a string representation of the path. Unlike "canonpath", this method returns the path standardized with Unix-style "/" directory separators. Current API available since 0.001. subsumes path("foo/bar")->subsumes("foo/bar/baz"); # true path("/foo/bar")->subsumes("/foo/baz"); # false Returns true if the first path is a prefix of the second path at a directory boundary. This does not resolve parent directory entries ("..") or symlinks: path("foo/bar")->subsumes("foo/bar/../baz"); # true If such things are important to you, ensure that both paths are resolved to the filesystem with "realpath": my $p1 = path("foo/bar")->realpath; my $p2 = path("foo/bar/../baz")->realpath; if ( $p1->subsumes($p2) ) { ... } Current API available since 0.048. touch path("foo.txt")->touch; path("foo.txt")->touch($epoch_secs); Like the Unix "touch" utility. Creates the file if it doesn't exist, or else changes the modification and access times to the current time. If the first argument is the epoch seconds then it will be used. Returns the path object so it can be easily chained with other methods: # won't die if foo.txt doesn't exist $content = path("foo.txt")->touch->slurp; Current API available since 0.015. touchpath path("bar/baz/foo.txt")->touchpath; Combines "mkpath" and "touch". Creates the parent directory if it doesn't exist, before touching the file. Returns the path object like "touch" does. Current API available since 0.022. visit path("/tmp")->visit( \&callback, \%options ); Wraps the "iterator" method to execute a callback for each directory entry. It returns a hash reference with any state accumulated during iteration. The options are the same as for "iterator": "recurse" and "follow_symlinks". Both default to false. The callback function will receive a "Path::Tiny" object as the first argument and a hash reference to accumulate state as the second argument. For example: # collect files sizes my $sizes = path("/tmp")->visit( sub { my ($path, $state) = @_; return if $path->is_dir; $state->{$path} = -s $path; }, { recurse => 1 } ); For convenience, the "Path::Tiny" object will also be locally aliased as the $_ global variable: # print paths matching /foo/ path("/tmp")->visit( sub { say if /foo/ }, { recurse => 1} ); If the callback returns a reference to a false scalar value, iteration will terminate. This is not the same as "pruning" a directory search; this just stops all iteration and returns the state hash reference. # find up to 10 files larger than 100K my $files = path("/tmp")->visit( sub { my ($path, $state) = @_; $state->{$path}++ if -s $path > 102400 return \0 if keys %$state == 10; }, { recurse => 1 } ); If you want more flexible iteration, use a module like Path::Iterator::Rule. Current API available since 0.062. volume $vol = path("/tmp/foo.txt")->volume; # "" $vol = path("C:/tmp/foo.txt")->volume; # "C:" Returns the volume portion of the path. This is equivalent equivalent to what File::Spec would give from "splitpath" and thus usually is the empty string on Unix-like operating systems or the drive letter for an absolute path on "MSWin32". Current API available since 0.001. EXCEPTION HANDLING Simple usage errors will generally croak. Failures of underlying Perl functions will be thrown as exceptions in the class "Path::Tiny::Error". A "Path::Tiny::Error" object will be a hash reference with the following fields: * "op" — a description of the operation, usually function call and any extra info * "file" — the file or directory relating to the error * "err" — hold $! at the time the error was thrown * "msg" — a string combining the above data and a Carp-like short stack trace Exception objects will stringify as the "msg" field. CAVEATS File locking If flock is not supported on a platform, it will not be used, even if locking is requested. See additional caveats below. NFS and BSD On BSD, Perl's flock implementation may not work to lock files on an NFS filesystem. Path::Tiny has some heuristics to detect this and will warn once and let you continue in an unsafe mode. If you want this failure to be fatal, you can fatalize the 'flock' warnings category: use warnings FATAL => 'flock'; AIX and locking AIX requires a write handle for locking. Therefore, calls that normally open a read handle and take a shared lock instead will open a read-write handle and take an exclusive lock. If the user does not have write permission, no lock will be used. utf8 vs UTF-8 All the *_utf8 methods use ":encoding(UTF-8)" -- either as ":unix:encoding(UTF-8)" (unbuffered) or ":raw:encoding(UTF-8)" (buffered) -- which is strict against the Unicode spec and disallows illegal Unicode codepoints or UTF-8 sequences. Unfortunately, ":encoding(UTF-8)" is very, very slow. If you install Unicode::UTF8 0.58 or later, that module will be used by some *_utf8 methods to encode or decode data after a raw, binary input/output operation, which is much faster. If you need the performance and can accept the security risk, "slurp({binmode => ":unix:utf8"})" will be faster than ":unix:encoding(UTF-8)" (but not as fast as "Unicode::UTF8"). Note that the *_utf8 methods read in raw mode. There is no CRLF translation on Windows. If you must have CRLF translation, use the regular input/output methods with an appropriate binmode: $path->spew_utf8($data); # raw $path->spew({binmode => ":encoding(UTF-8)"}, $data; # LF -> CRLF Consider PerlIO::utf8_strict for a faster PerlIO layer alternative to ":encoding(UTF-8)", though it does not appear to be as fast as the "Unicode::UTF8" approach. Default IO layers and the open pragma If you have Perl 5.10 or later, file input/output methods ("slurp", "spew", etc.) and high-level handle opening methods ( "filehandle", "openr", "openw", etc. ) respect default encodings set by the "-C" switch or lexical open settings of the caller. For UTF-8, this is almost certainly slower than using the dedicated "_utf8" methods if you have Unicode::UTF8. TYPE CONSTRAINTS AND COERCION A standard MooseX::Types library is available at MooseX::Types::Path::Tiny. A Type::Tiny equivalent is available as Types::Path::Tiny. SEE ALSO These are other file/path utilities, which may offer a different feature set than "Path::Tiny". * File::chmod * File::Fu * IO::All * Path::Class These iterators may be slightly faster than the recursive iterator in "Path::Tiny": * Path::Iterator::Rule * File::Next There are probably comparable, non-Tiny tools. Let me know if you want me to add a module to the list. This module was featured in the 2013 Perl Advent Calendar . SUPPORT Bugs / Feature Requests Please report any bugs or feature requests through the issue tracker at . You will be notified automatically of any progress on your issue. Source Code This is open source software. The code repository is available for public review and contribution under the terms of the license. git clone https://github.com/dagolden/Path-Tiny.git AUTHOR David Golden CONTRIBUTORS * Alex Efros * Chris Williams * David Golden * David Steinbrunner * Doug Bell * Gabor Szabo * Gabriel Andrade * George Hartzell * Geraud Continsouzas * Goro Fuji * Graham Knop * James Hunt * Karen Etheridge * Mark Ellis * Martin Kjeldsen * Michael G. Schwern * Philippe Bruhat (BooK) * Regina Verbae * Roy Ivy III * Shlomi Fish * Smylers * Tatsuhiko Miyagawa * Toby Inkster * Yanick Champoux * 김도형 - Keedi Kim COPYRIGHT AND LICENSE This software is Copyright (c) 2014 by David Golden. This is free software, licensed under: The Apache License, Version 2.0, January 2004 Path-Tiny-0.076/t/000755 000765 000024 00000000000 12622375237 014051 5ustar00davidstaff000000 000000 Path-Tiny-0.076/tidyall.ini000644 000765 000024 00000000240 12622375237 015745 0ustar00davidstaff000000 000000 ; Install Code::TidyAll ; run "tidyall -a" to tidy all files ; run "tidyall -g" to tidy only files modified from git [PerlTidy] select = {lib,t}/**/*.{pl,pm,t} Path-Tiny-0.076/xt/000755 000765 000024 00000000000 12622375237 014241 5ustar00davidstaff000000 000000 Path-Tiny-0.076/xt/author/000755 000765 000024 00000000000 12622375237 015543 5ustar00davidstaff000000 000000 Path-Tiny-0.076/xt/release/000755 000765 000024 00000000000 12622375237 015661 5ustar00davidstaff000000 000000 Path-Tiny-0.076/xt/release/distmeta.t000644 000765 000024 00000000172 12622375237 017660 0ustar00davidstaff000000 000000 #!perl # This file was automatically generated by Dist::Zilla::Plugin::MetaTests. use Test::CPAN::Meta; meta_yaml_ok(); Path-Tiny-0.076/xt/release/minimum-version.t000644 000765 000024 00000000266 12622375237 021210 0ustar00davidstaff000000 000000 #!perl use Test::More; eval "use Test::MinimumVersion"; plan skip_all => "Test::MinimumVersion required for testing minimum versions" if $@; all_minimum_version_ok( qq{5.010} ); Path-Tiny-0.076/xt/release/portability.t000644 000765 000024 00000000332 12622375237 020406 0ustar00davidstaff000000 000000 #!perl use strict; use warnings; use Test::More; eval 'use Test::Portability::Files'; plan skip_all => 'Test::Portability::Files required for testing portability' if $@; options(test_one_dot => 0); run_tests(); Path-Tiny-0.076/xt/author/00-compile.t000644 000765 000024 00000002352 12622375237 017577 0ustar00davidstaff000000 000000 use 5.006; use strict; use warnings; # this test was generated with Dist::Zilla::Plugin::Test::Compile 2.054 use Test::More; plan tests => 2; my @module_files = ( 'Path/Tiny.pm' ); # fake home for cpan-testers use File::Temp; local $ENV{HOME} = File::Temp::tempdir( CLEANUP => 1 ); my $inc_switch = -d 'blib' ? '-Mblib' : '-Ilib'; use File::Spec; use IPC::Open3; use IO::Handle; open my $stdin, '<', File::Spec->devnull or die "can't open devnull: $!"; my @warnings; for my $lib (@module_files) { # see L my $stderr = IO::Handle->new; my $pid = open3($stdin, '>&STDERR', $stderr, $^X, $inc_switch, '-e', "require q[$lib]"); binmode $stderr, ':crlf' if $^O eq 'MSWin32'; my @_warnings = <$stderr>; waitpid($pid, 0); is($?, 0, "$lib loaded ok"); shift @_warnings if @_warnings and $_warnings[0] =~ /^Using .*\bblib/ and not eval { require blib; blib->VERSION('1.01') }; if (@_warnings) { warn @_warnings; push @warnings, @_warnings; } } is(scalar(@warnings), 0, 'no warnings found') or diag 'got warnings: ', ( Test::More->can('explain') ? Test::More::explain(\@warnings) : join("\n", '', @warnings) ); Path-Tiny-0.076/xt/author/critic.t000644 000765 000024 00000000435 12622375237 017207 0ustar00davidstaff000000 000000 #!perl use strict; use warnings; use Test::More; use English qw(-no_match_vars); eval "use Test::Perl::Critic"; plan skip_all => 'Test::Perl::Critic required to criticise code' if $@; Test::Perl::Critic->import( -profile => "perlcritic.rc" ) if -e "perlcritic.rc"; all_critic_ok(); Path-Tiny-0.076/xt/author/pod-coverage.t000644 000765 000024 00000000334 12622375237 020303 0ustar00davidstaff000000 000000 #!perl # This file was automatically generated by Dist::Zilla::Plugin::PodCoverageTests. use Test::Pod::Coverage 1.08; use Pod::Coverage::TrustPod; all_pod_coverage_ok({ coverage_class => 'Pod::Coverage::TrustPod' }); Path-Tiny-0.076/xt/author/pod-spell.t000644 000765 000024 00000001664 12622375237 017636 0ustar00davidstaff000000 000000 use strict; use warnings; use Test::More; # generated by Dist::Zilla::Plugin::Test::PodSpelling 2.007000 use Test::Spelling 0.12; use Pod::Wordlist; add_stopwords(); all_pod_files_spelling_ok( qw( bin lib ) ); __DATA__ AIX BENCHMARKING CRLF SHA NFS canonpath codepoints cwd dirname fatalize lstat mkpath opena openr openrw openw realpath stringifying subclasses touchpath UNC unlinked utf David Golden dagolden Alex Efros powerman Chris Williams bingos xdg Steinbrunner dsteinbrunner Doug Bell madcityzen Gabor Szabo szabgab Gabriel Andrade gabiruh George Hartzell hartzell Geraud Continsouzas geraud Goro Fuji gfuji Graham Knop haarg James Hunt james Karen Etheridge ether Mark Ellis mark Martin Kjeldsen mk Michael Schwern mschwern Philippe Bruhat BooK book Regina Verbae regina Roy Ivy III RIVY Shlomi Fish shlomif Smylers Tatsuhiko Miyagawa miyagawa Toby Inkster tobyink Yanick Champoux yanick 김도형 Keedi Kim keedi lib Path Tiny Path-Tiny-0.076/xt/author/pod-syntax.t000644 000765 000024 00000000252 12622375237 020035 0ustar00davidstaff000000 000000 #!perl # This file was automatically generated by Dist::Zilla::Plugin::PodSyntaxTests. use strict; use warnings; use Test::More; use Test::Pod 1.41; all_pod_files_ok(); Path-Tiny-0.076/xt/author/test-version.t000644 000765 000024 00000000640 12622375237 020372 0ustar00davidstaff000000 000000 use strict; use warnings; use Test::More; # generated by Dist::Zilla::Plugin::Test::Version 1.05 use Test::Version; my @imports = qw( version_all_ok ); my $params = { is_strict => 0, has_version => 1, multiple => 0, }; push @imports, $params if version->parse( $Test::Version::VERSION ) >= version->parse('1.002'); Test::Version->import(@imports); version_all_ok; done_testing; Path-Tiny-0.076/t/00-report-prereqs.dd000644 000765 000024 00000010006 12622375237 017566 0ustar00davidstaff000000 000000 do { my $x = { 'configure' => { 'requires' => { 'ExtUtils::MakeMaker' => '6.17', 'perl' => '5.008001' } }, 'develop' => { 'requires' => { 'Dist::Zilla' => '5', 'Dist::Zilla::Plugin::MinimumPerl' => '0', 'Dist::Zilla::Plugin::OnlyCorePrereqs' => '0', 'Dist::Zilla::Plugin::Prereqs' => '0', 'Dist::Zilla::Plugin::RemovePrereqs' => '0', 'Dist::Zilla::PluginBundle::DAGOLDEN' => '0.072', 'English' => '0', 'File::Spec' => '0', 'File::Temp' => '0', 'IO::Handle' => '0', 'IPC::Open3' => '0', 'Pod::Coverage::TrustPod' => '0', 'Pod::Wordlist' => '0', 'Software::License::Apache_2_0' => '0', 'Test::CPAN::Meta' => '0', 'Test::More' => '0', 'Test::Pod' => '1.41', 'Test::Pod::Coverage' => '1.08', 'Test::Spelling' => '0.12', 'Test::Version' => '1', 'blib' => '1.01' } }, 'runtime' => { 'recommends' => { 'Unicode::UTF8' => '0.58' }, 'requires' => { 'Carp' => '0', 'Cwd' => '0', 'Digest' => '1.03', 'Digest::SHA' => '5.45', 'Exporter' => '5.57', 'Fcntl' => '0', 'File::Copy' => '0', 'File::Glob' => '0', 'File::Path' => '2.07', 'File::Spec' => '3.40', 'File::Temp' => '0.19', 'File::stat' => '0', 'constant' => '0', 'if' => '0', 'overload' => '0', 'perl' => '5.008001', 'strict' => '0', 'warnings' => '0' } }, 'test' => { 'recommends' => { 'CPAN::Meta' => '2.120900', 'Test::FailWarnings' => '0', 'Test::MockRandom' => '0' }, 'requires' => { 'ExtUtils::MakeMaker' => '0', 'File::Basename' => '0', 'File::Spec' => '3.40', 'File::Spec::Functions' => '0', 'File::Spec::Unix' => '0', 'File::Temp' => '0.19', 'Test::More' => '0.96', 'lib' => '0', 'open' => '0', 'perl' => '5.008001' } } }; $x; }Path-Tiny-0.076/t/00-report-prereqs.t000644 000765 000024 00000012731 12622375237 017451 0ustar00davidstaff000000 000000 #!perl use strict; use warnings; # This test was generated by Dist::Zilla::Plugin::Test::ReportPrereqs 0.021 use Test::More tests => 1; use ExtUtils::MakeMaker; use File::Spec; # from $version::LAX my $lax_version_re = qr/(?: undef | (?: (?:[0-9]+) (?: \. | (?:\.[0-9]+) (?:_[0-9]+)? )? | (?:\.[0-9]+) (?:_[0-9]+)? ) | (?: v (?:[0-9]+) (?: (?:\.[0-9]+)+ (?:_[0-9]+)? )? | (?:[0-9]+)? (?:\.[0-9]+){2,} (?:_[0-9]+)? ) )/x; # hide optional CPAN::Meta modules from prereq scanner # and check if they are available my $cpan_meta = "CPAN::Meta"; my $cpan_meta_pre = "CPAN::Meta::Prereqs"; my $HAS_CPAN_META = eval "require $cpan_meta; $cpan_meta->VERSION('2.120900')" && eval "require $cpan_meta_pre"; ## no critic # Verify requirements? my $DO_VERIFY_PREREQS = 1; sub _max { my $max = shift; $max = ( $_ > $max ) ? $_ : $max for @_; return $max; } sub _merge_prereqs { my ($collector, $prereqs) = @_; # CPAN::Meta::Prereqs object if (ref $collector eq $cpan_meta_pre) { return $collector->with_merged_prereqs( CPAN::Meta::Prereqs->new( $prereqs ) ); } # Raw hashrefs for my $phase ( keys %$prereqs ) { for my $type ( keys %{ $prereqs->{$phase} } ) { for my $module ( keys %{ $prereqs->{$phase}{$type} } ) { $collector->{$phase}{$type}{$module} = $prereqs->{$phase}{$type}{$module}; } } } return $collector; } my @include = qw( ); my @exclude = qw( ); # Add static prereqs to the included modules list my $static_prereqs = do 't/00-report-prereqs.dd'; # Merge all prereqs (either with ::Prereqs or a hashref) my $full_prereqs = _merge_prereqs( ( $HAS_CPAN_META ? $cpan_meta_pre->new : {} ), $static_prereqs ); # Add dynamic prereqs to the included modules list (if we can) my ($source) = grep { -f } 'MYMETA.json', 'MYMETA.yml'; if ( $source && $HAS_CPAN_META ) { if ( my $meta = eval { CPAN::Meta->load_file($source) } ) { $full_prereqs = _merge_prereqs($full_prereqs, $meta->prereqs); } } else { $source = 'static metadata'; } my @full_reports; my @dep_errors; my $req_hash = $HAS_CPAN_META ? $full_prereqs->as_string_hash : $full_prereqs; # Add static includes into a fake section for my $mod (@include) { $req_hash->{other}{modules}{$mod} = 0; } for my $phase ( qw(configure build test runtime develop other) ) { next unless $req_hash->{$phase}; next if ($phase eq 'develop' and not $ENV{AUTHOR_TESTING}); for my $type ( qw(requires recommends suggests conflicts modules) ) { next unless $req_hash->{$phase}{$type}; my $title = ucfirst($phase).' '.ucfirst($type); my @reports = [qw/Module Want Have/]; for my $mod ( sort keys %{ $req_hash->{$phase}{$type} } ) { next if $mod eq 'perl'; next if grep { $_ eq $mod } @exclude; my $file = $mod; $file =~ s{::}{/}g; $file .= ".pm"; my ($prefix) = grep { -e File::Spec->catfile($_, $file) } @INC; my $want = $req_hash->{$phase}{$type}{$mod}; $want = "undef" unless defined $want; $want = "any" if !$want && $want == 0; my $req_string = $want eq 'any' ? 'any version required' : "version '$want' required"; if ($prefix) { my $have = MM->parse_version( File::Spec->catfile($prefix, $file) ); $have = "undef" unless defined $have; push @reports, [$mod, $want, $have]; if ( $DO_VERIFY_PREREQS && $HAS_CPAN_META && $type eq 'requires' ) { if ( $have !~ /\A$lax_version_re\z/ ) { push @dep_errors, "$mod version '$have' cannot be parsed ($req_string)"; } elsif ( ! $full_prereqs->requirements_for( $phase, $type )->accepts_module( $mod => $have ) ) { push @dep_errors, "$mod version '$have' is not in required range '$want'"; } } } else { push @reports, [$mod, $want, "missing"]; if ( $DO_VERIFY_PREREQS && $type eq 'requires' ) { push @dep_errors, "$mod is not installed ($req_string)"; } } } if ( @reports ) { push @full_reports, "=== $title ===\n\n"; my $ml = _max( map { length $_->[0] } @reports ); my $wl = _max( map { length $_->[1] } @reports ); my $hl = _max( map { length $_->[2] } @reports ); if ($type eq 'modules') { splice @reports, 1, 0, ["-" x $ml, "", "-" x $hl]; push @full_reports, map { sprintf(" %*s %*s\n", -$ml, $_->[0], $hl, $_->[2]) } @reports; } else { splice @reports, 1, 0, ["-" x $ml, "-" x $wl, "-" x $hl]; push @full_reports, map { sprintf(" %*s %*s %*s\n", -$ml, $_->[0], $wl, $_->[1], $hl, $_->[2]) } @reports; } push @full_reports, "\n"; } } } if ( @full_reports ) { diag "\nVersions for all modules listed in $source (including optional ones):\n\n", @full_reports; } if ( @dep_errors ) { diag join("\n", "\n*** WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING ***\n", "The following REQUIRED prerequisites were not satisfied:\n", @dep_errors, "\n" ); } pass; # vim: ts=4 sts=4 sw=4 et: Path-Tiny-0.076/t/basename.t000644 000765 000024 00000001560 12622375237 016013 0ustar00davidstaff000000 000000 use 5.008001; use strict; use warnings; use Test::More 0.96; use lib 't/lib'; use TestUtils qw/exception/; use Path::Tiny; use Cwd; my $IS_WIN32 = $^O eq 'MSWin32'; my @cases = ( [ 'foo.txt', [ '.txt', '.png' ], 'foo' ], [ 'foo.png', [ '.txt', '.png' ], 'foo' ], [ 'foo.txt', [ qr/\.txt/, qr/\.png/ ], 'foo' ], [ 'foo.png', [ qr/\.txt/, qr/\.png/ ], 'foo' ], [ 'foo.txt', ['.jpeg'], 'foo.txt' ], [ 'foo/.txt/bar.txt', [ qr/\.txt/, qr/\.png/ ], 'bar' ], ); for my $c (@cases) { my ( $input, $args, $result ) = @$c; my $path = path($input); my $base = $path->basename(@$args); is( $base, $result, "$path -> $result" ); } done_testing; # # This file is part of Path-Tiny # # This software is Copyright (c) 2014 by David Golden. # # This is free software, licensed under: # # The Apache License, Version 2.0, January 2004 # Path-Tiny-0.076/t/basic.t000644 000765 000024 00000013421 12622375237 015320 0ustar00davidstaff000000 000000 use 5.008001; use strict; use warnings; use Test::More 0.96; use File::Spec; use Path::Tiny; use Cwd; my $IS_WIN32 = $^O eq 'MSWin32'; use lib 't/lib'; use TestUtils qw/exception/; my $file1 = path('foo.txt'); isa_ok( $file1, "Path::Tiny" ); ok $file1->isa('Path::Tiny'); is $file1, 'foo.txt'; ok $file1->is_relative; is $file1->dirname, '.'; is $file1->basename, 'foo.txt'; my $file2 = path( 'dir', 'bar.txt' ); is $file2, 'dir/bar.txt'; ok !$file2->is_absolute; is $file2->dirname, 'dir/'; is $file2->basename, 'bar.txt'; my $dir = path('tmp'); is $dir, 'tmp'; ok !$dir->is_absolute; is $dir->basename, 'tmp'; my $dir2 = path('/tmp'); is $dir2, '/tmp'; ok $dir2->is_absolute; my $cat = path( $dir, 'foo' ); is $cat, 'tmp/foo'; $cat = $dir->child('foo'); is $cat, 'tmp/foo'; is $cat->dirname, 'tmp/'; is $cat->basename, 'foo'; $cat = path( $dir2, 'foo' ); is $cat, '/tmp/foo'; $cat = $dir2->child('foo'); is $cat, '/tmp/foo'; isa_ok $cat, 'Path::Tiny'; is $cat->dirname, '/tmp/'; $cat = $dir2->child('foo'); is $cat, '/tmp/foo'; isa_ok $cat, 'Path::Tiny'; is $cat->basename, 'foo'; my $sib = $cat->sibling('bar'); is $sib, '/tmp/bar'; isa_ok $sib, 'Path::Tiny'; my $file = path('/foo//baz/./foo'); is $file, '/foo/baz/foo'; is $file->dirname, '/foo/baz/'; is $file->parent, '/foo/baz'; { my $file = path("foo/bar/baz"); is( $file->canonpath, File::Spec->canonpath("$file"), "canonpath" ); } { my $dir = path('/foo/bar/baz'); is $dir->parent, '/foo/bar'; is $dir->parent->parent, '/foo'; is $dir->parent->parent->parent, '/'; is $dir->parent->parent->parent->parent, '/'; $dir = path('foo/bar/baz'); is $dir->parent, 'foo/bar'; is $dir->parent->parent, 'foo'; is $dir->parent->parent->parent, '.'; is $dir->parent->parent->parent->parent, '..'; is $dir->parent->parent->parent->parent->parent, '../..'; } { my $dir = path("foo/"); is $dir, 'foo'; is $dir->parent, '.'; } { # Special cases for my $bad ( [''], [undef], [], [ '', 'var', 'tmp' ], [ 'foo', '', 'bar' ] ) { like( exception { path(@$bad) }, qr/positive-length/, "exception" ); } is( Path::Tiny->cwd, path( Cwd::getcwd() ) ); is( path('.')->absolute, path( Cwd::getcwd() ) ); } { my $file = path('/tmp/foo/bar.txt'); is $file->relative('/tmp'), 'foo/bar.txt'; is $file->relative('/tmp/foo'), 'bar.txt'; is $file->relative('/tmp/'), 'foo/bar.txt'; is $file->relative('/tmp/foo/'), 'bar.txt'; $file = path('one/two/three'); is $file->relative('one'), 'two/three'; } { my $file = Path::Tiny->new( File::Spec->rootdir ); my $root = Path::Tiny->rootdir; is( $file, $root, "rootdir is like path('/')" ); is( $file->child("lib"), "/lib", "child of rootdir is correct" ); } # constructor { is( path(qw/foo bar baz/), Path::Tiny->new(qw/foo bar baz/), "path() vs new" ); is( path(qw/foo bar baz/), path("foo/bar/baz"), "path(a,b,c) vs path('a/b/c')" ); } # tilde processing { my ($homedir) = glob('~'); $homedir =~ tr[\\][/] if $IS_WIN32; my $username = path($homedir)->basename; my ($root_homedir) = glob('~root'); my ($missing_homedir) = glob('~idontthinkso'); my @tests = ( # [arg for path(), expected string (undef if eq arg for path()), test string] ['~', $homedir, 'Test my homedir' ], ['~/', $homedir, 'Test my homedir with trailing "/"' ], ['~/foo/bar', $homedir.'/foo/bar', 'Test my homedir with longer path' ], ['~/foo/bar/', $homedir.'/foo/bar', 'Test my homedir, longer path and trailing "/"' ], ['~root', $root_homedir, 'Test root homedir' ], ['~root/', $root_homedir, 'Test root homedir with trailing /' ], ['~root/foo/bar', $root_homedir.'/foo/bar', 'Test root homedir with longer path' ], ['~root/foo/bar/', $root_homedir.'/foo/bar', 'Test root homedir, longer path and trailing "/"'], ['~idontthinkso', undef, 'Test homedir of nonexistant user' ], ['~idontthinkso', $missing_homedir, 'Test homedir of nonexistant user (via glob)' ], ['~blah blah', undef, 'Test space' ], ['~this is fun', undef, 'Test multiple spaces' ], ['~yikes \' apostrophe!', undef, 'Test spaces and embedded apostrophe' ], ['~hum " quote', undef, 'Test spaces and embedded quote' ], ['~hello ~there', undef, 'Test space-separated tildes' ], ["~fun\ttimes", undef, 'Test tab' ], ["~new\nline", undef, 'Test newline' ], ['~'.$username.' file', undef, 'Test \'~$username file\'' ], ); for my $test (@tests) { is(path($test->[0]), defined $test->[1] ? $test->[1] : $test->[0], $test->[2]); } } # freeze/thaw { my $path = path("/foo/bar/baz"); is( Path::Tiny->THAW( "fake", $path->FREEZE("fake") ), $path, "FREEZE-THAW roundtrip" ); } # assertions { my $err = exception { path("aljfakdlfadks")->assert( sub { $_->exists } ) }; like( $err, qr/failed assertion/, "assert exists" ); my $path; $err = exception { $path = path("t")->assert( sub { -d && -r _ } ) }; is( $err, '', "no exception if assertion succeeds" ); isa_ok( $path, "Path::Tiny", "assertion return value" ); $err = exception { path(".")->visit( sub { $_[1]->{$_} = { path => $_ } }, { recurse => 1 }, ); }; is $err, "", 'no exception'; } done_testing(); Path-Tiny-0.076/t/children.t000644 000765 000024 00000002154 12622375237 016030 0ustar00davidstaff000000 000000 use 5.008001; use strict; use warnings; use Test::More 0.96; use File::Basename (); use File::Temp (); use File::Spec::Unix; use lib 't/lib'; use TestUtils qw/exception/; use Path::Tiny; my $tempdir = File::Temp->newdir; my @kids = qw/apple banana carrot/; path($tempdir)->child($_)->touch for @kids; my @expected = map { path( File::Spec::Unix->catfile( $tempdir, $_ ) ) } @kids; is_deeply( [ sort { $a cmp $b } path($tempdir)->children ], [ sort @expected ], "children correct" ); my $regexp = qr/.a/; is_deeply( [ sort { $a cmp $b } path($tempdir)->children($regexp) ], [ sort grep { my $child = File::Basename::basename($_); $child =~ /$regexp/ } @expected ], "children correct with Regexp argument" ); my $arrayref = []; eval { path($tempdir)->children($arrayref) }; like $@, qr/Invalid argument '\Q$arrayref\E' for children()/, 'children with invalid argument'; done_testing; # # This file is part of Path-Tiny # # This software is Copyright (c) 2014 by David Golden. # # This is free software, licensed under: # # The Apache License, Version 2.0, January 2004 # Path-Tiny-0.076/t/chmod.t000644 000765 000024 00000001774 12622375237 015341 0ustar00davidstaff000000 000000 use 5.008001; use strict; use warnings; use Test::More 0.96; use lib 't/lib'; use TestUtils qw/exception/; use Path::Tiny; my $fh = path("t/data/chmod.txt")->openr; while ( my $line = <$fh> ) { chomp $line; my ( $chmod, $orig, $expect ) = split " ", $line; my $got = sprintf( "%05o", Path::Tiny::_symbolic_chmod( oct($orig), $chmod ) ); is( $got, $expect, "$orig -> $chmod -> $got" ); } my $path = Path::Tiny->tempfile; like( exception { $path->chmod("ldkakdfa") }, qr/Invalid mode argument/, "Invalid mode throws exception" ); like( exception { $path->chmod("sdfa=kdajfkl") }, qr/Invalid mode clause/, "Invalid mode clause throws exception" ); ok( exception { path("adljfasldfj")->chmod(0700) }, "Nonexistent file throws exception" ); done_testing; # # This file is part of Path-Tiny # # This software is Copyright (c) 2014 by David Golden. # # This is free software, licensed under: # # The Apache License, Version 2.0, January 2004 # # vim: ts=4 sts=4 sw=4 et: Path-Tiny-0.076/t/data/000755 000765 000024 00000000000 12622375237 014762 5ustar00davidstaff000000 000000 Path-Tiny-0.076/t/digest.t000644 000765 000024 00000002330 12622375237 015513 0ustar00davidstaff000000 000000 use 5.008001; use strict; use warnings; use Test::More 0.96; use lib 't/lib'; use TestUtils qw/exception/; use Path::Tiny; use Digest; my $dir = Path::Tiny->tempdir; my $file = $dir->child('foo.bin'); my $chunk = pack( "Z*", "Hello Path::Tiny\nThis is packed binary string\n" ); ok( $file->spew_raw($chunk), "created test file with packed binary string" ); is( $file->digest, 'a98e605049836e8adb36d351abb95a09e9e5e200703576ecdaec0e697d17d626', 'digest SHA-256 (hardcoded)', ); my $sha = Digest->new('SHA-256'); $sha->add($chunk); my $sha_hex = $sha->hexdigest; is( $file->digest, $sha_hex, 'digest SHA-256' ); is( $file->digest( { chunk_size => 10 } ), $sha_hex, 'digest SHA-256 (chunked)' ); is( $file->digest('MD5'), 'ce05aca61c0e58d7396073b668bcafd0', 'digest MD5 (hardcoded)', ); my $md5 = Digest->new('MD5'); $md5->add($chunk); my $md5_hex = $md5->hexdigest; is( $file->digest('MD5'), $md5_hex, 'digest MD5', ); is( $file->digest( { chunk_size => 10 }, 'MD5' ), $md5_hex, 'digest MD5 (chunked)' ); done_testing; # # This file is part of Path-Tiny # # This software is Copyright (c) 2014 by David Golden. # # This is free software, licensed under: # # The Apache License, Version 2.0, January 2004 # Path-Tiny-0.076/t/exception.t000644 000765 000024 00000002414 12622375237 016235 0ustar00davidstaff000000 000000 use 5.008001; use strict; use warnings; use Test::More 0.96; use lib 't/lib'; use TestUtils qw/exception/; use Path::Tiny; my $err; $err = exception { path("aljfakdlfadks")->slurp }; like( $err, qr/at \Q$0\E/, "exception reported at caller's package" ); for my $m (qw/append iterator lines lines_raw lines_utf8 slurp spew/) { $err = exception { path("foo")->$m( { wibble => 1 } ) }; like( $err, qr/Invalid option\(s\) for $m: wibble/, "$m bad args" ); } $err = exception { path("foo")->visit( sub { 1 }, { wibble => 1 } ); }; like( $err, qr/Invalid option\(s\) for visit: wibble/, "visit bad args" ); # exclude append/spew because they handle hash/not-hash themselves my $scalar = [qw/array ref/]; for my $m (qw/iterator lines lines_raw lines_utf8 slurp/) { $err = exception { path("foo")->$m($scalar) }; like( $err, qr/Options for $m must be a hash reference/, "$m not hashref" ); } $err = exception { path("foo")->visit( sub { 1 }, $scalar ); }; like( $err, qr/Options for visit must be a hash reference/, "visit not hashref" ); done_testing; # # This file is part of Path-Tiny # # This software is Copyright (c) 2014 by David Golden. # # This is free software, licensed under: # # The Apache License, Version 2.0, January 2004 # # vim: ts=4 sts=4 sw=4 et: Path-Tiny-0.076/t/exports.t000644 000765 000024 00000001242 12622375237 015741 0ustar00davidstaff000000 000000 use 5.008001; use strict; use warnings; use Test::More 0.96; use lib 't/lib'; use TestUtils qw/exception/; use Path::Tiny qw/path cwd rootdir tempdir tempfile/; isa_ok( path("."), 'Path::Tiny', 'path' ); isa_ok( cwd, 'Path::Tiny', 'cwd' ); isa_ok( rootdir, 'Path::Tiny', 'rootdir' ); isa_ok( tempfile( TEMPLATE => 'tempXXXXXXX' ), 'Path::Tiny', 'tempfile' ); isa_ok( tempdir( TEMPLATE => 'tempXXXXXXX' ), 'Path::Tiny', 'tempdir' ); done_testing; # # This file is part of Path-Tiny # # This software is Copyright (c) 2014 by David Golden. # # This is free software, licensed under: # # The Apache License, Version 2.0, January 2004 # # vim: ts=4 sts=4 sw=4 et: Path-Tiny-0.076/t/filesystem.t000644 000765 000024 00000026502 12622375237 016427 0ustar00davidstaff000000 000000 use 5.008001; use strict; use warnings; use Test::More 0.96; use File::Temp qw(tmpnam tempdir); use File::Spec; use Cwd; use lib 't/lib'; use TestUtils qw/exception/; use Path::Tiny; # Tests adapted from Path::Class t/basic.t my $file = path( scalar tmpnam() ); ok $file, "Got a filename via tmpnam()"; { my $fh = $file->openw; ok $fh, "Opened $file for writing"; ok print( $fh "Foo\n" ), "Printed to $file"; } ok -e $file, "$file should exist"; ok $file->is_file, "it's a file!"; if ( -e "/dev/null" ) { ok( path("/dev/null")->is_file, "/dev/null is_file, too" ); } my ( $volume, $dirname, $basename ) = map { s{\\}{/}; $_ } File::Spec->splitpath($file); is( $file->volume, $volume, "volume correct" ); is( $file->volume, $volume, "volume cached " ); # for coverage is( $file->dirname, $dirname, "dirname correct" ); is( $file->basename, $basename, "basename correct" ); { my $fh = $file->openr; is scalar <$fh>, "Foo\n", "Read contents of $file correctly"; } note "stat"; { my $stat = $file->stat; ok $stat; cmp_ok $stat->mtime, '>', time() - 20; # Modified within last 20 seconds $stat = $file->parent->stat; ok $stat; } note "stat/lstat with no file"; { my $file = "i/do/not/exist"; ok exception { path($file)->stat }; ok exception { path($file)->lstat }; } 1 while unlink $file; ok not -e $file; my $dir = path( tempdir( TMPDIR => 1, CLEANUP => 1 ) ); ok $dir; ok -d $dir; ok $dir->is_dir, "It's a directory!"; $file = $dir->child('foo.x'); $file->touch; ok -e $file; my $epoch = time - 10; utime $epoch, $epoch, $file; $file->touch; ok( $file->stat->mtime > $epoch, "touch sets utime as current time" ); $file->touch($epoch); ok( $file->stat->mtime == $epoch, "touch sets utime as 10 secs before" ); { my @files = $dir->children; is scalar @files, 1 or diag explain \@files; ok scalar grep { /foo\.x/ } @files; } ok $dir->remove_tree, "Removed $dir"; ok !-e $dir, "$dir no longer exists"; ok !$dir->remove_tree, "Removing non-existent dir returns false"; my $tmpdir = Path::Tiny->tempdir; { $dir = path( $tmpdir, 'foo', 'bar' ); $dir->parent->remove_tree if -e $dir->parent; ok $dir->mkpath, "Created $dir"; ok -d $dir, "$dir is a directory"; $dir = $dir->parent; ok $dir->remove_tree( { safe => 1 } ); # check that we pass through args ok !-e $dir; } { $dir = path( $tmpdir, 'foo' ); ok $dir->mkpath; ok $dir->child('dir')->mkpath; ok -d $dir->child('dir'); ok $dir->child('file.x')->touch; ok $dir->child('0')->touch; ok $dir->child('foo/bar/baz.txt')->touchpath; subtest 'iterator' => sub { my @contents; my $iter = $dir->iterator; while ( my $file = $iter->() ) { push @contents, $file; } is scalar @contents, 4 or diag explain \@contents; is( $iter->(), undef, "exhausted iterator is undef" ); my $joined = join ' ', sort map $_->basename, grep { -f $_ } @contents; is $joined, '0 file.x' or diag explain \@contents; my ($subdir) = grep { $_ eq $dir->child('dir') } @contents; ok $subdir; is -d $subdir, 1; my ($file) = grep { $_ eq $dir->child('file.x') } @contents; ok $file; is -d $file, ''; }; subtest 'visit' => sub { my @contents; $dir->visit( sub { push @contents, $_[0] } ); is scalar @contents, 4 or diag explain \@contents; my $joined = join ' ', sort map $_->basename, grep { -f $_ } @contents; is $joined, '0 file.x' or diag explain \@contents; my ($subdir) = grep { $_ eq $dir->child('dir') } @contents; ok $subdir; is -d $subdir, 1; my ($file) = grep { $_ eq $dir->child('file.x') } @contents; ok $file; is -d $file, ''; }; ok $dir->remove_tree; ok !-e $dir; # Try again with directory called '0', in curdir my $orig = Path::Tiny->cwd; ok $dir->mkpath; ok chdir($dir); my $dir2 = path("."); ok $dir2->child('0')->mkpath; ok -d $dir2->child('0'); subtest 'iterator' => sub { my @contents; my $iter = $dir2->iterator; while ( my $file = $iter->() ) { push @contents, $file; } ok grep { $_ eq '0' } @contents; }; subtest 'visit' => sub { my @contents; $dir2->visit( sub { push @contents, $_[0] } ); ok grep { $_ eq '0' } @contents; }; ok chdir($orig); ok $dir->remove_tree; ok !-e $dir; } { my $file = path( $tmpdir, 'slurp' ); ok $file; my $fh = $file->openw or die "Can't create $file: $!"; print $fh "Line1\nLine2\n"; close $fh; ok -e $file; my $content = $file->slurp; is $content, "Line1\nLine2\n"; my @content = $file->lines; is_deeply \@content, [ "Line1\n", "Line2\n" ]; @content = $file->lines( { chomp => 1 } ); is_deeply \@content, [ "Line1", "Line2" ]; ok( $file->remove, "removing file" ); ok !-e $file, "file is gone"; ok !$file->remove, "removing file again returns false"; my $subdir = $tmpdir->child('subdir'); ok $subdir->mkpath; ok exception { $subdir->remove }, "calling 'remove' on a directory throws"; ok rmdir $subdir; my $orig = Path::Tiny->cwd; ok chdir $tmpdir; my $zero_file = path '0'; ok $zero_file->openw; ok $zero_file->remove, "removing file called '0'"; ok chdir $orig; } { my $file = path( $tmpdir, 'slurp' ); ok $file; my $fh = $file->openw(':raw') or die "Can't create $file: $!"; print $fh "Line1\r\nLine2\r\n\302\261\r\n"; close $fh; ok -e $file; my $content = $file->slurp( { binmode => ':raw' } ); is $content, "Line1\r\nLine2\r\n\302\261\r\n", "slurp raw"; my $line3 = "\302\261\n"; utf8::decode($line3); $content = $file->slurp( { binmode => ':crlf:utf8' } ); is $content, "Line1\nLine2\n" . $line3, "slurp+crlf+utf8"; my @content = $file->lines( { binmode => ':crlf:utf8' } ); is_deeply \@content, [ "Line1\n", "Line2\n", $line3 ], "lines+crlf+utf8"; chop($line3); @content = $file->lines( { chomp => 1, binmode => ':crlf:utf8' } ); is_deeply \@content, [ "Line1", "Line2", $line3 ], "lines+chomp+crlf+utf8"; $file->remove; ok not -e $file; } { my $file = path( $tmpdir, 'spew' ); $file->remove() if $file->exists; $file->spew( { binmode => ':raw' }, "Line1\r\n" ); $file->append( { binmode => ':raw' }, "Line2" ); my $content = $file->slurp( { binmode => ':raw' } ); is( $content, "Line1\r\nLine2" ); } { # Make sure we can make an absolute/relative roundtrip my $cwd = path("."); is $cwd, $cwd->absolute->relative, "from $cwd to " . $cwd->absolute . " to " . $cwd->absolute->relative; } { # realpath should resolve .. my $lib = path("t/../lib"); my $real = $lib->realpath; unlike $real, qr/\.\./, "updir gone from realpath"; my $abs_lib = $lib->absolute; my $abs_t = path("t")->absolute; my $case = $abs_t->child("../lib"); is( $case->realpath, $lib->realpath, "realpath on absolute" ); # non-existent directory in realpath should throw error eval { path("lkajdfak/djslakdj")->realpath }; like( $@, qr/Error resolving realpath/, "caught error from realpath on non-existent dir" ); # but non-existent basename in realpath should throw error eval { path("./djslakdj")->realpath }; is( $@, '', "no error from realpath on non-existent last component" ); } subtest "copy()" => sub { my $file = $tmpdir->child("foo.txt"); $file->spew("Hello World\n"); my $copy; subtest "dest is a file" => sub { $copy = $tmpdir->child("bar.txt"); my $result = $file->copy($copy); is "$result" => "$copy", "returned the right file"; is( $copy->slurp, "Hello World\n", "file copied" ); }; subtest "dest is a dir" => sub { # new tempdir nto to clobber the original foo.txt my $tmpdir = Path::Tiny->tempdir; my $result = $file->copy($tmpdir); is "$result" => "$tmpdir/foo.txt", "returned the right file"; is $result->slurp, "Hello World\n", "file copied"; }; subtest "try some different chmods" => sub { ok( $copy->chmod(0000), "chmod(0000)" ); ok( $copy->chmod("0400"), "chmod('0400')" ); SKIP: { skip "No exception if run as root", 1 if $> == 0; skip "No exception writing to read-only file", 1 unless exception { open my $fh, ">", "$copy" or die }; # probe if actually read-only my $error = exception { $file->copy($copy) }; ok( $error, "copy throws error if permission denied" ); like( $error, qr/\Q$file/, "error messages includes the source file name" ); like( $error, qr/\Q$copy/, "error messages includes the destination file name" ); } ok( $copy->chmod("u+w"), "chmod('u+w')" ); }; }; { $tmpdir->child( "subdir", "touched.txt" )->touchpath->spew("Hello World\n"); is( $tmpdir->child( "subdir", "touched.txt" )->slurp, "Hello World\n", "touch can chain" ); } SKIP: { my $newtmp = Path::Tiny->tempdir; my $file = $newtmp->child("foo.txt"); my $link = $newtmp->child("bar.txt"); $file->spew("Hello World\n"); eval { symlink $file => $link }; skip "symlink unavailable", 1 if $@; ok( $link->lstat->size, "lstat" ); ok $link->remove, 'remove symbolic link'; ok $file->remove; $file = $newtmp->child("foo.txt"); $link = $newtmp->child("bar.txt"); $file->spew("Hello World\n"); ok symlink $file => $link; ok $file->remove; ok $link->remove, 'remove broken symbolic link'; my $dir = $newtmp->child('foo'); $link = $newtmp->child("bar"); ok $dir->mkpath; ok -d $dir; $file = $dir->child("baz.txt"); $file->spew("Hello World\n"); ok symlink $dir => $link; ok $link->remove_tree, 'remove_tree symbolic link'; ok $dir->remove_tree; $dir = $newtmp->child('foo'); $link = $newtmp->child("bar"); ok $dir->mkpath; ok -d $dir; $file = $dir->child("baz.txt"); $file->spew("Hello World\n"); ok symlink $dir => $link; ok $dir->remove_tree; ok $link->remove_tree, 'remove_tree broken symbolic link'; $file = $newtmp->child("foo.txt"); $link = $newtmp->child("bar.txt"); my $link2 = $newtmp->child("baz.txt"); $file->spew("Hello World\n"); ok symlink $file => $link; ok symlink $link => $link2; $link2->spew("Hello Perl\n"); ok -l $link2, 'path is still symbolic link after spewing'; is readlink($link2), $link, 'symbolic link is available after spewing'; is readlink($link), $file, 'symbolic link is available after spewing'; is $file->slurp, "Hello Perl\n", 'spewing follows the link and replace the destination instead'; } # We don't have subsume so comment these out. Keep in case we # implement it later ##{ ## my $t = path( 't'); ## my $foo_bar = $t->child('foo','bar'); ## $foo_bar->remove; # Make sure it doesn't exist ## ## ok $t->subsumes($foo_bar), "t subsumes t/foo/bar"; ## ok !$t->contains($foo_bar), "t doesn't contain t/foo/bar"; ## ## $foo_bar->mkpath; ## ok $t->subsumes($foo_bar), "t still subsumes t/foo/bar"; ## ok $t->contains($foo_bar), "t now contains t/foo/bar"; ## ## $t->child('foo')->remove; ##} done_testing; Path-Tiny-0.076/t/input_output.t000644 000765 000024 00000040205 12622375237 017016 0ustar00davidstaff000000 000000 use 5.008001; use strict; use warnings; use Test::More 0.96; use lib 't/lib'; use TestUtils qw/exception/; use Path::Tiny; my $tmp = Path::Tiny->tempdir; sub _lines { return ( "Line1\r\n", "Line2\n" ); } sub _utf8_lines { my $line3 = "\302\261\n"; utf8::decode($line3); return ( _lines(), $line3 ); } sub _no_end_of_newline_lines { return ( _lines(), "No end of newline" ); } sub _utf8_no_end_of_newline_lines { return ( _utf8_lines(), "No end of newline" ); } subtest "spew -> slurp" => sub { my $file = Path::Tiny->tempfile; ok( $file->spew(_lines), "spew" ); is( $file->slurp, join( '', _lines ), "slurp" ); }; subtest "spew -> slurp (empty)" => sub { my $file = Path::Tiny->tempfile; ok( $file->spew, "spew" ); is( $file->slurp, '', "slurp" ); }; subtest "spew -> slurp (arrayref)" => sub { my $file = Path::Tiny->tempfile; ok( $file->spew( [_lines] ), "spew" ); is( $file->slurp, join( '', _lines ), "slurp" ); }; subtest "spew -> slurp (binmode)" => sub { my $file = Path::Tiny->tempfile; ok( $file->spew( { binmode => ":utf8" }, _utf8_lines ), "spew" ); is( $file->slurp( { binmode => ":utf8" } ), join( '', _utf8_lines ), "slurp" ); }; subtest "spew -> slurp (open hint)" => sub { plan skip_all => "Needs 5.10" unless $] >= 5.010; use open IO => ":utf8"; my $file = Path::Tiny->tempfile; ok( $file->spew(_utf8_lines), "spew" ); my $got = $file->slurp(); is( $got, join( '', _utf8_lines ), "slurp" ); ok( utf8::is_utf8($got), "is UTF8" ); }; subtest "spew -> slurp (UTF-8)" => sub { my $file = Path::Tiny->tempfile; ok( $file->spew_utf8(_utf8_lines), "spew" ); my $got = $file->slurp_utf8(); is( $got, join( '', _utf8_lines ), "slurp" ); ok( utf8::is_utf8($got), "is UTF8" ); }; subtest "spew -> slurp (raw)" => sub { my $file = Path::Tiny->tempfile; ok( $file->spew_raw(_lines), "spew" ); is( $file->slurp_raw, join( '', _lines ), "slurp" ); }; subtest "spew -> lines" => sub { my $file = Path::Tiny->tempfile; ok( $file->spew(_lines), "spew" ); is( join( '', $file->lines ), join( '', _lines ), "lines" ); is( scalar $file->lines, my $cnt =()= _lines, "lines (scalar)" ); }; subtest "spew -> lines (open hint)" => sub { plan skip_all => "Needs 5.10" unless $] >= 5.010; use open IO => ":utf8"; my $file = Path::Tiny->tempfile; ok( $file->spew(_utf8_lines), "spew" ); my $got = join( '', $file->lines() ); is( $got, join( '', _utf8_lines ), "slurp" ); ok( utf8::is_utf8($got), "is UTF8" ); }; subtest "spew -> lines (UTF-8)" => sub { my $file = Path::Tiny->tempfile; ok( $file->spew_utf8(_utf8_lines), "spew" ); my $got = join( '', $file->lines_utf8() ); is( $got, join( '', _utf8_lines ), "slurp" ); ok( utf8::is_utf8($got), "is UTF8" ); is( scalar $file->lines, my $cnt =()= _utf8_lines, "lines (scalar)" ); }; subtest "spew -> lines (raw)" => sub { my $file = Path::Tiny->tempfile; ok( $file->spew_raw(_lines), "spew" ); is( join( '', $file->lines_raw ), join( '', _lines ), "lines" ); }; subtest "spew -> lines (count)" => sub { my $file = Path::Tiny->tempfile; ok( $file->spew(_lines), "spew" ); my @exp = _lines; is( join( '', $file->lines( { count => 2 } ) ), join( '', @exp[ 0 .. 1 ] ), "lines" ); is( join( '', $file->lines( { count => -2 } ) ), join( '', @exp[ 0 .. 1 ] ), "lines" ); }; subtest "spew -> lines (count, less than)" => sub { my $file = Path::Tiny->tempfile; ok( $file->spew(_lines), "spew" ); my @exp = _lines; is( join( '', $file->lines( { count => 1 } ) ), $exp[0], "lines" ); is( join( '', $file->lines( { count => -1 } ) ), $exp[1], "lines" ); }; subtest "spew -> lines (count, more than)" => sub { my $file = Path::Tiny->tempfile; ok( $file->spew(_lines), "spew" ); my @exp = _lines; is( join( '|', $file->lines( { count => 3 } ) ), join( "|", @exp ), "lines" ); is( join( '|', $file->lines( { count => -3 } ) ), join( "|", @exp ), "lines" ); }; subtest "spew -> lines (count, chomp)" => sub { my $file = Path::Tiny->tempfile; ok( $file->spew(_lines), "spew" ); my @exp = map { s/[\r\n]+//; $_ } _lines; is( join( '', $file->lines( { chomp => 1, count => 2 } ) ), join( '', @exp[ 0 .. 1 ] ), "lines" ); is( join( '', $file->lines( { chomp => 1, count => -2 } ) ), join( '', @exp[ 0 .. 1 ] ), "lines" ); }; subtest "spew -> lines (count, no end of newline)" => sub { my $file = Path::Tiny->tempfile; ok( $file->spew(_no_end_of_newline_lines), "spew" ); my @exp = _no_end_of_newline_lines; is( join( '', $file->lines( { count => 3 } ) ), join( '', @exp[ 0 .. 2 ] ), "lines" ); is( join( '', $file->lines( { count => -3 } ) ), join( '', @exp[ 0 .. 2 ] ), "lines" ); }; subtest "spew -> lines (count, less than, no end of newline)" => sub { my $file = Path::Tiny->tempfile; ok( $file->spew(_no_end_of_newline_lines), "spew" ); my @exp = _no_end_of_newline_lines; is( join( '', $file->lines( { count => 1 } ) ), $exp[0], "lines" ); is( join( '', $file->lines( { count => -1 } ) ), $exp[2], "lines" ); }; subtest "spew -> lines (count, more than, no end of newline)" => sub { my $file = Path::Tiny->tempfile; ok( $file->spew(_no_end_of_newline_lines), "spew" ); my @exp = _no_end_of_newline_lines; is( join( '|', $file->lines( { count => 4 } ) ), join( "|", @exp ), "lines" ); is( join( '|', $file->lines( { count => -4 } ) ), join( "|", @exp ), "lines" ); }; subtest "spew -> lines (count, chomp, no end of newline)" => sub { my $file = Path::Tiny->tempfile; ok( $file->spew(_no_end_of_newline_lines), "spew" ); my @exp = map { s/[\r\n]+//; $_ } _no_end_of_newline_lines; is( join( '', $file->lines( { chomp => 1, count => 3 } ) ), join( '', @exp[ 0 .. 2 ] ), "lines" ); is( join( '', $file->lines( { chomp => 1, count => -3 } ) ), join( '', @exp[ 0 .. 2 ] ), "lines" ); }; subtest "spew -> lines (count, UTF-8)" => sub { my $file = Path::Tiny->tempfile; ok( $file->spew_utf8(_utf8_lines), "spew" ); my @exp = _utf8_lines; is( join( '', $file->lines_utf8( { count => 3 } ) ), join( '', @exp ), "lines" ); is( join( '', $file->lines_utf8( { count => -3 } ) ), join( '', @exp ), "lines" ); }; subtest "spew -> lines (count, chomp, UTF-8)" => sub { my $file = Path::Tiny->tempfile; ok( $file->spew_utf8(_utf8_lines), "spew" ); my @exp = map { s/[\r\n]+//; $_ } _utf8_lines; is( join( '', $file->lines_utf8( { chomp => 1, count => 2 } ) ), join( '', @exp[ 0 .. 1 ] ), "lines" ); is( join( '', $file->lines_utf8( { chomp => 1, count => -2 } ) ), join( '', @exp[ 1 .. 2 ] ), "lines" ); }; subtest "spew -> lines (chomp, UTF-8)" => sub { my $file = Path::Tiny->tempfile; ok( $file->spew_utf8(_utf8_lines), "spew" ); my @exp = map { s/[\r\n]+//; $_ } _utf8_lines; is( join( '', $file->lines_utf8( { chomp => 1 } ) ), join( '', @exp ), "lines" ); }; subtest "spew -> lines (count, UTF-8, no end of newline)" => sub { my $file = Path::Tiny->tempfile; ok( $file->spew_utf8(_utf8_no_end_of_newline_lines), "spew" ); my @exp = _utf8_no_end_of_newline_lines; is( join( '', $file->lines_utf8( { count => 4 } ) ), join( '', @exp ), "lines" ); is( join( '', $file->lines_utf8( { count => -4 } ) ), join( '', @exp ), "lines" ); }; subtest "spew -> lines (count, chomp, UTF-8, no end of newline)" => sub { my $file = Path::Tiny->tempfile; ok( $file->spew_utf8(_utf8_no_end_of_newline_lines), "spew" ); my @exp = map { s/[\r\n]+//; $_ } _utf8_no_end_of_newline_lines; is( join( '', $file->lines_utf8( { chomp => 1, count => 2 } ) ), join( '', @exp[ 0 .. 1 ] ), "lines" ); is( join( '', $file->lines_utf8( { chomp => 1, count => -2 } ) ), join( '', @exp[ 2 .. 3 ] ), "lines" ); }; subtest "spew -> lines (count, raw)" => sub { my $file = Path::Tiny->tempfile; ok( $file->spew_raw(_lines), "spew" ); my @exp = _lines; is( join( '', $file->lines_raw( { count => 2 } ) ), join( '', @exp ), "lines" ); is( join( '', $file->lines_raw( { count => -2 } ) ), join( '', @exp ), "lines" ); }; subtest "spew -> lines (count, raw, no end of newline)" => sub { my $file = Path::Tiny->tempfile; ok( $file->spew_raw(_no_end_of_newline_lines), "spew" ); my @exp = _no_end_of_newline_lines; is( join( '', $file->lines_raw( { count => 3 } ) ), join( '', @exp ), "lines" ); is( join( '', $file->lines_raw( { count => -3 } ) ), join( '', @exp ), "lines" ); }; subtest "append -> slurp" => sub { my $file = Path::Tiny->tempfile; ok( $file->append(_lines), "append" ); is( $file->slurp, join( '', _lines ), "slurp" ); }; subtest "append -> slurp (empty)" => sub { my $file = Path::Tiny->tempfile; ok( $file->append, "append" ); is( $file->slurp, "", "slurp" ); }; subtest "append -> slurp (arrayref)" => sub { my $file = Path::Tiny->tempfile; ok( $file->append( [_lines] ), "append" ); is( $file->slurp, join( '', _lines ), "slurp" ); }; subtest "append -> slurp (piecemeal)" => sub { my $file = Path::Tiny->tempfile; ok( $file->append($_), "piecemeal append" ) for _lines; is( $file->slurp, join( '', _lines ), "slurp" ); }; subtest "append -> slurp (binmode)" => sub { my $file = Path::Tiny->tempfile; ok( $file->append( { binmode => ":utf8" }, _utf8_lines ), "append" ); is( $file->slurp( { binmode => ":utf8" } ), join( '', _utf8_lines ), "slurp" ); }; subtest "append -> slurp (truncate)" => sub { my $file = Path::Tiny->tempfile; ok( $file->append(_lines), "append" ); is( $file->slurp, join( '', _lines ), "slurp" ); ok( $file->append( { truncate => 1 }, _lines ), "append with truncate" ); is( $file->slurp, join( '', _lines ), "slurp" ); }; subtest "append -> slurp (open hint)" => sub { plan skip_all => "Needs 5.10" unless $] >= 5.010; use open IO => ':utf8'; my $file = Path::Tiny->tempfile; ok( $file->append(_utf8_lines), "append" ); is( $file->slurp, join( '', _utf8_lines ), "slurp" ); }; subtest "append -> slurp (UTF-8)" => sub { my $file = Path::Tiny->tempfile; ok( $file->append_utf8(_utf8_lines), "append" ); is( $file->slurp_utf8, join( '', _utf8_lines ), "slurp" ); }; subtest "append -> slurp (truncate, UTF8)" => sub { my $file = Path::Tiny->tempfile; ok( $file->append_utf8(_utf8_lines), "append" ); is( $file->slurp_utf8, join( '', _utf8_lines ), "slurp" ); ok( $file->append_utf8( { truncate => 1 }, _utf8_lines ), "append with truncate" ); is( $file->slurp_utf8, join( '', _utf8_lines ), "slurp" ); }; subtest "append -> slurp (raw)" => sub { my $file = Path::Tiny->tempfile; ok( $file->append_raw(_lines), "append" ); is( $file->slurp_raw, join( '', _lines ), "slurp" ); }; subtest "append -> slurp (truncate, raw)" => sub { my $file = Path::Tiny->tempfile; ok( $file->append_raw(_lines), "append" ); is( $file->slurp_raw, join( '', _lines ), "slurp" ); ok( $file->append_raw( { truncate => 1 }, _lines ), "append with truncate" ); is( $file->slurp_raw, join( '', _lines ), "slurp" ); }; subtest "openw -> openr" => sub { my $file = Path::Tiny->tempfile; { my $fh = $file->openw; ok( ( print {$fh} _lines ), "openw & print" ); } { my $fh = $file->openr; my $got = do { local $/, <$fh> }; is( $got, join( '', _lines ), "openr & read" ); } }; subtest "openw -> openr (open hint)" => sub { plan skip_all => "Needs 5.10" unless $] >= 5.010; use open IO => ':utf8'; my $file = Path::Tiny->tempfile; { my $fh = $file->openw; ok( ( print {$fh} _utf8_lines ), "openw & print" ); } { my $fh = $file->openr; my $got = do { local $/, <$fh> }; is( $got, join( '', _utf8_lines ), "openr & read" ); ok( utf8::is_utf8($got), "is UTF8" ); } }; subtest "openw -> openr (UTF-8)" => sub { my $file = Path::Tiny->tempfile; { my $fh = $file->openw_utf8; ok( ( print {$fh} _utf8_lines ), "openw & print" ); } { my $fh = $file->openr_utf8; my $got = do { local $/, <$fh> }; is( $got, join( '', _utf8_lines ), "openr & read" ); ok( utf8::is_utf8($got), "is UTF8" ); } }; subtest "openw -> openr (raw)" => sub { my $file = Path::Tiny->tempfile; { my $fh = $file->openw_raw; ok( ( print {$fh} _lines ), "openw & print" ); } { my $fh = $file->openr_raw; my $got = do { local $/, <$fh> }; is( $got, join( '', _lines ), "openr & read" ); } }; subtest "opena -> openr" => sub { my $file = Path::Tiny->tempfile; my @lines = _lines; { my $fh = $file->openw; ok( ( print {$fh} shift @lines ), "openw & print one line" ); } { my $fh = $file->opena; ok( ( print {$fh} @lines ), "opena & print rest of lines" ); } { my $fh = $file->openr; my $got = do { local $/, <$fh> }; is( $got, join( '', _lines ), "openr & read" ); } }; subtest "opena -> openr (open hint)" => sub { plan skip_all => "Needs 5.10" unless $] >= 5.010; use open IO => ':utf8'; my $file = Path::Tiny->tempfile; my @lines = _utf8_lines; { my $fh = $file->openw; ok( ( print {$fh} shift @lines ), "openw & print one line" ); } { my $fh = $file->opena; ok( ( print {$fh} @lines ), "opena & print rest of lines" ); } { my $fh = $file->openr; my $got = do { local $/, <$fh> }; is( $got, join( '', _utf8_lines ), "openr & read" ); ok( utf8::is_utf8($got), "is UTF8" ); } }; subtest "opena -> openr (UTF-8)" => sub { my $file = Path::Tiny->tempfile; my @lines = _utf8_lines; { my $fh = $file->openw_utf8; ok( ( print {$fh} shift @lines ), "openw & print one line" ); } { my $fh = $file->opena_utf8; ok( ( print {$fh} @lines ), "opena & print rest of lines" ); } { my $fh = $file->openr_utf8; my $got = do { local $/, <$fh> }; is( $got, join( '', _utf8_lines ), "openr & read" ); ok( utf8::is_utf8($got), "is UTF8" ); } }; subtest "opena -> openr (raw)" => sub { my $file = Path::Tiny->tempfile; my @lines = _lines; { my $fh = $file->openw_raw; ok( ( print {$fh} shift @lines ), "openw & print one line" ); } { my $fh = $file->opena_raw; ok( ( print {$fh} @lines ), "opena & print rest of lines" ); } { my $fh = $file->openr_raw; my $got = do { local $/, <$fh> }; is( $got, join( '', _lines ), "openr & read" ); } }; subtest "openrw" => sub { my $file = Path::Tiny->tempfile; my $fh = $file->openrw; ok( ( print {$fh} _lines ), "openrw & print" ); ok( seek( $fh, 0, 0 ), "seek back to start" ); my $got = do { local $/, <$fh> }; is( $got, join( '', _lines ), "openr & read" ); }; subtest "openrw (open hint)" => sub { plan skip_all => "Needs 5.10" unless $] >= 5.010; use open IO => ':utf8'; my $file = Path::Tiny->tempfile; my $fh = $file->openrw; ok( ( print {$fh} _utf8_lines ), "openrw & print" ); ok( seek( $fh, 0, 0 ), "seek back to start" ); my $got = do { local $/, <$fh> }; is( $got, join( '', _utf8_lines ), "openr & read" ); ok( utf8::is_utf8($got), "is UTF8" ); }; subtest "openrw (UTF-8)" => sub { my $file = Path::Tiny->tempfile; my $fh = $file->openrw_utf8; ok( ( print {$fh} _utf8_lines ), "openrw & print" ); ok( seek( $fh, 0, 0 ), "seek back to start" ); my $got = do { local $/, <$fh> }; is( $got, join( '', _utf8_lines ), "openr & read" ); ok( utf8::is_utf8($got), "is UTF8" ); }; subtest "openrw (raw)" => sub { my $file = Path::Tiny->tempfile; my $fh = $file->openrw_raw; ok( ( print {$fh} _lines ), "openrw & print" ); ok( seek( $fh, 0, 0 ), "seek back to start" ); my $got = do { local $/, <$fh> }; is( $got, join( '', _lines ), "openr & read" ); }; done_testing; # # This file is part of Path-Tiny # # This software is Copyright (c) 2014 by David Golden. # # This is free software, licensed under: # # The Apache License, Version 2.0, January 2004 # Path-Tiny-0.076/t/input_output_no_UU.t000644 000765 000024 00000000602 12622375237 020120 0ustar00davidstaff000000 000000 use 5.008001; use strict; use warnings; use Test::More 0.96; # Tiny equivalent of Devel::Hide BEGIN { $INC{'Unicode/UTF8.pm'} = undef; } note "Hiding Unicode::UTF8"; do "t/input_output.t"; # # This file is part of Path-Tiny # # This software is Copyright (c) 2014 by David Golden. # # This is free software, licensed under: # # The Apache License, Version 2.0, January 2004 # Path-Tiny-0.076/t/lib/000755 000765 000024 00000000000 12622375237 014617 5ustar00davidstaff000000 000000 Path-Tiny-0.076/t/locking.t000644 000765 000024 00000002121 12622375237 015660 0ustar00davidstaff000000 000000 use 5.008001; use strict; use warnings; use Test::More 0.96; use File::Spec; use Cwd; use lib 't/lib'; use TestUtils qw/exception/; use Fcntl ':flock'; use Path::Tiny; my $IS_BSD = $^O =~ /bsd$/; if ($IS_BSD) { # is temp partition lockable? my $file = Path::Tiny->tempfile; open my $fh, ">>", $file; flock $fh, LOCK_EX or plan skip_all => "Can't lock tempfiles on this OS/filesystem"; } subtest 'write locks blocks read lock' => sub { my $file = Path::Tiny->tempfile; ok $file, "Got a tempfile"; my $fh = $file->openw( { locked => 1 } ); ok $fh, "Opened file for writing with lock"; $fh->autoflush(1); print {$fh} "hello"; # check if a different process can get a lock; use RW mode for AIX my $locktester = Path::Tiny->tempfile; $locktester->spew(<<"HERE"); use strict; use warnings; use Fcntl ':flock'; open my \$fh, "+<", "$file"; exit flock( \$fh, LOCK_SH|LOCK_NB ); HERE my $rc = system( $^X, $locktester ); isnt( $rc, -1, "ran process to try to get lock" ); is( $rc >> 8, 0, "process failed to get lock" ); }; done_testing; Path-Tiny-0.076/t/mkpath.t000644 000765 000024 00000001616 12622375237 015526 0ustar00davidstaff000000 000000 use 5.008001; use strict; use warnings; use Test::More 0.96; use File::Temp (); use lib 't/lib'; use TestUtils qw/exception/; use Path::Tiny; my $tempdir = File::Temp->newdir; my $path = path($tempdir)->child("foo"); ok( !-e $path, "target directory not created yet" ); ok( $path->mkpath, "mkpath on directory returned true" ); ok( -d $path, "target directory created" ); if ( $^O ne 'MSWin32' ) { my $path2 = path($tempdir)->child("bar"); ok( !-e $path2, "target directory not created yet" ); ok( $path2->mkpath( { mode => 0700 } ), "mkpath on directory with mode" ); is( $path2->stat->mode & 0777, 0700, "correct mode" ); ok( -d $path2, "target directory created" ); } done_testing; # # This file is part of Path-Tiny # # This software is Copyright (c) 2014 by David Golden. # # This is free software, licensed under: # # The Apache License, Version 2.0, January 2004 # Path-Tiny-0.076/t/mutable_tree_while_iterating.t000644 000765 000024 00000002674 12622375237 022155 0ustar00davidstaff000000 000000 use strict; use warnings; use Test::More 0.88; use Path::Tiny; use lib 't/lib'; use TestUtils qw/exception tempd/; use Path::Tiny; my $wd = tempd; my @tree = qw( base/Bethlehem/XDG/gift_list.txt base/Vancouver/ETHER/.naughty base/Vancouver/ETHER/gift_list.txt base/New_York/XDG/gift_list.txt ); path($_)->touchpath for @tree; subtest 'iterator' => sub { my @files; my $iter = path('base')->iterator( { recurse => 1 } ); my $exception = exception { while ( my $path = $iter->() ) { $path->remove_tree if $path->child('.naughty')->is_file; push @files, $path if $path->is_file; } }; is( $exception, '', 'can remove directories while traversing' ); is_deeply( [ sort @files ], [ 'base/Bethlehem/XDG/gift_list.txt', 'base/New_York/XDG/gift_list.txt' ], 'remaining files', ); }; subtest 'visit' => sub { my @files; my $exception = exception { path('base')->visit( sub { my $path = shift; $path->remove_tree if $path->child('.naughty')->is_file; push @files, $path if $path->is_file; }, { recurse => 1 }, ); }; is( $exception, '', 'can remove directories while traversing' ); is_deeply( [ sort @files ], [ 'base/Bethlehem/XDG/gift_list.txt', 'base/New_York/XDG/gift_list.txt' ], 'remaining files', ); }; done_testing; Path-Tiny-0.076/t/normalize.t000644 000765 000024 00000001602 12622375237 016235 0ustar00davidstaff000000 000000 use 5.008001; use strict; use warnings; use Test::More 0.96; use lib 't/lib'; use TestUtils qw/exception/; use Path::Tiny; my @cases = ( #<<< [ '.' => '.' ], [ './' => '.' ], [ '/' => '/' ], [ '/.' => '/' ], [ '..' => '..' ], [ '/..' => '/' ], [ '../' => '..' ], [ '../..' => '../..' ], [ '/./' => '/' ], [ '/foo/' => '/foo' ], [ 'foo/' => 'foo' ], [ './foo' => 'foo' ], [ 'foo/.' => 'foo' ], #>>> ); for my $c (@cases) { my ( $in, $out ) = @$c; my $label = defined($in) ? $in : "undef"; $label = "empty" unless length $label; is( path($in)->stringify, $out, sprintf( "%5s -> %-5s", $label, $out ) ); } done_testing; # # This file is part of Path-Tiny # # This software is Copyright (c) 2014 by David Golden. # # This is free software, licensed under: # # The Apache License, Version 2.0, January 2004 # Path-Tiny-0.076/t/overloading.t000644 000765 000024 00000001026 12622375237 016546 0ustar00davidstaff000000 000000 use 5.008001; use strict; use warnings; use Test::More 0.96; use lib 't/lib'; use TestUtils qw/exception/; use Path::Tiny; my $path = path("t/stringify.t"); is( "$path", "t/stringify.t", "stringify via overloading" ); is( $path->stringify, "t/stringify.t", "stringify via method" ); ok( $path, "boolifies to true" ); done_testing; # # This file is part of Path-Tiny # # This software is Copyright (c) 2014 by David Golden. # # This is free software, licensed under: # # The Apache License, Version 2.0, January 2004 # Path-Tiny-0.076/t/parent.t000644 000765 000024 00000006100 12622375237 015524 0ustar00davidstaff000000 000000 use 5.008001; use strict; use warnings; use Test::More 0.96; use lib 't/lib'; use TestUtils qw/exception/; my $DEBUG; BEGIN { $DEBUG = 0 } BEGIN { if ($DEBUG) { require Path::Class; Path::Class->import } } my $IS_WIN32 = $^O eq 'MSWin32'; use Path::Tiny; use File::Spec::Functions qw/canonpath/; sub canonical { my $d = canonpath(shift); $d =~ s{\\}{/}g; $d .= "/" if $d =~ m{//[^/]+/[^/]+$}; return $d; } my @cases = ( #<<< No perltidy "absolute" => [ "/foo/bar" => "/foo" => "/" => "/" ], "relative" => [ "foo/bar/baz" => "foo/bar" => "foo" => "." => ".." => "../.." => "../../.." ], "absolute with .." => [ "/foo/bar/../baz" => "/foo/bar/.." => "/foo/bar/../.." => "/foo/bar/../../.." ], "relative with .." => [ "foo/bar/../baz" => "foo/bar/.." => "foo/bar/../.." => "foo/bar/../../.." ], "relative with leading .." => [ "../foo/bar" => "../foo" => ".." => "../.." ], "absolute with internal dots" => [ "/foo..bar/baz..bam" => "/foo..bar" => "/" ], "relative with internal dots" => [ "foo/bar..baz/wib..wob" => "foo/bar..baz" => "foo" => "." => ".." ], "absolute with leading dots" => [ "/..foo/..bar" => "/..foo" => "/" ], "relative with leading dots" => [ "..foo/..bar/..wob" => "..foo/..bar" => "..foo" => "." => ".." ], "absolute with trailing dots" => [ "/foo../bar.." => "/foo.." => "/" ], "relative with trailing dots" => [ "foo../bar../wob.." => "foo../bar.." => "foo.." => "." => ".." ], #>>> ); my @win32_cases = ( #<<< No perltidy "absolute with drive" => [ "C:/foo/bar" => "C:/foo" => "C:/" => "C:/" ], "absolute with drive and .." => [ "C:/foo/bar/../baz" => "C:/foo" => "C:/" ], "absolute with UNC" => [ "//server/share/foo/bar" => "//server/share/foo" => "//server/share/" => "//server/share/" ], "absolute with drive, UNC and .." => [ "//server/share/foo/bar/../baz" => "//server/share/foo" => "//server/share/" ], #>>> ); push @cases, @win32_cases if $IS_WIN32; while (@cases) { my ( $label, $list ) = splice( @cases, 0, 2 ); subtest $label => sub { my $path = path( shift @$list ); while (@$list) { for my $i ( undef, 0, 1 .. @$list ) { my $n = ( defined $i && $i > 0 ) ? $i : 1; my $expect = $list->[ $n - 1 ]; my $got = $path->parent($i); my $s = defined($i) ? $i : "undef"; is( $got, canonical($expect), "parent($s): $path -> $got" ); is( dir("$path")->parent, canonical($expect), "Path::Class agrees" ) if $DEBUG; } $path = $path->parent; shift @$list; } if ( $path !~ m{\Q..\E} ) { ok( $path->is_rootdir, "final path is root directory" ); } }; } done_testing; # # This file is part of Path-Tiny # # This software is Copyright (c) 2014 by David Golden. # # This is free software, licensed under: # # The Apache License, Version 2.0, January 2004 # Path-Tiny-0.076/t/README000644 000765 000024 00000000326 12622375237 014732 0ustar00davidstaff000000 000000 Some test files are adapted from those in Path::Class. Path::Tiny isn't API compatible so some adjustments have been made. For the most part, these tests are here to see if it handles special cases the same way. Path-Tiny-0.076/t/recurse.t000644 000765 000024 00000007640 12622375237 015715 0ustar00davidstaff000000 000000 use 5.006; use strict; use warnings; use Test::More 0.92; use File::Temp; use Config; use lib 't/lib'; use TestUtils qw/exception tempd/; use Path::Tiny; #--------------------------------------------------------------------------# subtest 'no symlinks' => sub { my $wd = tempd; my @tree = qw( aaaa.txt bbbb.txt cccc/dddd.txt cccc/eeee/ffff.txt gggg.txt ); my @breadth = qw( aaaa.txt bbbb.txt cccc gggg.txt cccc/dddd.txt cccc/eeee cccc/eeee/ffff.txt ); path($_)->touchpath for @tree; subtest 'iterator' => sub { my $iter = path(".")->iterator( { recurse => 1 } ); my @files; while ( my $f = $iter->() ) { push @files, "$f"; } is_deeply( [ sort @files ], [ sort @breadth ], "Breadth first iteration" ) or diag explain \@files; }; subtest 'visit' => sub { my @files; path(".")->visit( sub { push @files, "$_[0]" }, { recurse => 1 }, ); is_deeply( [ sort @files ], [ sort @breadth ], "Breadth first iteration" ) or diag explain \@files; }; subtest 'visit state' => sub { my $result = path(".")->visit( sub { $_[1]->{$_}++ }, { recurse => 1 }, ); is_deeply( [ sort keys %$result ], [ sort @breadth ], "Breadth first iteration" ) or diag explain $result; }; subtest 'visit abort' => sub { my $result = path(".")->visit( sub { return \0 if ++$_[1]->{count} == 2 }, { recurse => 1 } ); is( $result->{count}, 2, "visitor aborted on false scalar ref" ); }; }; subtest 'with symlinks' => sub { plan skip_all => "No symlink support" unless $Config{d_symlink}; my $wd = tempd; my @tree = qw( aaaa.txt bbbb.txt cccc/dddd.txt cccc/eeee/ffff.txt gggg.txt ); my @follow = qw( aaaa.txt bbbb.txt cccc gggg.txt pppp qqqq.txt cccc/dddd.txt cccc/eeee cccc/eeee/ffff.txt pppp/ffff.txt ); my @nofollow = qw( aaaa.txt bbbb.txt cccc gggg.txt pppp qqqq.txt cccc/dddd.txt cccc/eeee cccc/eeee/ffff.txt ); path($_)->touchpath for @tree; symlink path( 'cccc', 'eeee' ), path('pppp'); symlink path('aaaa.txt'), path('qqqq.txt'); subtest 'no follow' => sub { # no-follow subtest 'iterator' => sub { my $iter = path(".")->iterator( { recurse => 1 } ); my @files; while ( my $f = $iter->() ) { push @files, "$f"; } is_deeply( [ sort @files ], [ sort @nofollow ], "Don't follow symlinks" ) or diag explain \@files; }; subtest 'visit' => sub { my @files; path(".")->visit( sub { push @files, "$_[0]" }, { recurse => 1 }, ); is_deeply( [ sort @files ], [ sort @nofollow ], "Don't follow symlinks" ) or diag explain \@files; }; }; subtest 'follow' => sub { subtest 'iterator' => sub { my $iter = path(".")->iterator( { recurse => 1, follow_symlinks => 1 } ); my @files; while ( my $f = $iter->() ) { push @files, "$f"; } is_deeply( [ sort @files ], [ sort @follow ], "Follow symlinks" ) or diag explain \@files; }, subtest 'visit' => sub { my @files; path(".") ->visit( sub { push @files, "$_[0]" }, { recurse => 1, follow_symlinks => 1 }, ); is_deeply( [ sort @files ], [ sort @follow ], "Follow symlinks" ) or diag explain \@files; }, ; }; }; done_testing; # # This file is part of Path-Tiny # # This software is Copyright (c) 2014 by David Golden. # # This is free software, licensed under: # # The Apache License, Version 2.0, January 2004 # Path-Tiny-0.076/t/rel-abs.t000644 000765 000024 00000001063 12622375237 015563 0ustar00davidstaff000000 000000 use 5.008001; use strict; use warnings; use Test::More 0.96; use lib 't/lib'; use TestUtils qw/exception/; use Path::Tiny; my $rel1 = path("."); my $abs1 = $rel1->absolute; is( $abs1->absolute, $abs1, "absolute of absolute is identity" ); my $rel2 = $rel1->child("t"); my $abs2 = $rel2->absolute; is( $rel2->absolute($abs1), $abs2, "absolute on base" ); done_testing; # # This file is part of Path-Tiny # # This software is Copyright (c) 2014 by David Golden. # # This is free software, licensed under: # # The Apache License, Version 2.0, January 2004 # Path-Tiny-0.076/t/subsumes.t000644 000765 000024 00000006242 12622375237 016110 0ustar00davidstaff000000 000000 use 5.008001; use strict; use warnings; use Test::More 0.96; use lib 't/lib'; use TestUtils qw/exception/; use Path::Tiny; use Cwd; my $IS_WIN32 = $^O eq 'MSWin32'; my @cases = ( # path1 => path2 => path1->subsumes(path2) "identity always subsumes" => [ [ '.' => '.' => 1 ], [ '/' => '/' => 1 ], [ '..' => '..' => 1 ], [ '../..' => '../..' => 1 ], [ '/foo/' => '/foo' => 1 ], [ 'foo/' => 'foo' => 1 ], [ './foo' => 'foo' => 1 ], [ 'foo/.' => 'foo' => 1 ], ], "absolute v. absolute" => [ [ '/foo' => '/foo/bar' => 1 ], [ '/foo' => '/foo/bar/baz' => 1 ], [ '/foo' => '/foo/bar/baz/' => 1 ], [ '/' => '/foo' => 1 ], [ '/foo' => '/bar' => 0 ], [ '/foo/bar' => '/foo/baz' => 0 ], ], "relative v. relative" => [ [ '.' => 'foo' => 1 ], [ 'foo' => 'foo/baz' => 1 ], [ './foo/bar' => 'foo/bar/baz' => 1 ], [ './foo/bar' => './foo/bar' => 1 ], [ './foo/bar' => 'foo/bar' => 1 ], [ 'foo/bar' => './foo/bar' => 1 ], [ 'foo/bar' => 'foo/baz' => 0 ], ], "relative v. absolute" => [ [ path(".")->absolute => 't' => 1 ], [ "." => path('t')->absolute => 1 ], [ "foo" => path('t')->absolute => 0 ], [ path("..")->realpath => 't' => 1 ], [ path("lib")->absolute => 't' => 0 ], ], "updirs in paths" => [ [ '/foo' => '/foo/bar/baz/..' => 1 ], [ '/foo/bar' => '/foo/bar/../baz' => $IS_WIN32 ? 0 : 1 ], [ '/foo/../bar' => '/bar' => $IS_WIN32 ? 1 : 0 ], [ '..' => '../bar' => 1 ], ], ); if ($IS_WIN32) { my $vol = path( Win32::GetCwd() )->volume . "/"; my $other = $vol ne 'Z:/' ? 'Z:/' : 'Y:/'; push @cases, 'Win32 cases', [ [ "C:/foo" => "C:/foo" => 1 ], [ "C:/foo" => "C:/bar" => 0 ], [ "C:/" => "C:/foo" => 1 ], [ "C:/" => "D:/" => 0 ], [ "${vol}foo" => "/foo" => 1 ], [ $vol => "/foo" => 1 ], [ $vol => $other => 0 ], [ "/" => $vol => 1 ], [ "/" => $other => 0 ], [ "/foo" => "${vol}foo" => 1 ], ]; } while (@cases) { my ( $subtest, $tests ) = splice( @cases, 0, 2 ); subtest $subtest => sub { for my $t (@$tests) { my ( $path1, $path2, $subsumes ) = @$t; my $label = join( " ", $path1, ( $subsumes ? "subsumes" : "does not subsume" ), $path2 ); ok( !!path($path1)->subsumes($path2) eq !!$subsumes, $label ) or diag "PATH 1:\n", explain( path($path1) ), "\nPATH2:\n", explain( path($path2) ); } }; } done_testing; # # This file is part of Path-Tiny # # This software is Copyright (c) 2014 by David Golden. # # This is free software, licensed under: # # The Apache License, Version 2.0, January 2004 # Path-Tiny-0.076/t/temp.t000644 000765 000024 00000003633 12622375237 015210 0ustar00davidstaff000000 000000 use 5.008001; use strict; use warnings; use Cwd; # hack around https://bugs.activestate.com/show_bug.cgi?id=104767 use Test::More 0.96; use File::Spec::Unix; use lib 't/lib'; use TestUtils qw/exception tempd/; use Path::Tiny; subtest "tempdir" => sub { my $tempdir = Path::Tiny->tempdir; my $string = $tempdir->stringify; ok( $tempdir->exists, "tempdir exists" ); undef $tempdir; ok( !-e $string, "tempdir destroyed" ); }; subtest "tempfile" => sub { my $tempfile = Path::Tiny->tempfile; my $string = $tempfile->stringify; ok( $tempfile->exists, "tempfile exists" ); undef $tempfile; ok( !-e $string, "tempfile destroyed" ); }; subtest "tempdir w/ TEMPLATE" => sub { my $tempdir = Path::Tiny->tempdir( TEMPLATE => "helloXXXXX" ); like( $tempdir, qr/hello/, "found template" ); }; subtest "tempfile w/ TEMPLATE" => sub { my $tempfile = Path::Tiny->tempfile( TEMPLATE => "helloXXXXX" ); like( $tempfile, qr/hello/, "found template" ); }; subtest "tempdir w/ leading template" => sub { my $tempdir = Path::Tiny->tempdir("helloXXXXX"); like( $tempdir, qr/hello/, "found template" ); }; subtest "tempfile w/ leading template" => sub { my $tempfile = Path::Tiny->tempfile("helloXXXXX"); like( $tempfile, qr/hello/, "found template" ); }; subtest "tempfile handle" => sub { my $tempfile = Path::Tiny->tempfile; my $fh = $tempfile->filehandle; is( ref $tempfile->[5], 'File::Temp', "cached File::Temp object" ); is( fileno $tempfile->[5], undef, "cached handle is closed" ); }; subtest "survives absolute" => sub { my $wd = tempd; my $tempdir = Path::Tiny->tempdir( DIR => '.' )->absolute; ok( -d $tempdir, "exists" ); }; done_testing; # # This file is part of Path-Tiny # # This software is Copyright (c) 2014 by David Golden. # # This is free software, licensed under: # # The Apache License, Version 2.0, January 2004 # Path-Tiny-0.076/t/visit.t000644 000765 000024 00000000677 12622375237 015406 0ustar00davidstaff000000 000000 use strict; use warnings; use Test::More tests => 3; use Path::Tiny; path('t')->visit(sub{ return [ ] }); pass "visit callback doesn't choke on random returned refs"; my $all; my $terminated; path('t')->visit(sub{ $all++ }); path('t')->visit(sub{ $terminated++; return \0 if $terminated == 10 }); is $terminated => 10, "terminated before the whole dir was read"; cmp_ok $all, '>=', $terminated, "we have more than 10 tests in that dir"; Path-Tiny-0.076/t/zz-atomic.t000644 000765 000024 00000001632 12622375237 016155 0ustar00davidstaff000000 000000 use 5.008001; use strict; use warnings; use Test::More 0.96; BEGIN { plan skip_all => "Can't mock random() with Path::Tiny already loaded" if $INC{'Path/Tiny.pm'}; eval "use Test::MockRandom 'Path::Tiny';"; plan skip_all => "Test::MockRandom required for atomicity tests" if $@; } use lib 't/lib'; use TestUtils qw/exception/; use Path::Tiny; srand(0); subtest "spew (atomic)" => sub { my $file = Path::Tiny->tempfile; ok( $file->spew("original"), "spew" ); is( $file->slurp, "original", "original file" ); my $tmp = $file->[Path::Tiny::PATH] . $$ . "0"; open my $fh, ">", $tmp; ok( $fh, "opened collision file '$tmp'" ); print $fh "collide!"; close $fh; my $error = exception { ok( $file->spew("overwritten"), "spew" ) }; ok( $error, "spew errors if the temp file exists" ); is( $file->slurp(), "original", "original file intact" ); }; done_testing(); Path-Tiny-0.076/t/zzz-spec.t000644 000765 000024 00000025044 12622375237 016030 0ustar00davidstaff000000 000000 use 5.008001; use strict; use warnings; use Test::More 0.96; use lib 't/lib'; use TestUtils qw/exception/; use Path::Tiny; use Cwd; my $IS_WIN32 = $^O eq 'MSWin32'; # tests adapted from File::Spec's t/Spec.t test # Each element in this array is a single test. Storing them this way makes # maintenance easy, and should be OK since perl should be pretty functional # before these tests are run. # the third column has Win32 specific alternative output; this appears to be # collapsing of foo/../bar type structures since Win32 has no symlinks and # doesn't need to keep the '..' part. -- xdg, 2013-01-30 my @tests = ( # [ Function , Expected , Win32-different ] [ "path('a','b','c')", 'a/b/c' ], [ "path('a','b','./c')", 'a/b/c' ], [ "path('./a','b','c')", 'a/b/c' ], [ "path('c')", 'c' ], [ "path('./c')", 'c' ], [ "path('/')", '/' ], [ "path('d1','d2','d3')", 'd1/d2/d3' ], [ "path('/','d2/d3')", '/d2/d3' ], [ "path('/.')", '/' ], [ "path('/./')", '/' ], [ "path('/a/./')", '/a' ], [ "path('/a/.')", '/a' ], [ "path('/../../')", '/' ], [ "path('/../..')", '/' ], [ "path('/t1/t2/t4')->relative('/t1/t2/t3')", '../t4' ], [ "path('/t1/t2')->relative('/t1/t2/t3')", '..' ], [ "path('/t1/t2/t3/t4')->relative('/t1/t2/t3')", 't4' ], [ "path('/t4/t5/t6')->relative('/t1/t2/t3')", '../../../t4/t5/t6' ], [ "path('/')->relative('/t1/t2/t3')", '../../..' ], [ "path('///')->relative('/t1/t2/t3')", '../../..' ], [ "path('/.')->relative('/t1/t2/t3')", '../../..' ], [ "path('/./')->relative('/t1/t2/t3')", '../../..' ], [ "path('/t1/t2/t3')->relative( '/')", 't1/t2/t3' ], [ "path('/t1/t2/t3')->relative( '/t1')", 't2/t3' ], [ "path('t1/t2/t3')->relative( 't1')", 't2/t3' ], [ "path('t1/t2/t3')->relative( 't4')", '../t1/t2/t3' ], [ "path('.')->relative( '.')", '.' ], [ "path('/')->relative( '/')", '.' ], [ "path('../t1')->relative( 't2/t3')", '../../../t1' ], [ "path('t1')->relative( 't2/../t3')", '../t1' ], [ "path('t4')->absolute('/t1/t2/t3')", '/t1/t2/t3/t4' ], [ "path('t4/t5')->absolute('/t1/t2/t3')", '/t1/t2/t3/t4/t5' ], [ "path('.')->absolute('/t1/t2/t3')", '/t1/t2/t3' ], [ "path('///../../..//./././a//b/.././c/././')", '/a/b/../c', '/a/c' ], [ "path('a/../../b/c')", 'a/../../b/c', '../b/c' ], [ "path('..')->absolute('/t1/t2/t3')", '/t1/t2/t3/..', '/t1/t2' ], [ "path('../t4')->absolute('/t1/t2/t3')", '/t1/t2/t3/../t4', '/t1/t2/t4' ], # need to wash through rootdir->absolute->child to pick up volume on Windows [ "path('/t1')->absolute('/t1/t2/t3')", Path::Tiny->rootdir->absolute->child("t1") ], ); my @win32_tests; # this is lazy so we don't invoke any calls unless we're on Windows if ($IS_WIN32) { @win32_tests = ( [ "path('/')", '/' ], [ "path('/', '../')", '/' ], [ "path('/', '..\\')", '/' ], [ "path('\\', '../')", '/' ], [ "path('\\', '..\\')", '/' ], [ "path('\\d1\\','d2')", '/d1/d2' ], [ "path('\\d1','d2')", '/d1/d2' ], [ "path('\\d1','\\d2')", '/d1/d2' ], [ "path('\\d1','\\d2\\')", '/d1/d2' ], [ "path('d1','d2','d3')", 'd1/d2/d3' ], [ "path('A:/d1','d2','d3')", 'A:/d1/d2/d3' ], [ "path('A:/')", 'A:/' ], [ "path('\\', 'foo')", '/foo' ], [ "path('A:', 'foo')", 'A:/foo' ], [ "path('a','b','c')", 'a/b/c' ], [ "path('a','b','.\\c')", 'a/b/c' ], [ "path('.\\a','b','c')", 'a/b/c' ], [ "path('c')", 'c' ], [ "path('.\\c')", 'c' ], [ "path('a/..','../b')", '../b' ], [ "path('A:', 'foo')", 'A:/foo' ], [ "path('a:/')", 'A:/' ], [ "path('A:f')", 'A:/f' ], [ "path('A:/')", 'A:/' ], [ "path('a\\..\\..\\b\\c')", '../b/c' ], [ "path('//a\\b//c')", '//a/b/c' ], [ "path('/a/..../c')", '/a/..../c' ], [ "path('//a/b\\c')", '//a/b/c' ], [ "path('////')", '/' ], [ "path('//')", '/' ], [ "path('/.')", '/' ], [ "path('//a/b/../../c')", '//a/b/c' ], [ "path('//a/b/c/../d')", '//a/b/d' ], [ "path('//a/b/c/../../d')", '//a/b/d' ], [ "path('//a/b/c/.../d')", '//a/b/d' ], [ "path('/a/b/c/../../d')", '/a/d' ], [ "path('/a/b/c/.../d')", '/a/d' ], [ "path('\\../temp\\')", '/temp' ], [ "path('\\../')", '/' ], [ "path('\\..\\')", '/' ], [ "path('/../')", '/' ], [ "path('/../')", '/' ], [ "path('d1/../foo')", 'foo' ], # if there's no C drive, getdcwd will probably return '', so fake it [ "path('C:')", path( eval { Cwd::getdcwd("C:") } || "C:/" ) ], [ "path('\\\\server\\share\\')", '//server/share/' ], [ "path('\\\\server\\share')", '//server/share/' ], [ "path('//server/share/')", '//server/share/' ], [ "path('//server/share')", '//server/share/' ], [ "path('//d1','d2')", '//d1/d2/' ], ); } # XXX not sure how to adapt this sanely for use with Path::Tiny testing, so # I'll punt for now ## ### FakeWin32 subclass (see below) just sets CWD to C:\one\two and getdcwd('D') to D:\alpha\beta ## ##[ "FakeWin32->abs2rel('/t1/t2/t3','/t1/t2/t3')", '.' ], ##[ "FakeWin32->abs2rel('/t1/t2/t4','/t1/t2/t3')", '..\\t4' ], ##[ "FakeWin32->abs2rel('/t1/t2','/t1/t2/t3')", '..' ], ##[ "FakeWin32->abs2rel('/t1/t2/t3/t4','/t1/t2/t3')", 't4' ], ##[ "FakeWin32->abs2rel('/t4/t5/t6','/t1/t2/t3')", '..\\..\\..\\t4\\t5\\t6' ], ##[ "FakeWin32->abs2rel('../t4','/t1/t2/t3')", '..\\..\\..\\one\\t4' ], # Uses _cwd() ##[ "FakeWin32->abs2rel('/','/t1/t2/t3')", '..\\..\\..' ], ##[ "FakeWin32->abs2rel('///','/t1/t2/t3')", '..\\..\\..' ], ##[ "FakeWin32->abs2rel('/.','/t1/t2/t3')", '..\\..\\..' ], ##[ "FakeWin32->abs2rel('/./','/t1/t2/t3')", '..\\..\\..' ], ##[ "FakeWin32->abs2rel('\\\\a/t1/t2/t4','/t2/t3')", '\\\\a\\t1\\t2\\t4' ], ##[ "FakeWin32->abs2rel('//a/t1/t2/t4','/t2/t3')", '\\\\a\\t1\\t2\\t4' ], ##[ "FakeWin32->abs2rel('A:/t1/t2/t3','A:/t1/t2/t3')", '.' ], ##[ "FakeWin32->abs2rel('A:/t1/t2/t3/t4','A:/t1/t2/t3')", 't4' ], ##[ "FakeWin32->abs2rel('A:/t1/t2/t3','A:/t1/t2/t3/t4')", '..' ], ##[ "FakeWin32->abs2rel('A:/t1/t2/t3','B:/t1/t2/t3')", 'A:\\t1\\t2\\t3' ], ##[ "FakeWin32->abs2rel('A:/t1/t2/t3/t4','B:/t1/t2/t3')", 'A:\\t1\\t2\\t3\\t4' ], ##[ "FakeWin32->abs2rel('E:/foo/bar/baz')", 'E:\\foo\\bar\\baz' ], ##[ "FakeWin32->abs2rel('C:/one/two/three')", 'three' ], ##[ "FakeWin32->abs2rel('C:\\Windows\\System32', 'C:\\')", 'Windows\System32' ], ##[ "FakeWin32->abs2rel('\\\\computer2\\share3\\foo.txt', '\\\\computer2\\share3')", 'foo.txt' ], ##[ "FakeWin32->abs2rel('C:\\one\\two\\t\\asd1\\', 't\\asd\\')", '..\\asd1' ], ##[ "FakeWin32->abs2rel('\\one\\two', 'A:\\foo')", 'C:\\one\\two' ], ## ##[ "FakeWin32->rel2abs('temp','C:/')", 'C:\\temp' ], ##[ "FakeWin32->rel2abs('temp','C:/a')", 'C:\\a\\temp' ], ##[ "FakeWin32->rel2abs('temp','C:/a/')", 'C:\\a\\temp' ], ##[ "FakeWin32->rel2abs('../','C:/')", 'C:\\' ], ##[ "FakeWin32->rel2abs('../','C:/a')", 'C:\\' ], ##[ "FakeWin32->rel2abs('\\foo','C:/a')", 'C:\\foo' ], ##[ "FakeWin32->rel2abs('temp','//prague_main/work/')", '\\\\prague_main\\work\\temp' ], ##[ "FakeWin32->rel2abs('../temp','//prague_main/work/')", '\\\\prague_main\\work\\temp' ], ##[ "FakeWin32->rel2abs('temp','//prague_main/work')", '\\\\prague_main\\work\\temp' ], ##[ "FakeWin32->rel2abs('../','//prague_main/work')", '\\\\prague_main\\work' ], ##[ "FakeWin32->rel2abs('D:foo.txt')", 'D:\\alpha\\beta\\foo.txt' ], ## ##can_ok('File::Spec::Win32', '_cwd'); ## ##{ ## package File::Spec::FakeWin32; ## use vars qw(@ISA); ## @ISA = qw(File::Spec::Win32); ## ## sub _cwd { 'C:\\one\\two' } ## ## # Some funky stuff to override Cwd::getdcwd() for testing purposes, ## # in the limited scope of the rel2abs() method. ## if ($Cwd::VERSION && $Cwd::VERSION gt '2.17') { # Avoid a 'used only once' warning ## local $^W; ## *rel2abs = sub { ## my $self = shift; ## local $^W; ## local *Cwd::getdcwd = sub { ## return 'D:\alpha\beta' if $_[0] eq 'D:'; ## return 'C:\one\two' if $_[0] eq 'C:'; ## return; ## }; ## *Cwd::getdcwd = *Cwd::getdcwd; # Avoid a 'used only once' warning ## return $self->SUPER::rel2abs(@_); ## }; ## *rel2abs = *rel2abs; # Avoid a 'used only once' warning ## } ##} # Tries a named function with the given args and compares the result against # an expected result. Works with functions that return scalars or arrays. for ( @tests, $IS_WIN32 ? @win32_tests : () ) { my ( $function, $expected, $win32case ) = @$_; $expected = $win32case if $IS_WIN32 && $win32case; $function =~ s#\\#\\\\#g; my $got = join ',', eval $function; if ($@) { is( $@, '', $function ); } else { is( $got, $expected, $function ); } } done_testing; # # This file is part of Path-Tiny # # This software is Copyright (c) 2014 by David Golden. # # This is free software, licensed under: # # The Apache License, Version 2.0, January 2004 # Path-Tiny-0.076/t/lib/TestUtils.pm000644 000765 000024 00000001653 12622375237 017122 0ustar00davidstaff000000 000000 use 5.008001; use strict; use warnings; package TestUtils; use Carp; use Cwd qw/getcwd/; use File::Temp 0.19 (); use Exporter; our @ISA = qw/Exporter/; our @EXPORT = qw( exception tempd ); # If we have Test::FailWarnings, use it BEGIN { eval { require Test::FailWarnings; 1 } and do { Test::FailWarnings->import }; } sub exception(&) { my $code = shift; my $success = eval { $code->(); 1 }; my $err = $@; return '' if $success; croak "Execution died, but the error was lost" unless $@; return $@; } sub tempd { my $guard = TestUtils::_Guard->new( { temp => File::Temp->newdir, origin => getcwd(), code => sub { chdir $_[0]{origin} }, } ); chdir $guard->{temp} or croak("Couldn't chdir: $!"); return $guard; } package TestUtils::_Guard; sub new { bless $_[1], $_[0] } sub DESTROY { $_[0]{code}->( $_[0] ) } 1; Path-Tiny-0.076/t/data/chmod.txt000644 000765 000024 00000142261 12622375237 016623 0ustar00davidstaff000000 000000 au=w,uo=x,go=wx 00777 00133 augo-rw,ug=rwx 00000 00770 augo-rw,ug=rwx 00777 00771 go+rwx 00000 00077 go+rwx 00777 00777 u=wx,ao=wx,go=rwx 00777 00377 augo=x,aug-rw 00777 00111 ug-w 00000 00000 ug-w 00777 00557 o+rx,uo-rw,au+wx 00777 00373 o+rx,uo-rw,au+wx 00000 00333 ugo=wx,auo=r,augo-x 00777 00444 a-x,u-rw,aug=rw 00777 00666 auo=rwx,u=x,ag-r 00777 00133 ugo+rw 00777 00777 ugo+rw 00000 00666 au=rwx 00777 00777 a-w,auo+r,ag=r 00777 00444 ao=rwx,ago-rwx 00777 00000 g=rwx 00000 00070 g=rwx 00777 00777 auo-w,go+rw 00000 00066 auo-w,go+rw 00777 00577 ao+rx 00777 00777 ao+rx 00000 00555 ugo+rwx,aug=x 00777 00111 auo+rw,o-rwx,ago=rw 00777 00666 uo+x 00777 00777 uo+x 00000 00101 u=w 00000 00200 u=w 00777 00277 ug=rw,ago+x,uo=rx 00777 00575 ag+rw 00000 00666 ag+rw 00777 00777 auo=x 00777 00111 augo+wx,uo+wx,o-w 00777 00775 augo+wx,uo+wx,o-w 00000 00331 a+rw 00000 00666 a+rw 00777 00777 ago-r,ug+wx 00000 00330 ago-r,ug+wx 00777 00333 g=rx,augo=rx 00777 00555 u=rwx,auo+rx,ug+rw 00000 00775 u=rwx,auo+rx,ug+rw 00777 00777 go+w 00000 00022 go+w 00777 00777 ugo=w,aug=rw,auo=rx 00777 00555 ago-r 00777 00333 ago-r 00000 00000 o-wx 00777 00774 o-wx 00000 00000 o+x,a+wx 00777 00777 o+x,a+wx 00000 00333 au-rw,auo+wx,ug+rw 00777 00773 augo=rw,aug=wx 00777 00333 augo+x,ugo-rwx 00777 00000 o-rwx,go+w 00777 00772 o-rwx,go+w 00000 00022 ag-rx 00777 00222 ag-rx 00000 00000 auo=rw,g+rx 00777 00676 aug+rwx,ug-rx,ao+rw 00777 00667 u-x,a-r 00000 00000 u-x,a-r 00777 00233 au+x 00000 00111 au+x 00777 00777 ao=w,augo=rx,aug-rwx 00777 00000 aug-rwx 00777 00000 a+rx,ug-x,ao+rx 00777 00777 a+rx,ug-x,ao+rx 00000 00555 go=x 00000 00011 go=x 00777 00711 ugo-rx,ago+rx 00000 00555 ugo-rx,ago+rx 00777 00777 go-wx,augo-wx,u+x 00777 00544 go-wx,augo-wx,u+x 00000 00100 au-rw,augo+rw 00000 00666 au-rw,augo+rw 00777 00777 ag-rx,au-w,ugo+x 00777 00111 augo=x,auo+wx,u-x 00777 00233 aug+x,auo+rx 00777 00777 aug+x,auo+rx 00000 00555 aug-w,a-rx 00777 00000 ugo=rx 00777 00555 au-wx,ugo-rwx,u+r 00777 00400 ug=rw,au+rwx 00777 00777 go=rw,o=w,ao-rw 00777 00100 go=rw,o=w,ao-rw 00000 00000 ugo+wx 00777 00777 ugo+wx 00000 00333 ug=x,o=rw,uo+r 00777 00516 augo+r,au+x 00777 00777 augo+r,au+x 00000 00555 g=r,ao+w 00777 00767 g=r,ao+w 00000 00262 augo+w,a+w,ug=rx 00000 00552 augo+w,a+w,ug=rx 00777 00557 ugo=rwx,ago+w,aug-rx 00777 00222 aug-rw,augo=w,ago=x 00777 00111 auo=x,ao-w 00777 00111 ug-x,ugo-w 00777 00445 ug-x,ugo-w 00000 00000 ao-rwx,a=rwx,ag-rw 00777 00111 ag=rwx,aug+r 00777 00777 go+rw,uo+x 00000 00167 go+rw,uo+x 00777 00777 ugo+w 00000 00222 ugo+w 00777 00777 ug+r 00000 00440 ug+r 00777 00777 u-r 00000 00000 u-r 00777 00377 ao=rwx,ug=r 00777 00447 o+wx,g-r 00000 00003 o+wx,g-r 00777 00737 uo+w 00000 00202 uo+w 00777 00777 ag-rw,g=r,auo-rx 00777 00000 au=w,ug-rx 00777 00222 a+rw,auo+wx,auo+rx 00777 00777 aug-r 00000 00000 aug-r 00777 00333 uo+r 00000 00404 uo+r 00777 00777 ago-x 00000 00000 ago-x 00777 00666 aug-rwx,augo+r 00777 00444 ag=rw,ao-rw,a=rx 00777 00555 ago=x,ugo=x,aug=rwx 00777 00777 ag+w 00777 00777 ag+w 00000 00222 o=r,ugo=r,ao=r 00777 00444 ao-wx,g-w 00777 00444 ao-wx,g-w 00000 00000 au-r,o-wx 00000 00000 au-r,o-wx 00777 00330 ag=rw,ago=x,aug-rx 00777 00000 aug+r,a-rwx,u-x 00777 00000 u-x,ag+wx,go-x 00000 00322 u-x,ag+wx,go-x 00777 00766 a-rw,a-w,ag=rx 00777 00555 ago-rw,aug=rwx 00777 00777 aug=r,ag=w 00777 00222 g-x,a=rw 00777 00666 ug+rwx 00000 00770 ug+rwx 00777 00777 aug+x,go=x 00777 00711 aug+x,go=x 00000 00111 ago=x,aug+x 00777 00111 go=rwx 00000 00077 go=rwx 00777 00777 au+rw,ugo=w,augo-rw 00777 00000 ag=rwx 00777 00777 augo=rx,go=rw 00777 00566 ag-rwx,o+rx,u=rx 00777 00505 ugo=x,auo+wx,ug-rx 00777 00223 u-wx,u-r,go-r 00000 00000 u-wx,u-r,go-r 00777 00033 au=rwx,aug=rw 00777 00666 au-wx 00777 00444 au-wx 00000 00000 aug=rwx,ao-rw 00777 00111 g+wx 00000 00030 g+wx 00777 00777 auo+wx,ago-x 00777 00666 auo+wx,ago-x 00000 00222 auo-rw,uo=wx 00777 00313 auo-rw,uo=wx 00000 00303 uo-wx,ao-rx 00777 00020 uo-wx,ao-rx 00000 00000 aug+rx,uo-x,ago=r 00777 00444 aug=rwx,g=rwx,aug=wx 00777 00333 ago+rx,ug-rwx,o+w 00777 00007 ago-rw 00777 00111 ago-rw 00000 00000 ao=w,o+rx,u=wx 00777 00327 au+w,ago-w 00777 00555 au+w,ago-w 00000 00000 au+x,aug+wx 00000 00333 au+x,aug+wx 00777 00777 ug=x,u=x 00000 00110 ug=x,u=x 00777 00117 ugo=wx,au=r,au+rwx 00777 00777 ug=wx 00000 00330 ug=wx 00777 00337 o-r,ago=x,a+wx 00777 00333 ago+rx,o-wx,au-rw 00777 00110 o+w,auo=rx 00777 00555 auo=wx,ao-rwx,au=rx 00777 00555 ag+x,ao+w 00000 00333 ag+x,ao+w 00777 00777 u=rw 00000 00600 u=rw 00777 00677 aug+w,o-x 00000 00222 aug+w,o-x 00777 00776 u+wx,ao=rwx,o+w 00777 00777 a+rw,ag+rx 00777 00777 g-rx 00000 00000 g-rx 00777 00727 g-w,au-rx,a+wx 00777 00333 u=r,ago+x,augo+w 00000 00733 u=r,ago+x,augo+w 00777 00777 ug-r,g-x,ago+x 00777 00337 ug-r,g-x,ago+x 00000 00111 u-w,ag-x 00000 00000 u-w,ag-x 00777 00466 go+x 00000 00011 go+x 00777 00777 g+x,ao-x 00777 00666 g+x,ao-x 00000 00000 augo+r,o=rw,aug-rw 00777 00110 augo+r,o=rw,aug-rw 00000 00000 aug+wx,o=r 00000 00334 aug+wx,o=r 00777 00774 u=rwx,o-wx,augo-rw 00777 00110 u=rwx,o-wx,augo-rw 00000 00100 ug-w,a=x,g=rx 00777 00151 g+rx,g+rwx,go-r 00777 00733 g+rx,g+rwx,go-r 00000 00030 au=w 00777 00222 augo-w,auo-x,ao-wx 00000 00000 augo-w,auo-x,ao-wx 00777 00444 ugo-rw,ao+x,ag-x 00777 00000 ugo=w,ago-r 00777 00222 auo-rw,aug=wx,aug-rw 00777 00111 aug-x,o-rx 00777 00662 aug-x,o-rx 00000 00000 ug+rwx,o+rw 00000 00776 ug+rwx,o+rw 00777 00777 auo-rw,augo=rwx,augo=rw 00777 00666 uo=rw,au+x 00000 00717 uo=rw,au+x 00777 00777 ug-r,ago-rx,o+wx 00777 00223 ug-r,ago-rx,o+wx 00000 00003 u=rw,augo=rw,ag+rx 00777 00777 u+wx,o-rw,augo=w 00777 00222 uo=wx,g-r,ao=x 00777 00111 g=w,go-rw,au+x 00777 00711 g=w,go-rw,au+x 00000 00111 auo+x,uo-rwx 00777 00070 auo+x,uo-rwx 00000 00010 o-w 00000 00000 o-w 00777 00775 ugo=w,ao-rw 00777 00000 a=rw 00777 00666 ao-rx,ugo-rw,auo+rwx 00777 00777 ao=rx,au+wx,augo-rw 00777 00111 a=rwx,ao+r,au+w 00777 00777 u+w,u-rwx,augo+r 00777 00477 u+w,u-rwx,augo+r 00000 00444 ugo=rwx 00777 00777 go-w,ug=rw,au+w 00000 00662 go-w,ug=rw,au+w 00777 00667 aug+w,auo=rx 00777 00555 ag=r 00777 00444 ug-r,augo-r,ugo-rx 00000 00000 ug-r,augo-r,ugo-rx 00777 00222 u-rwx,ago=x 00777 00111 u-wx,ugo=wx,ao+x 00777 00333 ao=rw 00777 00666 g=x,auo=r 00777 00444 go=rw 00000 00066 go=rw 00777 00766 a+rx 00000 00555 a+rx 00777 00777 au-rx,go=r 00000 00044 au-rx,go=r 00777 00244 augo-x,ag+rw,ago=rwx 00777 00777 g=rx 00777 00757 g=rx 00000 00050 ug+rwx,augo-wx,aug=wx 00777 00333 ugo-wx,aug=rx 00777 00555 au+r 00777 00777 au+r 00000 00444 au+x,au+w 00000 00333 au+x,au+w 00777 00777 go+x,ug-x,uo+rx 00777 00767 go+x,ug-x,uo+rx 00000 00505 ago-rx,ug+x 00000 00110 ago-rx,ug+x 00777 00332 a=r,ag+r,go+wx 00777 00477 g=r 00000 00040 g=r 00777 00747 ugo+w,ago=r,auo+rx 00777 00555 ago=r,ao+rwx,ugo+wx 00777 00777 a-rw,ag=r 00777 00444 ugo+rwx 00777 00777 a+rx,o-w 00000 00555 a+rx,o-w 00777 00775 ao+r,o+r 00000 00444 ao+r,o+r 00777 00777 o=rw,augo+rwx,au=rw 00777 00666 ago-rw,u=w,ao=rwx 00777 00777 u+rw,go=rx,ag+rw 00777 00777 u+rw,go=rx,ag+rw 00000 00677 u=rx,a+wx 00000 00733 u=rx,a+wx 00777 00777 ugo+rx 00000 00555 ugo+rx 00777 00777 uo=rw 00777 00676 uo=rw 00000 00606 a+rwx,aug=wx,auo-r 00777 00333 uo+wx 00777 00777 uo+wx 00000 00303 a-rw,ao+r 00777 00555 a-rw,ao+r 00000 00444 ugo-rx,au-r,ao+x 00000 00111 ugo-rx,au-r,ao+x 00777 00333 ag-rx,a-rwx 00777 00000 ago+wx,uo-rx 00000 00232 ago+wx,uo-rx 00777 00272 ago-r,g=rw,ao=rwx 00777 00777 ug+x,go=rw 00777 00766 ug+x,go=rw 00000 00166 g+rw,auo=x 00777 00111 augo=rx 00777 00555 ag-r,go=r 00777 00344 ag-r,go=r 00000 00044 aug=x 00777 00111 go-r,u=wx 00000 00300 go-r,u=wx 00777 00333 ugo-wx,a=rw,augo-rx 00777 00222 augo+rwx,au=w 00777 00222 ag=x,aug-w 00777 00111 ug=x,u=r,auo=r 00777 00444 o+rwx,ugo=r,a+rw 00777 00666 ug-wx 00777 00447 ug-wx 00000 00000 uo-x,aug+w 00000 00222 uo-x,aug+w 00777 00676 au+rw,ago-x 00777 00666 ug=rw,go=x 00777 00611 ug=rx,ago=rwx,g-rwx 00777 00707 au=rwx,ugo+w,ao=rwx 00777 00777 augo-rx,ug+w 00000 00220 augo-rx,ug+w 00777 00222 ao+x,ugo=wx,au+rw 00777 00777 ug=wx,u=w 00000 00230 ug=wx,u=w 00777 00237 ago+x,au-rw 00777 00111 augo+r,aug=rx 00777 00555 ao=rw,ug+wx 00777 00776 ag-w,augo-w 00777 00555 ag-w,augo-w 00000 00000 o-rwx 00000 00000 o-rwx 00777 00770 ugo-w 00000 00000 ugo-w 00777 00555 ugo+rw,uo-w,aug=r 00777 00444 ago=rwx,ag-rx 00777 00222 o=x,uo-x,auo-x 00777 00660 o=x,uo-x,auo-x 00000 00000 g-rx,au-x,ago+r 00777 00666 g-rx,au-x,ago+r 00000 00444 go+rw 00777 00777 go+rw 00000 00066 u-wx,augo=w,go-rx 00777 00222 aug=wx,ago=r,auo-r 00777 00000 au+rx,go=wx 00000 00533 au+rx,go=wx 00777 00733 au-rx 00000 00000 au-rx 00777 00222 augo+rw 00000 00666 augo+rw 00777 00777 ao=wx,augo-rx,aug=w 00777 00222 o+wx,o+rx 00777 00777 o+wx,o+rx 00000 00007 o-wx,uo-x 00777 00674 o-wx,uo-x 00000 00000 ao+rw 00777 00777 ao+rw 00000 00666 g+x,ago-rx,a+rwx 00777 00777 ao+rwx,u-wx 00777 00477 aug=r,a-w 00777 00444 ago=x,g+rx,ago=wx 00777 00333 uo+rw,au+r 00000 00646 uo+rw,au+r 00777 00777 aug-wx,o-x 00777 00444 aug-wx,o-x 00000 00000 ao+w 00777 00777 ao+w 00000 00222 u=x,g+rwx,au=x 00777 00111 uo=rw,au=x,g+r 00777 00151 au+rw 00000 00666 au+rw 00777 00777 ao=r,go=rx,ag=rx 00777 00555 ug=rx,ago+w,aug+wx 00000 00773 ug=rx,ago+w,aug+wx 00777 00777 au+rwx,au+rwx,go-rx 00777 00722 uo+wx,ag-wx,augo=rx 00777 00555 o+rx,augo+rw 00000 00667 o+rx,augo+rw 00777 00777 o-rx,ao+wx,ao=wx 00777 00333 uo+rw,a-w 00000 00404 uo+rw,a-w 00777 00555 ug+wx 00000 00330 ug+wx 00777 00777 ago-x,ago=rx,ao-rw 00777 00111 ao-rw,auo=w,ag-x 00777 00222 go+rx,ugo+rwx 00777 00777 o+rwx,o+rx,g-rx 00777 00727 o+rwx,o+rx,g-rx 00000 00007 a=x,augo=r 00777 00444 auo-rw 00000 00000 auo-rw 00777 00111 augo=rx,go=r 00777 00544 ag+r,ugo-rw 00000 00000 ag+r,ugo-rw 00777 00111 auo-rx,a+rx 00000 00555 auo-rx,a+rx 00777 00777 ug+rw 00777 00777 ug+rw 00000 00660 auo=rx,auo-rx 00777 00000 aug+w,aug-rw,ago=x 00777 00111 ugo=r,aug=wx,a-w 00777 00111 ago=rx 00777 00555 u-rw,go+rwx,ugo=x 00777 00111 o=rw,uo+wx,aug=r 00777 00444 ug+wx,aug=rx 00777 00555 u=x,ago-wx,ag=rw 00777 00666 aug=rwx 00777 00777 uo+x,aug-rw,ug=r 00777 00441 uo-r,o-rw 00000 00000 uo-r,o-rw 00777 00371 g+rw 00777 00777 g+rw 00000 00060 uo+rw,au=x 00777 00111 ug-w,ao-wx 00777 00444 ug-w,ao-wx 00000 00000 a=rx,ag-r,ago-w 00777 00111 go-rwx,go=rw 00000 00066 go-rwx,go=rw 00777 00766 o+rw 00000 00006 o+rw 00777 00777 ao+x,a=r,ao+rw 00777 00666 aug+x,ao-x 00777 00666 aug+x,ao-x 00000 00000 uo=r,ug+wx,g+w 00000 00734 uo=r,ug+wx,g+w 00777 00774 o-rw,auo=r,augo=rw 00777 00666 au=w,ago-wx,g=rwx 00777 00070 a+wx,ug-x,aug=x 00777 00111 ug-wx,ugo=r 00777 00444 ag-r,g-r,go=wx 00000 00033 ag-r,g-r,go=wx 00777 00333 ag-x,aug+x 00777 00777 ag-x,aug+x 00000 00111 augo=r 00777 00444 go+wx,ao=x,ao+rw 00777 00777 au+x,ag-rx,o=wx 00000 00003 au+x,ag-rx,o=wx 00777 00223 a+x,ago+rwx,uo=rx 00777 00575 ug-rw 00777 00117 ug-rw 00000 00000 u=w,go-w,ao+wx 00777 00377 u=w,go-w,ao+wx 00000 00333 uo-rwx,g-rwx 00777 00000 ago+r,ago+rwx,ago=r 00777 00444 auo=w,o+rx 00777 00227 go+wx,u+rx,uo-wx 00000 00430 go+wx,u+rx,uo-wx 00777 00474 ao+x 00777 00777 ao+x 00000 00111 ag-rw,a-rw,ao+rx 00777 00555 auo-r 00777 00333 auo-r 00000 00000 o+rw,ag=rw,o=x 00777 00661 go=rwx,go+rwx,ag=rx 00777 00555 aug=rx,auo-rwx,augo=r 00777 00444 ao-rwx,au=w,u+rwx 00777 00722 aug+w 00777 00777 aug+w 00000 00222 o-rw 00000 00000 o-rw 00777 00771 go+rwx,ug=rwx 00777 00777 auo+rx,au-w 00777 00555 a-wx 00777 00444 a-wx 00000 00000 au=rwx,go+rwx 00777 00777 o+rx 00000 00005 o+rx 00777 00777 g=wx 00777 00737 g=wx 00000 00030 ago=r 00777 00444 auo=rw,go-r,go-rx 00777 00622 ugo=wx,ago=rx,o+wx 00777 00557 go=rwx,ago+x,a+r 00000 00577 go=rwx,ago+x,a+r 00777 00777 ag-wx 00000 00000 ag-wx 00777 00444 o-wx,uo-rwx 00000 00000 o-wx,uo-rwx 00777 00070 u-wx 00777 00477 u-wx 00000 00000 u+rwx,ugo-x,u-x 00777 00666 u+rwx,ugo-x,u-x 00000 00600 ugo=rw 00777 00666 au+rx,g=w,auo=w 00777 00222 a-wx,ago-x 00000 00000 a-wx,ago-x 00777 00444 u+rw,au-rwx 00777 00000 augo-wx,aug+wx 00000 00333 augo-wx,aug+wx 00777 00777 g+r 00777 00777 g+r 00000 00040 aug=rwx,augo-rx 00777 00222 ug=w,aug+rwx,uo=rx 00777 00575 a=rwx 00777 00777 ugo=r,g-r,a=wx 00777 00333 g+rwx 00000 00070 g+rwx 00777 00777 au=x,a-wx,au+x 00777 00111 go-x,ao-r,ag=x 00777 00111 ao=r,ao+rx 00777 00555 ag+w,ao-rw,ag+wx 00777 00333 g+r,o-r,augo-rw 00777 00111 g+r,o-r,augo-rw 00000 00000 go+r 00000 00044 go+r 00777 00777 ao=r,o+rwx 00777 00447 ago=r,go=rwx 00777 00477 ao+rwx,ag+r,ugo-rwx 00777 00000 ao=wx 00777 00333 ago+wx,aug+rwx 00777 00777 ao=wx,aug=wx 00777 00333 ao=w,a-r,ao+rx 00777 00777 aug+w,u-x,auo+wx 00000 00333 aug+w,u-x,auo+wx 00777 00777 o=wx,go=rw,ag=x 00777 00111 uo-rwx,uo-rwx 00000 00000 uo-rwx,uo-rwx 00777 00070 o=x 00000 00001 o=x 00777 00771 ao-rwx 00777 00000 o-x,uo-w,ao=w 00777 00222 au+r,u=r 00777 00477 au+r,u=r 00000 00444 go=rx,g+wx 00000 00075 go=rx,g+wx 00777 00775 ag+w,o+rwx,ago=r 00777 00444 auo-w,u-x 00777 00455 auo-w,u-x 00000 00000 ug-rw,uo-w,aug-rx 00777 00000 a+x,ao+r 00777 00777 a+x,ao+r 00000 00555 ag=rwx,aug-wx 00777 00444 au+w,ugo-rw,ugo+rx 00777 00555 g=rw 00000 00060 g=rw 00777 00767 a-rx 00777 00222 a-rx 00000 00000 ugo-x,ag+rx 00777 00777 ugo-x,ag+rx 00000 00555 auo-rwx,au-rwx,ag+x 00777 00111 uo-w 00000 00000 uo-w 00777 00575 o+rwx 00000 00007 o+rwx 00777 00777 ago-rx 00777 00222 ago-rx 00000 00000 ao+rwx,ao+rw 00777 00777 au=w,ao+wx,g-rx 00777 00323 o-x,g+rw 00777 00776 o-x,g+rw 00000 00060 u+rx,uo+rw 00777 00777 u+rx,uo+rw 00000 00706 ugo-rw 00000 00000 ugo-rw 00777 00111 ag-r,ago=x 00777 00111 go=x,a=x,ago=wx 00777 00333 ao-x 00777 00666 ao-x 00000 00000 u+rw,aug=rw,uo=x 00777 00161 uo+w,ago-rwx 00777 00000 augo=x 00777 00111 ug=x,go+rw 00777 00177 ug=x,go+rw 00000 00176 ugo=rw,ag=w 00777 00222 g+rx,u-w,ug+rx 00777 00577 g+rx,u-w,ug+rx 00000 00550 ug=rx,auo-rwx,u+r 00777 00400 a+rwx,go-w 00777 00755 o-x,auo-rwx,go-x 00777 00000 u-rw,ao=w,u+rx 00777 00722 ugo+x,a=rx,ag=wx 00777 00333 auo+x 00777 00777 auo+x 00000 00111 ugo+wx,ugo+w 00777 00777 ugo+wx,ugo+w 00000 00333 ag+x 00777 00777 ag+x 00000 00111 go-rx,au+rx 00777 00777 go-rx,au+rx 00000 00555 ao+rwx,go+x 00777 00777 a=wx 00777 00333 u+rwx,o+r 00777 00777 u+rwx,o+r 00000 00704 auo=rx,u-rwx 00777 00055 u=x,au-w 00000 00100 u=x,au-w 00777 00155 auo+rwx,ago-rw 00777 00111 ao+x,u=w,g-rw 00777 00217 ao+x,u=w,g-rw 00000 00211 a=w,ag+r,g+w 00777 00666 g-rw 00777 00717 g-rw 00000 00000 augo+x 00000 00111 augo+x 00777 00777 o-rx,g-rwx,ag=rx 00777 00555 augo=rw,aug+r 00777 00666 uo+rwx 00000 00707 uo+rwx 00777 00777 aug-rx,ao+x,uo=rw 00777 00636 aug-rx,ao+x,uo=rw 00000 00616 u-r,ago-rx,ug=rw 00777 00662 u-r,ago-rx,ug=rw 00000 00660 au=wx,ugo+rx,go=x 00777 00711 o-rx,ugo+x,ao-rx 00000 00000 o-rx,ugo+x,ao-rx 00777 00222 augo-w,a=rwx,o-rw 00777 00771 o+wx 00000 00003 o+wx 00777 00777 aug-w,aug+wx 00777 00777 aug-w,aug+wx 00000 00333 ug-rwx,aug-r,augo-rwx 00777 00000 aug+rw 00777 00777 aug+rw 00000 00666 augo+rwx,go-w,ao-w 00777 00555 o-w,o=w 00777 00772 o-w,o=w 00000 00002 o-rwx,ao-x 00000 00000 o-rwx,ao-x 00777 00660 au-x,g-rx,u+r 00000 00400 au-x,g-rx,u+r 00777 00626 ao=wx,au+w 00777 00333 ao=rwx,aug-rwx,au=x 00777 00111 aug+x,a-rwx 00777 00000 go-rx,go+x 00000 00011 go-rx,go+x 00777 00733 au-wx,au-w,ugo+wx 00000 00333 au-wx,au-w,ugo+wx 00777 00777 augo-rx,go-x 00000 00000 augo-rx,go-x 00777 00222 go-rx 00000 00000 go-rx 00777 00722 o+rwx,uo-rwx,augo-rwx 00777 00000 auo=w,ago=rwx,g-r 00777 00737 ago-w 00000 00000 ago-w 00777 00555 aug+wx,ugo-rx,go-r 00777 00222 g-x,auo+x 00777 00777 g-x,auo+x 00000 00111 ao-x,uo-rw,aug-rw 00777 00000 go-x,au=rx 00777 00555 a+r 00777 00777 a+r 00000 00444 ao-rw 00777 00111 ao-rw 00000 00000 ug-rx 00777 00227 ug-rx 00000 00000 ago-rwx 00777 00000 uo-rwx 00777 00070 uo-rwx 00000 00000 ag-rw,o+w 00777 00113 ag-rw,o+w 00000 00002 au=rx,augo=w,go-rwx 00777 00200 g=wx,u=x,a=rx 00777 00555 augo-x,u=wx,a+r 00777 00766 augo-x,u=wx,a+r 00000 00744 go+rwx,ag+rx 00000 00577 go+rwx,ag+rx 00777 00777 ago+rw,a=rx,ug-wx 00777 00445 ago-rx,ago+w,uo=r 00777 00424 auo+wx 00000 00333 auo+wx 00777 00777 ago+w,aug=rwx 00777 00777 a-rx,go+wx,ago-rx 00777 00222 a-rx,go+wx,ago-rx 00000 00022 aug+r 00000 00444 aug+r 00777 00777 aug+rw,ugo+rw,u=wx 00777 00377 aug+rw,ugo+rw,u=wx 00000 00366 a-wx,au-rwx,ag-wx 00777 00000 o+wx,a-x,ugo+rw 00777 00666 u=rwx,uo-x,ugo-rwx 00777 00000 aug-rw 00000 00000 aug-rw 00777 00111 uo=x 00777 00171 uo=x 00000 00101 auo-w,ug+wx,ug-wx 00000 00000 auo-w,ug+wx,ug-wx 00777 00445 uo+rwx,uo=wx 00000 00303 uo+rwx,uo=wx 00777 00373 auo=rw 00777 00666 ug-rw,au-rw,o=rwx 00777 00117 ug-rw,au-rw,o=rwx 00000 00007 ugo-x 00000 00000 ugo-x 00777 00666 ao=wx,ug-rw,augo-rwx 00777 00000 o=w 00000 00002 o=w 00777 00772 a=x,uo-w,ugo-wx 00777 00000 ag-rw 00000 00000 ag-rw 00777 00111 uo=rx,ug-rw,g-wx 00777 00105 go=x,ug-w,uo-wx 00777 00410 go=x,ug-w,uo-wx 00000 00010 uo+r,g-r 00000 00404 uo+r,g-r 00777 00737 au+rwx,g=wx,uo+rx 00777 00737 ao=w,g-rw,aug+x 00777 00313 augo=wx,go-rx 00777 00322 augo+w,go-x,u+rx 00777 00766 augo+w,go-x,u+rx 00000 00722 g=x,ago=rwx 00777 00777 a=w,u=r,o-rw 00777 00420 o+x,auo+rwx,ugo+wx 00777 00777 go=wx,ag=r 00777 00444 a+x,aug=rwx 00777 00777 g=rx,uo+rx 00777 00757 g=rx,uo+rx 00000 00555 auo-wx,aug-w 00777 00444 auo-wx,aug-w 00000 00000 g+rx,go+r 00777 00777 g+rx,go+r 00000 00054 a-r 00000 00000 a-r 00777 00333 a=rw,ao-w 00777 00444 u-rx 00000 00000 u-rx 00777 00277 g-r 00777 00737 g-r 00000 00000 a+w 00000 00222 a+w 00777 00777 au-x,ug-r 00000 00000 au-x,ug-r 00777 00226 go-x 00000 00000 go-x 00777 00766 a+w,aug=x 00777 00111 ao-rw,uo+rx,aug-wx 00777 00404 ago=x,uo-rw,auo=rw 00777 00666 o-rx,ag=rwx 00777 00777 au+wx,ugo+x 00000 00333 au+wx,ugo+x 00777 00777 g+rx 00777 00777 g+rx 00000 00050 ag=rx,o=wx 00777 00553 aug-x 00777 00666 aug-x 00000 00000 ag-r,o=rwx,aug=wx 00777 00333 a+w,ugo+rwx,ug-wx 00777 00447 aug=rwx,ao=rwx,ugo+rw 00777 00777 au-rwx,ao=r,go=r 00777 00444 u=wx,ugo+rwx 00777 00777 ao-x,ag-r 00777 00222 ao-x,ag-r 00000 00000 ugo+r 00777 00777 ugo+r 00000 00444 au=wx,aug=w 00777 00222 go-rw,o+rw 00000 00006 go-rw,o+rw 00777 00717 ug=rwx,augo+wx,a+wx 00000 00773 ug=rwx,augo+wx,a+wx 00777 00777 ag+x,uo-x 00777 00676 ag+x,uo-x 00000 00010 uo=rwx,o+rw 00000 00707 uo=rwx,o+rw 00777 00777 auo=rw,go=wx,ao-rwx 00777 00000 au=rw,ug-rwx,aug-w 00777 00004 uo+rw 00777 00777 uo+rw 00000 00606 g-rwx 00000 00000 g-rwx 00777 00707 auo=r,auo-wx,o+rwx 00777 00447 o-r,au=rw,ag+w 00777 00666 o=rw 00777 00776 o=rw 00000 00006 go+r,auo+rw 00000 00666 go+r,auo+rw 00777 00777 ago-rwx,go=wx,ug-rw 00777 00013 ao=r,uo-rx,a-rwx 00777 00000 ag=wx,uo-r 00777 00333 ag+r,ugo+wx 00777 00777 ag-wx,g=rx 00000 00050 ag-wx,g=rx 00777 00454 ug+rx,ag-rwx 00777 00000 augo=rx,o+wx,au=wx 00777 00333 o+rw,go-rwx 00000 00000 o+rw,go-rwx 00777 00700 ago=rw,au=x,ao=r 00777 00444 ug-rw,a=rwx 00777 00777 go+rwx,ao-rw 00777 00111 go+rwx,ao-rw 00000 00011 ugo+rx,au=rwx 00777 00777 ao+wx,uo-rw,augo+w 00777 00373 ao+wx,uo-rw,augo+w 00000 00333 au=x 00777 00111 ugo+w,ag+rwx 00777 00777 ago=rw,go-r,augo=rwx 00777 00777 ago-rx,ao=wx 00777 00333 au=rx,au=x 00777 00111 augo+rx,go+rwx,aug+r 00000 00577 augo+rx,go+rwx,aug+r 00777 00777 ago=rwx,ag-wx 00777 00444 ag=w,augo-wx 00777 00000 g+rx,ag+rw 00777 00777 g+rx,ag+rw 00000 00676 uo+rx,ugo=w,a+r 00777 00666 au-w,auo+x 00777 00555 au-w,auo+x 00000 00111 aug-w,auo-wx,auo=wx 00777 00333 u=wx,g+w,auo-rwx 00777 00000 auo=w,go-r 00777 00222 ugo-r,u+wx,aug=x 00777 00111 g=r,ug=rw 00000 00660 g=r,ug=rw 00777 00667 uo-rwx,augo=r 00777 00444 augo+rx 00000 00555 augo+rx 00777 00777 ao+rx,ago=x 00777 00111 auo+rw,ag=x,aug=x 00777 00111 a+wx 00777 00777 a+wx 00000 00333 au=x,ugo=wx 00777 00333 auo-w 00777 00555 auo-w 00000 00000 ag-rwx,auo-rx,go+w 00777 00022 ug+rx,ago=w 00777 00222 uo-r,g=rwx,ugo=w 00777 00222 ao=w 00777 00222 auo-rwx 00777 00000 a=rw,u=rx,u-rw 00777 00166 aug-rx,au-r 00777 00222 aug-rx,au-r 00000 00000 uo-r,ago=rx 00777 00555 g+x,uo=rx 00777 00575 g+x,uo=rx 00000 00515 ago=rwx,auo-x,ago=rx 00777 00555 ug+x 00777 00777 ug+x 00000 00110 ug=r,uo-x,au-rwx 00777 00000 ao-rw,ug-wx 00777 00001 ao-rw,ug-wx 00000 00000 ug-r,a+rwx 00777 00777 ugo-wx,ug-wx,ug=wx 00000 00330 ugo-wx,ug-wx,ug=wx 00777 00334 u+w,au-wx,ug=r 00000 00440 u+w,au-wx,ug=r 00777 00444 auo+r,g+w,o+r 00777 00777 auo+r,g+w,o+r 00000 00464 ugo+x 00777 00777 ugo+x 00000 00111 ago-w,aug-rw 00000 00000 ago-w,aug-rw 00777 00111 aug-wx,go=rw 00000 00066 aug-wx,go=rw 00777 00466 ago-rw,go+w,a-w 00000 00000 ago-rw,go+w,a-w 00777 00111 au+w,ao=wx,ug=rwx 00777 00773 uo+rwx,uo+r 00000 00707 uo+rwx,uo+r 00777 00777 ugo+rx,au+rwx,ug-x 00777 00667 o=rwx,g-x 00000 00007 o=rwx,g-x 00777 00767 ug-r,au+wx 00777 00337 ug-r,au+wx 00000 00333 ago=w,augo=r 00777 00444 augo+w 00777 00777 augo+w 00000 00222 a=w,uo+wx 00777 00323 g-rw,aug=x,go-rw 00777 00111 augo-rw,aug=r 00777 00444 auo-rw,augo-rw,ao+rw 00777 00777 auo-rw,augo-rw,ao+rw 00000 00666 auo-rx 00777 00222 auo-rx 00000 00000 u+r,uo=rx,ag=wx 00777 00333 ao=x,uo-w 00777 00111 ugo-rx,ago-rwx,ao+rw 00777 00666 augo=wx,o=x 00777 00331 uo+r,ago+x,au-x 00000 00404 uo+r,ago+x,au-x 00777 00666 au=wx,g-wx,o=rw 00777 00306 auo+r 00777 00777 auo+r 00000 00444 ugo-r 00777 00333 ugo-r 00000 00000 aug=r,au-wx,augo-wx 00777 00444 ago+wx,ago=wx,ao-rwx 00777 00000 au+rx,ugo-x,o-rx 00777 00662 au+rx,ugo-x,o-rx 00000 00440 ugo-rwx,a+w 00777 00222 auo+rwx,o+x 00777 00777 ago+x,ago=w,aug-x 00777 00222 ao+w,uo+rw 00000 00626 ao+w,uo+rw 00777 00777 uo-r 00777 00373 uo-r 00000 00000 uo=rw,ao-rx 00777 00222 uo=rw,ao-rx 00000 00202 u-rw 00777 00177 u-rw 00000 00000 au-rx,a=wx 00777 00333 g-wx 00777 00747 g-wx 00000 00000 ago-x,a+rwx 00777 00777 go=w 00777 00722 go=w 00000 00022 ao=x 00777 00111 ago=w 00777 00222 uo=w,ugo-rx,auo+w 00777 00222 auo-rwx,a=rw 00777 00666 go-r,ago+wx 00777 00733 go-r,ago+wx 00000 00333 a-wx,ao=w,augo=x 00777 00111 ago=wx,u+rw 00777 00733 ao=rx 00777 00555 ag+wx 00777 00777 ag+wx 00000 00333 ago=x,augo=rx 00777 00555 ago+wx,uo+rwx,augo=w 00777 00222 auo=wx 00777 00333 ago+rx 00777 00777 ago+rx 00000 00555 uo-wx,ugo+x,ugo-rw 00777 00111 ago-r,ao+rwx,augo+rx 00777 00777 u+rwx 00777 00777 u+rwx 00000 00700 ugo=r 00777 00444 a+rx,go-rwx,ug=rwx 00777 00770 a=x,ugo-x,ug-r 00777 00000 aug=x,ag=x 00777 00111 au=wx,auo-w 00777 00111 aug=rw,go=w,g-w 00777 00602 u-rwx 00777 00077 u-rwx 00000 00000 uo=r,aug-rx,ao=wx 00777 00333 ugo=x,g+rx 00777 00151 ao-x,au+wx,ag+rx 00777 00777 o=r,au+rwx 00777 00777 aug-rwx,ag=wx 00777 00333 ag+rw,g=x,auo=rx 00777 00555 a=rwx,ugo=wx,au=rwx 00777 00777 ao=rwx,augo-w 00777 00555 ugo=w,au-x,uo-rw 00777 00020 ug+x,u=rx 00777 00577 ug+x,u=rx 00000 00510 ugo+rwx,u+rwx,aug-wx 00777 00444 ugo+x,o=r 00777 00774 ugo+x,o=r 00000 00114 au=w,uo=x 00777 00121 ao=rx,go+rw 00777 00577 ag=x 00777 00111 ug-wx,g-wx 00000 00000 ug-wx,g-wx 00777 00447 aug-x,augo+rw,g=wx 00777 00636 ao+rw,ago=w 00777 00222 ug-rw,u+rwx,ao=rwx 00777 00777 o-rw,ugo-rw 00777 00111 o-rw,ugo-rw 00000 00000 aug+wx,auo-w 00000 00111 aug+wx,auo-w 00777 00555 auo=wx,aug-r 00777 00333 auo=r 00777 00444 ug+w,au-wx,aug-w 00777 00444 ug+w,au-wx,aug-w 00000 00000 ao-rw,auo+rwx,g+w 00777 00777 ugo=rx,go=x 00777 00511 auo-rwx,o-x 00777 00000 auo+rw 00000 00666 auo+rw 00777 00777 ago=rx,ago+rwx,augo-rx 00777 00222 g+x 00000 00010 g+x 00777 00777 o-x,aug+w 00000 00222 o-x,aug+w 00777 00776 a=x,uo=r,a-w 00777 00414 augo+rwx,g+wx 00777 00777 au-rx,ago-rx 00777 00222 au-rx,ago-rx 00000 00000 ao-rx 00000 00000 ao-rx 00777 00222 a+x,ag=wx 00777 00333 auo=rwx 00777 00777 ao-r 00000 00000 ao-r 00777 00333 a=r,ug-w 00777 00444 g+x,ago+rwx,u-rw 00777 00177 ug+rx,go=rw,u=rw 00777 00666 ago-r,ag-rwx,au-w 00777 00000 ago=w,u=rwx 00777 00722 ug-wx,ug+rw 00777 00667 ug-wx,ug+rw 00000 00660 o=x,auo+rwx 00777 00777 aug=wx 00777 00333 ag=rx,ao-rw,g+r 00777 00151 ao+wx 00000 00333 ao+wx 00777 00777 augo=w,augo+r,g-rw 00777 00606 auo=rx,au+rwx,a-wx 00777 00444 au-rw,aug+rx 00777 00555 go+rwx,ago+wx,a=w 00777 00222 augo=rwx,ag-rw 00777 00111 a=rx,a=r,ugo=wx 00777 00333 au-w,aug=wx 00777 00333 uo-wx,au-r 00000 00000 uo-wx,au-r 00777 00030 uo-rx,go+x,g+r 00000 00051 uo-rx,go+x,g+r 00777 00273 ag=r,au=rwx 00777 00777 ug+rwx,ug+wx 00777 00777 ug+rwx,ug+wx 00000 00770 a-w 00000 00000 a-w 00777 00555 u+r 00777 00777 u+r 00000 00400 augo=r,augo+w,uo+r 00777 00666 u+rw,go-rx 00777 00722 u+rw,go-rx 00000 00600 ag=rx 00777 00555 augo-w,u=x,augo=wx 00777 00333 aug-wx,go-x 00000 00000 aug-wx,go-x 00777 00444 ao=x,auo=rwx 00777 00777 uo=rwx 00000 00707 uo=rwx 00777 00777 o-w,au=rw 00777 00666 ugo=w 00777 00222 g-wx,aug+wx,u-x 00777 00677 g-wx,aug+wx,u-x 00000 00233 ag=x,u-wx 00777 00011 g=r,ao=rx 00777 00555 ao+r 00777 00777 ao+r 00000 00444 u+wx 00000 00300 u+wx 00777 00777 ag=rwx,ugo+w 00777 00777 u=rx 00777 00577 u=rx 00000 00500 au=rw,o=rwx,o=wx 00777 00663 ago+x,auo-wx 00777 00444 ago+x,auo-wx 00000 00000 ago+rwx 00777 00777 aug-rwx,ao-rwx 00777 00000 a+rwx,u=r 00777 00477 ag+rw,au+x,ug+rx 00777 00777 o+wx,u+r 00000 00403 o+wx,u+r 00777 00777 ag+x,auo-wx,a=rwx 00777 00777 go-w,ugo-w 00777 00555 go-w,ugo-w 00000 00000 ao=rwx 00777 00777 ago=x 00777 00111 uo+w,ao-r,augo-rwx 00777 00000 auo-wx,go-w 00777 00444 auo-wx,go-w 00000 00000 g-rx,u-r 00000 00000 g-rx,u-r 00777 00327 augo-rwx,a=w,a-w 00777 00000 au=r 00777 00444 aug=rw,auo+x,ugo+rx 00777 00777 ag-x,uo+x 00777 00767 ag-x,uo+x 00000 00101 a+w,ugo+wx 00777 00777 a+w,ugo+wx 00000 00333 augo+rwx 00777 00777 augo-r,o+rx 00777 00337 augo-r,o+rx 00000 00005 ao-wx 00777 00444 ao-wx 00000 00000 au-rw 00000 00000 au-rw 00777 00111 go+rw,au+rx 00000 00577 go+rw,au+rx 00777 00777 ugo+w,augo=rw,aug=rx 00777 00555 ag+rwx 00777 00777 a+rwx,uo+r 00777 00777 ug-w,aug-r 00000 00000 ug-w,aug-r 00777 00113 uo+rx,aug-wx 00777 00444 uo+rx,aug-wx 00000 00404 ao=w,o+wx 00777 00223 uo=rwx,g+rw,u+rx 00000 00767 uo=rwx,g+rw,u+rx 00777 00777 aug-rwx,augo=rx,au-wx 00777 00444 ag-rwx 00777 00000 ug=w,u+x 00000 00320 ug=w,u+x 00777 00327 ug=rwx,g+r 00000 00770 ug=rwx,g+r 00777 00777 g-rwx,au-x 00777 00606 g-rwx,au-x 00000 00000 ao-wx,go=rx 00000 00055 ao-wx,go=rx 00777 00455 ao=x,ug-x,ugo+rx 00777 00555 ug+x,u=r,go+w 00000 00432 ug+x,u=r,go+w 00777 00477 go+rx 00000 00055 go+rx 00777 00777 a=rw,ugo+wx,ago=rw 00777 00666 ug+x,o=r 00777 00774 ug+x,o=r 00000 00114 o+w 00777 00777 o+w 00000 00002 ag+w,go-wx 00777 00744 ag+w,go-wx 00000 00200 u-wx,ago=rwx 00777 00777 ago+r 00000 00444 ago+r 00777 00777 go-wx,auo-rx,ag+r 00000 00444 go-wx,auo-rx,ag+r 00777 00644 auo+w 00777 00777 auo+w 00000 00222 uo-rw,ao=rx,ugo-x 00777 00444 aug+w,o-w 00777 00775 aug+w,o-w 00000 00220 ug=r 00777 00447 ug=r 00000 00440 augo-rw 00000 00000 augo-rw 00777 00111 ag+x,aug+w,au=r 00777 00444 o=r,auo+wx,uo-rw 00777 00171 o=r,auo+wx,uo-rw 00000 00131 ugo-rx,ao+rx,ug+rx 00777 00777 ugo-rx,ao+rx,ug+rx 00000 00555 ao+w,ug-rx 00777 00227 ao+w,ug-rx 00000 00222 a+rwx,go-r 00777 00733 uo=x,ago=wx,ugo+rwx 00777 00777 uo=r 00777 00474 uo=r 00000 00404 o+rw,aug+rx,ugo=rwx 00777 00777 uo-rx 00777 00272 uo-rx 00000 00000 u-rwx,ago+rx 00777 00577 u-rwx,ago+rx 00000 00555 ag-rw,o+w,ug=rx 00777 00553 ag-rw,o+w,ug=rx 00000 00552 u=rw,ago+r,ug=x 00000 00114 u=rw,ago+r,ug=x 00777 00117 aug=w 00777 00222 a=x,ago=rwx,au=rx 00777 00555 ago=rx,ago+x 00777 00555 go-r 00777 00733 go-r 00000 00000 aug=x,augo-rwx,uo+rw 00777 00606 auo-wx,g=rwx,o-x 00000 00070 auo-wx,g=rwx,o-x 00777 00474 auo=rw,uo-rw 00777 00060 go=r 00777 00744 go=r 00000 00044 augo-w,ag-rx 00777 00000 o=w,ag=wx,a=wx 00777 00333 aug=rx 00777 00555 o=w,u-rw 00777 00172 o=w,u-rw 00000 00002 ag-rwx,u=x,o-r 00777 00100 ao+wx,uo=wx 00000 00333 ao+wx,uo=wx 00777 00373 u=wx 00777 00377 u=wx 00000 00300 g-x 00000 00000 g-x 00777 00767 au+rw,o+rx 00000 00667 au+rw,o+rx 00777 00777 ago+x,ug=w,u-x 00000 00221 ago+x,ug=w,u-x 00777 00227 auo+w,au-rwx 00777 00000 ag+rw,ao-rx 00777 00222 ug+w 00777 00777 ug+w 00000 00220 Path-Tiny-0.076/lib/Path/000755 000765 000024 00000000000 12622375237 015250 5ustar00davidstaff000000 000000 Path-Tiny-0.076/lib/Path/Tiny.pm000644 000765 000024 00000270052 12622375237 016537 0ustar00davidstaff000000 000000 use 5.008001; use strict; use warnings; package Path::Tiny; # ABSTRACT: File path utility our $VERSION = '0.076'; # Dependencies use Config; use Exporter 5.57 (qw/import/); use File::Spec 3.40 (); use Carp (); our @EXPORT = qw/path/; our @EXPORT_OK = qw/cwd rootdir tempfile tempdir/; use constant { PATH => 0, CANON => 1, VOL => 2, DIR => 3, FILE => 4, TEMP => 5, IS_BSD => ( scalar $^O =~ /bsd$/ ), IS_WIN32 => ( $^O eq 'MSWin32' ), }; use overload ( q{""} => sub { $_[0]->[PATH] }, bool => sub () { 1 }, fallback => 1, ); # FREEZE/THAW per Sereal/CBOR/Types::Serialiser protocol sub FREEZE { return $_[0]->[PATH] } sub THAW { return path( $_[2] ) } { no warnings 'once'; *TO_JSON = *FREEZE }; my $HAS_UU; # has Unicode::UTF8; lazily populated sub _check_UU { !!eval { require Unicode::UTF8; Unicode::UTF8->VERSION(0.58); 1 }; } my $HAS_FLOCK = $Config{d_flock} || $Config{d_fcntl_can_lock} || $Config{d_lockf}; # notions of "root" directories differ on Win32: \\server\dir\ or C:\ or \ my $SLASH = qr{[\\/]}; my $NOTSLASH = qr{[^\\/]}; my $DRV_VOL = qr{[a-z]:}i; my $UNC_VOL = qr{$SLASH $SLASH $NOTSLASH+ $SLASH $NOTSLASH+}x; my $WIN32_ROOT = qr{(?: $UNC_VOL $SLASH | $DRV_VOL $SLASH | $SLASH )}x; sub _win32_vol { my ( $path, $drv ) = @_; require Cwd; my $dcwd = eval { Cwd::getdcwd($drv) }; # C: -> C:\some\cwd # getdcwd on non-existent drive returns empty string # so just use the original drive Z: -> Z: $dcwd = "$drv" unless defined $dcwd && length $dcwd; # normalize dwcd to end with a slash: might be C:\some\cwd or D:\ or Z: $dcwd =~ s{$SLASH?$}{/}; # make the path absolute with dcwd $path =~ s{^$DRV_VOL}{$dcwd}; return $path; } # This is a string test for before we have the object; see is_rootdir for well-formed # object test sub _is_root { return IS_WIN32() ? ( $_[0] =~ /^$WIN32_ROOT$/ ) : ( $_[0] eq '/' ); } # mode bits encoded for chmod in symbolic mode my %MODEBITS = ( om => 0007, gm => 0070, um => 0700 ); ## no critic { my $m = 0; $MODEBITS{$_} = ( 1 << $m++ ) for qw/ox ow or gx gw gr ux uw ur/ }; sub _symbolic_chmod { my ( $mode, $symbolic ) = @_; for my $clause ( split /,\s*/, $symbolic ) { if ( $clause =~ m{\A([augo]+)([=+-])([rwx]+)\z} ) { my ( $who, $action, $perms ) = ( $1, $2, $3 ); $who =~ s/a/ugo/g; for my $w ( split //, $who ) { my $p = 0; $p |= $MODEBITS{"$w$_"} for split //, $perms; if ( $action eq '=' ) { $mode = ( $mode & ~$MODEBITS{"${w}m"} ) | $p; } else { $mode = $action eq "+" ? ( $mode | $p ) : ( $mode & ~$p ); } } } else { Carp::croak("Invalid mode clause '$clause' for chmod()"); } } return $mode; } # flock doesn't work on NFS on BSD. Since program authors often can't control # or detect that, we warn once instead of being fatal if we can detect it and # people who need it strict can fatalize the 'flock' category #<<< No perltidy { package flock; use if Path::Tiny::IS_BSD(), 'warnings::register' } #>>> my $WARNED_BSD_NFS = 0; sub _throw { my ( $self, $function, $file ) = @_; if ( IS_BSD() && $function =~ /^flock/ && $! =~ /operation not supported/i && !warnings::fatal_enabled('flock') ) { if ( !$WARNED_BSD_NFS ) { warnings::warn( flock => "No flock for NFS on BSD: continuing in unsafe mode" ); $WARNED_BSD_NFS++; } } else { Path::Tiny::Error->throw( $function, ( defined $file ? $file : $self->[PATH] ), $! ); } return; } # cheapo option validation sub _get_args { my ( $raw, @valid ) = @_; if ( defined($raw) && ref($raw) ne 'HASH' ) { my ( undef, undef, undef, $called_as ) = caller(1); $called_as =~ s{^.*::}{}; Carp::croak("Options for $called_as must be a hash reference"); } my $cooked = {}; for my $k (@valid) { $cooked->{$k} = delete $raw->{$k} if exists $raw->{$k}; } if ( keys %$raw ) { my ( undef, undef, undef, $called_as ) = caller(1); $called_as =~ s{^.*::}{}; Carp::croak( "Invalid option(s) for $called_as: " . join( ", ", keys %$raw ) ); } return $cooked; } #--------------------------------------------------------------------------# # Constructors #--------------------------------------------------------------------------# #pod =construct path #pod #pod $path = path("foo/bar"); #pod $path = path("/tmp", "file.txt"); # list #pod $path = path("."); # cwd #pod $path = path("~user/file.txt"); # tilde processing #pod #pod Constructs a C object. It doesn't matter if you give a file or #pod directory path. It's still up to you to call directory-like methods only on #pod directories and file-like methods only on files. This function is exported #pod automatically by default. #pod #pod The first argument must be defined and have non-zero length or an exception #pod will be thrown. This prevents subtle, dangerous errors with code like #pod C<< path( maybe_undef() )->remove_tree >>. #pod #pod If the first component of the path is a tilde ('~') then the component will be #pod replaced with the output of C. If the first component of the path #pod is a tilde followed by a user name then the component will be replaced with #pod output of C. Behaviour for non-existent users depends on #pod the output of C on the system. #pod #pod On Windows, if the path consists of a drive identifier without a path component #pod (C or C), it will be expanded to the absolute path of the current #pod directory on that volume using C. #pod #pod If called with a single C argument, the original is returned unless #pod the original is holding a temporary file or directory reference in which case a #pod stringified copy is made. #pod #pod $path = path("foo/bar"); #pod $temp = Path::Tiny->tempfile; #pod #pod $p2 = path($path); # like $p2 = $path #pod $t2 = path($temp); # like $t2 = path( "$temp" ) #pod #pod This optimizes copies without proliferating references unexpectedly if a copy is #pod made by code outside your control. #pod #pod Current API available since 0.017. #pod #pod =cut sub path { my $path = shift; Carp::croak("Path::Tiny paths require defined, positive-length parts") unless 1 + @_ == grep { defined && length } $path, @_; # non-temp Path::Tiny objects are effectively immutable and can be reused if ( !@_ && ref($path) eq __PACKAGE__ && !$path->[TEMP] ) { return $path; } # stringify objects $path = "$path"; # expand relative volume paths on windows; put trailing slash on UNC root if ( IS_WIN32() ) { $path = _win32_vol( $path, $1 ) if $path =~ m{^($DRV_VOL)(?:$NOTSLASH|$)}; $path .= "/" if $path =~ m{^$UNC_VOL$}; } # concatenations stringifies objects, too if (@_) { $path .= ( _is_root($path) ? "" : "/" ) . join( "/", @_ ); } # canonicalize, but with unix slashes and put back trailing volume slash my $cpath = $path = File::Spec->canonpath($path); $path =~ tr[\\][/] if IS_WIN32(); $path .= "/" if IS_WIN32() && $path =~ m{^$UNC_VOL$}; # root paths must always have a trailing slash, but other paths must not if ( _is_root($path) ) { $path =~ s{/?$}{/}; } else { $path =~ s{/$}{}; } # do any tilde expansions if ( $path =~ m{^(~[^/]*).*} ) { require File::Glob; my ($homedir) = File::Glob::bsd_glob($1); $homedir =~ tr[\\][/] if IS_WIN32(); $path =~ s{^(~[^/]*)}{$homedir}; } bless [ $path, $cpath ], __PACKAGE__; } #pod =construct new #pod #pod $path = Path::Tiny->new("foo/bar"); #pod #pod This is just like C, but with method call overhead. (Why would you #pod do that?) #pod #pod Current API available since 0.001. #pod #pod =cut sub new { shift; path(@_) } #pod =construct cwd #pod #pod $path = Path::Tiny->cwd; # path( Cwd::getcwd ) #pod $path = cwd; # optional export #pod #pod Gives you the absolute path to the current directory as a C object. #pod This is slightly faster than C<< path(".")->absolute >>. #pod #pod C may be exported on request and used as a function instead of as a #pod method. #pod #pod Current API available since 0.018. #pod #pod =cut sub cwd { require Cwd; return path( Cwd::getcwd() ); } #pod =construct rootdir #pod #pod $path = Path::Tiny->rootdir; # / #pod $path = rootdir; # optional export #pod #pod Gives you C<< File::Spec->rootdir >> as a C object if you're too #pod picky for C. #pod #pod C may be exported on request and used as a function instead of as a #pod method. #pod #pod Current API available since 0.018. #pod #pod =cut sub rootdir { path( File::Spec->rootdir ) } #pod =construct tempfile, tempdir #pod #pod $temp = Path::Tiny->tempfile( @options ); #pod $temp = Path::Tiny->tempdir( @options ); #pod $temp = tempfile( @options ); # optional export #pod $temp = tempdir( @options ); # optional export #pod #pod C passes the options to C<< File::Temp->new >> and returns a C #pod object with the file name. The C option is enabled by default. #pod #pod The resulting C object is cached. When the C object is #pod destroyed, the C object will be as well. #pod #pod C annoyingly requires you to specify a custom template in slightly #pod different ways depending on which function or method you call, but #pod C lets you ignore that and can take either a leading template or a #pod C