From a89ea5237a740e5f3f0d550e5fe4477eb2e898d0 Mon Sep 17 00:00:00 2001 From: Packit Date: Sep 22 2020 08:33:53 +0000 Subject: perl-File-Temp-0.230.600 base --- diff --git a/CONTRIBUTING b/CONTRIBUTING new file mode 100644 index 0000000..7eddd40 --- /dev/null +++ b/CONTRIBUTING @@ -0,0 +1,100 @@ + +CONTRIBUTING + +Thank you for considering contributing to this distribution. This file +contains instructions that will help you work with the source code. + +PLEASE NOTE that if you have any questions or difficulties, you can reach the +maintainer(s) through the bug queue described later in this document +(preferred), or by emailing the releaser directly. You are not required to +follow any of the steps in this document to submit a patch or bug report; +these are just recommendations, intended to help you (and help us help you +faster). + +The distribution is managed with Dist::Zilla (https://metacpan.org/release/Dist-Zilla). +This means than many of the usual files you might expect are not in the +repository, but are generated at release time (e.g. Makefile.PL). + +However, you can run tests directly using the 'prove' tool: + + $ prove -l + $ prove -lv t/some_test_file.t + $ prove -lvr t/ + +In most cases, 'prove' is entirely sufficient for you to test any +patches you have. + +You may need to satisfy some dependencies. The easiest way to satisfy +dependencies is to install the last release -- this is available at +https://metacpan.org/release/File-Temp + +If you use cpanminus, you can do it without downloading the tarball first: + + $ cpanm --reinstall --installdeps --with-recommends File::Temp + +Dist::Zilla is a very powerful authoring tool, but requires a number of +author-specific plugins. If you would like to use it for contributing, +install it from CPAN, then run one of the following commands, depending on +your CPAN client: + + $ cpan `dzil authordeps --missing` +or + $ dzil authordeps --missing | cpanm + +You should then also install any additional requirements not needed by the +dzil build but may be needed by tests or other development: + + $ cpan `dzil listdeps --author --missing` +or + $ dzil listdeps --author --missing | cpanm + +Or, you can use the 'dzil stale' command to install all requirements at once: + + $ cpan Dist::Zilla::App::Command::stale + $ cpan `dzil stale --all` +or + $ cpanm Dist::Zilla::App::Command::stale + $ dzil stale --all | cpanm + +You can also do this via cpanm directly: + + $ cpanm --reinstall --installdeps --with-develop --with-recommends File::Temp + +Once installed, here are some dzil commands you might try: + + $ dzil build + $ dzil test + $ dzil test --release + $ dzil xtest + $ dzil listdeps --json + $ dzil build --notgz + +You can learn more about Dist::Zilla at http://dzil.org/. + +The code for this distribution is hosted at GitHub. The repository is: +https://github.com/Perl-Toolchain-Gang/File-Temp +You can submit code changes by forking the repository, pushing your code +changes to your clone, and then submitting a pull request. Detailed +instructions for doing that is available here: + +https://help.github.com/articles/creating-a-pull-request + +If you have found a bug, but do not have an accompanying patch to fix it, you +can submit an issue report here: +https://rt.cpan.org/Public/Dist/Display.html?Name=File-Temp +or via email: bug-File-Temp@rt.cpan.org + +There is also a mailing list available for users of this distribution, at +http://lists.perl.org/list/cpan-workers.html +There is also an irc channel available for users of this distribution, at +irc://irc.perl.org/#toolchain + +If you send me a patch or pull request, your name and email address will be +included in the documentation as a contributor (using the attribution on the +commit or patch), unless you specifically request for it not to be. If you +wish to be listed under a different name or address, you should submit a pull +request to the .mailmap file to contain the correct mapping. + + +This file was generated via Dist::Zilla::Plugin::GenerateFile::FromShareDir 0.014 from a +template file originating in Dist-Zilla-PluginBundle-Author-ETHER-0.141. diff --git a/CONTRIBUTING.mkdn b/CONTRIBUTING.mkdn new file mode 100644 index 0000000..761c9db --- /dev/null +++ b/CONTRIBUTING.mkdn @@ -0,0 +1,87 @@ +## 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/ + diff --git a/Changes b/Changes new file mode 100644 index 0000000..7535d94 --- /dev/null +++ b/Changes @@ -0,0 +1,379 @@ +0.2306 2018-06-24 19:33:47Z + - switch from 'use vars' to 'our' + +0.2305 2018-04-19 11:58:49Z (TRIAL RELEASE) + - documentation updates for what versions contain what features + (thanks, Brian Mowrey! RT#101518) + - fix bad use of skip() in tests (RT#95922) + - Fall back to CSIDL_LOCAL_APPDATA under taint on Windows (RT#60340) + - update distribution tooling + +0.2304 2013-10-10 13:16:27Z + + * List all detectable dependencies for completeness. (Test::More had + been unintentionally omitted in the last release and many core + dependencies had never been listed.) + +0.2303 2013-10-09 13:57:21Z + + * Remove compile test and associated dependencies + +0.2302 2013-09-26 13:45:35Z + + * Drop minimum Perl version back to 5.6 (erroneously bumped by dzil) + * Do not inherit from Exporter (requires Exporter 5.57) (thanks to + Olivier Mengué) + * 'use base ...' => 'use parent ...' as parent is lighter (thanks to + Olivier Mengué) + +0.2301 2013-04-11 15:30:05Z + + * dist.ini: Managed with Dist::Zilla now; generates Makefile.PL + to avoid circular dependency when using Build.PL + +0.23 2013-03-14 Tim Jenness + + * Build.PL: Use Module::Build + + * Temp.pm: internally holds absolute path for cleanup (Fixes RT #44924) + + * t/rmtree.t: (new) Test temp dir removal explicitly. + + * t/tempfile.t: Correctly tests directory removal from chdir. + + * Temp.pm: Clean up temp directory on exit even if it is the + current directory. Patch supplied by Ed Avis and fixes RT #45246. + + * Temp.pm: Defer unlinking tempfiles if initial unlink fails + instad of croaking; fixes problems on NFS (RT #82720) + + * Temp.pm: Allow leading template to new() for consistency with + newdir() + + * Temp.pm: Calling tempfile or tempdir as a class method now + produce a more useful fatal error message + + * Temp.pm: new/newdir/tempfile/tempdir now all allow either + a leading template argument or a TEMPLATE option + + * Temp.pm: Overload numify with refaddr() in same manner as IO::File + (closes RT #47397 from Kevin Ryde) + +0.22 2009-06-28 Tim Jenness + + * t/fork.t: Fix portability problems in fork.t and remove left + over file (RT #41557) + +0.21 2008-11-12 Tim Jenness + + * Temp.pm: Clean out $FILES_CREATED_BY_OBJECT when the destructor + runs. Otherwise memory does not get returned. Really bad idea for + daemons. (Thanks to Maxime Therreault RT #37621) + + * Temp.pm: Integrate patches from bleadperl for cygwin. (thanks to + Jari Aalto RT #36376) + + * t/seekable.t: seekable test was failing on perl 5.6.0 so we now + skip the specific test. (thanks to Zefram) + + * Temp.pm: Remove the test on the parent directory to see if a file + can be written. This will be found out anyway as soon as the file open + is attempted. AFS systems may fail a -w test but still allow a file to + be created. (thanks to Christopher Ellison) + + * Temp.pm: Put an eval around rmtree. Some versions of rmtree croak + if you attempt to remove a directory that you are inside. (debian bug + 479317 and RT #35779). + + * Temp.pm: Localize special variables in END blocks and destructors. + +0.20 2007-12-20 Tim Jenness + + * t/lock.t: Fix logic problem with BEGIN block that was causing grief on some + systems (thanks to Steve Peters for patch). + +0.19 2007-11-19 Tim Jenness + + * Temp.pm (tempfile): Add EXLOCK option which can be used to disable O_EXLOCK + + * t/lock.t: Test ability to disable O_EXLOCK + + * Temp.pm (newdir): Add object oriented interface to "tempdir". Use + File::Temp->newdir() + + * Temp.pm (tempdir): Add a note to the tempdir documentation to + clarify that the default is for the directory not to be temporary + and that use of an OO approach may be required (thanks to David + Golden's annotation on CPAN). + + * Temp.pm (_randchar): Remove _randchar function (no longer used) + + * Temp.pm: Add note about File::Tempdir module + + * Temp.pm (new): Track pid used when file created and make sure + object destructor deletes the file only when the current pid + matches the original pid (RT#11067 again - thanks to Grousse) + Added new test (fork.t) to test this behaviour. + + * t/seekable.t: Add tests to verify fix for RT#22052 + + * Temp.pm (_is_safe): Correct cluck message to match uid check + (thanks to Alexey Tourbin RT #14218) + + * Temp.pm: Add note on use of binmode to modify encoding. (prompted + by Wolfgang Husmann) + + * Temp.pm (tempfile): Add TMPDIR flag to simplify + tempdir(template, DIR => File::Spec->tmpdir) and to remove confusion + for tempdir interface. (thanks to Brendan O'Dea - debian bug #351373) + + * META.yml: Update to v1.0 spec YAML spec. (thanks to Alexandr Ciornii RT# 23524) + + * Temp.pm: Localize $@ when using eval to prevent leakage (prompted by Zefram) + + * Makefile.PL: Support LICENSE in newer ExtUtils::MakeMaker implementations + (thanks to Alexandr Ciornii RT #23524) + + * t/seekable.t: Skip seek test on older IO::Seekable versions. + (thanks to Sebastien Aperghis-Tramoni RT #23524) + + * Temp.pm: Allow XXX replacement to run on perl 5.005 and 5.004. + (thanks to Sebastien Aperghis-Tramoni RT #23524) + + * Temp.pm: Fix range of random character determination such that the last character + in the list (_) will appear occassionally. (Thanks to Peter Dintelmann perl RT# 41345) + + * Temp.pm: Clarify error message when parent directory does not exist (thanks to + Peter Dintelmann perl RT # 41346) + + * Temp.pm: Carp::Heavy does not exist on older perls (eg 5.005) so wrap the require + in an eval (Thanks to Sebastien Aperghis-Tramoni, Jesse Vincent, Slaven Rezic + and Robin Barker RT #26841) + + * Temp.pm: Replace "new File::Temp" with "File::Temp->new" at the behest of H. Merijn + Brand + +0.18 2007-01-21 Tim Jenness + + * Temp.pm: Provide "cmp" overloading so File::Temp object can + be compared to filename directly. (Rafael Garcia-Suarez) + + * Temp.pm: Remove umask control (was not thread-safe) + (thanks to Peter Dintelmann, Gisle Aas) + + * t/cmp.t: New test file + + * Temp.pm: Export SEEK_* constants (Matt Lawrence RT #22052) + +0.17 2006-08-18 Tim Jenness + + * Temp.pm: Also inherit from IO::Seekable so that seek and tell + methods can work on filehandles (thanks to Rick Myers and Toby Corkindale). + + * t/seekable.t: Add test script from Rick Myers. + + * Temp.pm: Add note about forking and resetting the random number generator + to prevent multiple clashes of temp file names. (pointed out by Brent Cowgill) + + * Temp.pm: pre-emptively load Carp::Heavy. If we don't when we run out of file + handles and attempt to call croak() we get an error message telling + us that Carp::Heavy won't load rather than an error telling us we + have run out of file handles. (pointed out by bjoern_at_hoehrmann.de RT #14151) + + * Temp.pm: Remove eg. from comments and replace with e.g. In pod + replace "e.g." with "for example". (David Landgren) + + * Temp.pm: Correct synopsis concerning the arguments to the + File::Temp constructor (Peter Valdemar Moerch). + + * Temp.pm: Update documentation to note that croak() will be + called by tempfile() and File::Temp->new if a problem occurs (thanks to Steve + Hay for pointing this out). + + * Temp.pm: Sebastien Aperghis-Tramoni indicates that File::Temp + works with perl 5.004 so change the minimum perl version. (RT #14149) + + * Temp.pm: Use effective uid rather than real uid (Alexey Tourbin RT #14218) + +0.16 2005-02-22 Tim Jenness + + * Temp.pm: Remove spurious debug statement + +0.15 2005-02-21 Tim Jenness + + * Temp.pm (unlink_on_destroy): Add post-object creation method to + control whether the temp file will be unlinked when the object + goes out of scope. + + * Temp.pm: Increase maximum number of tries before aborting. + + * Temp.pm: Add $KEEP_ALL to allow the temporary files to be + retained whilst debugging (suggestion from Ed Avis [and others]). + + * Temp.pm: Temp files should have been opened O_NOFOLLOW rather + than O_FOLLOW! (thanks to Marc Tardif) + + * Temp.pm: Add cleanup() function so that temp files that would be + removed by an END block can be removed by a daemon. (RT wishlist + item #6928 by Robert Rothenberg) + + * Temp.pm: Force chmod on file before unlinking it. This can be a + problem on windows (see RT bug #6935). tempdir() has been fixed by + Slaven's earlier patch to change the rmtree arguments. + + * Temp.pm (top_system_uid): Add interix patch from Todd Vierling + + * Temp.pm (_gettemp): Pod patch from Steven Lembark clarifying the + error message associated with two few XXXXs + + * Temp.pm: Add note on forking and make sure that END blocks only + remove temporary files created by the current process ID (prompted + by Daniel Macks in RT bug #11067) + + * Temp.pm (cmpstat): Roman Vasicek reported problems with the _ + filehandle. Play it safe and remove that handle. (see RT bug #8822) + + * t/tempfile.t: Add test for write proteceted temp file (thanks to + Slaven Rezic) + + * Temp.pm (_can_do_level): Change argument to rmtree to make it + attempt to remove write-protected files on cleanup (thanks to + Slaven Rezic) + + * Temp.pm: Add note on binmode usage + +0.14 2003-08-16 Tim Jenness + + * t/object.t: Add test of OO interface and switch to Test::More + + * Temp.pm: Add object-oriented interface. + + * Temp.pm: mpeix fixes from Ken Hirsch + +0.13 2003-08-15 Tim Jenness + + * Temp.pm: Integrate doc fixes from bleadperl (Slaven Rezic and + Jeffrey Friedl) + + * Makefile.PL: Add INSTALLDIRS switch on perl version so that the + module installs into the correct place for perl 5.6.1 and newer. + + * Temp.pm: Synch with perl 5.8.0 v0.13 MacOS fixes (Chris Nandor) + +0.12 2001-02-22 Tim Jenness + + * t/posix.t: The unlink0 tests now skip on failure + + * t/mktemp.t: The unlink0 tests now skip on failure + + * Temp.pm (tmpfile): tmpfile returns undef on failure rather than + croaking. + + * Temp.pm: + -Add fix for CGI::Carp + [Thanks to John Labovitz ] + - Use error string to propogate reason rather than a carp + +0.11 2000-11-24 Tim Jenness + + * t/tempfile.t: Add a test to make sure the file is present after + close and another to use tempfile in a scalar context. + + * Temp.pm: Fix bug on NT with O_TEMPORARY causing the file to be + removed before the program exits. + + * Temp.pm: Incorporate fixes up to bleedperl 7825. Cross platform + fixes. + + * t/security.t: Incorporate fixes from bleedperl 7825 - adds more + cross platform support and more skips on the basis that this is + not testing your system security, just the module. + + * Temp.pm (_gettemp): Dont use VMS::Stdio if we want the file + to remain after closing. + + * Temp.pm (_can_do_level): cygwin patch + + * Temp.pm: Add OPENTEMPFLAGS to support UNLINK=>0 + More tweaks to VMS support (now uses VMS::Stdio) + +0.09 2000-07-26 Tim Jenness + + * README: Update for V0.09 + + * t/security.t: OS/2 can not do the security tests. + + * Temp.pm: Add Support for VMS and OS/2 + +0.08 2000-05-15 Tim Jenness + + * t/mktemp.t: Skip the test for unlink0 if it fails since in most + cases this indicates an NFS problem. + + * Temp.pm (_can_do_level): Add check to make sure an OS can handle + the required safe level + (safe_level): Check the level can be supported before allowing it + to change + (END): Change order of cleanup so that files are removed ahead of + temp dirs (since files may be in the temp dirs) + + * Temp.pm: Reorganize END block + + * t/tempfile.t: Correct tests for new position of END{} block + + * t/security.t: Correct tests for new position of END{} block + + * t/posix.t: add # to print output + + * t/tempfile.t: Add # to print output + + * t/mktemp.t: Add # to print output + + * t/security.t: Add # to print output + + * Temp.pm: Calculate OPENFLAGS outside of subroutine. This + improves speed of the commands by nearly a factor of 3. + (_replace_XX): Inline the character replacement code rather than + using _randchar subroutine. Improves performance by an additional 8%. + + * t/posix.t: Add explicit autoflush on filehandle + + * t/mktemp.t: Add explicit autoflush on filehandle + + * Temp.pm: (unlink0): Disallow HIGH and MEDIUM tests if running + perl 5.005 or earlier. + + * t/security.t: Specify perl version to allow for tests + + * Add support for perl 5.005 (remove 'our' and auto-vivifying file + handles). VERSION NUMBER NOW 0.07 + + * README: Update in preparation for V0.06 + + * Temp.pm (_deferred_unlink): Add new internal routine to centralise the + configuring of END blocks. This also fixes a bug where only the + first file was being unlinked in the END block (due to scoping). + + (_can_unlink_opened_file): Rename from _can_unlink. Will now + return false if running on Windows. + + (_is_verysafe): If _PC_CHOWN_RESTRICTED is not available assume + that "chown giveaway" is possible anyway. + + (unlink0): If can not unlink an open file, simply defer removal + until later. + + (_gettemp): Add O_NOINHERIT and O_TEMPORARY flags to sysopen if + they are available (Thanks to Tom Christiansen for this) + + * t/mktemp.t: Add test + + * t/posix.t: Add test + + * t/security.t: Add test + + * t/tempfile.t: Add test + +0.05 2000-03-14 Tim Jenness + + * Release v0.05 to CPAN diff --git a/INSTALL b/INSTALL new file mode 100644 index 0000000..94130d8 --- /dev/null +++ b/INSTALL @@ -0,0 +1,52 @@ +This is the Perl distribution File-Temp. + +Installing File-Temp is straightforward. + +## Installation with cpanm + +If you have cpanm, you only need one line: + + % cpanm File::Temp + +If it does not have permission to install modules to the current perl, cpanm +will automatically set up and install to a local::lib in your home directory. +See the local::lib documentation (https://metacpan.org/pod/local::lib) for +details on enabling it in your environment. + +## Installing with the CPAN shell + +Alternatively, if your CPAN shell is set up, you should just be able to do: + + % cpan File::Temp + +## Manual installation + +As a last resort, you can manually install it. Download the tarball, untar it, +then build it: + + % perl Makefile.PL + % make && make test + +Then install it: + + % make install + +On Windows platforms, you should use `dmake` or `nmake`, instead of `make`. + +If your perl is system-managed, you can create a local::lib in your home +directory to install modules to. For details, see the local::lib documentation: +https://metacpan.org/pod/local::lib + + +The prerequisites of this distribution will also have to be installed manually. The +prerequisites are listed in one of the files: `MYMETA.yml` or `MYMETA.json` generated +by running the manual build process described above. + +## Documentation + +File-Temp documentation is available as POD. +You can run `perldoc` from a shell to read the documentation: + + % perldoc File::Temp +For more information on installing Perl modules via CPAN, please see: +https://www.cpan.org/modules/INSTALL.html diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..c2ecebb --- /dev/null +++ b/LICENSE @@ -0,0 +1,379 @@ +This software is copyright (c) 2018 by Tim Jenness and the UK Particle Physics and Astronomy Research Council. + +This is free software; you can redistribute it and/or modify it under +the same terms as the Perl 5 programming language system itself. + +Terms of the Perl programming language system itself + +a) the GNU General Public License as published by the Free + Software Foundation; either version 1, or (at your option) any + later version, or +b) the "Artistic License" + +--- The GNU General Public License, Version 1, February 1989 --- + +This software is Copyright (c) 2018 by Tim Jenness and the UK Particle Physics and Astronomy Research Council. + +This is free software, licensed under: + + The GNU General Public License, Version 1, February 1989 + + GNU GENERAL PUBLIC LICENSE + Version 1, February 1989 + + Copyright (C) 1989 Free Software Foundation, Inc. + 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The license agreements of most software companies try to keep users +at the mercy of those companies. By contrast, our General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. The +General Public License applies to the Free Software Foundation's +software and to any other program whose authors commit to using it. +You can use it for your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Specifically, the General Public License is designed to make +sure that you have the freedom to give away or sell copies of free +software, that you receive source code or can get it if you want it, +that you can change the software or use pieces of it in new free +programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of a such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must tell them their rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any program or other work which +contains a notice placed by the copyright holder saying it may be +distributed under the terms of this General Public License. The +"Program", below, refers to any such program or work, and a "work based +on the Program" means either the Program or any work containing the +Program or a portion of it, either verbatim or with modifications. Each +licensee is addressed as "you". + + 1. You may copy and distribute verbatim copies of the Program's source +code as you receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice and +disclaimer of warranty; keep intact all the notices that refer to this +General Public License and to the absence of any warranty; and give any +other recipients of the Program a copy of this General Public License +along with the Program. You may charge a fee for the physical act of +transferring a copy. + + 2. You may modify your copy or copies of the Program or any portion of +it, and copy and distribute such modifications under the terms of Paragraph +1 above, provided that you also do the following: + + a) cause the modified files to carry prominent notices stating that + you changed the files and the date of any change; and + + b) cause the whole of any work that you distribute or publish, that + in whole or in part contains the Program or any part thereof, either + with or without modifications, to be licensed at no charge to all + third parties under the terms of this General Public License (except + that you may choose to grant warranty protection to some or all + third parties, at your option). + + c) If the modified program normally reads commands interactively when + run, you must cause it, when started running for such interactive use + in the simplest and most usual way, to print or display an + announcement including an appropriate copyright notice and a notice + that there is no warranty (or else, saying that you provide a + warranty) and that users may redistribute the program under these + conditions, and telling the user how to view a copy of this General + Public License. + + d) You may charge a fee for the physical act of transferring a + copy, and you may at your option offer warranty protection in + exchange for a fee. + +Mere aggregation of another independent work with the Program (or its +derivative) on a volume of a storage or distribution medium does not bring +the other work under the scope of these terms. + + 3. You may copy and distribute the Program (or a portion or derivative of +it, under Paragraph 2) in object code or executable form under the terms of +Paragraphs 1 and 2 above provided that you also do one of the following: + + a) accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of + Paragraphs 1 and 2 above; or, + + b) accompany it with a written offer, valid for at least three + years, to give any third party free (except for a nominal charge + for the cost of distribution) a complete machine-readable copy of the + corresponding source code, to be distributed under the terms of + Paragraphs 1 and 2 above; or, + + c) accompany it with the information you received as to where the + corresponding source code may be obtained. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form alone.) + +Source code for a work means the preferred form of the work for making +modifications to it. For an executable file, complete source code means +all the source code for all modules it contains; but, as a special +exception, it need not include source code for modules which are standard +libraries that accompany the operating system on which the executable +file runs, or for standard header files or definitions files that +accompany that operating system. + + 4. You may not copy, modify, sublicense, distribute or transfer the +Program except as expressly provided under this General Public License. +Any attempt otherwise to copy, modify, sublicense, distribute or transfer +the Program is void, and will automatically terminate your rights to use +the Program under this License. However, parties who have received +copies, or rights to use copies, from you under this General Public +License will not have their licenses terminated so long as such parties +remain in full compliance. + + 5. By copying, distributing or modifying the Program (or any work based +on the Program) you indicate your acceptance of this license to do so, +and all its terms and conditions. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the original +licensor to copy, distribute or modify the Program subject to these +terms and conditions. You may not impose any further restrictions on the +recipients' exercise of the rights granted herein. + + 7. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of the license which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +the license, you may choose any version ever published by the Free Software +Foundation. + + 8. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + Appendix: How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to humanity, the best way to achieve this is to make it +free software which everyone can redistribute and change under these +terms. + + To do so, attach the following notices to the program. It is safest to +attach them to the start of each source file to most effectively convey +the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) 19yy + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 1, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) 19xx name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the +appropriate parts of the General Public License. Of course, the +commands you use may be called something other than `show w' and `show +c'; they could even be mouse-clicks or menu items--whatever suits your +program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + program `Gnomovision' (a program to direct compilers to make passes + at assemblers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +That's all there is to it! + + +--- The Artistic License 1.0 --- + +This software is Copyright (c) 2018 by Tim Jenness and the UK Particle Physics and Astronomy Research Council. + +This is free software, licensed under: + + The Artistic License 1.0 + +The Artistic License + +Preamble + +The intent of this document is to state the conditions under which a Package +may be copied, such that the Copyright Holder maintains some semblance of +artistic control over the development of the package, while giving the users of +the package the right to use and distribute the Package in a more-or-less +customary fashion, plus the right to make reasonable modifications. + +Definitions: + + - "Package" refers to the collection of files distributed by the Copyright + Holder, and derivatives of that collection of files created through + textual modification. + - "Standard Version" refers to such a Package if it has not been modified, + or has been modified in accordance with the wishes of the Copyright + Holder. + - "Copyright Holder" is whoever is named in the copyright or copyrights for + the package. + - "You" is you, if you're thinking about copying or distributing this Package. + - "Reasonable copying fee" is whatever you can justify on the basis of media + cost, duplication charges, time of people involved, and so on. (You will + not be required to justify it to the Copyright Holder, but only to the + computing community at large as a market that must bear the fee.) + - "Freely Available" means that no fee is charged for the item itself, though + there may be fees involved in handling the item. It also means that + recipients of the item may redistribute it under the same conditions they + received it. + +1. You may make and give away verbatim copies of the source form of the +Standard Version of this Package without restriction, provided that you +duplicate all of the original copyright notices and associated disclaimers. + +2. You may apply bug fixes, portability fixes and other modifications derived +from the Public Domain or from the Copyright Holder. A Package modified in such +a way shall still be considered the Standard Version. + +3. You may otherwise modify your copy of this Package in any way, provided that +you insert a prominent notice in each changed file stating how and when you +changed that file, and provided that you do at least ONE of the following: + + a) place your modifications in the Public Domain or otherwise make them + Freely Available, such as by posting said modifications to Usenet or an + equivalent medium, or placing the modifications on a major archive site + such as ftp.uu.net, or by allowing the Copyright Holder to include your + modifications in the Standard Version of the Package. + + b) use the modified Package only within your corporation or organization. + + c) rename any non-standard executables so the names do not conflict with + standard executables, which must also be provided, and provide a separate + manual page for each non-standard executable that clearly documents how it + differs from the Standard Version. + + d) make other distribution arrangements with the Copyright Holder. + +4. You may distribute the programs of this Package in object code or executable +form, provided that you do at least ONE of the following: + + a) distribute a Standard Version of the executables and library files, + together with instructions (in the manual page or equivalent) on where to + get the Standard Version. + + b) accompany the distribution with the machine-readable source of the Package + with your modifications. + + c) accompany any non-standard executables with their corresponding Standard + Version executables, giving the non-standard executables non-standard + names, and clearly documenting the differences in manual pages (or + equivalent), together with instructions on where to get the Standard + Version. + + d) make other distribution arrangements with the Copyright Holder. + +5. You may charge a reasonable copying fee for any distribution of this +Package. You may charge any fee you choose for support of this Package. You +may not charge a fee for this Package itself. However, you may distribute this +Package in aggregate with other (possibly commercial) programs as part of a +larger (possibly commercial) software distribution provided that you do not +advertise this Package as a product of your own. + +6. The scripts and library files supplied as input to or produced as output +from the programs of this Package do not automatically fall under the copyright +of this Package, but belong to whomever generated them, and may be sold +commercially, and may be aggregated with this Package. + +7. C or perl subroutines supplied by you and linked into this Package shall not +be considered part of this Package. + +8. The name of the Copyright Holder may not be used to endorse or promote +products derived from this software without specific prior written permission. + +9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF +MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + +The End + diff --git a/MANIFEST b/MANIFEST new file mode 100644 index 0000000..12a2cfb --- /dev/null +++ b/MANIFEST @@ -0,0 +1,40 @@ +# This file was automatically generated by Dist::Zilla::Plugin::Manifest v6.012. +CONTRIBUTING +CONTRIBUTING.mkdn +Changes +INSTALL +LICENSE +MANIFEST +META.json +META.yml +Makefile.PL +README +README.mkdn +dist.ini +lib/File/Temp.pm +misc/benchmark.pl +misc/results.txt +t/00-report-prereqs.dd +t/00-report-prereqs.t +t/cmp.t +t/fork.t +t/lock.t +t/mktemp.t +t/object.t +t/posix.t +t/rmtree.t +t/security.t +t/seekable.t +t/tempfile.t +xt/author/00-compile.t +xt/author/changes_has_content.t +xt/author/kwalitee.t +xt/author/mojibake.t +xt/author/pod-coverage.t +xt/author/pod-no404s.t +xt/author/pod-spell.t +xt/author/pod-syntax.t +xt/author/portability.t +xt/release/changes_has_content.t +xt/release/cpan-changes.t +xt/release/distmeta.t diff --git a/META.json b/META.json new file mode 100644 index 0000000..a2494b6 --- /dev/null +++ b/META.json @@ -0,0 +1,1302 @@ +{ + "abstract" : "return name and handle of a temporary file safely", + "author" : [ + "Tim Jenness " + ], + "dynamic_config" : 1, + "generated_by" : "Dist::Zilla version 6.012, CPAN::Meta::Converter version 2.150010", + "license" : [ + "perl_5" + ], + "meta-spec" : { + "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", + "version" : 2 + }, + "name" : "File-Temp", + "no_index" : { + "directory" : [ + "t", + "xt" + ] + }, + "prereqs" : { + "configure" : { + "requires" : { + "ExtUtils::MakeMaker" : "0" + } + }, + "develop" : { + "recommends" : { + "Dist::Zilla::PluginBundle::Author::ETHER" : "0.141", + "Dist::Zilla::PluginBundle::Git::VersionManager" : "0.007" + }, + "requires" : { + "Encode" : "0", + "File::Spec" : "0", + "IO::Handle" : "0", + "IPC::Open3" : "0", + "Pod::Coverage::TrustPod" : "0", + "Pod::Wordlist" : "0", + "Test::CPAN::Changes" : "0.19", + "Test::CPAN::Meta" : "0", + "Test::Kwalitee" : "1.21", + "Test::Mojibake" : "0", + "Test::More" : "0.96", + "Test::Pod" : "1.41", + "Test::Pod::Coverage" : "1.08", + "Test::Pod::No404s" : "0", + "Test::Portability::Files" : "0", + "Test::Spelling" : "0.12", + "warnings" : "0" + } + }, + "runtime" : { + "requires" : { + "Carp" : "0", + "Carp::Heavy" : "0", + "Cwd" : "0", + "Exporter" : "5.57", + "Fcntl" : "1.03", + "File::Path" : "2.06", + "File::Spec" : "0.8", + "IO::Handle" : "0", + "IO::Seekable" : "0", + "POSIX" : "0", + "Scalar::Util" : "0", + "Symbol" : "0", + "constant" : "0", + "overload" : "0", + "parent" : "0.221", + "perl" : "5.006", + "strict" : "0" + } + }, + "test" : { + "recommends" : { + "CPAN::Meta" : "2.120900" + }, + "requires" : { + "ExtUtils::MakeMaker" : "0", + "File::Spec" : "0.8", + "FileHandle" : "0", + "Test::More" : "0", + "warnings" : "0" + } + }, + "x_Dist_Zilla" : { + "requires" : { + "Dist::Zilla" : "5", + "Dist::Zilla::Plugin::Authority" : "1.009", + "Dist::Zilla::Plugin::AutoMetaResources" : "0", + "Dist::Zilla::Plugin::AutoPrereqs" : "5.038", + "Dist::Zilla::Plugin::BumpVersionAfterRelease::Transitional" : "0.004", + "Dist::Zilla::Plugin::CheckIssues" : "0", + "Dist::Zilla::Plugin::CheckMetaResources" : "0", + "Dist::Zilla::Plugin::CheckPrereqsIndexed" : "0.019", + "Dist::Zilla::Plugin::CheckSelfDependency" : "0", + "Dist::Zilla::Plugin::CheckStrictVersion" : "0", + "Dist::Zilla::Plugin::ConfirmRelease" : "0", + "Dist::Zilla::Plugin::CopyFilesFromRelease" : "0", + "Dist::Zilla::Plugin::DualLife" : "0", + "Dist::Zilla::Plugin::EnsureLatestPerl" : "0", + "Dist::Zilla::Plugin::FileFinder::ByName" : "0", + "Dist::Zilla::Plugin::GenerateFile::FromShareDir" : "0", + "Dist::Zilla::Plugin::Git::Check" : "0", + "Dist::Zilla::Plugin::Git::CheckFor::CorrectBranch" : "0.004", + "Dist::Zilla::Plugin::Git::CheckFor::MergeConflicts" : "0", + "Dist::Zilla::Plugin::Git::Commit" : "2.020", + "Dist::Zilla::Plugin::Git::Contributors" : "0.029", + "Dist::Zilla::Plugin::Git::Describe" : "0.004", + "Dist::Zilla::Plugin::Git::GatherDir" : "2.016", + "Dist::Zilla::Plugin::Git::Push" : "0", + "Dist::Zilla::Plugin::Git::Remote::Check" : "0", + "Dist::Zilla::Plugin::Git::Tag" : "0", + "Dist::Zilla::Plugin::GitHub::Update" : "0.40", + "Dist::Zilla::Plugin::GithubMeta" : "0.54", + "Dist::Zilla::Plugin::InstallGuide" : "1.200005", + "Dist::Zilla::Plugin::Keywords" : "0.004", + "Dist::Zilla::Plugin::License" : "5.038", + "Dist::Zilla::Plugin::MakeMaker" : "0", + "Dist::Zilla::Plugin::Manifest" : "0", + "Dist::Zilla::Plugin::MetaConfig" : "0", + "Dist::Zilla::Plugin::MetaJSON" : "0", + "Dist::Zilla::Plugin::MetaNoIndex" : "0", + "Dist::Zilla::Plugin::MetaProvides::Package" : "1.15000002", + "Dist::Zilla::Plugin::MetaResources" : "0", + "Dist::Zilla::Plugin::MetaTests" : "0", + "Dist::Zilla::Plugin::MetaYAML" : "0", + "Dist::Zilla::Plugin::MojibakeTests" : "0.8", + "Dist::Zilla::Plugin::NextRelease" : "5.033", + "Dist::Zilla::Plugin::OSPrereqs" : "0", + "Dist::Zilla::Plugin::OnlyCorePrereqs" : "0.014", + "Dist::Zilla::Plugin::PodCoverageTests" : "5.040", + "Dist::Zilla::Plugin::PodSyntaxTests" : "5.040", + "Dist::Zilla::Plugin::PodWeaver" : "4.005", + "Dist::Zilla::Plugin::Prereqs" : "0", + "Dist::Zilla::Plugin::Prereqs::AuthorDeps" : "0.006", + "Dist::Zilla::Plugin::PromptIfStale" : "0", + "Dist::Zilla::Plugin::Readme" : "0", + "Dist::Zilla::Plugin::ReadmeAnyFromPod" : "0.142180", + "Dist::Zilla::Plugin::RewriteVersion::Transitional" : "0.004", + "Dist::Zilla::Plugin::Run::AfterBuild" : "0.041", + "Dist::Zilla::Plugin::Run::AfterRelease" : "0.038", + "Dist::Zilla::Plugin::RunExtraTests" : "0.024", + "Dist::Zilla::Plugin::StaticInstall" : "0.005", + "Dist::Zilla::Plugin::Test::CPAN::Changes" : "0.012", + "Dist::Zilla::Plugin::Test::ChangesHasContent" : "0", + "Dist::Zilla::Plugin::Test::Compile" : "2.039", + "Dist::Zilla::Plugin::Test::Kwalitee" : "2.10", + "Dist::Zilla::Plugin::Test::Pod::No404s" : "1.003", + "Dist::Zilla::Plugin::Test::PodSpelling" : "2.006003", + "Dist::Zilla::Plugin::Test::Portability" : "2.000007", + "Dist::Zilla::Plugin::Test::ReportPrereqs" : "0.022", + "Dist::Zilla::Plugin::TestRelease" : "0", + "Dist::Zilla::Plugin::UploadToCPAN" : "0", + "Dist::Zilla::Plugin::UseUnsafeInc" : "0", + "Dist::Zilla::PluginBundle::Author::ETHER" : "0.119", + "Dist::Zilla::PluginBundle::Git::VersionManager" : "0.007", + "Software::License::Perl_5" : "0" + } + } + }, + "provides" : { + "File::Temp" : { + "file" : "lib/File/Temp.pm", + "version" : "0.2306" + }, + "File::Temp::Dir" : { + "file" : "lib/File/Temp.pm", + "version" : "0.2306" + } + }, + "release_status" : "stable", + "resources" : { + "bugtracker" : { + "mailto" : "bug-File-Temp@rt.cpan.org", + "web" : "https://rt.cpan.org/Public/Dist/Display.html?Name=File-Temp" + }, + "homepage" : "https://github.com/Perl-Toolchain-Gang/File-Temp", + "repository" : { + "type" : "git", + "url" : "https://github.com/Perl-Toolchain-Gang/File-Temp.git", + "web" : "https://github.com/Perl-Toolchain-Gang/File-Temp" + }, + "x_IRC" : "irc://irc.perl.org/#toolchain", + "x_MailingList" : "http://lists.perl.org/list/cpan-workers.html" + }, + "version" : "0.2306", + "x_Dist_Zilla" : { + "perl" : { + "version" : "5.028000" + }, + "plugins" : [ + { + "class" : "Dist::Zilla::Plugin::Prereqs", + "config" : { + "Dist::Zilla::Plugin::Prereqs" : { + "phase" : "develop", + "type" : "recommends" + } + }, + "name" : "@Author::ETHER/pluginbundle version", + "version" : "6.012" + }, + { + "class" : "Dist::Zilla::Plugin::PromptIfStale", + "config" : { + "Dist::Zilla::Plugin::PromptIfStale" : { + "check_all_plugins" : 0, + "check_all_prereqs" : 0, + "modules" : [ + "Dist::Zilla::PluginBundle::Author::ETHER" + ], + "phase" : "build", + "run_under_travis" : 0, + "skip" : [] + } + }, + "name" : "@Author::ETHER/stale modules, build", + "version" : "0.055" + }, + { + "class" : "Dist::Zilla::Plugin::FileFinder::ByName", + "name" : "@Author::ETHER/Examples", + "version" : "6.012" + }, + { + "class" : "Dist::Zilla::Plugin::Git::GatherDir", + "config" : { + "Dist::Zilla::Plugin::GatherDir" : { + "exclude_filename" : [ + "CONTRIBUTING", + "INSTALL", + "LICENSE", + "Makefile.PL", + "README.pod" + ], + "exclude_match" : [], + "follow_symlinks" : 0, + "include_dotfiles" : 0, + "prefix" : "", + "prune_directory" : [], + "root" : "." + }, + "Dist::Zilla::Plugin::Git::GatherDir" : { + "include_untracked" : 0 + } + }, + "name" : "@Author::ETHER/Git::GatherDir", + "version" : "2.045" + }, + { + "class" : "Dist::Zilla::Plugin::MetaYAML", + "name" : "@Author::ETHER/MetaYAML", + "version" : "6.012" + }, + { + "class" : "Dist::Zilla::Plugin::MetaJSON", + "name" : "@Author::ETHER/MetaJSON", + "version" : "6.012" + }, + { + "class" : "Dist::Zilla::Plugin::Readme", + "name" : "@Author::ETHER/Readme", + "version" : "6.012" + }, + { + "class" : "Dist::Zilla::Plugin::Manifest", + "name" : "@Author::ETHER/Manifest", + "version" : "6.012" + }, + { + "class" : "Dist::Zilla::Plugin::License", + "name" : "@Author::ETHER/License", + "version" : "6.012" + }, + { + "class" : "Dist::Zilla::Plugin::GenerateFile::FromShareDir", + "config" : { + "Dist::Zilla::Plugin::GenerateFile::FromShareDir" : { + "destination_filename" : "CONTRIBUTING", + "dist" : "Dist-Zilla-PluginBundle-Author-ETHER", + "encoding" : "UTF-8", + "has_xs" : 0, + "location" : "build", + "source_filename" : "CONTRIBUTING" + }, + "Dist::Zilla::Role::RepoFileInjector" : { + "allow_overwrite" : 1, + "repo_root" : ".", + "version" : "0.009" + } + }, + "name" : "@Author::ETHER/generate CONTRIBUTING", + "version" : "0.014" + }, + { + "class" : "Dist::Zilla::Plugin::InstallGuide", + "name" : "@Author::ETHER/InstallGuide", + "version" : "1.200009" + }, + { + "class" : "Dist::Zilla::Plugin::Test::Compile", + "config" : { + "Dist::Zilla::Plugin::Test::Compile" : { + "bail_out_on_fail" : 1, + "fail_on_warning" : "author", + "fake_home" : 0, + "filename" : "xt/author/00-compile.t", + "module_finder" : [ + ":InstallModules" + ], + "needs_display" : 0, + "phase" : "develop", + "script_finder" : [ + ":PerlExecFiles", + "@Author::ETHER/Examples" + ], + "skips" : [], + "switch" : [] + } + }, + "name" : "@Author::ETHER/Test::Compile", + "version" : "2.058" + }, + { + "class" : "Dist::Zilla::Plugin::MetaTests", + "name" : "@Author::ETHER/MetaTests", + "version" : "6.012" + }, + { + "class" : "Dist::Zilla::Plugin::Test::CPAN::Changes", + "config" : { + "Dist::Zilla::Plugin::Test::CPAN::Changes" : { + "changelog" : "Changes" + } + }, + "name" : "@Author::ETHER/Test::CPAN::Changes", + "version" : "0.012" + }, + { + "class" : "Dist::Zilla::Plugin::GenerateFile::FromShareDir", + "config" : { + "Dist::Zilla::Plugin::GenerateFile::FromShareDir" : { + "destination_filename" : "xt/author/changes_has_content.t", + "dist" : "Dist-Zilla-PluginBundle-Author-ETHER", + "encoding" : "UTF-8", + "location" : "build", + "source_filename" : "changes_has_content.t" + }, + "Dist::Zilla::Role::RepoFileInjector" : { + "allow_overwrite" : 1, + "repo_root" : ".", + "version" : "0.009" + } + }, + "name" : "@Author::ETHER/generate xt/author/changes_has_content.t", + "version" : "0.014" + }, + { + "class" : "Dist::Zilla::Plugin::Test::ChangesHasContent", + "name" : "@Author::ETHER/Test::ChangesHasContent", + "version" : "0.011" + }, + { + "class" : "Dist::Zilla::Plugin::PodSyntaxTests", + "name" : "@Author::ETHER/PodSyntaxTests", + "version" : "6.012" + }, + { + "class" : "Dist::Zilla::Plugin::PodCoverageTests", + "name" : "@Author::ETHER/PodCoverageTests", + "version" : "6.012" + }, + { + "class" : "Dist::Zilla::Plugin::Test::PodSpelling", + "config" : { + "Dist::Zilla::Plugin::Test::PodSpelling" : { + "directories" : [ + "examples", + "lib", + "script", + "t", + "xt" + ], + "spell_cmd" : "", + "stopwords" : [ + "APIs", + "Christiansen", + "EXLOCK", + "NFS", + "OpenBSD", + "POSIX", + "Ryde", + "TMPDIR", + "Tilly", + "TopSystemUID", + "UNLINK", + "chdir'ed", + "cmpstat", + "destructor", + "dirname", + "endeavour", + "et", + "irc", + "isa", + "newdir", + "numifies", + "unix", + "unlink", + "unlinked", + "unlinking" + ], + "wordlist" : "Pod::Wordlist" + } + }, + "name" : "@Author::ETHER/Test::PodSpelling", + "version" : "2.007005" + }, + { + "class" : "Dist::Zilla::Plugin::Test::Pod::No404s", + "name" : "@Author::ETHER/Test::Pod::No404s", + "version" : "1.004" + }, + { + "class" : "Dist::Zilla::Plugin::Test::Kwalitee", + "config" : { + "Dist::Zilla::Plugin::Test::Kwalitee" : { + "filename" : "xt/author/kwalitee.t", + "skiptest" : [] + } + }, + "name" : "@Author::ETHER/Test::Kwalitee", + "version" : "2.12" + }, + { + "class" : "Dist::Zilla::Plugin::MojibakeTests", + "name" : "@Author::ETHER/MojibakeTests", + "version" : "0.8" + }, + { + "class" : "Dist::Zilla::Plugin::Test::ReportPrereqs", + "name" : "@Author::ETHER/Test::ReportPrereqs", + "version" : "0.027" + }, + { + "class" : "Dist::Zilla::Plugin::Test::Portability", + "config" : { + "Dist::Zilla::Plugin::Test::Portability" : { + "options" : "" + } + }, + "name" : "@Author::ETHER/Test::Portability", + "version" : "2.001000" + }, + { + "class" : "Dist::Zilla::Plugin::Git::Describe", + "name" : "@Author::ETHER/Git::Describe", + "version" : "0.007" + }, + { + "class" : "Dist::Zilla::Plugin::PodWeaver", + "config" : { + "Dist::Zilla::Plugin::PodWeaver" : { + "config_plugins" : [ + "@Author::ETHER" + ], + "finder" : [ + ":InstallModules", + ":ExecFiles" + ], + "plugins" : [ + { + "class" : "Pod::Weaver::Plugin::EnsurePod5", + "name" : "@Author::ETHER/EnsurePod5", + "version" : "4.015" + }, + { + "class" : "Pod::Weaver::Plugin::H1Nester", + "name" : "@Author::ETHER/H1Nester", + "version" : "4.015" + }, + { + "class" : "Pod::Weaver::Plugin::SingleEncoding", + "name" : "@Author::ETHER/SingleEncoding", + "version" : "4.015" + }, + { + "class" : "Pod::Weaver::Plugin::Transformer", + "name" : "@Author::ETHER/List", + "version" : "4.015" + }, + { + "class" : "Pod::Weaver::Plugin::Transformer", + "name" : "@Author::ETHER/Verbatim", + "version" : "4.015" + }, + { + "class" : "Pod::Weaver::Section::Region", + "name" : "@Author::ETHER/header", + "version" : "4.015" + }, + { + "class" : "Pod::Weaver::Section::Name", + "name" : "@Author::ETHER/Name", + "version" : "4.015" + }, + { + "class" : "Pod::Weaver::Section::Version", + "name" : "@Author::ETHER/Version", + "version" : "4.015" + }, + { + "class" : "Pod::Weaver::Section::Region", + "name" : "@Author::ETHER/prelude", + "version" : "4.015" + }, + { + "class" : "Pod::Weaver::Section::Generic", + "name" : "SYNOPSIS", + "version" : "4.015" + }, + { + "class" : "Pod::Weaver::Section::Generic", + "name" : "DESCRIPTION", + "version" : "4.015" + }, + { + "class" : "Pod::Weaver::Section::Generic", + "name" : "OVERVIEW", + "version" : "4.015" + }, + { + "class" : "Pod::Weaver::Section::Collect", + "name" : "ATTRIBUTES", + "version" : "4.015" + }, + { + "class" : "Pod::Weaver::Section::Collect", + "name" : "METHODS", + "version" : "4.015" + }, + { + "class" : "Pod::Weaver::Section::Collect", + "name" : "FUNCTIONS", + "version" : "4.015" + }, + { + "class" : "Pod::Weaver::Section::Collect", + "name" : "TYPES", + "version" : "4.015" + }, + { + "class" : "Pod::Weaver::Section::Leftovers", + "name" : "@Author::ETHER/Leftovers", + "version" : "4.015" + }, + { + "class" : "Pod::Weaver::Section::Region", + "name" : "@Author::ETHER/postlude", + "version" : "4.015" + }, + { + "class" : "Pod::Weaver::Section::GenerateSection", + "name" : "@Author::ETHER/generate SUPPORT", + "version" : "1.06" + }, + { + "class" : "Pod::Weaver::Section::AllowOverride", + "name" : "@Author::ETHER/allow override SUPPORT", + "version" : "0.05" + }, + { + "class" : "Pod::Weaver::Section::Authors", + "name" : "@Author::ETHER/Authors", + "version" : "4.015" + }, + { + "class" : "Pod::Weaver::Section::Contributors", + "name" : "@Author::ETHER/Contributors", + "version" : "0.009" + }, + { + "class" : "Pod::Weaver::Section::Legal", + "name" : "@Author::ETHER/Legal", + "version" : "4.015" + }, + { + "class" : "Pod::Weaver::Section::Region", + "name" : "@Author::ETHER/footer", + "version" : "4.015" + } + ] + } + }, + "name" : "@Author::ETHER/PodWeaver", + "version" : "4.008" + }, + { + "class" : "Dist::Zilla::Plugin::GithubMeta", + "name" : "@Author::ETHER/GithubMeta", + "version" : "0.58" + }, + { + "class" : "Dist::Zilla::Plugin::AutoMetaResources", + "name" : "@Author::ETHER/AutoMetaResources", + "version" : "1.21" + }, + { + "class" : "Dist::Zilla::Plugin::Authority", + "name" : "@Author::ETHER/Authority", + "version" : "1.009" + }, + { + "class" : "Dist::Zilla::Plugin::MetaNoIndex", + "name" : "@Author::ETHER/MetaNoIndex", + "version" : "6.012" + }, + { + "class" : "Dist::Zilla::Plugin::MetaProvides::Package", + "config" : { + "Dist::Zilla::Plugin::MetaProvides::Package" : { + "finder" : [ + ":InstallModules" + ], + "finder_objects" : [ + { + "class" : "Dist::Zilla::Plugin::FinderCode", + "name" : ":InstallModules", + "version" : "6.012" + } + ], + "include_underscores" : 0 + }, + "Dist::Zilla::Role::MetaProvider::Provider" : { + "$Dist::Zilla::Role::MetaProvider::Provider::VERSION" : "2.002004", + "inherit_missing" : 0, + "inherit_version" : 0, + "meta_noindex" : 1 + }, + "Dist::Zilla::Role::ModuleMetadata" : { + "Module::Metadata" : "1.000033", + "version" : "0.006" + } + }, + "name" : "@Author::ETHER/MetaProvides::Package", + "version" : "2.004003" + }, + { + "class" : "Dist::Zilla::Plugin::MetaConfig", + "name" : "@Author::ETHER/MetaConfig", + "version" : "6.012" + }, + { + "class" : "Dist::Zilla::Plugin::Keywords", + "config" : { + "Dist::Zilla::Plugin::Keywords" : { + "keywords" : [] + } + }, + "name" : "@Author::ETHER/Keywords", + "version" : "0.007" + }, + { + "class" : "Dist::Zilla::Plugin::UseUnsafeInc", + "config" : { + "Dist::Zilla::Plugin::UseUnsafeInc" : { + "dot_in_INC" : 0 + } + }, + "name" : "@Author::ETHER/UseUnsafeInc", + "version" : "0.001" + }, + { + "class" : "Dist::Zilla::Plugin::AutoPrereqs", + "name" : "@Author::ETHER/AutoPrereqs", + "version" : "6.012" + }, + { + "class" : "Dist::Zilla::Plugin::Prereqs::AuthorDeps", + "name" : "@Author::ETHER/Prereqs::AuthorDeps", + "version" : "0.006" + }, + { + "class" : "Dist::Zilla::Plugin::MakeMaker", + "config" : { + "Dist::Zilla::Role::TestRunner" : { + "default_jobs" : 9 + } + }, + "name" : "@Author::ETHER/MakeMaker", + "version" : "6.012" + }, + { + "class" : "Dist::Zilla::Plugin::Git::Contributors", + "config" : { + "Dist::Zilla::Plugin::Git::Contributors" : { + "git_version" : "2.17.0", + "include_authors" : 0, + "include_releaser" : 1, + "order_by" : "commits", + "paths" : [] + } + }, + "name" : "@Author::ETHER/Git::Contributors", + "version" : "0.034" + }, + { + "class" : "Dist::Zilla::Plugin::StaticInstall", + "config" : { + "Dist::Zilla::Plugin::StaticInstall" : { + "dry_run" : 0, + "mode" : "off" + } + }, + "name" : "@Author::ETHER/StaticInstall", + "version" : "0.011" + }, + { + "class" : "Dist::Zilla::Plugin::RunExtraTests", + "config" : { + "Dist::Zilla::Role::TestRunner" : { + "default_jobs" : 9 + } + }, + "name" : "@Author::ETHER/RunExtraTests", + "version" : "0.029" + }, + { + "class" : "Dist::Zilla::Plugin::CheckSelfDependency", + "config" : { + "Dist::Zilla::Plugin::CheckSelfDependency" : { + "finder" : [ + ":InstallModules" + ] + }, + "Dist::Zilla::Role::ModuleMetadata" : { + "Module::Metadata" : "1.000033", + "version" : "0.006" + } + }, + "name" : "@Author::ETHER/CheckSelfDependency", + "version" : "0.011" + }, + { + "class" : "Dist::Zilla::Plugin::Run::AfterBuild", + "config" : { + "Dist::Zilla::Plugin::Run::Role::Runner" : { + "fatal_errors" : 1, + "quiet" : 1, + "run" : [ + "bash -c \"test -e .ackrc && grep -q -- '--ignore-dir=.latest' .ackrc || echo '--ignore-dir=.latest' >> .ackrc; if [[ `dirname '%d'` != .build ]]; then test -e .ackrc && grep -q -- '--ignore-dir=%d' .ackrc || echo '--ignore-dir=%d' >> .ackrc; fi\"" + ], + "version" : "0.047" + } + }, + "name" : "@Author::ETHER/.ackrc", + "version" : "0.047" + }, + { + "class" : "Dist::Zilla::Plugin::Run::AfterBuild", + "config" : { + "Dist::Zilla::Plugin::Run::Role::Runner" : { + "eval" : [ + "if ('%d' =~ /^%n-[.[:xdigit:]]+$/) { unlink '.latest'; symlink '%d', '.latest'; }" + ], + "fatal_errors" : 0, + "quiet" : 1, + "version" : "0.047" + } + }, + "name" : "@Author::ETHER/.latest", + "version" : "0.047" + }, + { + "class" : "Dist::Zilla::Plugin::CheckStrictVersion", + "name" : "@Author::ETHER/CheckStrictVersion", + "version" : "0.001" + }, + { + "class" : "Dist::Zilla::Plugin::CheckMetaResources", + "name" : "@Author::ETHER/CheckMetaResources", + "version" : "0.001" + }, + { + "class" : "Dist::Zilla::Plugin::EnsureLatestPerl", + "config" : { + "Dist::Zilla::Plugin::EnsureLatestPerl" : { + "Module::CoreList" : "5.20180622" + } + }, + "name" : "@Author::ETHER/EnsureLatestPerl", + "version" : "0.008" + }, + { + "class" : "Dist::Zilla::Plugin::PromptIfStale", + "config" : { + "Dist::Zilla::Plugin::PromptIfStale" : { + "check_all_plugins" : 1, + "check_all_prereqs" : 1, + "modules" : [], + "phase" : "release", + "run_under_travis" : 0, + "skip" : [] + } + }, + "name" : "@Author::ETHER/stale modules, release", + "version" : "0.055" + }, + { + "class" : "Dist::Zilla::Plugin::Git::Check", + "config" : { + "Dist::Zilla::Plugin::Git::Check" : { + "untracked_files" : "die" + }, + "Dist::Zilla::Role::Git::DirtyFiles" : { + "allow_dirty" : [], + "allow_dirty_match" : [], + "changelog" : "Changes" + }, + "Dist::Zilla::Role::Git::Repo" : { + "git_version" : "2.17.0", + "repo_root" : "." + } + }, + "name" : "@Author::ETHER/initial check", + "version" : "2.045" + }, + { + "class" : "Dist::Zilla::Plugin::Git::CheckFor::MergeConflicts", + "config" : { + "Dist::Zilla::Role::Git::Repo" : { + "git_version" : "2.17.0", + "repo_root" : "." + } + }, + "name" : "@Author::ETHER/Git::CheckFor::MergeConflicts", + "version" : "0.014" + }, + { + "class" : "Dist::Zilla::Plugin::Git::CheckFor::CorrectBranch", + "config" : { + "Dist::Zilla::Role::Git::Repo" : { + "git_version" : "2.17.0", + "repo_root" : "." + } + }, + "name" : "@Author::ETHER/Git::CheckFor::CorrectBranch", + "version" : "0.014" + }, + { + "class" : "Dist::Zilla::Plugin::Git::Remote::Check", + "name" : "@Author::ETHER/Git::Remote::Check", + "version" : "0.1.2" + }, + { + "class" : "Dist::Zilla::Plugin::CheckPrereqsIndexed", + "name" : "@Author::ETHER/CheckPrereqsIndexed", + "version" : "0.020" + }, + { + "class" : "Dist::Zilla::Plugin::TestRelease", + "name" : "@Author::ETHER/TestRelease", + "version" : "6.012" + }, + { + "class" : "Dist::Zilla::Plugin::Git::Check", + "config" : { + "Dist::Zilla::Plugin::Git::Check" : { + "untracked_files" : "die" + }, + "Dist::Zilla::Role::Git::DirtyFiles" : { + "allow_dirty" : [], + "allow_dirty_match" : [], + "changelog" : "Changes" + }, + "Dist::Zilla::Role::Git::Repo" : { + "git_version" : "2.17.0", + "repo_root" : "." + } + }, + "name" : "@Author::ETHER/after tests", + "version" : "2.045" + }, + { + "class" : "Dist::Zilla::Plugin::CheckIssues", + "name" : "@Author::ETHER/CheckIssues", + "version" : "0.010" + }, + { + "class" : "Dist::Zilla::Plugin::UploadToCPAN", + "name" : "@Author::ETHER/UploadToCPAN", + "version" : "6.012" + }, + { + "class" : "Dist::Zilla::Plugin::CopyFilesFromRelease", + "config" : { + "Dist::Zilla::Plugin::CopyFilesFromRelease" : { + "filename" : [ + "CONTRIBUTING", + "INSTALL", + "LICENCE", + "LICENSE", + "ppport.h" + ], + "match" : [] + } + }, + "name" : "@Author::ETHER/copy generated files", + "version" : "0.007" + }, + { + "class" : "Dist::Zilla::Plugin::ReadmeAnyFromPod", + "config" : { + "Dist::Zilla::Role::FileWatcher" : { + "version" : "0.006" + } + }, + "name" : "@Author::ETHER/ReadmeAnyFromPod", + "version" : "0.163250" + }, + { + "class" : "Dist::Zilla::Plugin::Prereqs", + "config" : { + "Dist::Zilla::Plugin::Prereqs" : { + "phase" : "develop", + "type" : "recommends" + } + }, + "name" : "@Author::ETHER/@Git::VersionManager/pluginbundle version", + "version" : "6.012" + }, + { + "class" : "Dist::Zilla::Plugin::RewriteVersion::Transitional", + "config" : { + "Dist::Zilla::Plugin::RewriteVersion" : { + "add_tarball_name" : 0, + "finders" : [ + ":ExecFiles", + ":InstallModules" + ], + "global" : 1, + "skip_version_provider" : 0 + }, + "Dist::Zilla::Plugin::RewriteVersion::Transitional" : {} + }, + "name" : "@Author::ETHER/@Git::VersionManager/RewriteVersion::Transitional", + "version" : "0.009" + }, + { + "class" : "Dist::Zilla::Plugin::MetaProvides::Update", + "name" : "@Author::ETHER/@Git::VersionManager/MetaProvides::Update", + "version" : "0.007" + }, + { + "class" : "Dist::Zilla::Plugin::CopyFilesFromRelease", + "config" : { + "Dist::Zilla::Plugin::CopyFilesFromRelease" : { + "filename" : [ + "Changes" + ], + "match" : [] + } + }, + "name" : "@Author::ETHER/@Git::VersionManager/CopyFilesFromRelease", + "version" : "0.007" + }, + { + "class" : "Dist::Zilla::Plugin::Git::Commit", + "config" : { + "Dist::Zilla::Plugin::Git::Commit" : { + "add_files_in" : [ + "." + ], + "commit_msg" : "%N-%v%t%n%n%c" + }, + "Dist::Zilla::Role::Git::DirtyFiles" : { + "allow_dirty" : [ + "CONTRIBUTING", + "Changes", + "INSTALL", + "LICENSE", + "README.pod" + ], + "allow_dirty_match" : [], + "changelog" : "Changes" + }, + "Dist::Zilla::Role::Git::Repo" : { + "git_version" : "2.17.0", + "repo_root" : "." + }, + "Dist::Zilla::Role::Git::StringFormatter" : { + "time_zone" : "local" + } + }, + "name" : "@Author::ETHER/@Git::VersionManager/release snapshot", + "version" : "2.045" + }, + { + "class" : "Dist::Zilla::Plugin::Git::Tag", + "config" : { + "Dist::Zilla::Plugin::Git::Tag" : { + "branch" : null, + "changelog" : "Changes", + "signed" : 0, + "tag" : "v0.2306", + "tag_format" : "v%v", + "tag_message" : "v%v%t" + }, + "Dist::Zilla::Role::Git::Repo" : { + "git_version" : "2.17.0", + "repo_root" : "." + }, + "Dist::Zilla::Role::Git::StringFormatter" : { + "time_zone" : "local" + } + }, + "name" : "@Author::ETHER/@Git::VersionManager/Git::Tag", + "version" : "2.045" + }, + { + "class" : "Dist::Zilla::Plugin::BumpVersionAfterRelease::Transitional", + "config" : { + "Dist::Zilla::Plugin::BumpVersionAfterRelease" : { + "finders" : [ + ":ExecFiles", + ":InstallModules" + ], + "global" : 1, + "munge_makefile_pl" : 1 + }, + "Dist::Zilla::Plugin::BumpVersionAfterRelease::Transitional" : {} + }, + "name" : "@Author::ETHER/@Git::VersionManager/BumpVersionAfterRelease::Transitional", + "version" : "0.009" + }, + { + "class" : "Dist::Zilla::Plugin::NextRelease", + "name" : "@Author::ETHER/@Git::VersionManager/NextRelease", + "version" : "6.012" + }, + { + "class" : "Dist::Zilla::Plugin::Git::Commit", + "config" : { + "Dist::Zilla::Plugin::Git::Commit" : { + "add_files_in" : [], + "commit_msg" : "increment $VERSION after %v release" + }, + "Dist::Zilla::Role::Git::DirtyFiles" : { + "allow_dirty" : [ + "Build.PL", + "Changes", + "Makefile.PL" + ], + "allow_dirty_match" : [ + "(?^:^lib/.*\\.pm$)" + ], + "changelog" : "Changes" + }, + "Dist::Zilla::Role::Git::Repo" : { + "git_version" : "2.17.0", + "repo_root" : "." + }, + "Dist::Zilla::Role::Git::StringFormatter" : { + "time_zone" : "local" + } + }, + "name" : "@Author::ETHER/@Git::VersionManager/post-release commit", + "version" : "2.045" + }, + { + "class" : "Dist::Zilla::Plugin::Prereqs", + "config" : { + "Dist::Zilla::Plugin::Prereqs" : { + "phase" : "x_Dist_Zilla", + "type" : "requires" + } + }, + "name" : "@Author::ETHER/@Git::VersionManager/prereqs for @Git::VersionManager", + "version" : "6.012" + }, + { + "class" : "Dist::Zilla::Plugin::Git::Push", + "config" : { + "Dist::Zilla::Plugin::Git::Push" : { + "push_to" : [ + "origin" + ], + "remotes_must_exist" : 1 + }, + "Dist::Zilla::Role::Git::Repo" : { + "git_version" : "2.17.0", + "repo_root" : "." + } + }, + "name" : "@Author::ETHER/Git::Push", + "version" : "2.045" + }, + { + "class" : "Dist::Zilla::Plugin::GitHub::Update", + "config" : { + "Dist::Zilla::Plugin::GitHub::Update" : { + "metacpan" : 1 + } + }, + "name" : "@Author::ETHER/GitHub::Update", + "version" : "0.45" + }, + { + "class" : "Dist::Zilla::Plugin::Run::AfterRelease", + "config" : { + "Dist::Zilla::Plugin::Run::Role::Runner" : { + "fatal_errors" : 0, + "quiet" : 0, + "run" : [ + "REDACTED" + ], + "version" : "0.047" + } + }, + "name" : "@Author::ETHER/install release", + "version" : "0.047" + }, + { + "class" : "Dist::Zilla::Plugin::Run::AfterRelease", + "config" : { + "Dist::Zilla::Plugin::Run::Role::Runner" : { + "eval" : [ + "print \"release complete!\\xa\"" + ], + "fatal_errors" : 1, + "quiet" : 1, + "version" : "0.047" + } + }, + "name" : "@Author::ETHER/release complete", + "version" : "0.047" + }, + { + "class" : "Dist::Zilla::Plugin::ConfirmRelease", + "name" : "@Author::ETHER/ConfirmRelease", + "version" : "6.012" + }, + { + "class" : "Dist::Zilla::Plugin::Prereqs", + "config" : { + "Dist::Zilla::Plugin::Prereqs" : { + "phase" : "x_Dist_Zilla", + "type" : "requires" + } + }, + "name" : "@Author::ETHER/prereqs for @Author::ETHER", + "version" : "6.012" + }, + { + "class" : "Dist::Zilla::Plugin::OSPrereqs", + "config" : { + "Dist::Zilla::Plugin::OSPrereqs" : { + "os" : "VMS" + } + }, + "name" : "VMS", + "version" : "0.011" + }, + { + "class" : "Dist::Zilla::Plugin::OSPrereqs", + "config" : { + "Dist::Zilla::Plugin::OSPrereqs" : { + "os" : "MSWin32" + } + }, + "name" : "MSWin32", + "version" : "0.011" + }, + { + "class" : "Dist::Zilla::Plugin::OnlyCorePrereqs", + "config" : { + "Dist::Zilla::Plugin::OnlyCorePrereqs" : { + "also_disallow" : [], + "check_dual_life_versions" : "0", + "deprecated_ok" : 0, + "phases" : [ + "configure", + "build", + "runtime", + "test" + ], + "skips" : [], + "starting_version" : "5.008003" + } + }, + "name" : "OnlyCorePrereqs", + "version" : "0.024" + }, + { + "class" : "Dist::Zilla::Plugin::DualLife", + "config" : { + "Dist::Zilla::Plugin::DualLife" : { + "entered_core" : "5.006001", + "eumm_bundled" : 0 + }, + "Dist::Zilla::Role::ModuleMetadata" : { + "Module::Metadata" : "1.000033", + "version" : "0.006" + } + }, + "name" : "DualLife", + "version" : "0.07" + }, + { + "class" : "Dist::Zilla::Plugin::MetaResources", + "name" : "MetaResources", + "version" : "6.012" + }, + { + "class" : "Dist::Zilla::Plugin::FinderCode", + "name" : ":InstallModules", + "version" : "6.012" + }, + { + "class" : "Dist::Zilla::Plugin::FinderCode", + "name" : ":IncModules", + "version" : "6.012" + }, + { + "class" : "Dist::Zilla::Plugin::FinderCode", + "name" : ":TestFiles", + "version" : "6.012" + }, + { + "class" : "Dist::Zilla::Plugin::FinderCode", + "name" : ":ExtraTestFiles", + "version" : "6.012" + }, + { + "class" : "Dist::Zilla::Plugin::FinderCode", + "name" : ":ExecFiles", + "version" : "6.012" + }, + { + "class" : "Dist::Zilla::Plugin::FinderCode", + "name" : ":PerlExecFiles", + "version" : "6.012" + }, + { + "class" : "Dist::Zilla::Plugin::FinderCode", + "name" : ":ShareFiles", + "version" : "6.012" + }, + { + "class" : "Dist::Zilla::Plugin::FinderCode", + "name" : ":MainModule", + "version" : "6.012" + }, + { + "class" : "Dist::Zilla::Plugin::FinderCode", + "name" : ":AllFiles", + "version" : "6.012" + }, + { + "class" : "Dist::Zilla::Plugin::FinderCode", + "name" : ":NoFiles", + "version" : "6.012" + }, + { + "class" : "Dist::Zilla::Plugin::VerifyPhases", + "name" : "@Author::ETHER/PHASE VERIFICATION", + "version" : "0.016" + } + ], + "zilla" : { + "class" : "Dist::Zilla::Dist::Builder", + "config" : { + "is_trial" : 0 + }, + "version" : "6.012" + } + }, + "x_authority" : "cpan:TJENNESS", + "x_contributors" : [ + "David Golden ", + "Karen Etheridge ", + "Olivier Mengue ", + "David Golden ", + "Peter Rabbitson ", + "Ben Tilly ", + "Kevin Ryde ", + "Peter John Acklam ", + "Slaven Rezic ", + "Slaven Rezic ", + "James E. Keenan ", + "Brian Mowrey ", + "Dagfinn Ilmari Manns\u00e5ker ", + "David Steinbrunner ", + "Ed Avis ", + "Guillem Jover " + ], + "x_generated_by_perl" : "v5.28.0", + "x_serialization_backend" : "Cpanel::JSON::XS version 4.04", + "x_static_install" : 0, + "x_use_unsafe_inc" : 0 +} + diff --git a/META.yml b/META.yml new file mode 100644 index 0000000..c862824 --- /dev/null +++ b/META.yml @@ -0,0 +1,909 @@ +--- +abstract: 'return name and handle of a temporary file safely' +author: + - 'Tim Jenness ' +build_requires: + ExtUtils::MakeMaker: '0' + File::Spec: '0.8' + FileHandle: '0' + Test::More: '0' + warnings: '0' +configure_requires: + ExtUtils::MakeMaker: '0' +dynamic_config: 1 +generated_by: 'Dist::Zilla version 6.012, CPAN::Meta::Converter version 2.150010' +license: perl +meta-spec: + url: http://module-build.sourceforge.net/META-spec-v1.4.html + version: '1.4' +name: File-Temp +no_index: + directory: + - t + - xt +provides: + File::Temp: + file: lib/File/Temp.pm + version: '0.2306' + File::Temp::Dir: + file: lib/File/Temp.pm + version: '0.2306' +requires: + Carp: '0' + Carp::Heavy: '0' + Cwd: '0' + Exporter: '5.57' + Fcntl: '1.03' + File::Path: '2.06' + File::Spec: '0.8' + IO::Handle: '0' + IO::Seekable: '0' + POSIX: '0' + Scalar::Util: '0' + Symbol: '0' + constant: '0' + overload: '0' + parent: '0.221' + perl: '5.006' + strict: '0' +resources: + IRC: irc://irc.perl.org/#toolchain + MailingList: http://lists.perl.org/list/cpan-workers.html + bugtracker: https://rt.cpan.org/Public/Dist/Display.html?Name=File-Temp + homepage: https://github.com/Perl-Toolchain-Gang/File-Temp + repository: https://github.com/Perl-Toolchain-Gang/File-Temp.git +version: '0.2306' +x_Dist_Zilla: + perl: + version: '5.028000' + plugins: + - + class: Dist::Zilla::Plugin::Prereqs + config: + Dist::Zilla::Plugin::Prereqs: + phase: develop + type: recommends + name: '@Author::ETHER/pluginbundle version' + version: '6.012' + - + class: Dist::Zilla::Plugin::PromptIfStale + config: + Dist::Zilla::Plugin::PromptIfStale: + check_all_plugins: 0 + check_all_prereqs: 0 + modules: + - Dist::Zilla::PluginBundle::Author::ETHER + phase: build + run_under_travis: 0 + skip: [] + name: '@Author::ETHER/stale modules, build' + version: '0.055' + - + class: Dist::Zilla::Plugin::FileFinder::ByName + name: '@Author::ETHER/Examples' + version: '6.012' + - + class: Dist::Zilla::Plugin::Git::GatherDir + config: + Dist::Zilla::Plugin::GatherDir: + exclude_filename: + - CONTRIBUTING + - INSTALL + - LICENSE + - Makefile.PL + - README.pod + exclude_match: [] + follow_symlinks: 0 + include_dotfiles: 0 + prefix: '' + prune_directory: [] + root: . + Dist::Zilla::Plugin::Git::GatherDir: + include_untracked: 0 + name: '@Author::ETHER/Git::GatherDir' + version: '2.045' + - + class: Dist::Zilla::Plugin::MetaYAML + name: '@Author::ETHER/MetaYAML' + version: '6.012' + - + class: Dist::Zilla::Plugin::MetaJSON + name: '@Author::ETHER/MetaJSON' + version: '6.012' + - + class: Dist::Zilla::Plugin::Readme + name: '@Author::ETHER/Readme' + version: '6.012' + - + class: Dist::Zilla::Plugin::Manifest + name: '@Author::ETHER/Manifest' + version: '6.012' + - + class: Dist::Zilla::Plugin::License + name: '@Author::ETHER/License' + version: '6.012' + - + class: Dist::Zilla::Plugin::GenerateFile::FromShareDir + config: + Dist::Zilla::Plugin::GenerateFile::FromShareDir: + destination_filename: CONTRIBUTING + dist: Dist-Zilla-PluginBundle-Author-ETHER + encoding: UTF-8 + has_xs: 0 + location: build + source_filename: CONTRIBUTING + Dist::Zilla::Role::RepoFileInjector: + allow_overwrite: 1 + repo_root: . + version: '0.009' + name: '@Author::ETHER/generate CONTRIBUTING' + version: '0.014' + - + class: Dist::Zilla::Plugin::InstallGuide + name: '@Author::ETHER/InstallGuide' + version: '1.200009' + - + class: Dist::Zilla::Plugin::Test::Compile + config: + Dist::Zilla::Plugin::Test::Compile: + bail_out_on_fail: '1' + fail_on_warning: author + fake_home: 0 + filename: xt/author/00-compile.t + module_finder: + - ':InstallModules' + needs_display: 0 + phase: develop + script_finder: + - ':PerlExecFiles' + - '@Author::ETHER/Examples' + skips: [] + switch: [] + name: '@Author::ETHER/Test::Compile' + version: '2.058' + - + class: Dist::Zilla::Plugin::MetaTests + name: '@Author::ETHER/MetaTests' + version: '6.012' + - + class: Dist::Zilla::Plugin::Test::CPAN::Changes + config: + Dist::Zilla::Plugin::Test::CPAN::Changes: + changelog: Changes + name: '@Author::ETHER/Test::CPAN::Changes' + version: '0.012' + - + class: Dist::Zilla::Plugin::GenerateFile::FromShareDir + config: + Dist::Zilla::Plugin::GenerateFile::FromShareDir: + destination_filename: xt/author/changes_has_content.t + dist: Dist-Zilla-PluginBundle-Author-ETHER + encoding: UTF-8 + location: build + source_filename: changes_has_content.t + Dist::Zilla::Role::RepoFileInjector: + allow_overwrite: 1 + repo_root: . + version: '0.009' + name: '@Author::ETHER/generate xt/author/changes_has_content.t' + version: '0.014' + - + class: Dist::Zilla::Plugin::Test::ChangesHasContent + name: '@Author::ETHER/Test::ChangesHasContent' + version: '0.011' + - + class: Dist::Zilla::Plugin::PodSyntaxTests + name: '@Author::ETHER/PodSyntaxTests' + version: '6.012' + - + class: Dist::Zilla::Plugin::PodCoverageTests + name: '@Author::ETHER/PodCoverageTests' + version: '6.012' + - + class: Dist::Zilla::Plugin::Test::PodSpelling + config: + Dist::Zilla::Plugin::Test::PodSpelling: + directories: + - examples + - lib + - script + - t + - xt + spell_cmd: '' + stopwords: + - APIs + - Christiansen + - EXLOCK + - NFS + - OpenBSD + - POSIX + - Ryde + - TMPDIR + - Tilly + - TopSystemUID + - UNLINK + - "chdir'ed" + - cmpstat + - destructor + - dirname + - endeavour + - et + - irc + - isa + - newdir + - numifies + - unix + - unlink + - unlinked + - unlinking + wordlist: Pod::Wordlist + name: '@Author::ETHER/Test::PodSpelling' + version: '2.007005' + - + class: Dist::Zilla::Plugin::Test::Pod::No404s + name: '@Author::ETHER/Test::Pod::No404s' + version: '1.004' + - + class: Dist::Zilla::Plugin::Test::Kwalitee + config: + Dist::Zilla::Plugin::Test::Kwalitee: + filename: xt/author/kwalitee.t + skiptest: [] + name: '@Author::ETHER/Test::Kwalitee' + version: '2.12' + - + class: Dist::Zilla::Plugin::MojibakeTests + name: '@Author::ETHER/MojibakeTests' + version: '0.8' + - + class: Dist::Zilla::Plugin::Test::ReportPrereqs + name: '@Author::ETHER/Test::ReportPrereqs' + version: '0.027' + - + class: Dist::Zilla::Plugin::Test::Portability + config: + Dist::Zilla::Plugin::Test::Portability: + options: '' + name: '@Author::ETHER/Test::Portability' + version: '2.001000' + - + class: Dist::Zilla::Plugin::Git::Describe + name: '@Author::ETHER/Git::Describe' + version: '0.007' + - + class: Dist::Zilla::Plugin::PodWeaver + config: + Dist::Zilla::Plugin::PodWeaver: + config_plugins: + - '@Author::ETHER' + finder: + - ':InstallModules' + - ':ExecFiles' + plugins: + - + class: Pod::Weaver::Plugin::EnsurePod5 + name: '@Author::ETHER/EnsurePod5' + version: '4.015' + - + class: Pod::Weaver::Plugin::H1Nester + name: '@Author::ETHER/H1Nester' + version: '4.015' + - + class: Pod::Weaver::Plugin::SingleEncoding + name: '@Author::ETHER/SingleEncoding' + version: '4.015' + - + class: Pod::Weaver::Plugin::Transformer + name: '@Author::ETHER/List' + version: '4.015' + - + class: Pod::Weaver::Plugin::Transformer + name: '@Author::ETHER/Verbatim' + version: '4.015' + - + class: Pod::Weaver::Section::Region + name: '@Author::ETHER/header' + version: '4.015' + - + class: Pod::Weaver::Section::Name + name: '@Author::ETHER/Name' + version: '4.015' + - + class: Pod::Weaver::Section::Version + name: '@Author::ETHER/Version' + version: '4.015' + - + class: Pod::Weaver::Section::Region + name: '@Author::ETHER/prelude' + version: '4.015' + - + class: Pod::Weaver::Section::Generic + name: SYNOPSIS + version: '4.015' + - + class: Pod::Weaver::Section::Generic + name: DESCRIPTION + version: '4.015' + - + class: Pod::Weaver::Section::Generic + name: OVERVIEW + version: '4.015' + - + class: Pod::Weaver::Section::Collect + name: ATTRIBUTES + version: '4.015' + - + class: Pod::Weaver::Section::Collect + name: METHODS + version: '4.015' + - + class: Pod::Weaver::Section::Collect + name: FUNCTIONS + version: '4.015' + - + class: Pod::Weaver::Section::Collect + name: TYPES + version: '4.015' + - + class: Pod::Weaver::Section::Leftovers + name: '@Author::ETHER/Leftovers' + version: '4.015' + - + class: Pod::Weaver::Section::Region + name: '@Author::ETHER/postlude' + version: '4.015' + - + class: Pod::Weaver::Section::GenerateSection + name: '@Author::ETHER/generate SUPPORT' + version: '1.06' + - + class: Pod::Weaver::Section::AllowOverride + name: '@Author::ETHER/allow override SUPPORT' + version: '0.05' + - + class: Pod::Weaver::Section::Authors + name: '@Author::ETHER/Authors' + version: '4.015' + - + class: Pod::Weaver::Section::Contributors + name: '@Author::ETHER/Contributors' + version: '0.009' + - + class: Pod::Weaver::Section::Legal + name: '@Author::ETHER/Legal' + version: '4.015' + - + class: Pod::Weaver::Section::Region + name: '@Author::ETHER/footer' + version: '4.015' + name: '@Author::ETHER/PodWeaver' + version: '4.008' + - + class: Dist::Zilla::Plugin::GithubMeta + name: '@Author::ETHER/GithubMeta' + version: '0.58' + - + class: Dist::Zilla::Plugin::AutoMetaResources + name: '@Author::ETHER/AutoMetaResources' + version: '1.21' + - + class: Dist::Zilla::Plugin::Authority + name: '@Author::ETHER/Authority' + version: '1.009' + - + class: Dist::Zilla::Plugin::MetaNoIndex + name: '@Author::ETHER/MetaNoIndex' + version: '6.012' + - + class: Dist::Zilla::Plugin::MetaProvides::Package + config: + Dist::Zilla::Plugin::MetaProvides::Package: + finder: + - ':InstallModules' + finder_objects: + - + class: Dist::Zilla::Plugin::FinderCode + name: ':InstallModules' + version: '6.012' + include_underscores: 0 + Dist::Zilla::Role::MetaProvider::Provider: + $Dist::Zilla::Role::MetaProvider::Provider::VERSION: '2.002004' + inherit_missing: '0' + inherit_version: '0' + meta_noindex: '1' + Dist::Zilla::Role::ModuleMetadata: + Module::Metadata: '1.000033' + version: '0.006' + name: '@Author::ETHER/MetaProvides::Package' + version: '2.004003' + - + class: Dist::Zilla::Plugin::MetaConfig + name: '@Author::ETHER/MetaConfig' + version: '6.012' + - + class: Dist::Zilla::Plugin::Keywords + config: + Dist::Zilla::Plugin::Keywords: + keywords: [] + name: '@Author::ETHER/Keywords' + version: '0.007' + - + class: Dist::Zilla::Plugin::UseUnsafeInc + config: + Dist::Zilla::Plugin::UseUnsafeInc: + dot_in_INC: 0 + name: '@Author::ETHER/UseUnsafeInc' + version: '0.001' + - + class: Dist::Zilla::Plugin::AutoPrereqs + name: '@Author::ETHER/AutoPrereqs' + version: '6.012' + - + class: Dist::Zilla::Plugin::Prereqs::AuthorDeps + name: '@Author::ETHER/Prereqs::AuthorDeps' + version: '0.006' + - + class: Dist::Zilla::Plugin::MakeMaker + config: + Dist::Zilla::Role::TestRunner: + default_jobs: 9 + name: '@Author::ETHER/MakeMaker' + version: '6.012' + - + class: Dist::Zilla::Plugin::Git::Contributors + config: + Dist::Zilla::Plugin::Git::Contributors: + git_version: 2.17.0 + include_authors: 0 + include_releaser: 1 + order_by: commits + paths: [] + name: '@Author::ETHER/Git::Contributors' + version: '0.034' + - + class: Dist::Zilla::Plugin::StaticInstall + config: + Dist::Zilla::Plugin::StaticInstall: + dry_run: 0 + mode: off + name: '@Author::ETHER/StaticInstall' + version: '0.011' + - + class: Dist::Zilla::Plugin::RunExtraTests + config: + Dist::Zilla::Role::TestRunner: + default_jobs: 9 + name: '@Author::ETHER/RunExtraTests' + version: '0.029' + - + class: Dist::Zilla::Plugin::CheckSelfDependency + config: + Dist::Zilla::Plugin::CheckSelfDependency: + finder: + - ':InstallModules' + Dist::Zilla::Role::ModuleMetadata: + Module::Metadata: '1.000033' + version: '0.006' + name: '@Author::ETHER/CheckSelfDependency' + version: '0.011' + - + class: Dist::Zilla::Plugin::Run::AfterBuild + config: + Dist::Zilla::Plugin::Run::Role::Runner: + fatal_errors: 1 + quiet: 1 + run: + - "bash -c \"test -e .ackrc && grep -q -- '--ignore-dir=.latest' .ackrc || echo '--ignore-dir=.latest' >> .ackrc; if [[ `dirname '%d'` != .build ]]; then test -e .ackrc && grep -q -- '--ignore-dir=%d' .ackrc || echo '--ignore-dir=%d' >> .ackrc; fi\"" + version: '0.047' + name: '@Author::ETHER/.ackrc' + version: '0.047' + - + class: Dist::Zilla::Plugin::Run::AfterBuild + config: + Dist::Zilla::Plugin::Run::Role::Runner: + eval: + - "if ('%d' =~ /^%n-[.[:xdigit:]]+$/) { unlink '.latest'; symlink '%d', '.latest'; }" + fatal_errors: 0 + quiet: 1 + version: '0.047' + name: '@Author::ETHER/.latest' + version: '0.047' + - + class: Dist::Zilla::Plugin::CheckStrictVersion + name: '@Author::ETHER/CheckStrictVersion' + version: '0.001' + - + class: Dist::Zilla::Plugin::CheckMetaResources + name: '@Author::ETHER/CheckMetaResources' + version: '0.001' + - + class: Dist::Zilla::Plugin::EnsureLatestPerl + config: + Dist::Zilla::Plugin::EnsureLatestPerl: + Module::CoreList: '5.20180622' + name: '@Author::ETHER/EnsureLatestPerl' + version: '0.008' + - + class: Dist::Zilla::Plugin::PromptIfStale + config: + Dist::Zilla::Plugin::PromptIfStale: + check_all_plugins: 1 + check_all_prereqs: 1 + modules: [] + phase: release + run_under_travis: 0 + skip: [] + name: '@Author::ETHER/stale modules, release' + version: '0.055' + - + class: Dist::Zilla::Plugin::Git::Check + config: + Dist::Zilla::Plugin::Git::Check: + untracked_files: die + Dist::Zilla::Role::Git::DirtyFiles: + allow_dirty: [] + allow_dirty_match: [] + changelog: Changes + Dist::Zilla::Role::Git::Repo: + git_version: 2.17.0 + repo_root: . + name: '@Author::ETHER/initial check' + version: '2.045' + - + class: Dist::Zilla::Plugin::Git::CheckFor::MergeConflicts + config: + Dist::Zilla::Role::Git::Repo: + git_version: 2.17.0 + repo_root: . + name: '@Author::ETHER/Git::CheckFor::MergeConflicts' + version: '0.014' + - + class: Dist::Zilla::Plugin::Git::CheckFor::CorrectBranch + config: + Dist::Zilla::Role::Git::Repo: + git_version: 2.17.0 + repo_root: . + name: '@Author::ETHER/Git::CheckFor::CorrectBranch' + version: '0.014' + - + class: Dist::Zilla::Plugin::Git::Remote::Check + name: '@Author::ETHER/Git::Remote::Check' + version: 0.1.2 + - + class: Dist::Zilla::Plugin::CheckPrereqsIndexed + name: '@Author::ETHER/CheckPrereqsIndexed' + version: '0.020' + - + class: Dist::Zilla::Plugin::TestRelease + name: '@Author::ETHER/TestRelease' + version: '6.012' + - + class: Dist::Zilla::Plugin::Git::Check + config: + Dist::Zilla::Plugin::Git::Check: + untracked_files: die + Dist::Zilla::Role::Git::DirtyFiles: + allow_dirty: [] + allow_dirty_match: [] + changelog: Changes + Dist::Zilla::Role::Git::Repo: + git_version: 2.17.0 + repo_root: . + name: '@Author::ETHER/after tests' + version: '2.045' + - + class: Dist::Zilla::Plugin::CheckIssues + name: '@Author::ETHER/CheckIssues' + version: '0.010' + - + class: Dist::Zilla::Plugin::UploadToCPAN + name: '@Author::ETHER/UploadToCPAN' + version: '6.012' + - + class: Dist::Zilla::Plugin::CopyFilesFromRelease + config: + Dist::Zilla::Plugin::CopyFilesFromRelease: + filename: + - CONTRIBUTING + - INSTALL + - LICENCE + - LICENSE + - ppport.h + match: [] + name: '@Author::ETHER/copy generated files' + version: '0.007' + - + class: Dist::Zilla::Plugin::ReadmeAnyFromPod + config: + Dist::Zilla::Role::FileWatcher: + version: '0.006' + name: '@Author::ETHER/ReadmeAnyFromPod' + version: '0.163250' + - + class: Dist::Zilla::Plugin::Prereqs + config: + Dist::Zilla::Plugin::Prereqs: + phase: develop + type: recommends + name: '@Author::ETHER/@Git::VersionManager/pluginbundle version' + version: '6.012' + - + class: Dist::Zilla::Plugin::RewriteVersion::Transitional + config: + Dist::Zilla::Plugin::RewriteVersion: + add_tarball_name: 0 + finders: + - ':ExecFiles' + - ':InstallModules' + global: 1 + skip_version_provider: 0 + Dist::Zilla::Plugin::RewriteVersion::Transitional: {} + name: '@Author::ETHER/@Git::VersionManager/RewriteVersion::Transitional' + version: '0.009' + - + class: Dist::Zilla::Plugin::MetaProvides::Update + name: '@Author::ETHER/@Git::VersionManager/MetaProvides::Update' + version: '0.007' + - + class: Dist::Zilla::Plugin::CopyFilesFromRelease + config: + Dist::Zilla::Plugin::CopyFilesFromRelease: + filename: + - Changes + match: [] + name: '@Author::ETHER/@Git::VersionManager/CopyFilesFromRelease' + version: '0.007' + - + class: Dist::Zilla::Plugin::Git::Commit + config: + Dist::Zilla::Plugin::Git::Commit: + add_files_in: + - . + commit_msg: '%N-%v%t%n%n%c' + Dist::Zilla::Role::Git::DirtyFiles: + allow_dirty: + - CONTRIBUTING + - Changes + - INSTALL + - LICENSE + - README.pod + allow_dirty_match: [] + changelog: Changes + Dist::Zilla::Role::Git::Repo: + git_version: 2.17.0 + repo_root: . + Dist::Zilla::Role::Git::StringFormatter: + time_zone: local + name: '@Author::ETHER/@Git::VersionManager/release snapshot' + version: '2.045' + - + class: Dist::Zilla::Plugin::Git::Tag + config: + Dist::Zilla::Plugin::Git::Tag: + branch: ~ + changelog: Changes + signed: 0 + tag: v0.2306 + tag_format: v%v + tag_message: v%v%t + Dist::Zilla::Role::Git::Repo: + git_version: 2.17.0 + repo_root: . + Dist::Zilla::Role::Git::StringFormatter: + time_zone: local + name: '@Author::ETHER/@Git::VersionManager/Git::Tag' + version: '2.045' + - + class: Dist::Zilla::Plugin::BumpVersionAfterRelease::Transitional + config: + Dist::Zilla::Plugin::BumpVersionAfterRelease: + finders: + - ':ExecFiles' + - ':InstallModules' + global: 1 + munge_makefile_pl: 1 + Dist::Zilla::Plugin::BumpVersionAfterRelease::Transitional: {} + name: '@Author::ETHER/@Git::VersionManager/BumpVersionAfterRelease::Transitional' + version: '0.009' + - + class: Dist::Zilla::Plugin::NextRelease + name: '@Author::ETHER/@Git::VersionManager/NextRelease' + version: '6.012' + - + class: Dist::Zilla::Plugin::Git::Commit + config: + Dist::Zilla::Plugin::Git::Commit: + add_files_in: [] + commit_msg: 'increment $VERSION after %v release' + Dist::Zilla::Role::Git::DirtyFiles: + allow_dirty: + - Build.PL + - Changes + - Makefile.PL + allow_dirty_match: + - (?^:^lib/.*\.pm$) + changelog: Changes + Dist::Zilla::Role::Git::Repo: + git_version: 2.17.0 + repo_root: . + Dist::Zilla::Role::Git::StringFormatter: + time_zone: local + name: '@Author::ETHER/@Git::VersionManager/post-release commit' + version: '2.045' + - + class: Dist::Zilla::Plugin::Prereqs + config: + Dist::Zilla::Plugin::Prereqs: + phase: x_Dist_Zilla + type: requires + name: '@Author::ETHER/@Git::VersionManager/prereqs for @Git::VersionManager' + version: '6.012' + - + class: Dist::Zilla::Plugin::Git::Push + config: + Dist::Zilla::Plugin::Git::Push: + push_to: + - origin + remotes_must_exist: 1 + Dist::Zilla::Role::Git::Repo: + git_version: 2.17.0 + repo_root: . + name: '@Author::ETHER/Git::Push' + version: '2.045' + - + class: Dist::Zilla::Plugin::GitHub::Update + config: + Dist::Zilla::Plugin::GitHub::Update: + metacpan: 1 + name: '@Author::ETHER/GitHub::Update' + version: '0.45' + - + class: Dist::Zilla::Plugin::Run::AfterRelease + config: + Dist::Zilla::Plugin::Run::Role::Runner: + fatal_errors: 0 + quiet: 0 + run: + - REDACTED + version: '0.047' + name: '@Author::ETHER/install release' + version: '0.047' + - + class: Dist::Zilla::Plugin::Run::AfterRelease + config: + Dist::Zilla::Plugin::Run::Role::Runner: + eval: + - 'print "release complete!\xa"' + fatal_errors: 1 + quiet: 1 + version: '0.047' + name: '@Author::ETHER/release complete' + version: '0.047' + - + class: Dist::Zilla::Plugin::ConfirmRelease + name: '@Author::ETHER/ConfirmRelease' + version: '6.012' + - + class: Dist::Zilla::Plugin::Prereqs + config: + Dist::Zilla::Plugin::Prereqs: + phase: x_Dist_Zilla + type: requires + name: '@Author::ETHER/prereqs for @Author::ETHER' + version: '6.012' + - + class: Dist::Zilla::Plugin::OSPrereqs + config: + Dist::Zilla::Plugin::OSPrereqs: + os: VMS + name: VMS + version: '0.011' + - + class: Dist::Zilla::Plugin::OSPrereqs + config: + Dist::Zilla::Plugin::OSPrereqs: + os: MSWin32 + name: MSWin32 + version: '0.011' + - + class: Dist::Zilla::Plugin::OnlyCorePrereqs + config: + Dist::Zilla::Plugin::OnlyCorePrereqs: + also_disallow: [] + check_dual_life_versions: '0' + deprecated_ok: '0' + phases: + - configure + - build + - runtime + - test + skips: [] + starting_version: '5.008003' + name: OnlyCorePrereqs + version: '0.024' + - + class: Dist::Zilla::Plugin::DualLife + config: + Dist::Zilla::Plugin::DualLife: + entered_core: '5.006001' + eumm_bundled: 0 + Dist::Zilla::Role::ModuleMetadata: + Module::Metadata: '1.000033' + version: '0.006' + name: DualLife + version: '0.07' + - + class: Dist::Zilla::Plugin::MetaResources + name: MetaResources + version: '6.012' + - + class: Dist::Zilla::Plugin::FinderCode + name: ':InstallModules' + version: '6.012' + - + class: Dist::Zilla::Plugin::FinderCode + name: ':IncModules' + version: '6.012' + - + class: Dist::Zilla::Plugin::FinderCode + name: ':TestFiles' + version: '6.012' + - + class: Dist::Zilla::Plugin::FinderCode + name: ':ExtraTestFiles' + version: '6.012' + - + class: Dist::Zilla::Plugin::FinderCode + name: ':ExecFiles' + version: '6.012' + - + class: Dist::Zilla::Plugin::FinderCode + name: ':PerlExecFiles' + version: '6.012' + - + class: Dist::Zilla::Plugin::FinderCode + name: ':ShareFiles' + version: '6.012' + - + class: Dist::Zilla::Plugin::FinderCode + name: ':MainModule' + version: '6.012' + - + class: Dist::Zilla::Plugin::FinderCode + name: ':AllFiles' + version: '6.012' + - + class: Dist::Zilla::Plugin::FinderCode + name: ':NoFiles' + version: '6.012' + - + class: Dist::Zilla::Plugin::VerifyPhases + name: '@Author::ETHER/PHASE VERIFICATION' + version: '0.016' + zilla: + class: Dist::Zilla::Dist::Builder + config: + is_trial: '0' + version: '6.012' +x_authority: cpan:TJENNESS +x_contributors: + - 'David Golden ' + - 'Karen Etheridge ' + - 'Olivier Mengue ' + - 'David Golden ' + - 'Peter Rabbitson ' + - 'Ben Tilly ' + - 'Kevin Ryde ' + - 'Peter John Acklam ' + - 'Slaven Rezic ' + - 'Slaven Rezic ' + - 'James E. Keenan ' + - 'Brian Mowrey ' + - 'Dagfinn Ilmari Mannsåker ' + - 'David Steinbrunner ' + - 'Ed Avis ' + - 'Guillem Jover ' +x_generated_by_perl: v5.28.0 +x_serialization_backend: 'YAML::Tiny version 1.73' +x_static_install: 0 +x_use_unsafe_inc: 0 diff --git a/Makefile.PL b/Makefile.PL new file mode 100644 index 0000000..04a6058 --- /dev/null +++ b/Makefile.PL @@ -0,0 +1,95 @@ +# This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v6.012. +use strict; +use warnings; + +use 5.006; + +use ExtUtils::MakeMaker; + +my %WriteMakefileArgs = ( + "ABSTRACT" => "return name and handle of a temporary file safely", + "AUTHOR" => "Tim Jenness ", + "CONFIGURE_REQUIRES" => { + "ExtUtils::MakeMaker" => 0 + }, + "DISTNAME" => "File-Temp", + "LICENSE" => "perl", + "MIN_PERL_VERSION" => "5.006", + "NAME" => "File::Temp", + "PREREQ_PM" => { + "Carp" => 0, + "Carp::Heavy" => 0, + "Cwd" => 0, + "Exporter" => "5.57", + "Fcntl" => "1.03", + "File::Path" => "2.06", + "File::Spec" => "0.8", + "IO::Handle" => 0, + "IO::Seekable" => 0, + "POSIX" => 0, + "Scalar::Util" => 0, + "Symbol" => 0, + "constant" => 0, + "overload" => 0, + "parent" => "0.221", + "strict" => 0 + }, + "TEST_REQUIRES" => { + "ExtUtils::MakeMaker" => 0, + "File::Spec" => "0.8", + "FileHandle" => 0, + "Test::More" => 0, + "warnings" => 0 + }, + "VERSION" => "0.2306", + "test" => { + "TESTS" => "t/*.t" + } +); + + +my %FallbackPrereqs = ( + "Carp" => 0, + "Carp::Heavy" => 0, + "Cwd" => 0, + "Exporter" => "5.57", + "ExtUtils::MakeMaker" => 0, + "Fcntl" => "1.03", + "File::Path" => "2.06", + "File::Spec" => "0.8", + "FileHandle" => 0, + "IO::Handle" => 0, + "IO::Seekable" => 0, + "POSIX" => 0, + "Scalar::Util" => 0, + "Symbol" => 0, + "Test::More" => 0, + "constant" => 0, + "overload" => 0, + "parent" => "0.221", + "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) }; + +if ( $^O eq 'VMS' ) { + $WriteMakefileArgs{PREREQ_PM}{'VMS::Stdio'} = $FallbackPrereqs{'VMS::Stdio'} = '0'; +} + +if ( $^O eq 'MSWin32' ) { + $WriteMakefileArgs{PREREQ_PM}{'Win32'} = $FallbackPrereqs{'Win32'} = '0'; +} + +$WriteMakefileArgs{INSTALLDIRS} = 'perl' + if "$]" >= 5.006001 && "$]" <= 5.011000; + +WriteMakefile(%WriteMakefileArgs); diff --git a/README b/README new file mode 100644 index 0000000..9f8b624 --- /dev/null +++ b/README @@ -0,0 +1,12 @@ +This archive contains the distribution File-Temp, +version 0.2306: + + return name and handle of a temporary file safely + +This software is copyright (c) 2018 by Tim Jenness and the UK Particle Physics and Astronomy Research Council. + +This is free software; you can redistribute it and/or modify it under +the same terms as the Perl 5 programming language system itself. + + +This README file was generated by Dist::Zilla::Plugin::Readme v6.012. diff --git a/README.mkdn b/README.mkdn new file mode 100644 index 0000000..761c9db --- /dev/null +++ b/README.mkdn @@ -0,0 +1,87 @@ +## 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/ + diff --git a/dist.ini b/dist.ini new file mode 100644 index 0000000..6b2ed4a --- /dev/null +++ b/dist.ini @@ -0,0 +1,59 @@ +name = File-Temp +author = Tim Jenness +license = Perl_5 +copyright_holder = Tim Jenness and the UK Particle Physics and Astronomy Research Council + +[@Author::ETHER] +:version = 0.119 +installer = MakeMaker +Authority.authority = cpan:TJENNESS +StaticInstall.mode = off ; dynamic prereqs +AutoPrereqs.skip[0] = VMS::Stdio +AutoPrereqs.skip[1] = Win32 +Test::PodSpelling.stopwords[0] = APIs +Test::PodSpelling.stopwords[1] = Christiansen +Test::PodSpelling.stopwords[2] = EXLOCK +Test::PodSpelling.stopwords[3] = NFS +Test::PodSpelling.stopwords[4] = OpenBSD +Test::PodSpelling.stopwords[5] = POSIX +Test::PodSpelling.stopwords[6] = Ryde +Test::PodSpelling.stopwords[7] = Tilly +Test::PodSpelling.stopwords[8] = TopSystemUID +Test::PodSpelling.stopwords[9] = TMPDIR +Test::PodSpelling.stopwords[10] = UNLINK +Test::PodSpelling.stopwords[11] = chdir'ed +Test::PodSpelling.stopwords[12] = cmpstat +Test::PodSpelling.stopwords[13] = destructor +Test::PodSpelling.stopwords[14] = dirname +Test::PodSpelling.stopwords[15] = endeavour +Test::PodSpelling.stopwords[16] = et +Test::PodSpelling.stopwords[17] = isa +Test::PodSpelling.stopwords[18] = newdir +Test::PodSpelling.stopwords[19] = numifies +Test::PodSpelling.stopwords[20] = unix +Test::PodSpelling.stopwords[21] = unlink +Test::PodSpelling.stopwords[22] = unlinked +Test::PodSpelling.stopwords[23] = unlinking +-remove = MinimumPerl ; it jumps to 5.8.3 because of _bugfix_magic_errno +-remove = Test::MinimumVersion ; "" +-remove = Test::NoTabs ; TODO +-remove = Test::EOL ; TODO +-remove = Test::CleanNamespaces ; TODO + +[OSPrereqs / VMS] +VMS::Stdio = 0 + +[OSPrereqs / MSWin32] +Win32 = 0 + +[OnlyCorePrereqs] +:version = 0.014 +check_dual_life_versions = 0 +starting_version = 5.008003 + +[DualLife] +entered_core = 5.006001 + +[MetaResources] +x_IRC = irc://irc.perl.org/#toolchain +x_MailingList = http://lists.perl.org/list/cpan-workers.html diff --git a/lib/File/Temp.pm b/lib/File/Temp.pm new file mode 100644 index 0000000..8e2b4fc --- /dev/null +++ b/lib/File/Temp.pm @@ -0,0 +1,3686 @@ +package File::Temp; # git description: v0.2305-8-g4787a5d +# ABSTRACT: return name and handle of a temporary file safely + +our $VERSION = '0.2306'; + +#pod =begin __INTERNALS +#pod +#pod =head1 PORTABILITY +#pod +#pod This section is at the top in order to provide easier access to +#pod porters. It is not expected to be rendered by a standard pod +#pod formatting tool. Please skip straight to the SYNOPSIS section if you +#pod are not trying to port this module to a new platform. +#pod +#pod This module is designed to be portable across operating systems and it +#pod currently supports Unix, VMS, DOS, OS/2, Windows and Mac OS +#pod (Classic). When porting to a new OS there are generally three main +#pod issues that have to be solved: +#pod +#pod =over 4 +#pod +#pod =item * +#pod +#pod Can the OS unlink an open file? If it can not then the +#pod C<_can_unlink_opened_file> method should be modified. +#pod +#pod =item * +#pod +#pod Are the return values from C reliable? By default all the +#pod return values from C are compared when unlinking a temporary +#pod file using the filename and the handle. Operating systems other than +#pod unix do not always have valid entries in all fields. If utility function +#pod C fails then the C comparison should be +#pod modified accordingly. +#pod +#pod =item * +#pod +#pod Security. Systems that can not support a test for the sticky bit +#pod on a directory can not use the MEDIUM and HIGH security tests. +#pod The C<_can_do_level> method should be modified accordingly. +#pod +#pod =back +#pod +#pod =end __INTERNALS +#pod +#pod =head1 SYNOPSIS +#pod +#pod use File::Temp qw/ tempfile tempdir /; +#pod +#pod $fh = tempfile(); +#pod ($fh, $filename) = tempfile(); +#pod +#pod ($fh, $filename) = tempfile( $template, DIR => $dir); +#pod ($fh, $filename) = tempfile( $template, SUFFIX => '.dat'); +#pod ($fh, $filename) = tempfile( $template, TMPDIR => 1 ); +#pod +#pod binmode( $fh, ":utf8" ); +#pod +#pod $dir = tempdir( CLEANUP => 1 ); +#pod ($fh, $filename) = tempfile( DIR => $dir ); +#pod +#pod Object interface: +#pod +#pod require File::Temp; +#pod use File::Temp (); +#pod use File::Temp qw/ :seekable /; +#pod +#pod $fh = File::Temp->new(); +#pod $fname = $fh->filename; +#pod +#pod $fh = File::Temp->new(TEMPLATE => $template); +#pod $fname = $fh->filename; +#pod +#pod $tmp = File::Temp->new( UNLINK => 0, SUFFIX => '.dat' ); +#pod print $tmp "Some data\n"; +#pod print "Filename is $tmp\n"; +#pod $tmp->seek( 0, SEEK_END ); +#pod +#pod $dir = File::Temp->newdir(); # CLEANUP => 1 by default +#pod +#pod The following interfaces are provided for compatibility with +#pod existing APIs. They should not be used in new code. +#pod +#pod MkTemp family: +#pod +#pod use File::Temp qw/ :mktemp /; +#pod +#pod ($fh, $file) = mkstemp( "tmpfileXXXXX" ); +#pod ($fh, $file) = mkstemps( "tmpfileXXXXXX", $suffix); +#pod +#pod $tmpdir = mkdtemp( $template ); +#pod +#pod $unopened_file = mktemp( $template ); +#pod +#pod POSIX functions: +#pod +#pod use File::Temp qw/ :POSIX /; +#pod +#pod $file = tmpnam(); +#pod $fh = tmpfile(); +#pod +#pod ($fh, $file) = tmpnam(); +#pod +#pod Compatibility functions: +#pod +#pod $unopened_file = File::Temp::tempnam( $dir, $pfx ); +#pod +#pod =head1 DESCRIPTION +#pod +#pod C can be used to create and open temporary files in a safe +#pod way. There is both a function interface and an object-oriented +#pod interface. The File::Temp constructor or the tempfile() function can +#pod be used to return the name and the open filehandle of a temporary +#pod file. The tempdir() function can be used to create a temporary +#pod directory. +#pod +#pod The security aspect of temporary file creation is emphasized such that +#pod a filehandle and filename are returned together. This helps guarantee +#pod that a race condition can not occur where the temporary file is +#pod created by another process between checking for the existence of the +#pod file and its opening. Additional security levels are provided to +#pod check, for example, that the sticky bit is set on world writable +#pod directories. See L<"safe_level"> for more information. +#pod +#pod For compatibility with popular C library functions, Perl implementations of +#pod the mkstemp() family of functions are provided. These are, mkstemp(), +#pod mkstemps(), mkdtemp() and mktemp(). +#pod +#pod Additionally, implementations of the standard L +#pod tmpnam() and tmpfile() functions are provided if required. +#pod +#pod Implementations of mktemp(), tmpnam(), and tempnam() are provided, +#pod but should be used with caution since they return only a filename +#pod that was valid when function was called, so cannot guarantee +#pod that the file will not exist by the time the caller opens the filename. +#pod +#pod Filehandles returned by these functions support the seekable methods. +#pod +#pod =cut + +# Toolchain targets v5.8.1, but we'll try to support back to v5.6 anyway. +# It might be possible to make this v5.5, but many v5.6isms are creeping +# into the code and tests. +use 5.006; +use strict; +use Carp; +use File::Spec 0.8; +use Cwd (); +use File::Path 2.06 qw/ rmtree /; +use Fcntl 1.03; +use IO::Seekable; # For SEEK_* +use Errno; +use Scalar::Util 'refaddr'; +require VMS::Stdio if $^O eq 'VMS'; + +# pre-emptively load Carp::Heavy. If we don't when we run out of file +# handles and attempt to call croak() we get an error message telling +# us that Carp::Heavy won't load rather than an error telling us we +# have run out of file handles. We either preload croak() or we +# switch the calls to croak from _gettemp() to use die. +eval { require Carp::Heavy; }; + +# Need the Symbol package if we are running older perl +require Symbol if $] < 5.006; + +### For the OO interface +use parent 0.221 qw/ IO::Handle IO::Seekable /; +use overload '""' => "STRINGIFY", '0+' => "NUMIFY", + fallback => 1; + +our $DEBUG = 0; +our $KEEP_ALL = 0; + +# We are exporting functions + +use Exporter 5.57 'import'; # 5.57 lets us import 'import' + +# Export list - to allow fine tuning of export table + +our @EXPORT_OK = qw{ + tempfile + tempdir + tmpnam + tmpfile + mktemp + mkstemp + mkstemps + mkdtemp + unlink0 + cleanup + SEEK_SET + SEEK_CUR + SEEK_END + }; + +# Groups of functions for export + +our %EXPORT_TAGS = ( + 'POSIX' => [qw/ tmpnam tmpfile /], + 'mktemp' => [qw/ mktemp mkstemp mkstemps mkdtemp/], + 'seekable' => [qw/ SEEK_SET SEEK_CUR SEEK_END /], + ); + +# add contents of these tags to @EXPORT +Exporter::export_tags('POSIX','mktemp','seekable'); + +# This is a list of characters that can be used in random filenames + +my @CHARS = (qw/ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z + a b c d e f g h i j k l m n o p q r s t u v w x y z + 0 1 2 3 4 5 6 7 8 9 _ + /); + +# Maximum number of tries to make a temp file before failing + +use constant MAX_TRIES => 1000; + +# Minimum number of X characters that should be in a template +use constant MINX => 4; + +# Default template when no template supplied + +use constant TEMPXXX => 'X' x 10; + +# Constants for the security level + +use constant STANDARD => 0; +use constant MEDIUM => 1; +use constant HIGH => 2; + +# OPENFLAGS. If we defined the flag to use with Sysopen here this gives +# us an optimisation when many temporary files are requested + +my $OPENFLAGS = O_CREAT | O_EXCL | O_RDWR; +my $LOCKFLAG; + +unless ($^O eq 'MacOS') { + for my $oflag (qw/ NOFOLLOW BINARY LARGEFILE NOINHERIT /) { + my ($bit, $func) = (0, "Fcntl::O_" . $oflag); + no strict 'refs'; + $OPENFLAGS |= $bit if eval { + # Make sure that redefined die handlers do not cause problems + # e.g. CGI::Carp + local $SIG{__DIE__} = sub {}; + local $SIG{__WARN__} = sub {}; + $bit = &$func(); + 1; + }; + } + # Special case O_EXLOCK + $LOCKFLAG = eval { + local $SIG{__DIE__} = sub {}; + local $SIG{__WARN__} = sub {}; + &Fcntl::O_EXLOCK(); + }; +} + +# On some systems the O_TEMPORARY flag can be used to tell the OS +# to automatically remove the file when it is closed. This is fine +# in most cases but not if tempfile is called with UNLINK=>0 and +# the filename is requested -- in the case where the filename is to +# be passed to another routine. This happens on windows. We overcome +# this by using a second open flags variable + +my $OPENTEMPFLAGS = $OPENFLAGS; +unless ($^O eq 'MacOS') { + for my $oflag (qw/ TEMPORARY /) { + my ($bit, $func) = (0, "Fcntl::O_" . $oflag); + local($@); + no strict 'refs'; + $OPENTEMPFLAGS |= $bit if eval { + # Make sure that redefined die handlers do not cause problems + # e.g. CGI::Carp + local $SIG{__DIE__} = sub {}; + local $SIG{__WARN__} = sub {}; + $bit = &$func(); + 1; + }; + } +} + +# Private hash tracking which files have been created by each process id via the OO interface +my %FILES_CREATED_BY_OBJECT; + +# INTERNAL ROUTINES - not to be used outside of package + +# Generic routine for getting a temporary filename +# modelled on OpenBSD _gettemp() in mktemp.c + +# The template must contain X's that are to be replaced +# with the random values + +# Arguments: + +# TEMPLATE - string containing the XXXXX's that is converted +# to a random filename and opened if required + +# Optionally, a hash can also be supplied containing specific options +# "open" => if true open the temp file, else just return the name +# default is 0 +# "mkdir"=> if true, we are creating a temp directory rather than tempfile +# default is 0 +# "suffixlen" => number of characters at end of PATH to be ignored. +# default is 0. +# "unlink_on_close" => indicates that, if possible, the OS should remove +# the file as soon as it is closed. Usually indicates +# use of the O_TEMPORARY flag to sysopen. +# Usually irrelevant on unix +# "use_exlock" => Indicates that O_EXLOCK should be used. Default is true. + +# Optionally a reference to a scalar can be passed into the function +# On error this will be used to store the reason for the error +# "ErrStr" => \$errstr + +# "open" and "mkdir" can not both be true +# "unlink_on_close" is not used when "mkdir" is true. + +# The default options are equivalent to mktemp(). + +# Returns: +# filehandle - open file handle (if called with doopen=1, else undef) +# temp name - name of the temp file or directory + +# For example: +# ($fh, $name) = _gettemp($template, "open" => 1); + +# for the current version, failures are associated with +# stored in an error string and returned to give the reason whilst debugging +# This routine is not called by any external function +sub _gettemp { + + croak 'Usage: ($fh, $name) = _gettemp($template, OPTIONS);' + unless scalar(@_) >= 1; + + # the internal error string - expect it to be overridden + # Need this in case the caller decides not to supply us a value + # need an anonymous scalar + my $tempErrStr; + + # Default options + my %options = ( + "open" => 0, + "mkdir" => 0, + "suffixlen" => 0, + "unlink_on_close" => 0, + "use_exlock" => 1, + "ErrStr" => \$tempErrStr, + ); + + # Read the template + my $template = shift; + if (ref($template)) { + # Use a warning here since we have not yet merged ErrStr + carp "File::Temp::_gettemp: template must not be a reference"; + return (); + } + + # Check that the number of entries on stack are even + if (scalar(@_) % 2 != 0) { + # Use a warning here since we have not yet merged ErrStr + carp "File::Temp::_gettemp: Must have even number of options"; + return (); + } + + # Read the options and merge with defaults + %options = (%options, @_) if @_; + + # Make sure the error string is set to undef + ${$options{ErrStr}} = undef; + + # Can not open the file and make a directory in a single call + if ($options{"open"} && $options{"mkdir"}) { + ${$options{ErrStr}} = "doopen and domkdir can not both be true\n"; + return (); + } + + # Find the start of the end of the Xs (position of last X) + # Substr starts from 0 + my $start = length($template) - 1 - $options{"suffixlen"}; + + # Check that we have at least MINX x X (e.g. 'XXXX") at the end of the string + # (taking suffixlen into account). Any fewer is insecure. + + # Do it using substr - no reason to use a pattern match since + # we know where we are looking and what we are looking for + + if (substr($template, $start - MINX + 1, MINX) ne 'X' x MINX) { + ${$options{ErrStr}} = "The template must end with at least ". + MINX . " 'X' characters\n"; + return (); + } + + # Replace all the X at the end of the substring with a + # random character or just all the XX at the end of a full string. + # Do it as an if, since the suffix adjusts which section to replace + # and suffixlen=0 returns nothing if used in the substr directly + # and generate a full path from the template + + my $path = _replace_XX($template, $options{"suffixlen"}); + + + # Split the path into constituent parts - eventually we need to check + # whether the directory exists + # We need to know whether we are making a temp directory + # or a tempfile + + my ($volume, $directories, $file); + my $parent; # parent directory + if ($options{"mkdir"}) { + # There is no filename at the end + ($volume, $directories, $file) = File::Spec->splitpath( $path, 1); + + # The parent is then $directories without the last directory + # Split the directory and put it back together again + my @dirs = File::Spec->splitdir($directories); + + # If @dirs only has one entry (i.e. the directory template) that means + # we are in the current directory + if ($#dirs == 0) { + $parent = File::Spec->curdir; + } else { + + if ($^O eq 'VMS') { # need volume to avoid relative dir spec + $parent = File::Spec->catdir($volume, @dirs[0..$#dirs-1]); + $parent = 'sys$disk:[]' if $parent eq ''; + } else { + + # Put it back together without the last one + $parent = File::Spec->catdir(@dirs[0..$#dirs-1]); + + # ...and attach the volume (no filename) + $parent = File::Spec->catpath($volume, $parent, ''); + } + + } + + } else { + + # Get rid of the last filename (use File::Basename for this?) + ($volume, $directories, $file) = File::Spec->splitpath( $path ); + + # Join up without the file part + $parent = File::Spec->catpath($volume,$directories,''); + + # If $parent is empty replace with curdir + $parent = File::Spec->curdir + unless $directories ne ''; + + } + + # Check that the parent directories exist + # Do this even for the case where we are simply returning a name + # not a file -- no point returning a name that includes a directory + # that does not exist or is not writable + + unless (-e $parent) { + ${$options{ErrStr}} = "Parent directory ($parent) does not exist"; + return (); + } + unless (-d $parent) { + ${$options{ErrStr}} = "Parent directory ($parent) is not a directory"; + return (); + } + + # Check the stickiness of the directory and chown giveaway if required + # If the directory is world writable the sticky bit + # must be set + + if (File::Temp->safe_level == MEDIUM) { + my $safeerr; + unless (_is_safe($parent,\$safeerr)) { + ${$options{ErrStr}} = "Parent directory ($parent) is not safe ($safeerr)"; + return (); + } + } elsif (File::Temp->safe_level == HIGH) { + my $safeerr; + unless (_is_verysafe($parent, \$safeerr)) { + ${$options{ErrStr}} = "Parent directory ($parent) is not safe ($safeerr)"; + return (); + } + } + + + # Now try MAX_TRIES time to open the file + for (my $i = 0; $i < MAX_TRIES; $i++) { + + # Try to open the file if requested + if ($options{"open"}) { + my $fh; + + # If we are running before perl5.6.0 we can not auto-vivify + if ($] < 5.006) { + $fh = &Symbol::gensym; + } + + # Try to make sure this will be marked close-on-exec + # XXX: Win32 doesn't respect this, nor the proper fcntl, + # but may have O_NOINHERIT. This may or may not be in Fcntl. + local $^F = 2; + + # Attempt to open the file + my $open_success = undef; + if ( $^O eq 'VMS' and $options{"unlink_on_close"} && !$KEEP_ALL) { + # make it auto delete on close by setting FAB$V_DLT bit + $fh = VMS::Stdio::vmssysopen($path, $OPENFLAGS, 0600, 'fop=dlt'); + $open_success = $fh; + } else { + my $flags = ( ($options{"unlink_on_close"} && !$KEEP_ALL) ? + $OPENTEMPFLAGS : + $OPENFLAGS ); + $flags |= $LOCKFLAG if (defined $LOCKFLAG && $options{use_exlock}); + $open_success = sysopen($fh, $path, $flags, 0600); + } + if ( $open_success ) { + + # in case of odd umask force rw + chmod(0600, $path); + + # Opened successfully - return file handle and name + return ($fh, $path); + + } else { + + # Error opening file - abort with error + # if the reason was anything but EEXIST + unless ($!{EEXIST}) { + ${$options{ErrStr}} = "Could not create temp file $path: $!"; + return (); + } + + # Loop round for another try + + } + } elsif ($options{"mkdir"}) { + + # Open the temp directory + if (mkdir( $path, 0700)) { + # in case of odd umask + chmod(0700, $path); + + return undef, $path; + } else { + + # Abort with error if the reason for failure was anything + # except EEXIST + unless ($!{EEXIST}) { + ${$options{ErrStr}} = "Could not create directory $path: $!"; + return (); + } + + # Loop round for another try + + } + + } else { + + # Return true if the file can not be found + # Directory has been checked previously + + return (undef, $path) unless -e $path; + + # Try again until MAX_TRIES + + } + + # Did not successfully open the tempfile/dir + # so try again with a different set of random letters + # No point in trying to increment unless we have only + # 1 X say and the randomness could come up with the same + # file MAX_TRIES in a row. + + # Store current attempt - in principle this implies that the + # 3rd time around the open attempt that the first temp file + # name could be generated again. Probably should store each + # attempt and make sure that none are repeated + + my $original = $path; + my $counter = 0; # Stop infinite loop + my $MAX_GUESS = 50; + + do { + + # Generate new name from original template + $path = _replace_XX($template, $options{"suffixlen"}); + + $counter++; + + } until ($path ne $original || $counter > $MAX_GUESS); + + # Check for out of control looping + if ($counter > $MAX_GUESS) { + ${$options{ErrStr}} = "Tried to get a new temp name different to the previous value $MAX_GUESS times.\nSomething wrong with template?? ($template)"; + return (); + } + + } + + # If we get here, we have run out of tries + ${ $options{ErrStr} } = "Have exceeded the maximum number of attempts (" + . MAX_TRIES . ") to open temp file/dir"; + + return (); + +} + +# Internal routine to replace the XXXX... with random characters +# This has to be done by _gettemp() every time it fails to +# open a temp file/dir + +# Arguments: $template (the template with XXX), +# $ignore (number of characters at end to ignore) + +# Returns: modified template + +sub _replace_XX { + + croak 'Usage: _replace_XX($template, $ignore)' + unless scalar(@_) == 2; + + my ($path, $ignore) = @_; + + # Do it as an if, since the suffix adjusts which section to replace + # and suffixlen=0 returns nothing if used in the substr directly + # Alternatively, could simply set $ignore to length($path)-1 + # Don't want to always use substr when not required though. + my $end = ( $] >= 5.006 ? "\\z" : "\\Z" ); + + if ($ignore) { + substr($path, 0, - $ignore) =~ s/X(?=X*$end)/$CHARS[ int( rand( @CHARS ) ) ]/ge; + } else { + $path =~ s/X(?=X*$end)/$CHARS[ int( rand( @CHARS ) ) ]/ge; + } + return $path; +} + +# Internal routine to force a temp file to be writable after +# it is created so that we can unlink it. Windows seems to occasionally +# force a file to be readonly when written to certain temp locations +sub _force_writable { + my $file = shift; + chmod 0600, $file; +} + + +# internal routine to check to see if the directory is safe +# First checks to see if the directory is not owned by the +# current user or root. Then checks to see if anyone else +# can write to the directory and if so, checks to see if +# it has the sticky bit set + +# Will not work on systems that do not support sticky bit + +#Args: directory path to check +# Optionally: reference to scalar to contain error message +# Returns true if the path is safe and false otherwise. +# Returns undef if can not even run stat() on the path + +# This routine based on version written by Tom Christiansen + +# Presumably, by the time we actually attempt to create the +# file or directory in this directory, it may not be safe +# anymore... Have to run _is_safe directly after the open. + +sub _is_safe { + + my $path = shift; + my $err_ref = shift; + + # Stat path + my @info = stat($path); + unless (scalar(@info)) { + $$err_ref = "stat(path) returned no values"; + return 0; + } + ; + return 1 if $^O eq 'VMS'; # owner delete control at file level + + # Check to see whether owner is neither superuser (or a system uid) nor me + # Use the effective uid from the $> variable + # UID is in [4] + if ($info[4] > File::Temp->top_system_uid() && $info[4] != $>) { + + Carp::cluck(sprintf "uid=$info[4] topuid=%s euid=$> path='$path'", + File::Temp->top_system_uid()); + + $$err_ref = "Directory owned neither by root nor the current user" + if ref($err_ref); + return 0; + } + + # check whether group or other can write file + # use 066 to detect either reading or writing + # use 022 to check writability + # Do it with S_IWOTH and S_IWGRP for portability (maybe) + # mode is in info[2] + if (($info[2] & &Fcntl::S_IWGRP) || # Is group writable? + ($info[2] & &Fcntl::S_IWOTH) ) { # Is world writable? + # Must be a directory + unless (-d $path) { + $$err_ref = "Path ($path) is not a directory" + if ref($err_ref); + return 0; + } + # Must have sticky bit set + unless (-k $path) { + $$err_ref = "Sticky bit not set on $path when dir is group|world writable" + if ref($err_ref); + return 0; + } + } + + return 1; +} + +# Internal routine to check whether a directory is safe +# for temp files. Safer than _is_safe since it checks for +# the possibility of chown giveaway and if that is a possibility +# checks each directory in the path to see if it is safe (with _is_safe) + +# If _PC_CHOWN_RESTRICTED is not set, does the full test of each +# directory anyway. + +# Takes optional second arg as scalar ref to error reason + +sub _is_verysafe { + + # Need POSIX - but only want to bother if really necessary due to overhead + require POSIX; + + my $path = shift; + print "_is_verysafe testing $path\n" if $DEBUG; + return 1 if $^O eq 'VMS'; # owner delete control at file level + + my $err_ref = shift; + + # Should Get the value of _PC_CHOWN_RESTRICTED if it is defined + # and If it is not there do the extensive test + local($@); + my $chown_restricted; + $chown_restricted = &POSIX::_PC_CHOWN_RESTRICTED() + if eval { &POSIX::_PC_CHOWN_RESTRICTED(); 1}; + + # If chown_resticted is set to some value we should test it + if (defined $chown_restricted) { + + # Return if the current directory is safe + return _is_safe($path,$err_ref) if POSIX::sysconf( $chown_restricted ); + + } + + # To reach this point either, the _PC_CHOWN_RESTRICTED symbol + # was not available or the symbol was there but chown giveaway + # is allowed. Either way, we now have to test the entire tree for + # safety. + + # Convert path to an absolute directory if required + unless (File::Spec->file_name_is_absolute($path)) { + $path = File::Spec->rel2abs($path); + } + + # Split directory into components - assume no file + my ($volume, $directories, undef) = File::Spec->splitpath( $path, 1); + + # Slightly less efficient than having a function in File::Spec + # to chop off the end of a directory or even a function that + # can handle ../ in a directory tree + # Sometimes splitdir() returns a blank at the end + # so we will probably check the bottom directory twice in some cases + my @dirs = File::Spec->splitdir($directories); + + # Concatenate one less directory each time around + foreach my $pos (0.. $#dirs) { + # Get a directory name + my $dir = File::Spec->catpath($volume, + File::Spec->catdir(@dirs[0.. $#dirs - $pos]), + '' + ); + + print "TESTING DIR $dir\n" if $DEBUG; + + # Check the directory + return 0 unless _is_safe($dir,$err_ref); + + } + + return 1; +} + + + +# internal routine to determine whether unlink works on this +# platform for files that are currently open. +# Returns true if we can, false otherwise. + +# Currently WinNT, OS/2 and VMS can not unlink an opened file +# On VMS this is because the O_EXCL flag is used to open the +# temporary file. Currently I do not know enough about the issues +# on VMS to decide whether O_EXCL is a requirement. + +sub _can_unlink_opened_file { + + if (grep { $^O eq $_ } qw/MSWin32 os2 VMS dos MacOS haiku/) { + return 0; + } else { + return 1; + } + +} + +# internal routine to decide which security levels are allowed +# see safe_level() for more information on this + +# Controls whether the supplied security level is allowed + +# $cando = _can_do_level( $level ) + +sub _can_do_level { + + # Get security level + my $level = shift; + + # Always have to be able to do STANDARD + return 1 if $level == STANDARD; + + # Currently, the systems that can do HIGH or MEDIUM are identical + if ( $^O eq 'MSWin32' || $^O eq 'os2' || $^O eq 'cygwin' || $^O eq 'dos' || $^O eq 'MacOS' || $^O eq 'mpeix') { + return 0; + } else { + return 1; + } + +} + +# This routine sets up a deferred unlinking of a specified +# filename and filehandle. It is used in the following cases: +# - Called by unlink0 if an opened file can not be unlinked +# - Called by tempfile() if files are to be removed on shutdown +# - Called by tempdir() if directories are to be removed on shutdown + +# Arguments: +# _deferred_unlink( $fh, $fname, $isdir ); +# +# - filehandle (so that it can be explicitly closed if open +# - filename (the thing we want to remove) +# - isdir (flag to indicate that we are being given a directory) +# [and hence no filehandle] + +# Status is not referred to since all the magic is done with an END block + +{ + # Will set up two lexical variables to contain all the files to be + # removed. One array for files, another for directories They will + # only exist in this block. + + # This means we only have to set up a single END block to remove + # all files. + + # in order to prevent child processes inadvertently deleting the parent + # temp files we use a hash to store the temp files and directories + # created by a particular process id. + + # %files_to_unlink contains values that are references to an array of + # array references containing the filehandle and filename associated with + # the temp file. + my (%files_to_unlink, %dirs_to_unlink); + + # Set up an end block to use these arrays + END { + local($., $@, $!, $^E, $?); + cleanup(at_exit => 1); + } + + # Cleanup function. Always triggered on END (with at_exit => 1) but + # can be invoked manually. + sub cleanup { + my %h = @_; + my $at_exit = delete $h{at_exit}; + $at_exit = 0 if not defined $at_exit; + { my @k = sort keys %h; die "unrecognized parameters: @k" if @k } + + if (!$KEEP_ALL) { + # Files + my @files = (exists $files_to_unlink{$$} ? + @{ $files_to_unlink{$$} } : () ); + foreach my $file (@files) { + # close the filehandle without checking its state + # in order to make real sure that this is closed + # if its already closed then I don't care about the answer + # probably a better way to do this + close($file->[0]); # file handle is [0] + + if (-f $file->[1]) { # file name is [1] + _force_writable( $file->[1] ); # for windows + unlink $file->[1] or warn "Error removing ".$file->[1]; + } + } + # Dirs + my @dirs = (exists $dirs_to_unlink{$$} ? + @{ $dirs_to_unlink{$$} } : () ); + my ($cwd, $cwd_to_remove); + foreach my $dir (@dirs) { + if (-d $dir) { + # Some versions of rmtree will abort if you attempt to remove + # the directory you are sitting in. For automatic cleanup + # at program exit, we avoid this by chdir()ing out of the way + # first. If not at program exit, it's best not to mess with the + # current directory, so just let it fail with a warning. + if ($at_exit) { + $cwd = Cwd::abs_path(File::Spec->curdir) if not defined $cwd; + my $abs = Cwd::abs_path($dir); + if ($abs eq $cwd) { + $cwd_to_remove = $dir; + next; + } + } + eval { rmtree($dir, $DEBUG, 0); }; + warn $@ if ($@ && $^W); + } + } + + if (defined $cwd_to_remove) { + # We do need to clean up the current directory, and everything + # else is done, so get out of there and remove it. + chdir $cwd_to_remove or die "cannot chdir to $cwd_to_remove: $!"; + my $updir = File::Spec->updir; + chdir $updir or die "cannot chdir to $updir: $!"; + eval { rmtree($cwd_to_remove, $DEBUG, 0); }; + warn $@ if ($@ && $^W); + } + + # clear the arrays + @{ $files_to_unlink{$$} } = () + if exists $files_to_unlink{$$}; + @{ $dirs_to_unlink{$$} } = () + if exists $dirs_to_unlink{$$}; + } + } + + + # This is the sub called to register a file for deferred unlinking + # This could simply store the input parameters and defer everything + # until the END block. For now we do a bit of checking at this + # point in order to make sure that (1) we have a file/dir to delete + # and (2) we have been called with the correct arguments. + sub _deferred_unlink { + + croak 'Usage: _deferred_unlink($fh, $fname, $isdir)' + unless scalar(@_) == 3; + + my ($fh, $fname, $isdir) = @_; + + warn "Setting up deferred removal of $fname\n" + if $DEBUG; + + # make sure we save the absolute path for later cleanup + # OK to untaint because we only ever use this internally + # as a file path, never interpolating into the shell + $fname = Cwd::abs_path($fname); + ($fname) = $fname =~ /^(.*)$/; + + # If we have a directory, check that it is a directory + if ($isdir) { + + if (-d $fname) { + + # Directory exists so store it + # first on VMS turn []foo into [.foo] for rmtree + $fname = VMS::Filespec::vmspath($fname) if $^O eq 'VMS'; + $dirs_to_unlink{$$} = [] + unless exists $dirs_to_unlink{$$}; + push (@{ $dirs_to_unlink{$$} }, $fname); + + } else { + carp "Request to remove directory $fname could not be completed since it does not exist!\n" if $^W; + } + + } else { + + if (-f $fname) { + + # file exists so store handle and name for later removal + $files_to_unlink{$$} = [] + unless exists $files_to_unlink{$$}; + push(@{ $files_to_unlink{$$} }, [$fh, $fname]); + + } else { + carp "Request to remove file $fname could not be completed since it is not there!\n" if $^W; + } + + } + + } + + +} + +# normalize argument keys to upper case and do consistent handling +# of leading template vs TEMPLATE +sub _parse_args { + my $leading_template = (scalar(@_) % 2 == 1 ? shift(@_) : '' ); + my %args = @_; + %args = map { uc($_), $args{$_} } keys %args; + + # template (store it in an array so that it will + # disappear from the arg list of tempfile) + my @template = ( + exists $args{TEMPLATE} ? $args{TEMPLATE} : + $leading_template ? $leading_template : () + ); + delete $args{TEMPLATE}; + + return( \@template, \%args ); +} + +#pod =head1 OBJECT-ORIENTED INTERFACE +#pod +#pod This is the primary interface for interacting with +#pod C. Using the OO interface a temporary file can be created +#pod when the object is constructed and the file can be removed when the +#pod object is no longer required. +#pod +#pod Note that there is no method to obtain the filehandle from the +#pod C object. The object itself acts as a filehandle. The object +#pod isa C and isa C so all those methods are +#pod available. +#pod +#pod Also, the object is configured such that it stringifies to the name of the +#pod temporary file and so can be compared to a filename directly. It numifies +#pod to the C the same as other handles and so can be compared to other +#pod handles with C<==>. +#pod +#pod $fh eq $filename # as a string +#pod $fh != \*STDOUT # as a number +#pod +#pod Available since 0.14. +#pod +#pod =over 4 +#pod +#pod =item B +#pod +#pod Create a temporary file object. +#pod +#pod my $tmp = File::Temp->new(); +#pod +#pod by default the object is constructed as if C +#pod was called without options, but with the additional behaviour +#pod that the temporary file is removed by the object destructor +#pod if UNLINK is set to true (the default). +#pod +#pod Supported arguments are the same as for C: UNLINK +#pod (defaulting to true), DIR, EXLOCK and SUFFIX. Additionally, the filename +#pod template is specified using the TEMPLATE option. The OPEN option +#pod is not supported (the file is always opened). +#pod +#pod $tmp = File::Temp->new( TEMPLATE => 'tempXXXXX', +#pod DIR => 'mydir', +#pod SUFFIX => '.dat'); +#pod +#pod Arguments are case insensitive. +#pod +#pod Can call croak() if an error occurs. +#pod +#pod Available since 0.14. +#pod +#pod TEMPLATE available since 0.23 +#pod +#pod =cut + +sub new { + my $proto = shift; + my $class = ref($proto) || $proto; + + my ($maybe_template, $args) = _parse_args(@_); + + # see if they are unlinking (defaulting to yes) + my $unlink = (exists $args->{UNLINK} ? $args->{UNLINK} : 1 ); + delete $args->{UNLINK}; + + # Protect OPEN + delete $args->{OPEN}; + + # Open the file and retain file handle and file name + my ($fh, $path) = tempfile( @$maybe_template, %$args ); + + print "Tmp: $fh - $path\n" if $DEBUG; + + # Store the filename in the scalar slot + ${*$fh} = $path; + + # Cache the filename by pid so that the destructor can decide whether to remove it + $FILES_CREATED_BY_OBJECT{$$}{$path} = 1; + + # Store unlink information in hash slot (plus other constructor info) + %{*$fh} = %$args; + + # create the object + bless $fh, $class; + + # final method-based configuration + $fh->unlink_on_destroy( $unlink ); + + return $fh; +} + +#pod =item B +#pod +#pod Create a temporary directory using an object oriented interface. +#pod +#pod $dir = File::Temp->newdir(); +#pod +#pod By default the directory is deleted when the object goes out of scope. +#pod +#pod Supports the same options as the C function. Note that directories +#pod created with this method default to CLEANUP => 1. +#pod +#pod $dir = File::Temp->newdir( $template, %options ); +#pod +#pod A template may be specified either with a leading template or +#pod with a TEMPLATE argument. +#pod +#pod Available since 0.19. +#pod +#pod TEMPLATE available since 0.23. +#pod +#pod =cut + +sub newdir { + my $self = shift; + + my ($maybe_template, $args) = _parse_args(@_); + + # handle CLEANUP without passing CLEANUP to tempdir + my $cleanup = (exists $args->{CLEANUP} ? $args->{CLEANUP} : 1 ); + delete $args->{CLEANUP}; + + my $tempdir = tempdir( @$maybe_template, %$args); + + # get a safe absolute path for cleanup, just like + # happens in _deferred_unlink + my $real_dir = Cwd::abs_path( $tempdir ); + ($real_dir) = $real_dir =~ /^(.*)$/; + + return bless { DIRNAME => $tempdir, + REALNAME => $real_dir, + CLEANUP => $cleanup, + LAUNCHPID => $$, + }, "File::Temp::Dir"; +} + +#pod =item B +#pod +#pod Return the name of the temporary file associated with this object +#pod (if the object was created using the "new" constructor). +#pod +#pod $filename = $tmp->filename; +#pod +#pod This method is called automatically when the object is used as +#pod a string. +#pod +#pod Current API available since 0.14 +#pod +#pod =cut + +sub filename { + my $self = shift; + return ${*$self}; +} + +sub STRINGIFY { + my $self = shift; + return $self->filename; +} + +# For reference, can't use '0+'=>\&Scalar::Util::refaddr directly because +# refaddr() demands one parameter only, whereas overload.pm calls with three +# even for unary operations like '0+'. +sub NUMIFY { + return refaddr($_[0]); +} + +#pod =item B +#pod +#pod Return the name of the temporary directory associated with this +#pod object (if the object was created using the "newdir" constructor). +#pod +#pod $dirname = $tmpdir->dirname; +#pod +#pod This method is called automatically when the object is used in string context. +#pod +#pod =item B +#pod +#pod Control whether the file is unlinked when the object goes out of scope. +#pod The file is removed if this value is true and $KEEP_ALL is not. +#pod +#pod $fh->unlink_on_destroy( 1 ); +#pod +#pod Default is for the file to be removed. +#pod +#pod Current API available since 0.15 +#pod +#pod =cut + +sub unlink_on_destroy { + my $self = shift; + if (@_) { + ${*$self}{UNLINK} = shift; + } + return ${*$self}{UNLINK}; +} + +#pod =item B +#pod +#pod When the object goes out of scope, the destructor is called. This +#pod destructor will attempt to unlink the file (using L) +#pod if the constructor was called with UNLINK set to 1 (the default state +#pod if UNLINK is not specified). +#pod +#pod No error is given if the unlink fails. +#pod +#pod If the object has been passed to a child process during a fork, the +#pod file will be deleted when the object goes out of scope in the parent. +#pod +#pod For a temporary directory object the directory will be removed unless +#pod the CLEANUP argument was used in the constructor (and set to false) or +#pod C was modified after creation. Note that if a temp +#pod directory is your current directory, it cannot be removed - a warning +#pod will be given in this case. C out of the directory before +#pod letting the object go out of scope. +#pod +#pod If the global variable $KEEP_ALL is true, the file or directory +#pod will not be removed. +#pod +#pod =cut + +sub DESTROY { + local($., $@, $!, $^E, $?); + my $self = shift; + + # Make sure we always remove the file from the global hash + # on destruction. This prevents the hash from growing uncontrollably + # and post-destruction there is no reason to know about the file. + my $file = $self->filename; + my $was_created_by_proc; + if (exists $FILES_CREATED_BY_OBJECT{$$}{$file}) { + $was_created_by_proc = 1; + delete $FILES_CREATED_BY_OBJECT{$$}{$file}; + } + + if (${*$self}{UNLINK} && !$KEEP_ALL) { + print "# ---------> Unlinking $self\n" if $DEBUG; + + # only delete if this process created it + return unless $was_created_by_proc; + + # The unlink1 may fail if the file has been closed + # by the caller. This leaves us with the decision + # of whether to refuse to remove the file or simply + # do an unlink without test. Seems to be silly + # to do this when we are trying to be careful + # about security + _force_writable( $file ); # for windows + unlink1( $self, $file ) + or unlink($file); + } +} + +#pod =back +#pod +#pod =head1 FUNCTIONS +#pod +#pod This section describes the recommended interface for generating +#pod temporary files and directories. +#pod +#pod =over 4 +#pod +#pod =item B +#pod +#pod This is the basic function to generate temporary files. +#pod The behaviour of the file can be changed using various options: +#pod +#pod $fh = tempfile(); +#pod ($fh, $filename) = tempfile(); +#pod +#pod Create a temporary file in the directory specified for temporary +#pod files, as specified by the tmpdir() function in L. +#pod +#pod ($fh, $filename) = tempfile($template); +#pod +#pod Create a temporary file in the current directory using the supplied +#pod template. Trailing `X' characters are replaced with random letters to +#pod generate the filename. At least four `X' characters must be present +#pod at the end of the template. +#pod +#pod ($fh, $filename) = tempfile($template, SUFFIX => $suffix) +#pod +#pod Same as previously, except that a suffix is added to the template +#pod after the `X' translation. Useful for ensuring that a temporary +#pod filename has a particular extension when needed by other applications. +#pod But see the WARNING at the end. +#pod +#pod ($fh, $filename) = tempfile($template, DIR => $dir); +#pod +#pod Translates the template as before except that a directory name +#pod is specified. +#pod +#pod ($fh, $filename) = tempfile($template, TMPDIR => 1); +#pod +#pod Equivalent to specifying a DIR of "File::Spec->tmpdir", writing the file +#pod into the same temporary directory as would be used if no template was +#pod specified at all. +#pod +#pod ($fh, $filename) = tempfile($template, UNLINK => 1); +#pod +#pod Return the filename and filehandle as before except that the file is +#pod automatically removed when the program exits (dependent on +#pod $KEEP_ALL). Default is for the file to be removed if a file handle is +#pod requested and to be kept if the filename is requested. In a scalar +#pod context (where no filename is returned) the file is always deleted +#pod either (depending on the operating system) on exit or when it is +#pod closed (unless $KEEP_ALL is true when the temp file is created). +#pod +#pod Use the object-oriented interface if fine-grained control of when +#pod a file is removed is required. +#pod +#pod If the template is not specified, a template is always +#pod automatically generated. This temporary file is placed in tmpdir() +#pod (L) unless a directory is specified explicitly with the +#pod DIR option. +#pod +#pod $fh = tempfile( DIR => $dir ); +#pod +#pod If called in scalar context, only the filehandle is returned and the +#pod file will automatically be deleted when closed on operating systems +#pod that support this (see the description of tmpfile() elsewhere in this +#pod document). This is the preferred mode of operation, as if you only +#pod have a filehandle, you can never create a race condition by fumbling +#pod with the filename. On systems that can not unlink an open file or can +#pod not mark a file as temporary when it is opened (for example, Windows +#pod NT uses the C flag) the file is marked for deletion when +#pod the program ends (equivalent to setting UNLINK to 1). The C +#pod flag is ignored if present. +#pod +#pod (undef, $filename) = tempfile($template, OPEN => 0); +#pod +#pod This will return the filename based on the template but +#pod will not open this file. Cannot be used in conjunction with +#pod UNLINK set to true. Default is to always open the file +#pod to protect from possible race conditions. A warning is issued +#pod if warnings are turned on. Consider using the tmpnam() +#pod and mktemp() functions described elsewhere in this document +#pod if opening the file is not required. +#pod +#pod If the operating system supports it (for example BSD derived systems), the +#pod filehandle will be opened with O_EXLOCK (open with exclusive file lock). +#pod This can sometimes cause problems if the intention is to pass the filename +#pod to another system that expects to take an exclusive lock itself (such as +#pod DBD::SQLite) whilst ensuring that the tempfile is not reused. In this +#pod situation the "EXLOCK" option can be passed to tempfile. By default EXLOCK +#pod will be true (this retains compatibility with earlier releases). +#pod +#pod ($fh, $filename) = tempfile($template, EXLOCK => 0); +#pod +#pod Options can be combined as required. +#pod +#pod Will croak() if there is an error. +#pod +#pod Available since 0.05. +#pod +#pod UNLINK flag available since 0.10. +#pod +#pod TMPDIR flag available since 0.19. +#pod +#pod EXLOCK flag available since 0.19. +#pod +#pod =cut + +sub tempfile { + if ( @_ && $_[0] eq 'File::Temp' ) { + croak "'tempfile' can't be called as a method"; + } + # Can not check for argument count since we can have any + # number of args + + # Default options + my %options = ( + "DIR" => undef, # Directory prefix + "SUFFIX" => '', # Template suffix + "UNLINK" => 0, # Do not unlink file on exit + "OPEN" => 1, # Open file + "TMPDIR" => 0, # Place tempfile in tempdir if template specified + "EXLOCK" => 1, # Open file with O_EXLOCK + ); + + # Check to see whether we have an odd or even number of arguments + my ($maybe_template, $args) = _parse_args(@_); + my $template = @$maybe_template ? $maybe_template->[0] : undef; + + # Read the options and merge with defaults + %options = (%options, %$args); + + # First decision is whether or not to open the file + if (! $options{"OPEN"}) { + + warn "tempfile(): temporary filename requested but not opened.\nPossibly unsafe, consider using tempfile() with OPEN set to true\n" + if $^W; + + } + + if ($options{"DIR"} and $^O eq 'VMS') { + + # on VMS turn []foo into [.foo] for concatenation + $options{"DIR"} = VMS::Filespec::vmspath($options{"DIR"}); + } + + # Construct the template + + # Have a choice of trying to work around the mkstemp/mktemp/tmpnam etc + # functions or simply constructing a template and using _gettemp() + # explicitly. Go for the latter + + # First generate a template if not defined and prefix the directory + # If no template must prefix the temp directory + if (defined $template) { + # End up with current directory if neither DIR not TMPDIR are set + if ($options{"DIR"}) { + + $template = File::Spec->catfile($options{"DIR"}, $template); + + } elsif ($options{TMPDIR}) { + + $template = File::Spec->catfile(_wrap_file_spec_tmpdir(), $template ); + + } + + } else { + + if ($options{"DIR"}) { + + $template = File::Spec->catfile($options{"DIR"}, TEMPXXX); + + } else { + + $template = File::Spec->catfile(_wrap_file_spec_tmpdir(), TEMPXXX); + + } + + } + + # Now add a suffix + $template .= $options{"SUFFIX"}; + + # Determine whether we should tell _gettemp to unlink the file + # On unix this is irrelevant and can be worked out after the file is + # opened (simply by unlinking the open filehandle). On Windows or VMS + # we have to indicate temporary-ness when we open the file. In general + # we only want a true temporary file if we are returning just the + # filehandle - if the user wants the filename they probably do not + # want the file to disappear as soon as they close it (which may be + # important if they want a child process to use the file) + # For this reason, tie unlink_on_close to the return context regardless + # of OS. + my $unlink_on_close = ( wantarray ? 0 : 1); + + # Create the file + my ($fh, $path, $errstr); + croak "Error in tempfile() using template $template: $errstr" + unless (($fh, $path) = _gettemp($template, + "open" => $options{'OPEN'}, + "mkdir"=> 0 , + "unlink_on_close" => $unlink_on_close, + "suffixlen" => length($options{'SUFFIX'}), + "ErrStr" => \$errstr, + "use_exlock" => $options{EXLOCK}, + ) ); + + # Set up an exit handler that can do whatever is right for the + # system. This removes files at exit when requested explicitly or when + # system is asked to unlink_on_close but is unable to do so because + # of OS limitations. + # The latter should be achieved by using a tied filehandle. + # Do not check return status since this is all done with END blocks. + _deferred_unlink($fh, $path, 0) if $options{"UNLINK"}; + + # Return + if (wantarray()) { + + if ($options{'OPEN'}) { + return ($fh, $path); + } else { + return (undef, $path); + } + + } else { + + # Unlink the file. It is up to unlink0 to decide what to do with + # this (whether to unlink now or to defer until later) + unlink0($fh, $path) or croak "Error unlinking file $path using unlink0"; + + # Return just the filehandle. + return $fh; + } + + +} + +# On Windows under taint mode, File::Spec could suggest "C:\" as a tempdir +# which might not be writable. If that is the case, we fallback to a +# user directory. See https://rt.cpan.org/Ticket/Display.html?id=60340 + +{ + my ($alt_tmpdir, $checked); + + sub _wrap_file_spec_tmpdir { + return File::Spec->tmpdir unless $^O eq "MSWin32" && ${^TAINT}; + + if ( $checked ) { + return $alt_tmpdir ? $alt_tmpdir : File::Spec->tmpdir; + } + + # probe what File::Spec gives and find a fallback + my $xxpath = _replace_XX( "X" x 10, 0 ); + + # First, see if File::Spec->tmpdir is writable + my $tmpdir = File::Spec->tmpdir; + my $testpath = File::Spec->catdir( $tmpdir, $xxpath ); + if (mkdir( $testpath, 0700) ) { + $checked = 1; + rmdir $testpath; + return $tmpdir; + } + + # Next, see if CSIDL_LOCAL_APPDATA is writable + require Win32; + my $local_app = File::Spec->catdir( + Win32::GetFolderPath( Win32::CSIDL_LOCAL_APPDATA() ), 'Temp' + ); + $testpath = File::Spec->catdir( $local_app, $xxpath ); + if ( -e $local_app or mkdir( $local_app, 0700 ) ) { + if (mkdir( $testpath, 0700) ) { + $checked = 1; + rmdir $testpath; + return $alt_tmpdir = $local_app; + } + } + + # Can't find something writable + croak << "HERE"; +Couldn't find a writable temp directory in taint mode. Tried: + $tmpdir + $local_app + +Try setting and untainting the TMPDIR environment variable. +HERE + + } +} + +#pod =item B +#pod +#pod This is the recommended interface for creation of temporary +#pod directories. By default the directory will not be removed on exit +#pod (that is, it won't be temporary; this behaviour can not be changed +#pod because of issues with backwards compatibility). To enable removal +#pod either use the CLEANUP option which will trigger removal on program +#pod exit, or consider using the "newdir" method in the object interface which +#pod will allow the directory to be cleaned up when the object goes out of +#pod scope. +#pod +#pod The behaviour of the function depends on the arguments: +#pod +#pod $tempdir = tempdir(); +#pod +#pod Create a directory in tmpdir() (see L). +#pod +#pod $tempdir = tempdir( $template ); +#pod +#pod Create a directory from the supplied template. This template is +#pod similar to that described for tempfile(). `X' characters at the end +#pod of the template are replaced with random letters to construct the +#pod directory name. At least four `X' characters must be in the template. +#pod +#pod $tempdir = tempdir ( DIR => $dir ); +#pod +#pod Specifies the directory to use for the temporary directory. +#pod The temporary directory name is derived from an internal template. +#pod +#pod $tempdir = tempdir ( $template, DIR => $dir ); +#pod +#pod Prepend the supplied directory name to the template. The template +#pod should not include parent directory specifications itself. Any parent +#pod directory specifications are removed from the template before +#pod prepending the supplied directory. +#pod +#pod $tempdir = tempdir ( $template, TMPDIR => 1 ); +#pod +#pod Using the supplied template, create the temporary directory in +#pod a standard location for temporary files. Equivalent to doing +#pod +#pod $tempdir = tempdir ( $template, DIR => File::Spec->tmpdir); +#pod +#pod but shorter. Parent directory specifications are stripped from the +#pod template itself. The C option is ignored if C is set +#pod explicitly. Additionally, C is implied if neither a template +#pod nor a directory are supplied. +#pod +#pod $tempdir = tempdir( $template, CLEANUP => 1); +#pod +#pod Create a temporary directory using the supplied template, but +#pod attempt to remove it (and all files inside it) when the program +#pod exits. Note that an attempt will be made to remove all files from +#pod the directory even if they were not created by this module (otherwise +#pod why ask to clean it up?). The directory removal is made with +#pod the rmtree() function from the L module. +#pod Of course, if the template is not specified, the temporary directory +#pod will be created in tmpdir() and will also be removed at program exit. +#pod +#pod Will croak() if there is an error. +#pod +#pod Current API available since 0.05. +#pod +#pod =cut + +# ' + +sub tempdir { + if ( @_ && $_[0] eq 'File::Temp' ) { + croak "'tempdir' can't be called as a method"; + } + + # Can not check for argument count since we can have any + # number of args + + # Default options + my %options = ( + "CLEANUP" => 0, # Remove directory on exit + "DIR" => '', # Root directory + "TMPDIR" => 0, # Use tempdir with template + ); + + # Check to see whether we have an odd or even number of arguments + my ($maybe_template, $args) = _parse_args(@_); + my $template = @$maybe_template ? $maybe_template->[0] : undef; + + # Read the options and merge with defaults + %options = (%options, %$args); + + # Modify or generate the template + + # Deal with the DIR and TMPDIR options + if (defined $template) { + + # Need to strip directory path if using DIR or TMPDIR + if ($options{'TMPDIR'} || $options{'DIR'}) { + + # Strip parent directory from the filename + # + # There is no filename at the end + $template = VMS::Filespec::vmspath($template) if $^O eq 'VMS'; + my ($volume, $directories, undef) = File::Spec->splitpath( $template, 1); + + # Last directory is then our template + $template = (File::Spec->splitdir($directories))[-1]; + + # Prepend the supplied directory or temp dir + if ($options{"DIR"}) { + + $template = File::Spec->catdir($options{"DIR"}, $template); + + } elsif ($options{TMPDIR}) { + + # Prepend tmpdir + $template = File::Spec->catdir(_wrap_file_spec_tmpdir(), $template); + + } + + } + + } else { + + if ($options{"DIR"}) { + + $template = File::Spec->catdir($options{"DIR"}, TEMPXXX); + + } else { + + $template = File::Spec->catdir(_wrap_file_spec_tmpdir(), TEMPXXX); + + } + + } + + # Create the directory + my $tempdir; + my $suffixlen = 0; + if ($^O eq 'VMS') { # dir names can end in delimiters + $template =~ m/([\.\]:>]+)$/; + $suffixlen = length($1); + } + if ( ($^O eq 'MacOS') && (substr($template, -1) eq ':') ) { + # dir name has a trailing ':' + ++$suffixlen; + } + + my $errstr; + croak "Error in tempdir() using $template: $errstr" + unless ((undef, $tempdir) = _gettemp($template, + "open" => 0, + "mkdir"=> 1 , + "suffixlen" => $suffixlen, + "ErrStr" => \$errstr, + ) ); + + # Install exit handler; must be dynamic to get lexical + if ( $options{'CLEANUP'} && -d $tempdir) { + _deferred_unlink(undef, $tempdir, 1); + } + + # Return the dir name + return $tempdir; + +} + +#pod =back +#pod +#pod =head1 MKTEMP FUNCTIONS +#pod +#pod The following functions are Perl implementations of the +#pod mktemp() family of temp file generation system calls. +#pod +#pod =over 4 +#pod +#pod =item B +#pod +#pod Given a template, returns a filehandle to the temporary file and the name +#pod of the file. +#pod +#pod ($fh, $name) = mkstemp( $template ); +#pod +#pod In scalar context, just the filehandle is returned. +#pod +#pod The template may be any filename with some number of X's appended +#pod to it, for example F. The trailing X's are replaced +#pod with unique alphanumeric combinations. +#pod +#pod Will croak() if there is an error. +#pod +#pod Current API available since 0.05. +#pod +#pod =cut + + + +sub mkstemp { + + croak "Usage: mkstemp(template)" + if scalar(@_) != 1; + + my $template = shift; + + my ($fh, $path, $errstr); + croak "Error in mkstemp using $template: $errstr" + unless (($fh, $path) = _gettemp($template, + "open" => 1, + "mkdir"=> 0 , + "suffixlen" => 0, + "ErrStr" => \$errstr, + ) ); + + if (wantarray()) { + return ($fh, $path); + } else { + return $fh; + } + +} + + +#pod =item B +#pod +#pod Similar to mkstemp(), except that an extra argument can be supplied +#pod with a suffix to be appended to the template. +#pod +#pod ($fh, $name) = mkstemps( $template, $suffix ); +#pod +#pod For example a template of C and suffix of C<.dat> +#pod would generate a file similar to F. +#pod +#pod Returns just the filehandle alone when called in scalar context. +#pod +#pod Will croak() if there is an error. +#pod +#pod Current API available since 0.05. +#pod +#pod =cut + +sub mkstemps { + + croak "Usage: mkstemps(template, suffix)" + if scalar(@_) != 2; + + + my $template = shift; + my $suffix = shift; + + $template .= $suffix; + + my ($fh, $path, $errstr); + croak "Error in mkstemps using $template: $errstr" + unless (($fh, $path) = _gettemp($template, + "open" => 1, + "mkdir"=> 0 , + "suffixlen" => length($suffix), + "ErrStr" => \$errstr, + ) ); + + if (wantarray()) { + return ($fh, $path); + } else { + return $fh; + } + +} + +#pod =item B +#pod +#pod Create a directory from a template. The template must end in +#pod X's that are replaced by the routine. +#pod +#pod $tmpdir_name = mkdtemp($template); +#pod +#pod Returns the name of the temporary directory created. +#pod +#pod Directory must be removed by the caller. +#pod +#pod Will croak() if there is an error. +#pod +#pod Current API available since 0.05. +#pod +#pod =cut + +#' # for emacs + +sub mkdtemp { + + croak "Usage: mkdtemp(template)" + if scalar(@_) != 1; + + my $template = shift; + my $suffixlen = 0; + if ($^O eq 'VMS') { # dir names can end in delimiters + $template =~ m/([\.\]:>]+)$/; + $suffixlen = length($1); + } + if ( ($^O eq 'MacOS') && (substr($template, -1) eq ':') ) { + # dir name has a trailing ':' + ++$suffixlen; + } + my ($junk, $tmpdir, $errstr); + croak "Error creating temp directory from template $template\: $errstr" + unless (($junk, $tmpdir) = _gettemp($template, + "open" => 0, + "mkdir"=> 1 , + "suffixlen" => $suffixlen, + "ErrStr" => \$errstr, + ) ); + + return $tmpdir; + +} + +#pod =item B +#pod +#pod Returns a valid temporary filename but does not guarantee +#pod that the file will not be opened by someone else. +#pod +#pod $unopened_file = mktemp($template); +#pod +#pod Template is the same as that required by mkstemp(). +#pod +#pod Will croak() if there is an error. +#pod +#pod Current API available since 0.05. +#pod +#pod =cut + +sub mktemp { + + croak "Usage: mktemp(template)" + if scalar(@_) != 1; + + my $template = shift; + + my ($tmpname, $junk, $errstr); + croak "Error getting name to temp file from template $template: $errstr" + unless (($junk, $tmpname) = _gettemp($template, + "open" => 0, + "mkdir"=> 0 , + "suffixlen" => 0, + "ErrStr" => \$errstr, + ) ); + + return $tmpname; +} + +#pod =back +#pod +#pod =head1 POSIX FUNCTIONS +#pod +#pod This section describes the re-implementation of the tmpnam() +#pod and tmpfile() functions described in L +#pod using the mkstemp() from this module. +#pod +#pod Unlike the L implementations, the directory used +#pod for the temporary file is not specified in a system include +#pod file (C) but simply depends on the choice of tmpdir() +#pod returned by L. On some implementations this +#pod location can be set using the C environment variable, which +#pod may not be secure. +#pod If this is a problem, simply use mkstemp() and specify a template. +#pod +#pod =over 4 +#pod +#pod =item B +#pod +#pod When called in scalar context, returns the full name (including path) +#pod of a temporary file (uses mktemp()). The only check is that the file does +#pod not already exist, but there is no guarantee that that condition will +#pod continue to apply. +#pod +#pod $file = tmpnam(); +#pod +#pod When called in list context, a filehandle to the open file and +#pod a filename are returned. This is achieved by calling mkstemp() +#pod after constructing a suitable template. +#pod +#pod ($fh, $file) = tmpnam(); +#pod +#pod If possible, this form should be used to prevent possible +#pod race conditions. +#pod +#pod See L for information on the choice of temporary +#pod directory for a particular operating system. +#pod +#pod Will croak() if there is an error. +#pod +#pod Current API available since 0.05. +#pod +#pod =cut + +sub tmpnam { + + # Retrieve the temporary directory name + my $tmpdir = _wrap_file_spec_tmpdir(); + + # XXX I don't know under what circumstances this occurs, -- xdg 2016-04-02 + croak "Error temporary directory is not writable" + if $tmpdir eq ''; + + # Use a ten character template and append to tmpdir + my $template = File::Spec->catfile($tmpdir, TEMPXXX); + + if (wantarray() ) { + return mkstemp($template); + } else { + return mktemp($template); + } + +} + +#pod =item B +#pod +#pod Returns the filehandle of a temporary file. +#pod +#pod $fh = tmpfile(); +#pod +#pod The file is removed when the filehandle is closed or when the program +#pod exits. No access to the filename is provided. +#pod +#pod If the temporary file can not be created undef is returned. +#pod Currently this command will probably not work when the temporary +#pod directory is on an NFS file system. +#pod +#pod Will croak() if there is an error. +#pod +#pod Available since 0.05. +#pod +#pod Returning undef if unable to create file added in 0.12. +#pod +#pod =cut + +sub tmpfile { + + # Simply call tmpnam() in a list context + my ($fh, $file) = tmpnam(); + + # Make sure file is removed when filehandle is closed + # This will fail on NFS + unlink0($fh, $file) + or return undef; + + return $fh; + +} + +#pod =back +#pod +#pod =head1 ADDITIONAL FUNCTIONS +#pod +#pod These functions are provided for backwards compatibility +#pod with common tempfile generation C library functions. +#pod +#pod They are not exported and must be addressed using the full package +#pod name. +#pod +#pod =over 4 +#pod +#pod =item B +#pod +#pod Return the name of a temporary file in the specified directory +#pod using a prefix. The file is guaranteed not to exist at the time +#pod the function was called, but such guarantees are good for one +#pod clock tick only. Always use the proper form of C +#pod with C if you must open such a filename. +#pod +#pod $filename = File::Temp::tempnam( $dir, $prefix ); +#pod +#pod Equivalent to running mktemp() with $dir/$prefixXXXXXXXX +#pod (using unix file convention as an example) +#pod +#pod Because this function uses mktemp(), it can suffer from race conditions. +#pod +#pod Will croak() if there is an error. +#pod +#pod Current API available since 0.05. +#pod +#pod =cut + +sub tempnam { + + croak 'Usage tempnam($dir, $prefix)' unless scalar(@_) == 2; + + my ($dir, $prefix) = @_; + + # Add a string to the prefix + $prefix .= 'XXXXXXXX'; + + # Concatenate the directory to the file + my $template = File::Spec->catfile($dir, $prefix); + + return mktemp($template); + +} + +#pod =back +#pod +#pod =head1 UTILITY FUNCTIONS +#pod +#pod Useful functions for dealing with the filehandle and filename. +#pod +#pod =over 4 +#pod +#pod =item B +#pod +#pod Given an open filehandle and the associated filename, make a safe +#pod unlink. This is achieved by first checking that the filename and +#pod filehandle initially point to the same file and that the number of +#pod links to the file is 1 (all fields returned by stat() are compared). +#pod Then the filename is unlinked and the filehandle checked once again to +#pod verify that the number of links on that file is now 0. This is the +#pod closest you can come to making sure that the filename unlinked was the +#pod same as the file whose descriptor you hold. +#pod +#pod unlink0($fh, $path) +#pod or die "Error unlinking file $path safely"; +#pod +#pod Returns false on error but croaks() if there is a security +#pod anomaly. The filehandle is not closed since on some occasions this is +#pod not required. +#pod +#pod On some platforms, for example Windows NT, it is not possible to +#pod unlink an open file (the file must be closed first). On those +#pod platforms, the actual unlinking is deferred until the program ends and +#pod good status is returned. A check is still performed to make sure that +#pod the filehandle and filename are pointing to the same thing (but not at +#pod the time the end block is executed since the deferred removal may not +#pod have access to the filehandle). +#pod +#pod Additionally, on Windows NT not all the fields returned by stat() can +#pod be compared. For example, the C and C fields seem to be +#pod different. Also, it seems that the size of the file returned by stat() +#pod does not always agree, with C being more accurate than +#pod C, presumably because of caching issues even when +#pod using autoflush (this is usually overcome by waiting a while after +#pod writing to the tempfile before attempting to C it). +#pod +#pod Finally, on NFS file systems the link count of the file handle does +#pod not always go to zero immediately after unlinking. Currently, this +#pod command is expected to fail on NFS disks. +#pod +#pod This function is disabled if the global variable $KEEP_ALL is true +#pod and an unlink on open file is supported. If the unlink is to be deferred +#pod to the END block, the file is still registered for removal. +#pod +#pod This function should not be called if you are using the object oriented +#pod interface since the it will interfere with the object destructor deleting +#pod the file. +#pod +#pod Available Since 0.05. +#pod +#pod If can not unlink open file, defer removal until later available since 0.06. +#pod +#pod =cut + +sub unlink0 { + + croak 'Usage: unlink0(filehandle, filename)' + unless scalar(@_) == 2; + + # Read args + my ($fh, $path) = @_; + + cmpstat($fh, $path) or return 0; + + # attempt remove the file (does not work on some platforms) + if (_can_unlink_opened_file()) { + + # return early (Without unlink) if we have been instructed to retain files. + return 1 if $KEEP_ALL; + + # XXX: do *not* call this on a directory; possible race + # resulting in recursive removal + croak "unlink0: $path has become a directory!" if -d $path; + unlink($path) or return 0; + + # Stat the filehandle + my @fh = stat $fh; + + print "Link count = $fh[3] \n" if $DEBUG; + + # Make sure that the link count is zero + # - Cygwin provides deferred unlinking, however, + # on Win9x the link count remains 1 + # On NFS the link count may still be 1 but we can't know that + # we are on NFS. Since we can't be sure, we'll defer it + + return 1 if $fh[3] == 0 || $^O eq 'cygwin'; + } + # fall-through if we can't unlink now + _deferred_unlink($fh, $path, 0); + return 1; +} + +#pod =item B +#pod +#pod Compare C of filehandle with C of provided filename. This +#pod can be used to check that the filename and filehandle initially point +#pod to the same file and that the number of links to the file is 1 (all +#pod fields returned by stat() are compared). +#pod +#pod cmpstat($fh, $path) +#pod or die "Error comparing handle with file"; +#pod +#pod Returns false if the stat information differs or if the link count is +#pod greater than 1. Calls croak if there is a security anomaly. +#pod +#pod On certain platforms, for example Windows, not all the fields returned by stat() +#pod can be compared. For example, the C and C fields seem to be +#pod different in Windows. Also, it seems that the size of the file +#pod returned by stat() does not always agree, with C being more +#pod accurate than C, presumably because of caching issues +#pod even when using autoflush (this is usually overcome by waiting a while +#pod after writing to the tempfile before attempting to C it). +#pod +#pod Not exported by default. +#pod +#pod Current API available since 0.14. +#pod +#pod =cut + +sub cmpstat { + + croak 'Usage: cmpstat(filehandle, filename)' + unless scalar(@_) == 2; + + # Read args + my ($fh, $path) = @_; + + warn "Comparing stat\n" + if $DEBUG; + + # Stat the filehandle - which may be closed if someone has manually + # closed the file. Can not turn off warnings without using $^W + # unless we upgrade to 5.006 minimum requirement + my @fh; + { + local ($^W) = 0; + @fh = stat $fh; + } + return unless @fh; + + if ($fh[3] > 1 && $^W) { + carp "unlink0: fstat found too many links; SB=@fh" if $^W; + } + + # Stat the path + my @path = stat $path; + + unless (@path) { + carp "unlink0: $path is gone already" if $^W; + return; + } + + # this is no longer a file, but may be a directory, or worse + unless (-f $path) { + confess "panic: $path is no longer a file: SB=@fh"; + } + + # Do comparison of each member of the array + # On WinNT dev and rdev seem to be different + # depending on whether it is a file or a handle. + # Cannot simply compare all members of the stat return + # Select the ones we can use + my @okstat = (0..$#fh); # Use all by default + if ($^O eq 'MSWin32') { + @okstat = (1,2,3,4,5,7,8,9,10); + } elsif ($^O eq 'os2') { + @okstat = (0, 2..$#fh); + } elsif ($^O eq 'VMS') { # device and file ID are sufficient + @okstat = (0, 1); + } elsif ($^O eq 'dos') { + @okstat = (0,2..7,11..$#fh); + } elsif ($^O eq 'mpeix') { + @okstat = (0..4,8..10); + } + + # Now compare each entry explicitly by number + for (@okstat) { + print "Comparing: $_ : $fh[$_] and $path[$_]\n" if $DEBUG; + # Use eq rather than == since rdev, blksize, and blocks (6, 11, + # and 12) will be '' on platforms that do not support them. This + # is fine since we are only comparing integers. + unless ($fh[$_] eq $path[$_]) { + warn "Did not match $_ element of stat\n" if $DEBUG; + return 0; + } + } + + return 1; +} + +#pod =item B +#pod +#pod Similar to C except after file comparison using cmpstat, the +#pod filehandle is closed prior to attempting to unlink the file. This +#pod allows the file to be removed without using an END block, but does +#pod mean that the post-unlink comparison of the filehandle state provided +#pod by C is not available. +#pod +#pod unlink1($fh, $path) +#pod or die "Error closing and unlinking file"; +#pod +#pod Usually called from the object destructor when using the OO interface. +#pod +#pod Not exported by default. +#pod +#pod This function is disabled if the global variable $KEEP_ALL is true. +#pod +#pod Can call croak() if there is a security anomaly during the stat() +#pod comparison. +#pod +#pod Current API available since 0.14. +#pod +#pod =cut + +sub unlink1 { + croak 'Usage: unlink1(filehandle, filename)' + unless scalar(@_) == 2; + + # Read args + my ($fh, $path) = @_; + + cmpstat($fh, $path) or return 0; + + # Close the file + close( $fh ) or return 0; + + # Make sure the file is writable (for windows) + _force_writable( $path ); + + # return early (without unlink) if we have been instructed to retain files. + return 1 if $KEEP_ALL; + + # remove the file + return unlink($path); +} + +#pod =item B +#pod +#pod Calling this function will cause any temp files or temp directories +#pod that are registered for removal to be removed. This happens automatically +#pod when the process exits but can be triggered manually if the caller is sure +#pod that none of the temp files are required. This method can be registered as +#pod an Apache callback. +#pod +#pod Note that if a temp directory is your current directory, it cannot be +#pod removed. C out of the directory first before calling +#pod C. (For the cleanup at program exit when the CLEANUP flag +#pod is set, this happens automatically.) +#pod +#pod On OSes where temp files are automatically removed when the temp file +#pod is closed, calling this function will have no effect other than to remove +#pod temporary directories (which may include temporary files). +#pod +#pod File::Temp::cleanup(); +#pod +#pod Not exported by default. +#pod +#pod Current API available since 0.15. +#pod +#pod =back +#pod +#pod =head1 PACKAGE VARIABLES +#pod +#pod These functions control the global state of the package. +#pod +#pod =over 4 +#pod +#pod =item B +#pod +#pod Controls the lengths to which the module will go to check the safety of the +#pod temporary file or directory before proceeding. +#pod Options are: +#pod +#pod =over 8 +#pod +#pod =item STANDARD +#pod +#pod Do the basic security measures to ensure the directory exists and is +#pod writable, that temporary files are opened only if they do not already +#pod exist, and that possible race conditions are avoided. Finally the +#pod L function is used to remove files safely. +#pod +#pod =item MEDIUM +#pod +#pod In addition to the STANDARD security, the output directory is checked +#pod to make sure that it is owned either by root or the user running the +#pod program. If the directory is writable by group or by other, it is then +#pod checked to make sure that the sticky bit is set. +#pod +#pod Will not work on platforms that do not support the C<-k> test +#pod for sticky bit. +#pod +#pod =item HIGH +#pod +#pod In addition to the MEDIUM security checks, also check for the +#pod possibility of ``chown() giveaway'' using the L +#pod sysconf() function. If this is a possibility, each directory in the +#pod path is checked in turn for safeness, recursively walking back to the +#pod root directory. +#pod +#pod For platforms that do not support the L +#pod C<_PC_CHOWN_RESTRICTED> symbol (for example, Windows NT) it is +#pod assumed that ``chown() giveaway'' is possible and the recursive test +#pod is performed. +#pod +#pod =back +#pod +#pod The level can be changed as follows: +#pod +#pod File::Temp->safe_level( File::Temp::HIGH ); +#pod +#pod The level constants are not exported by the module. +#pod +#pod Currently, you must be running at least perl v5.6.0 in order to +#pod run with MEDIUM or HIGH security. This is simply because the +#pod safety tests use functions from L that are not +#pod available in older versions of perl. The problem is that the version +#pod number for Fcntl is the same in perl 5.6.0 and in 5.005_03 even though +#pod they are different versions. +#pod +#pod On systems that do not support the HIGH or MEDIUM safety levels +#pod (for example Win NT or OS/2) any attempt to change the level will +#pod be ignored. The decision to ignore rather than raise an exception +#pod allows portable programs to be written with high security in mind +#pod for the systems that can support this without those programs failing +#pod on systems where the extra tests are irrelevant. +#pod +#pod If you really need to see whether the change has been accepted +#pod simply examine the return value of C. +#pod +#pod $newlevel = File::Temp->safe_level( File::Temp::HIGH ); +#pod die "Could not change to high security" +#pod if $newlevel != File::Temp::HIGH; +#pod +#pod Available since 0.05. +#pod +#pod =cut + +{ + # protect from using the variable itself + my $LEVEL = STANDARD; + sub safe_level { + my $self = shift; + if (@_) { + my $level = shift; + if (($level != STANDARD) && ($level != MEDIUM) && ($level != HIGH)) { + carp "safe_level: Specified level ($level) not STANDARD, MEDIUM or HIGH - ignoring\n" if $^W; + } else { + # Don't allow this on perl 5.005 or earlier + if ($] < 5.006 && $level != STANDARD) { + # Cant do MEDIUM or HIGH checks + croak "Currently requires perl 5.006 or newer to do the safe checks"; + } + # Check that we are allowed to change level + # Silently ignore if we can not. + $LEVEL = $level if _can_do_level($level); + } + } + return $LEVEL; + } +} + +#pod =item TopSystemUID +#pod +#pod This is the highest UID on the current system that refers to a root +#pod UID. This is used to make sure that the temporary directory is +#pod owned by a system UID (C, C, C etc) rather than +#pod simply by root. +#pod +#pod This is required since on many unix systems C is not owned +#pod by root. +#pod +#pod Default is to assume that any UID less than or equal to 10 is a root +#pod UID. +#pod +#pod File::Temp->top_system_uid(10); +#pod my $topid = File::Temp->top_system_uid; +#pod +#pod This value can be adjusted to reduce security checking if required. +#pod The value is only relevant when C is set to MEDIUM or higher. +#pod +#pod Available since 0.05. +#pod +#pod =cut + +{ + my $TopSystemUID = 10; + $TopSystemUID = 197108 if $^O eq 'interix'; # "Administrator" + sub top_system_uid { + my $self = shift; + if (@_) { + my $newuid = shift; + croak "top_system_uid: UIDs should be numeric" + unless $newuid =~ /^\d+$/s; + $TopSystemUID = $newuid; + } + return $TopSystemUID; + } +} + +#pod =item B<$KEEP_ALL> +#pod +#pod Controls whether temporary files and directories should be retained +#pod regardless of any instructions in the program to remove them +#pod automatically. This is useful for debugging but should not be used in +#pod production code. +#pod +#pod $File::Temp::KEEP_ALL = 1; +#pod +#pod Default is for files to be removed as requested by the caller. +#pod +#pod In some cases, files will only be retained if this variable is true +#pod when the file is created. This means that you can not create a temporary +#pod file, set this variable and expect the temp file to still be around +#pod when the program exits. +#pod +#pod =item B<$DEBUG> +#pod +#pod Controls whether debugging messages should be enabled. +#pod +#pod $File::Temp::DEBUG = 1; +#pod +#pod Default is for debugging mode to be disabled. +#pod +#pod Available since 0.15. +#pod +#pod =back +#pod +#pod =head1 WARNING +#pod +#pod For maximum security, endeavour always to avoid ever looking at, +#pod touching, or even imputing the existence of the filename. You do not +#pod know that that filename is connected to the same file as the handle +#pod you have, and attempts to check this can only trigger more race +#pod conditions. It's far more secure to use the filehandle alone and +#pod dispense with the filename altogether. +#pod +#pod If you need to pass the handle to something that expects a filename +#pod then on a unix system you can use C<"/dev/fd/" . fileno($fh)> for +#pod arbitrary programs. Perl code that uses the 2-argument version of +#pod C<< open >> can be passed C<< "+<=&" . fileno($fh) >>. Otherwise you +#pod will need to pass the filename. You will have to clear the +#pod close-on-exec bit on that file descriptor before passing it to another +#pod process. +#pod +#pod use Fcntl qw/F_SETFD F_GETFD/; +#pod fcntl($tmpfh, F_SETFD, 0) +#pod or die "Can't clear close-on-exec flag on temp fh: $!\n"; +#pod +#pod =head2 Temporary files and NFS +#pod +#pod Some problems are associated with using temporary files that reside +#pod on NFS file systems and it is recommended that a local filesystem +#pod is used whenever possible. Some of the security tests will most probably +#pod fail when the temp file is not local. Additionally, be aware that +#pod the performance of I/O operations over NFS will not be as good as for +#pod a local disk. +#pod +#pod =head2 Forking +#pod +#pod In some cases files created by File::Temp are removed from within an +#pod END block. Since END blocks are triggered when a child process exits +#pod (unless C is used by the child) File::Temp takes care +#pod to only remove those temp files created by a particular process ID. This +#pod means that a child will not attempt to remove temp files created by the +#pod parent process. +#pod +#pod If you are forking many processes in parallel that are all creating +#pod temporary files, you may need to reset the random number seed using +#pod srand(EXPR) in each child else all the children will attempt to walk +#pod through the same set of random file names and may well cause +#pod themselves to give up if they exceed the number of retry attempts. +#pod +#pod =head2 Directory removal +#pod +#pod Note that if you have chdir'ed into the temporary directory and it is +#pod subsequently cleaned up (either in the END block or as part of object +#pod destruction), then you will get a warning from File::Path::rmtree(). +#pod +#pod =head2 Taint mode +#pod +#pod If you need to run code under taint mode, updating to the latest +#pod L is highly recommended. On Windows, if the directory +#pod given by L isn't writable, File::Temp will attempt +#pod to fallback to the user's local application data directory or croak +#pod with an error. +#pod +#pod =head2 BINMODE +#pod +#pod The file returned by File::Temp will have been opened in binary mode +#pod if such a mode is available. If that is not correct, use the C +#pod function to change the mode of the filehandle. +#pod +#pod Note that you can modify the encoding of a file opened by File::Temp +#pod also by using C. +#pod +#pod =head1 HISTORY +#pod +#pod Originally began life in May 1999 as an XS interface to the system +#pod mkstemp() function. In March 2000, the OpenBSD mkstemp() code was +#pod translated to Perl for total control of the code's +#pod security checking, to ensure the presence of the function regardless of +#pod operating system and to help with portability. The module was shipped +#pod as a standard part of perl from v5.6.1. +#pod +#pod Thanks to Tom Christiansen for suggesting that this module +#pod should be written and providing ideas for code improvements and +#pod security enhancements. +#pod +#pod =head1 SEE ALSO +#pod +#pod L, L, L, L +#pod +#pod See L and L, L for +#pod different implementations of temporary file handling. +#pod +#pod See L for an alternative object-oriented wrapper for +#pod the C function. +#pod +#pod =cut + +package File::Temp::Dir; # git description: v0.2305-8-g4787a5d + +our $VERSION = '0.2306'; + +use File::Path qw/ rmtree /; +use strict; +use overload '""' => "STRINGIFY", + '0+' => \&File::Temp::NUMIFY, + fallback => 1; + +# private class specifically to support tempdir objects +# created by File::Temp->newdir + +# ostensibly the same method interface as File::Temp but without +# inheriting all the IO::Seekable methods and other cruft + +# Read-only - returns the name of the temp directory + +sub dirname { + my $self = shift; + return $self->{DIRNAME}; +} + +sub STRINGIFY { + my $self = shift; + return $self->dirname; +} + +sub unlink_on_destroy { + my $self = shift; + if (@_) { + $self->{CLEANUP} = shift; + } + return $self->{CLEANUP}; +} + +sub DESTROY { + my $self = shift; + local($., $@, $!, $^E, $?); + if ($self->unlink_on_destroy && + $$ == $self->{LAUNCHPID} && !$File::Temp::KEEP_ALL) { + if (-d $self->{REALNAME}) { + # Some versions of rmtree will abort if you attempt to remove + # the directory you are sitting in. We protect that and turn it + # into a warning. We do this because this occurs during object + # destruction and so can not be caught by the user. + eval { rmtree($self->{REALNAME}, $File::Temp::DEBUG, 0); }; + warn $@ if ($@ && $^W); + } + } +} + +1; + + +# vim: ts=2 sts=2 sw=2 et: + +__END__ + +=pod + +=encoding UTF-8 + +=head1 NAME + +File::Temp - return name and handle of a temporary file safely + +=head1 VERSION + +version 0.2306 + +=head1 SYNOPSIS + + use File::Temp qw/ tempfile tempdir /; + + $fh = tempfile(); + ($fh, $filename) = tempfile(); + + ($fh, $filename) = tempfile( $template, DIR => $dir); + ($fh, $filename) = tempfile( $template, SUFFIX => '.dat'); + ($fh, $filename) = tempfile( $template, TMPDIR => 1 ); + + binmode( $fh, ":utf8" ); + + $dir = tempdir( CLEANUP => 1 ); + ($fh, $filename) = tempfile( DIR => $dir ); + +Object interface: + + require File::Temp; + use File::Temp (); + use File::Temp qw/ :seekable /; + + $fh = File::Temp->new(); + $fname = $fh->filename; + + $fh = File::Temp->new(TEMPLATE => $template); + $fname = $fh->filename; + + $tmp = File::Temp->new( UNLINK => 0, SUFFIX => '.dat' ); + print $tmp "Some data\n"; + print "Filename is $tmp\n"; + $tmp->seek( 0, SEEK_END ); + + $dir = File::Temp->newdir(); # CLEANUP => 1 by default + +The following interfaces are provided for compatibility with +existing APIs. They should not be used in new code. + +MkTemp family: + + use File::Temp qw/ :mktemp /; + + ($fh, $file) = mkstemp( "tmpfileXXXXX" ); + ($fh, $file) = mkstemps( "tmpfileXXXXXX", $suffix); + + $tmpdir = mkdtemp( $template ); + + $unopened_file = mktemp( $template ); + +POSIX functions: + + use File::Temp qw/ :POSIX /; + + $file = tmpnam(); + $fh = tmpfile(); + + ($fh, $file) = tmpnam(); + +Compatibility functions: + + $unopened_file = File::Temp::tempnam( $dir, $pfx ); + +=head1 DESCRIPTION + +C can be used to create and open temporary files in a safe +way. There is both a function interface and an object-oriented +interface. The File::Temp constructor or the tempfile() function can +be used to return the name and the open filehandle of a temporary +file. The tempdir() function can be used to create a temporary +directory. + +The security aspect of temporary file creation is emphasized such that +a filehandle and filename are returned together. This helps guarantee +that a race condition can not occur where the temporary file is +created by another process between checking for the existence of the +file and its opening. Additional security levels are provided to +check, for example, that the sticky bit is set on world writable +directories. See L<"safe_level"> for more information. + +For compatibility with popular C library functions, Perl implementations of +the mkstemp() family of functions are provided. These are, mkstemp(), +mkstemps(), mkdtemp() and mktemp(). + +Additionally, implementations of the standard L +tmpnam() and tmpfile() functions are provided if required. + +Implementations of mktemp(), tmpnam(), and tempnam() are provided, +but should be used with caution since they return only a filename +that was valid when function was called, so cannot guarantee +that the file will not exist by the time the caller opens the filename. + +Filehandles returned by these functions support the seekable methods. + +=begin __INTERNALS + +=head1 PORTABILITY + +This section is at the top in order to provide easier access to +porters. It is not expected to be rendered by a standard pod +formatting tool. Please skip straight to the SYNOPSIS section if you +are not trying to port this module to a new platform. + +This module is designed to be portable across operating systems and it +currently supports Unix, VMS, DOS, OS/2, Windows and Mac OS +(Classic). When porting to a new OS there are generally three main +issues that have to be solved: +=over 4 + +=item * + +Can the OS unlink an open file? If it can not then the +C<_can_unlink_opened_file> method should be modified. + +=item * + +Are the return values from C reliable? By default all the +return values from C are compared when unlinking a temporary +file using the filename and the handle. Operating systems other than +unix do not always have valid entries in all fields. If utility function +C fails then the C comparison should be +modified accordingly. + +=item * + +Security. Systems that can not support a test for the sticky bit +on a directory can not use the MEDIUM and HIGH security tests. +The C<_can_do_level> method should be modified accordingly. + +=back + +=end __INTERNALS + +=head1 OBJECT-ORIENTED INTERFACE + +This is the primary interface for interacting with +C. Using the OO interface a temporary file can be created +when the object is constructed and the file can be removed when the +object is no longer required. + +Note that there is no method to obtain the filehandle from the +C object. The object itself acts as a filehandle. The object +isa C and isa C so all those methods are +available. + +Also, the object is configured such that it stringifies to the name of the +temporary file and so can be compared to a filename directly. It numifies +to the C the same as other handles and so can be compared to other +handles with C<==>. + + $fh eq $filename # as a string + $fh != \*STDOUT # as a number + +Available since 0.14. + +=over 4 + +=item B + +Create a temporary file object. + + my $tmp = File::Temp->new(); + +by default the object is constructed as if C +was called without options, but with the additional behaviour +that the temporary file is removed by the object destructor +if UNLINK is set to true (the default). + +Supported arguments are the same as for C: UNLINK +(defaulting to true), DIR, EXLOCK and SUFFIX. Additionally, the filename +template is specified using the TEMPLATE option. The OPEN option +is not supported (the file is always opened). + + $tmp = File::Temp->new( TEMPLATE => 'tempXXXXX', + DIR => 'mydir', + SUFFIX => '.dat'); + +Arguments are case insensitive. + +Can call croak() if an error occurs. + +Available since 0.14. + +TEMPLATE available since 0.23 + +=item B + +Create a temporary directory using an object oriented interface. + + $dir = File::Temp->newdir(); + +By default the directory is deleted when the object goes out of scope. + +Supports the same options as the C function. Note that directories +created with this method default to CLEANUP => 1. + + $dir = File::Temp->newdir( $template, %options ); + +A template may be specified either with a leading template or +with a TEMPLATE argument. + +Available since 0.19. + +TEMPLATE available since 0.23. + +=item B + +Return the name of the temporary file associated with this object +(if the object was created using the "new" constructor). + + $filename = $tmp->filename; + +This method is called automatically when the object is used as +a string. + +Current API available since 0.14 + +=item B + +Return the name of the temporary directory associated with this +object (if the object was created using the "newdir" constructor). + + $dirname = $tmpdir->dirname; + +This method is called automatically when the object is used in string context. + +=item B + +Control whether the file is unlinked when the object goes out of scope. +The file is removed if this value is true and $KEEP_ALL is not. + + $fh->unlink_on_destroy( 1 ); + +Default is for the file to be removed. + +Current API available since 0.15 + +=item B + +When the object goes out of scope, the destructor is called. This +destructor will attempt to unlink the file (using L) +if the constructor was called with UNLINK set to 1 (the default state +if UNLINK is not specified). + +No error is given if the unlink fails. + +If the object has been passed to a child process during a fork, the +file will be deleted when the object goes out of scope in the parent. + +For a temporary directory object the directory will be removed unless +the CLEANUP argument was used in the constructor (and set to false) or +C was modified after creation. Note that if a temp +directory is your current directory, it cannot be removed - a warning +will be given in this case. C out of the directory before +letting the object go out of scope. + +If the global variable $KEEP_ALL is true, the file or directory +will not be removed. + +=back + +=head1 FUNCTIONS + +This section describes the recommended interface for generating +temporary files and directories. + +=over 4 + +=item B + +This is the basic function to generate temporary files. +The behaviour of the file can be changed using various options: + + $fh = tempfile(); + ($fh, $filename) = tempfile(); + +Create a temporary file in the directory specified for temporary +files, as specified by the tmpdir() function in L. + + ($fh, $filename) = tempfile($template); + +Create a temporary file in the current directory using the supplied +template. Trailing `X' characters are replaced with random letters to +generate the filename. At least four `X' characters must be present +at the end of the template. + + ($fh, $filename) = tempfile($template, SUFFIX => $suffix) + +Same as previously, except that a suffix is added to the template +after the `X' translation. Useful for ensuring that a temporary +filename has a particular extension when needed by other applications. +But see the WARNING at the end. + + ($fh, $filename) = tempfile($template, DIR => $dir); + +Translates the template as before except that a directory name +is specified. + + ($fh, $filename) = tempfile($template, TMPDIR => 1); + +Equivalent to specifying a DIR of "File::Spec->tmpdir", writing the file +into the same temporary directory as would be used if no template was +specified at all. + + ($fh, $filename) = tempfile($template, UNLINK => 1); + +Return the filename and filehandle as before except that the file is +automatically removed when the program exits (dependent on +$KEEP_ALL). Default is for the file to be removed if a file handle is +requested and to be kept if the filename is requested. In a scalar +context (where no filename is returned) the file is always deleted +either (depending on the operating system) on exit or when it is +closed (unless $KEEP_ALL is true when the temp file is created). + +Use the object-oriented interface if fine-grained control of when +a file is removed is required. + +If the template is not specified, a template is always +automatically generated. This temporary file is placed in tmpdir() +(L) unless a directory is specified explicitly with the +DIR option. + + $fh = tempfile( DIR => $dir ); + +If called in scalar context, only the filehandle is returned and the +file will automatically be deleted when closed on operating systems +that support this (see the description of tmpfile() elsewhere in this +document). This is the preferred mode of operation, as if you only +have a filehandle, you can never create a race condition by fumbling +with the filename. On systems that can not unlink an open file or can +not mark a file as temporary when it is opened (for example, Windows +NT uses the C flag) the file is marked for deletion when +the program ends (equivalent to setting UNLINK to 1). The C +flag is ignored if present. + + (undef, $filename) = tempfile($template, OPEN => 0); + +This will return the filename based on the template but +will not open this file. Cannot be used in conjunction with +UNLINK set to true. Default is to always open the file +to protect from possible race conditions. A warning is issued +if warnings are turned on. Consider using the tmpnam() +and mktemp() functions described elsewhere in this document +if opening the file is not required. + +If the operating system supports it (for example BSD derived systems), the +filehandle will be opened with O_EXLOCK (open with exclusive file lock). +This can sometimes cause problems if the intention is to pass the filename +to another system that expects to take an exclusive lock itself (such as +DBD::SQLite) whilst ensuring that the tempfile is not reused. In this +situation the "EXLOCK" option can be passed to tempfile. By default EXLOCK +will be true (this retains compatibility with earlier releases). + + ($fh, $filename) = tempfile($template, EXLOCK => 0); + +Options can be combined as required. + +Will croak() if there is an error. + +Available since 0.05. + +UNLINK flag available since 0.10. + +TMPDIR flag available since 0.19. + +EXLOCK flag available since 0.19. + +=item B + +This is the recommended interface for creation of temporary +directories. By default the directory will not be removed on exit +(that is, it won't be temporary; this behaviour can not be changed +because of issues with backwards compatibility). To enable removal +either use the CLEANUP option which will trigger removal on program +exit, or consider using the "newdir" method in the object interface which +will allow the directory to be cleaned up when the object goes out of +scope. + +The behaviour of the function depends on the arguments: + + $tempdir = tempdir(); + +Create a directory in tmpdir() (see L). + + $tempdir = tempdir( $template ); + +Create a directory from the supplied template. This template is +similar to that described for tempfile(). `X' characters at the end +of the template are replaced with random letters to construct the +directory name. At least four `X' characters must be in the template. + + $tempdir = tempdir ( DIR => $dir ); + +Specifies the directory to use for the temporary directory. +The temporary directory name is derived from an internal template. + + $tempdir = tempdir ( $template, DIR => $dir ); + +Prepend the supplied directory name to the template. The template +should not include parent directory specifications itself. Any parent +directory specifications are removed from the template before +prepending the supplied directory. + + $tempdir = tempdir ( $template, TMPDIR => 1 ); + +Using the supplied template, create the temporary directory in +a standard location for temporary files. Equivalent to doing + + $tempdir = tempdir ( $template, DIR => File::Spec->tmpdir); + +but shorter. Parent directory specifications are stripped from the +template itself. The C option is ignored if C is set +explicitly. Additionally, C is implied if neither a template +nor a directory are supplied. + + $tempdir = tempdir( $template, CLEANUP => 1); + +Create a temporary directory using the supplied template, but +attempt to remove it (and all files inside it) when the program +exits. Note that an attempt will be made to remove all files from +the directory even if they were not created by this module (otherwise +why ask to clean it up?). The directory removal is made with +the rmtree() function from the L module. +Of course, if the template is not specified, the temporary directory +will be created in tmpdir() and will also be removed at program exit. + +Will croak() if there is an error. + +Current API available since 0.05. + +=back + +=head1 MKTEMP FUNCTIONS + +The following functions are Perl implementations of the +mktemp() family of temp file generation system calls. + +=over 4 + +=item B + +Given a template, returns a filehandle to the temporary file and the name +of the file. + + ($fh, $name) = mkstemp( $template ); + +In scalar context, just the filehandle is returned. + +The template may be any filename with some number of X's appended +to it, for example F. The trailing X's are replaced +with unique alphanumeric combinations. + +Will croak() if there is an error. + +Current API available since 0.05. + +=item B + +Similar to mkstemp(), except that an extra argument can be supplied +with a suffix to be appended to the template. + + ($fh, $name) = mkstemps( $template, $suffix ); + +For example a template of C and suffix of C<.dat> +would generate a file similar to F. + +Returns just the filehandle alone when called in scalar context. + +Will croak() if there is an error. + +Current API available since 0.05. + +=item B + +Create a directory from a template. The template must end in +X's that are replaced by the routine. + + $tmpdir_name = mkdtemp($template); + +Returns the name of the temporary directory created. + +Directory must be removed by the caller. + +Will croak() if there is an error. + +Current API available since 0.05. + +=item B + +Returns a valid temporary filename but does not guarantee +that the file will not be opened by someone else. + + $unopened_file = mktemp($template); + +Template is the same as that required by mkstemp(). + +Will croak() if there is an error. + +Current API available since 0.05. + +=back + +=head1 POSIX FUNCTIONS + +This section describes the re-implementation of the tmpnam() +and tmpfile() functions described in L +using the mkstemp() from this module. + +Unlike the L implementations, the directory used +for the temporary file is not specified in a system include +file (C) but simply depends on the choice of tmpdir() +returned by L. On some implementations this +location can be set using the C environment variable, which +may not be secure. +If this is a problem, simply use mkstemp() and specify a template. + +=over 4 + +=item B + +When called in scalar context, returns the full name (including path) +of a temporary file (uses mktemp()). The only check is that the file does +not already exist, but there is no guarantee that that condition will +continue to apply. + + $file = tmpnam(); + +When called in list context, a filehandle to the open file and +a filename are returned. This is achieved by calling mkstemp() +after constructing a suitable template. + + ($fh, $file) = tmpnam(); + +If possible, this form should be used to prevent possible +race conditions. + +See L for information on the choice of temporary +directory for a particular operating system. + +Will croak() if there is an error. + +Current API available since 0.05. + +=item B + +Returns the filehandle of a temporary file. + + $fh = tmpfile(); + +The file is removed when the filehandle is closed or when the program +exits. No access to the filename is provided. + +If the temporary file can not be created undef is returned. +Currently this command will probably not work when the temporary +directory is on an NFS file system. + +Will croak() if there is an error. + +Available since 0.05. + +Returning undef if unable to create file added in 0.12. + +=back + +=head1 ADDITIONAL FUNCTIONS + +These functions are provided for backwards compatibility +with common tempfile generation C library functions. + +They are not exported and must be addressed using the full package +name. + +=over 4 + +=item B + +Return the name of a temporary file in the specified directory +using a prefix. The file is guaranteed not to exist at the time +the function was called, but such guarantees are good for one +clock tick only. Always use the proper form of C +with C if you must open such a filename. + + $filename = File::Temp::tempnam( $dir, $prefix ); + +Equivalent to running mktemp() with $dir/$prefixXXXXXXXX +(using unix file convention as an example) + +Because this function uses mktemp(), it can suffer from race conditions. + +Will croak() if there is an error. + +Current API available since 0.05. + +=back + +=head1 UTILITY FUNCTIONS + +Useful functions for dealing with the filehandle and filename. + +=over 4 + +=item B + +Given an open filehandle and the associated filename, make a safe +unlink. This is achieved by first checking that the filename and +filehandle initially point to the same file and that the number of +links to the file is 1 (all fields returned by stat() are compared). +Then the filename is unlinked and the filehandle checked once again to +verify that the number of links on that file is now 0. This is the +closest you can come to making sure that the filename unlinked was the +same as the file whose descriptor you hold. + + unlink0($fh, $path) + or die "Error unlinking file $path safely"; + +Returns false on error but croaks() if there is a security +anomaly. The filehandle is not closed since on some occasions this is +not required. + +On some platforms, for example Windows NT, it is not possible to +unlink an open file (the file must be closed first). On those +platforms, the actual unlinking is deferred until the program ends and +good status is returned. A check is still performed to make sure that +the filehandle and filename are pointing to the same thing (but not at +the time the end block is executed since the deferred removal may not +have access to the filehandle). + +Additionally, on Windows NT not all the fields returned by stat() can +be compared. For example, the C and C fields seem to be +different. Also, it seems that the size of the file returned by stat() +does not always agree, with C being more accurate than +C, presumably because of caching issues even when +using autoflush (this is usually overcome by waiting a while after +writing to the tempfile before attempting to C it). + +Finally, on NFS file systems the link count of the file handle does +not always go to zero immediately after unlinking. Currently, this +command is expected to fail on NFS disks. + +This function is disabled if the global variable $KEEP_ALL is true +and an unlink on open file is supported. If the unlink is to be deferred +to the END block, the file is still registered for removal. + +This function should not be called if you are using the object oriented +interface since the it will interfere with the object destructor deleting +the file. + +Available Since 0.05. + +If can not unlink open file, defer removal until later available since 0.06. + +=item B + +Compare C of filehandle with C of provided filename. This +can be used to check that the filename and filehandle initially point +to the same file and that the number of links to the file is 1 (all +fields returned by stat() are compared). + + cmpstat($fh, $path) + or die "Error comparing handle with file"; + +Returns false if the stat information differs or if the link count is +greater than 1. Calls croak if there is a security anomaly. + +On certain platforms, for example Windows, not all the fields returned by stat() +can be compared. For example, the C and C fields seem to be +different in Windows. Also, it seems that the size of the file +returned by stat() does not always agree, with C being more +accurate than C, presumably because of caching issues +even when using autoflush (this is usually overcome by waiting a while +after writing to the tempfile before attempting to C it). + +Not exported by default. + +Current API available since 0.14. + +=item B + +Similar to C except after file comparison using cmpstat, the +filehandle is closed prior to attempting to unlink the file. This +allows the file to be removed without using an END block, but does +mean that the post-unlink comparison of the filehandle state provided +by C is not available. + + unlink1($fh, $path) + or die "Error closing and unlinking file"; + +Usually called from the object destructor when using the OO interface. + +Not exported by default. + +This function is disabled if the global variable $KEEP_ALL is true. + +Can call croak() if there is a security anomaly during the stat() +comparison. + +Current API available since 0.14. + +=item B + +Calling this function will cause any temp files or temp directories +that are registered for removal to be removed. This happens automatically +when the process exits but can be triggered manually if the caller is sure +that none of the temp files are required. This method can be registered as +an Apache callback. + +Note that if a temp directory is your current directory, it cannot be +removed. C out of the directory first before calling +C. (For the cleanup at program exit when the CLEANUP flag +is set, this happens automatically.) + +On OSes where temp files are automatically removed when the temp file +is closed, calling this function will have no effect other than to remove +temporary directories (which may include temporary files). + + File::Temp::cleanup(); + +Not exported by default. + +Current API available since 0.15. + +=back + +=head1 PACKAGE VARIABLES + +These functions control the global state of the package. + +=over 4 + +=item B + +Controls the lengths to which the module will go to check the safety of the +temporary file or directory before proceeding. +Options are: + +=over 8 + +=item STANDARD + +Do the basic security measures to ensure the directory exists and is +writable, that temporary files are opened only if they do not already +exist, and that possible race conditions are avoided. Finally the +L function is used to remove files safely. + +=item MEDIUM + +In addition to the STANDARD security, the output directory is checked +to make sure that it is owned either by root or the user running the +program. If the directory is writable by group or by other, it is then +checked to make sure that the sticky bit is set. + +Will not work on platforms that do not support the C<-k> test +for sticky bit. + +=item HIGH + +In addition to the MEDIUM security checks, also check for the +possibility of ``chown() giveaway'' using the L +sysconf() function. If this is a possibility, each directory in the +path is checked in turn for safeness, recursively walking back to the +root directory. + +For platforms that do not support the L +C<_PC_CHOWN_RESTRICTED> symbol (for example, Windows NT) it is +assumed that ``chown() giveaway'' is possible and the recursive test +is performed. + +=back + +The level can be changed as follows: + + File::Temp->safe_level( File::Temp::HIGH ); + +The level constants are not exported by the module. + +Currently, you must be running at least perl v5.6.0 in order to +run with MEDIUM or HIGH security. This is simply because the +safety tests use functions from L that are not +available in older versions of perl. The problem is that the version +number for Fcntl is the same in perl 5.6.0 and in 5.005_03 even though +they are different versions. + +On systems that do not support the HIGH or MEDIUM safety levels +(for example Win NT or OS/2) any attempt to change the level will +be ignored. The decision to ignore rather than raise an exception +allows portable programs to be written with high security in mind +for the systems that can support this without those programs failing +on systems where the extra tests are irrelevant. + +If you really need to see whether the change has been accepted +simply examine the return value of C. + + $newlevel = File::Temp->safe_level( File::Temp::HIGH ); + die "Could not change to high security" + if $newlevel != File::Temp::HIGH; + +Available since 0.05. + +=item TopSystemUID + +This is the highest UID on the current system that refers to a root +UID. This is used to make sure that the temporary directory is +owned by a system UID (C, C, C etc) rather than +simply by root. + +This is required since on many unix systems C is not owned +by root. + +Default is to assume that any UID less than or equal to 10 is a root +UID. + + File::Temp->top_system_uid(10); + my $topid = File::Temp->top_system_uid; + +This value can be adjusted to reduce security checking if required. +The value is only relevant when C is set to MEDIUM or higher. + +Available since 0.05. + +=item B<$KEEP_ALL> + +Controls whether temporary files and directories should be retained +regardless of any instructions in the program to remove them +automatically. This is useful for debugging but should not be used in +production code. + + $File::Temp::KEEP_ALL = 1; + +Default is for files to be removed as requested by the caller. + +In some cases, files will only be retained if this variable is true +when the file is created. This means that you can not create a temporary +file, set this variable and expect the temp file to still be around +when the program exits. + +=item B<$DEBUG> + +Controls whether debugging messages should be enabled. + + $File::Temp::DEBUG = 1; + +Default is for debugging mode to be disabled. + +Available since 0.15. + +=back + +=head1 WARNING + +For maximum security, endeavour always to avoid ever looking at, +touching, or even imputing the existence of the filename. You do not +know that that filename is connected to the same file as the handle +you have, and attempts to check this can only trigger more race +conditions. It's far more secure to use the filehandle alone and +dispense with the filename altogether. + +If you need to pass the handle to something that expects a filename +then on a unix system you can use C<"/dev/fd/" . fileno($fh)> for +arbitrary programs. Perl code that uses the 2-argument version of +C<< open >> can be passed C<< "+<=&" . fileno($fh) >>. Otherwise you +will need to pass the filename. You will have to clear the +close-on-exec bit on that file descriptor before passing it to another +process. + + use Fcntl qw/F_SETFD F_GETFD/; + fcntl($tmpfh, F_SETFD, 0) + or die "Can't clear close-on-exec flag on temp fh: $!\n"; + +=head2 Temporary files and NFS + +Some problems are associated with using temporary files that reside +on NFS file systems and it is recommended that a local filesystem +is used whenever possible. Some of the security tests will most probably +fail when the temp file is not local. Additionally, be aware that +the performance of I/O operations over NFS will not be as good as for +a local disk. + +=head2 Forking + +In some cases files created by File::Temp are removed from within an +END block. Since END blocks are triggered when a child process exits +(unless C is used by the child) File::Temp takes care +to only remove those temp files created by a particular process ID. This +means that a child will not attempt to remove temp files created by the +parent process. + +If you are forking many processes in parallel that are all creating +temporary files, you may need to reset the random number seed using +srand(EXPR) in each child else all the children will attempt to walk +through the same set of random file names and may well cause +themselves to give up if they exceed the number of retry attempts. + +=head2 Directory removal + +Note that if you have chdir'ed into the temporary directory and it is +subsequently cleaned up (either in the END block or as part of object +destruction), then you will get a warning from File::Path::rmtree(). + +=head2 Taint mode + +If you need to run code under taint mode, updating to the latest +L is highly recommended. On Windows, if the directory +given by L isn't writable, File::Temp will attempt +to fallback to the user's local application data directory or croak +with an error. + +=head2 BINMODE + +The file returned by File::Temp will have been opened in binary mode +if such a mode is available. If that is not correct, use the C +function to change the mode of the filehandle. + +Note that you can modify the encoding of a file opened by File::Temp +also by using C. + +=head1 HISTORY + +Originally began life in May 1999 as an XS interface to the system +mkstemp() function. In March 2000, the OpenBSD mkstemp() code was +translated to Perl for total control of the code's +security checking, to ensure the presence of the function regardless of +operating system and to help with portability. The module was shipped +as a standard part of perl from v5.6.1. + +Thanks to Tom Christiansen for suggesting that this module +should be written and providing ideas for code improvements and +security enhancements. + +=head1 SEE ALSO + +L, L, L, L + +See L and L, L for +different implementations of temporary file handling. + +See L for an alternative object-oriented wrapper for +the C function. + +=for Pod::Coverage STRINGIFY NUMIFY top_system_uid + +=head1 SUPPORT + +Bugs may be submitted through L +(or L). + +There is also a mailing list available for users of this distribution, at +L. + +There is also an irc channel available for users of this distribution, at +L on C|irc://irc.perl.org/#toolchain>. + +=head1 AUTHOR + +Tim Jenness + +=head1 CONTRIBUTORS + +=for stopwords David Golden Karen Etheridge Olivier Mengue Peter Rabbitson Ben Tilly Kevin Ryde John Acklam Slaven Rezic James E. Keenan Brian Mowrey Dagfinn Ilmari Mannsåker Steinbrunner Ed Avis Guillem Jover + +=over 4 + +=item * + +David Golden + +=item * + +Karen Etheridge + +=item * + +Olivier Mengue + +=item * + +David Golden + +=item * + +Peter Rabbitson + +=item * + +Ben Tilly + +=item * + +Kevin Ryde + +=item * + +Peter John Acklam + +=item * + +Slaven Rezic + +=item * + +Slaven Rezic + +=item * + +James E. Keenan + +=item * + +Brian Mowrey + +=item * + +Dagfinn Ilmari Mannsåker + +=item * + +David Steinbrunner + +=item * + +Ed Avis + +=item * + +Guillem Jover + +=back + +=head1 COPYRIGHT AND LICENSE + +This software is copyright (c) 2018 by Tim Jenness and the UK Particle Physics and Astronomy Research Council. + +This is free software; you can redistribute it and/or modify it under +the same terms as the Perl 5 programming language system itself. + +=cut diff --git a/misc/benchmark.pl b/misc/benchmark.pl new file mode 100755 index 0000000..bdea837 --- /dev/null +++ b/misc/benchmark.pl @@ -0,0 +1,42 @@ +#!/usr/local/bin/perl -w + +# Simple benchmark of temporary file creation (no filename just a handle) +# Uses the following: +# - temporary file creation created by IO::File +# - temporary file creation using File::Temp (uses security checking) +# - A roll-our-own wrapper on top of POSIX::tempnam (essentially +# a compact form of File::Temp without all the extras) taken from +# the Perl cookbook + +# Would not + +use strict; +use Benchmark; +use IO::File; +use POSIX qw/ tmpnam /; +use File::Temp qw/ tempfile /; +use Symbol; + +# Benchmark IO::File and File::Temp + +timethese(10000, { + 'IO::File' => sub { + my $fh = IO::File::new_tmpfile || die $ !; + }, + 'File::Temp::tempfile' => sub { + my $fh = tempfile() || die $ !; + }, + 'POSIX::tmpnam' => sub { + my $fh = gensym;; + my $name; + for (;;) { + $name = tmpnam(); + sysopen( $fh, $name, O_RDWR | O_CREAT | O_EXCL ) + && last; + } + unlink $name; + } + } + ); + + diff --git a/misc/results.txt b/misc/results.txt new file mode 100644 index 0000000..b73196a --- /dev/null +++ b/misc/results.txt @@ -0,0 +1,33 @@ +This file contains the results of the File::Temp benchmark script +by File::Temp version, perl version and OS. + +On Windows NT, currently have problems with this benchmark since it +runs into a file limit after a while (this is because unlinking of the +open file is deferred until the end of the program rather than closing +it and unlinking it explcitly round the loop). + +Times are in CPU seconds. + +VERSION PERL OS File::Temp/s IO::File/s POSIX::tmpnam + +0.07 5.6.0 linux(1) 22.4 1.7 2.1 + 5.005_03 linux(1) 33.6 1.6 2.1 + +0.08 5.6.0 linux(1) 8.1 1.7 2.1 + 5.005_03 linux(1) 8.4 1.6 2.1 + + 5.6.0 solaris(2) 32.3 237.0 229.5 + + 5.005_03 dig.unix(3) 153.2 44.9 51.5 + + + + +1. A 600 MHz pentium III running RedHat 6.1 + +2. A Sparc Ultra 1 running Solaris 2.6. /tmp local, /var/tmp on NFS + (/var/tmp is the default temp location on Solaris and is used by + POSIX::tmpnam whereas /tmp is used by File::Temp since that is the + location specified by File::Spec) + +3. DEC 3000 Alpha running digital unix 4.0. diff --git a/t/00-report-prereqs.dd b/t/00-report-prereqs.dd new file mode 100644 index 0000000..3f152e6 --- /dev/null +++ b/t/00-report-prereqs.dd @@ -0,0 +1,142 @@ +do { my $x = { + 'configure' => { + 'requires' => { + 'ExtUtils::MakeMaker' => '0' + } + }, + 'develop' => { + 'recommends' => { + 'Dist::Zilla::PluginBundle::Author::ETHER' => '0.141', + 'Dist::Zilla::PluginBundle::Git::VersionManager' => '0.007' + }, + 'requires' => { + 'Encode' => '0', + 'File::Spec' => '0', + 'IO::Handle' => '0', + 'IPC::Open3' => '0', + 'Pod::Coverage::TrustPod' => '0', + 'Pod::Wordlist' => '0', + 'Test::CPAN::Changes' => '0.19', + 'Test::CPAN::Meta' => '0', + 'Test::Kwalitee' => '1.21', + 'Test::Mojibake' => '0', + 'Test::More' => '0.96', + 'Test::Pod' => '1.41', + 'Test::Pod::Coverage' => '1.08', + 'Test::Pod::No404s' => '0', + 'Test::Portability::Files' => '0', + 'Test::Spelling' => '0.12', + 'warnings' => '0' + } + }, + 'runtime' => { + 'requires' => { + 'Carp' => '0', + 'Carp::Heavy' => '0', + 'Cwd' => '0', + 'Exporter' => '5.57', + 'Fcntl' => '1.03', + 'File::Path' => '2.06', + 'File::Spec' => '0.8', + 'IO::Handle' => '0', + 'IO::Seekable' => '0', + 'POSIX' => '0', + 'Scalar::Util' => '0', + 'Symbol' => '0', + 'constant' => '0', + 'overload' => '0', + 'parent' => '0.221', + 'perl' => '5.006', + 'strict' => '0' + } + }, + 'test' => { + 'recommends' => { + 'CPAN::Meta' => '2.120900' + }, + 'requires' => { + 'ExtUtils::MakeMaker' => '0', + 'File::Spec' => '0.8', + 'FileHandle' => '0', + 'Test::More' => '0', + 'warnings' => '0' + } + }, + 'x_Dist_Zilla' => { + 'requires' => { + 'Dist::Zilla' => '5', + 'Dist::Zilla::Plugin::Authority' => '1.009', + 'Dist::Zilla::Plugin::AutoMetaResources' => '0', + 'Dist::Zilla::Plugin::AutoPrereqs' => '5.038', + 'Dist::Zilla::Plugin::BumpVersionAfterRelease::Transitional' => '0.004', + 'Dist::Zilla::Plugin::CheckIssues' => '0', + 'Dist::Zilla::Plugin::CheckMetaResources' => '0', + 'Dist::Zilla::Plugin::CheckPrereqsIndexed' => '0.019', + 'Dist::Zilla::Plugin::CheckSelfDependency' => '0', + 'Dist::Zilla::Plugin::CheckStrictVersion' => '0', + 'Dist::Zilla::Plugin::ConfirmRelease' => '0', + 'Dist::Zilla::Plugin::CopyFilesFromRelease' => '0', + 'Dist::Zilla::Plugin::DualLife' => '0', + 'Dist::Zilla::Plugin::EnsureLatestPerl' => '0', + 'Dist::Zilla::Plugin::FileFinder::ByName' => '0', + 'Dist::Zilla::Plugin::GenerateFile::FromShareDir' => '0', + 'Dist::Zilla::Plugin::Git::Check' => '0', + 'Dist::Zilla::Plugin::Git::CheckFor::CorrectBranch' => '0.004', + 'Dist::Zilla::Plugin::Git::CheckFor::MergeConflicts' => '0', + 'Dist::Zilla::Plugin::Git::Commit' => '2.020', + 'Dist::Zilla::Plugin::Git::Contributors' => '0.029', + 'Dist::Zilla::Plugin::Git::Describe' => '0.004', + 'Dist::Zilla::Plugin::Git::GatherDir' => '2.016', + 'Dist::Zilla::Plugin::Git::Push' => '0', + 'Dist::Zilla::Plugin::Git::Remote::Check' => '0', + 'Dist::Zilla::Plugin::Git::Tag' => '0', + 'Dist::Zilla::Plugin::GitHub::Update' => '0.40', + 'Dist::Zilla::Plugin::GithubMeta' => '0.54', + 'Dist::Zilla::Plugin::InstallGuide' => '1.200005', + 'Dist::Zilla::Plugin::Keywords' => '0.004', + 'Dist::Zilla::Plugin::License' => '5.038', + 'Dist::Zilla::Plugin::MakeMaker' => '0', + 'Dist::Zilla::Plugin::Manifest' => '0', + 'Dist::Zilla::Plugin::MetaConfig' => '0', + 'Dist::Zilla::Plugin::MetaJSON' => '0', + 'Dist::Zilla::Plugin::MetaNoIndex' => '0', + 'Dist::Zilla::Plugin::MetaProvides::Package' => '1.15000002', + 'Dist::Zilla::Plugin::MetaResources' => '0', + 'Dist::Zilla::Plugin::MetaTests' => '0', + 'Dist::Zilla::Plugin::MetaYAML' => '0', + 'Dist::Zilla::Plugin::MojibakeTests' => '0.8', + 'Dist::Zilla::Plugin::NextRelease' => '5.033', + 'Dist::Zilla::Plugin::OSPrereqs' => '0', + 'Dist::Zilla::Plugin::OnlyCorePrereqs' => '0.014', + 'Dist::Zilla::Plugin::PodCoverageTests' => '5.040', + 'Dist::Zilla::Plugin::PodSyntaxTests' => '5.040', + 'Dist::Zilla::Plugin::PodWeaver' => '4.005', + 'Dist::Zilla::Plugin::Prereqs' => '0', + 'Dist::Zilla::Plugin::Prereqs::AuthorDeps' => '0.006', + 'Dist::Zilla::Plugin::PromptIfStale' => '0', + 'Dist::Zilla::Plugin::Readme' => '0', + 'Dist::Zilla::Plugin::ReadmeAnyFromPod' => '0.142180', + 'Dist::Zilla::Plugin::RewriteVersion::Transitional' => '0.004', + 'Dist::Zilla::Plugin::Run::AfterBuild' => '0.041', + 'Dist::Zilla::Plugin::Run::AfterRelease' => '0.038', + 'Dist::Zilla::Plugin::RunExtraTests' => '0.024', + 'Dist::Zilla::Plugin::StaticInstall' => '0.005', + 'Dist::Zilla::Plugin::Test::CPAN::Changes' => '0.012', + 'Dist::Zilla::Plugin::Test::ChangesHasContent' => '0', + 'Dist::Zilla::Plugin::Test::Compile' => '2.039', + 'Dist::Zilla::Plugin::Test::Kwalitee' => '2.10', + 'Dist::Zilla::Plugin::Test::Pod::No404s' => '1.003', + 'Dist::Zilla::Plugin::Test::PodSpelling' => '2.006003', + 'Dist::Zilla::Plugin::Test::Portability' => '2.000007', + 'Dist::Zilla::Plugin::Test::ReportPrereqs' => '0.022', + 'Dist::Zilla::Plugin::TestRelease' => '0', + 'Dist::Zilla::Plugin::UploadToCPAN' => '0', + 'Dist::Zilla::Plugin::UseUnsafeInc' => '0', + 'Dist::Zilla::PluginBundle::Author::ETHER' => '0.119', + 'Dist::Zilla::PluginBundle::Git::VersionManager' => '0.007', + 'Software::License::Perl_5' => '0' + } + } + }; + $x; + } \ No newline at end of file diff --git a/t/00-report-prereqs.t b/t/00-report-prereqs.t new file mode 100644 index 0000000..5bc246e --- /dev/null +++ b/t/00-report-prereqs.t @@ -0,0 +1,198 @@ +#!perl + +use strict; +use warnings; + +# This test was generated by Dist::Zilla::Plugin::Test::ReportPrereqs 0.027 + +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( + Encode + JSON::PP + Pod::Coverage + Sub::Name + YAML + autodie +); + +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'; +my $cpan_meta_error; +if ( $source && $HAS_CPAN_META + && (my $meta = eval { CPAN::Meta->load_file($source) } ) +) { + $full_prereqs = _merge_prereqs($full_prereqs, $meta->prereqs); +} +else { + $cpan_meta_error = $@; # capture error from CPAN::Meta->load_file($source) + $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 ( $cpan_meta_error || @dep_errors ) { + diag "\n*** WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING ***\n"; +} + +if ( $cpan_meta_error ) { + my ($orig_source) = grep { -f } 'MYMETA.json', 'MYMETA.yml'; + diag "\nCPAN::Meta->load_file('$orig_source') failed with: $cpan_meta_error\n"; +} + +if ( @dep_errors ) { + diag join("\n", + "\nThe following REQUIRED prerequisites were not satisfied:\n", + @dep_errors, + "\n" + ); +} + +pass; + +# vim: ts=4 sts=4 sw=4 et: diff --git a/t/cmp.t b/t/cmp.t new file mode 100644 index 0000000..d826ede --- /dev/null +++ b/t/cmp.t @@ -0,0 +1,51 @@ +#!perl -w +# Test overloading + +use Test::More tests => 19; +use strict; + +BEGIN {use_ok( "File::Temp" ); } + +{ + my $fh = new File::Temp(); + isa_ok ($fh, 'File::Temp'); + + ok( "$fh" ne "foo", "compare stringified object with string"); + ok( $fh ne "foo", "compare object with string"); + ok( $fh eq $fh, "compare eq with self"); + + ok( $fh != 0, "compare != 0"); + ok( $fh == $fh, "compare == with self"); + ok( $fh != \*STDOUT, "compare != \*STDOUT"); + + { + my $num = $fh+0; + like ($num, qr/^\d+$/, '+0 is a number'); + } + { + my $str = "$fh"; + unlike ($str, qr/^\d+$/, '"" is not a number'); + } +} + +{ + my $fh = File::Temp->newdir(); + isa_ok ($fh, 'File::Temp::Dir'); + + ok( "$fh" ne "foo", "compare stringified object with string"); + ok( $fh ne "foo", "compare object with string"); + ok( $fh eq $fh, "compare eq with self"); + + ok( $fh != 0, "compare != 0"); + ok( $fh == $fh, "compare == with self"); + ok( $fh != \*STDOUT, "compare != \*STDOUT"); + + { + my $num = $fh+0; + like ($num, qr/^\d+$/, '+0 is a number'); + } + { + my $str = "$fh"; + unlike ($str, qr/^\d+$/, '"" is not a number'); + } +} diff --git a/t/fork.t b/t/fork.t new file mode 100644 index 0000000..fd3f5a6 --- /dev/null +++ b/t/fork.t @@ -0,0 +1,103 @@ +#!/usr/bin/perl +$| = 1; + +# Note that because fork loses test count we do not use Test::More + +use strict; + +BEGIN { + require Config; + my $can_fork = $Config::Config{d_fork} || + (($^O eq 'MSWin32' || $^O eq 'NetWare') and + $Config::Config{useithreads} and + $Config::Config{ccflags} =~ /-DPERL_IMPLICIT_SYS/ + ); + if ( $can_fork ) { + print "1..8\n"; + } else { + print "1..0 # Skip No fork available\n"; + exit; + } +} + +use File::Temp; + +# OO interface + +my $file = File::Temp->new(); + +myok( 1, -f $file->filename, "OO File exists" ); + +my $children = 2; +for my $i (1 .. $children) { + my $pid = fork; + die "Can't fork: $!" unless defined $pid; + if ($pid) { + # parent process + next; + } else { + # in a child we can't keep the count properly so we do it manually + # make sure that child 1 dies first + srand(); + my $time = (($i-1) * 5) +int(rand(5)); + print "# child $i sleeping for $time seconds\n"; + sleep($time); + my $count = $i + 1; + myok( $count, -f $file->filename(), "OO file present in child $i" ); + print "# child $i exiting\n"; + exit; + } +} + +while ($children) { + wait; + $children--; +} + + + +myok( 4, -f $file->filename(), "OO File exists in parent" ); + +# non-OO interface + +my ($fh, $filename) = File::Temp::tempfile( UNLINK => 1 ); + +myok( 5, -f $filename, "non-OO File exists" ); + +$children = 2; +for my $i (1 .. $children) { + my $pid = fork; + die "Can't fork: $!" unless defined $pid; + if ($pid) { + # parent process + next; + } else { + srand(); + my $time = (($i-1) * 5) +int(rand(5)); + print "# child $i sleeping for $time seconds\n"; + sleep($time); + my $count = 5 + $i; + myok( $count, -f $filename, "non-OO File present in child $i" ); + print "# child $i exiting\n"; + exit; + } +} + +while ($children) { + wait; + $children--; +} +myok(8, -f $filename, "non-OO File exists in parent" ); + + +# Local ok sub handles explicit number +sub myok { + my ($count, $test, $msg) = @_; + + if ($test) { + print "ok $count - $msg\n"; + } else { + print "not ok $count - $msg\n"; + } + return $test; +} diff --git a/t/lock.t b/t/lock.t new file mode 100644 index 0000000..ff8c7f9 --- /dev/null +++ b/t/lock.t @@ -0,0 +1,60 @@ +#!perl -w +# Test O_EXLOCK + +use Test::More; +use strict; +use Fcntl; + +BEGIN { +# see if we have O_EXLOCK + eval { &Fcntl::O_EXLOCK; }; + if ($@) { + plan skip_all => 'Do not seem to have O_EXLOCK'; + } else { + plan tests => 4; + use_ok( "File::Temp" ); + } +} + +# Need Symbol package for lexical filehandle on older perls +require Symbol if $] < 5.006; + +# Get a tempfile with O_EXLOCK +my $fh = new File::Temp(); +ok( -e "$fh", "temp file is present" ); + +# try to open it with a lock +my $flags = O_CREAT | O_RDWR | O_EXLOCK; + +my $timeout = 5; +my $status; +eval { + local $SIG{ALRM} = sub { die "alarm\n" }; # NB: \n required + alarm $timeout; + my $newfh; + $newfh = &Symbol::gensym if $] < 5.006; + $status = sysopen($newfh, "$fh", $flags, 0600); + alarm 0; +}; +if ($@) { + die unless $@ eq "alarm\n"; # propagate unexpected errors + # timed out +} +ok( !$status, "File $fh is locked" ); + +# Now get a tempfile with locking disabled +$fh = new File::Temp( EXLOCK => 0 ); + +eval { + local $SIG{ALRM} = sub { die "alarm\n" }; # NB: \n required + alarm $timeout; + my $newfh; + $newfh = &Symbol::gensym if $] < 5.006; + $status = sysopen($newfh, "$fh", $flags, 0600); + alarm 0; +}; +if ($@) { + die unless $@ eq "alarm\n"; # propagate unexpected errors + # timed out +} +ok( $status, "File $fh is not locked"); diff --git a/t/mktemp.t b/t/mktemp.t new file mode 100644 index 0000000..105e495 --- /dev/null +++ b/t/mktemp.t @@ -0,0 +1,113 @@ +#!/usr/local/bin/perl -w + +# Test for mktemp family of commands in File::Temp +# Use STANDARD safe level for these tests + +use strict; +use Test::More tests => 9; + +use File::Spec; +use File::Path; +use File::Temp qw/ :mktemp unlink0 /; +use FileHandle; + +ok(1); + +# MKSTEMP - test + +# Create file in temp directory +my $template = File::Spec->catfile(File::Temp::_wrap_file_spec_tmpdir(), 'wowserXXXX'); + +(my $fh, $template) = mkstemp($template); + +print "# MKSTEMP: FH is $fh File is $template fileno=".fileno($fh)."\n"; +# Check if the file exists +ok( (-e $template) ); + +# Autoflush +$fh->autoflush(1) if $] >= 5.006; + +# Try printing something to the file +my $string = "woohoo\n"; +print $fh $string; + +# rewind the file +ok(seek( $fh, 0, 0)); + +# Read from the file +my $line = <$fh>; + +# compare with previous string +ok($string, $line); + +# Tidy up +# This test fails on Windows NT since it seems that the size returned by +# stat(filehandle) does not always equal the size of the stat(filename) +# This must be due to caching. In particular this test writes 7 bytes +# to the file which are not recognised by stat(filename) +# Simply waiting 3 seconds seems to be enough for the system to update + +if ($^O eq 'MSWin32') { + sleep 3; +} +my $status = unlink0($fh, $template); +if ($status) { + ok( $status ); +} else { + SKIP: { + skip("Skip test failed probably due to \$TMPDIR being on NFS",1); + } +} + +# MKSTEMPS +# File with suffix. This is created in the current directory so +# may be problematic on NFS + +$template = "suffixXXXXXX"; +my $suffix = ".dat"; + +($fh, my $fname) = mkstemps($template, $suffix); + +print "# MKSTEMPS: File is $template -> $fname fileno=".fileno($fh)."\n"; +# Check if the file exists +ok( (-e $fname) ); + +# This fails if you are running on NFS +# If this test fails simply skip it rather than doing a hard failure +$status = unlink0($fh, $fname); + +if ($status) { + ok($status); +} else { + SKIP: { + skip("Skip test failed probably due to cwd being on NFS",1) + } +} + +# MKDTEMP +# Temp directory + +$template = File::Spec->catdir(File::Temp::_wrap_file_spec_tmpdir(), 'tmpdirXXXXXX'); + +my $tmpdir = mkdtemp($template); + +print "# MKDTEMP: Name is $tmpdir from template $template\n"; + +ok( (-d $tmpdir ) ); + +# Need to tidy up after myself +rmtree($tmpdir); + +# MKTEMP +# Just a filename, not opened + +$template = File::Spec->catfile(File::Temp::_wrap_file_spec_tmpdir(), 'mytestXXXXXX'); + +my $tmpfile = mktemp($template); + +print "# MKTEMP: Tempfile is $template -> $tmpfile\n"; + +# Okay if template no longer has XXXXX in + + +ok( ($tmpfile !~ /XXXXX$/) ); diff --git a/t/object.t b/t/object.t new file mode 100644 index 0000000..942de19 --- /dev/null +++ b/t/object.t @@ -0,0 +1,163 @@ +#!/usr/local/bin/perl -w +# Test for File::Temp - OO interface + +use strict; +use Test::More tests => 35; +use File::Spec; + +# Will need to check that all files were unlinked correctly +# Set up an END block here to do it + +# Arrays containing list of dirs/files to test +my (@files, @dirs, @still_there); + +# And a test for files that should still be around +# These are tidied up +END { + foreach (@still_there) { + ok( -f $_, "Check $_ exists" ); + ok( unlink( $_ ), "Unlinked $_" ); + ok( !(-f $_), "$_ no longer there"); + } +} + +# Loop over an array hoping that the files dont exist +END { foreach (@files) { ok( !(-e $_), "File $_ should not be there" )} } + +# And a test for directories +END { foreach (@dirs) { ok( !(-d $_), "Directory $_ should not be there" ) } } + +# Need to make sure that the END blocks are setup before +# the ones that File::Temp configures since END blocks are evaluated +# in reverse order and we need to check the files *after* File::Temp +# removes them +BEGIN {use_ok( "File::Temp" ); } + +# Check for misuse +eval { File::Temp->tempfile }; +like( $@, qr/can't be called as a method/, "File::Temp->tempfile error" ); +eval { File::Temp->tempdir }; +like( $@, qr/can't be called as a method/, "File::Temp->tempfile error" ); + +# Tempfile +# Open tempfile in some directory, unlink at end +my $fh = new File::Temp( SUFFIX => '.txt' ); + +ok( (-f "$fh"), "File $fh exists" ); +# Should still be around after closing +ok( close( $fh ), "Close file $fh" ); +ok( (-f "$fh"), "File $fh still exists after close" ); +# Check again at exit +push(@files, "$fh"); + +# OO tempdir +my $tdir = File::Temp->newdir(); +my $dirname = "$tdir"; # Stringify overload +ok( -d $dirname, "Directory $tdir exists"); +undef $tdir; +ok( !-d $dirname, "Directory should now be gone"); + +# with template +$tdir = File::Temp->newdir( TEMPLATE => 'helloXXXXX' ); +like( "$tdir", qr/hello/, "Directory with TEMPLATE" ); +undef $tdir; + +$tdir = File::Temp->newdir( 'helloXXXXX' ); +like( "$tdir", qr/hello/, "Directory with leading template" ); +undef $tdir; + +# Quick basic tempfile test +my $qfh = File::Temp->new(); +my $qfname = "$qfh"; +ok (-f $qfname, "temp file exists"); +undef $qfh; +ok( !-f $qfname, "temp file now gone"); + + +# TEMPDIR test as somewhere to put the temp files +# Create temp directory in current dir +my $template = 'tmpdirXXXXXX'; +print "# Template: $template\n"; +my $tempdir = File::Temp::tempdir( $template , + DIR => File::Spec->curdir, + CLEANUP => 1, + ); + +print "# TEMPDIR: $tempdir\n"; + +ok( (-d $tempdir), "Does $tempdir directory exist" ); +push(@dirs, $tempdir); + +# Create file in the temp dir +$fh = new File::Temp( + DIR => $tempdir, + SUFFIX => '.dat', + ); + +ok( $fh->unlink_on_destroy, "should unlink"); +print "# TEMPFILE: Created $fh\n"; + +ok( (-f "$fh"), "File $fh exists in tempdir?"); +push(@files, "$fh"); + +# Test tempfile +# ..and again (without unlinking it) +$fh = new File::Temp( DIR => $tempdir, UNLINK => 0 ); + +print "# TEMPFILE: Created $fh\n"; +ok( (-f "$fh" ), "Second file $fh exists in tempdir [nounlink]?"); +push(@files, "$fh"); + +# and another (with template) + +$fh = new File::Temp( TEMPLATE => 'helloXXXXXXX', + DIR => $tempdir, + SUFFIX => '.dat', + ); + +print "# TEMPFILE: Created $fh\n"; + +# and with a leading template +$fh = File::Temp->new( 'helloXXXXXXX', + DIR => $tempdir, + SUFFIX => '.dat', + ); + +print "# TEMPFILE: Created $fh\n"; + +ok( (-f "$fh"), "File $fh exists? [from leading template]" ); +like( "$fh", qr/hello/, "saw template" ); +push(@files, "$fh"); + + + +# Create a temporary file that should stay around after +# it has been closed +$fh = new File::Temp( TEMPLATE => 'permXXXXXXX', UNLINK => 0); + +print "# TEMPFILE: Created $fh\n"; +ok( -f "$fh", "File $fh exists?" ); +ok( close( $fh ), "Close file $fh" ); +ok( ! $fh->unlink_on_destroy, "should not unlink"); +push( @still_there, "$fh"); # check at END + +# Now create a temp file that will remain when the object +# goes out of scope because of $KEEP_ALL +$fh = new File::Temp( TEMPLATE => 'permXXXXXXX', UNLINK => 1); + +print "# TEMPFILE: Created $fh\n"; +ok( -f "$fh", "File $fh exists?" ); +ok( close( $fh ), "Close file $fh" ); +ok( $fh->unlink_on_destroy, "should unlink (in principle)"); +push( @still_there, "$fh"); # check at END +$File::Temp::KEEP_ALL = 1; + +# Make sure destructors run +undef $fh; + +# allow end blocks to run +$File::Temp::KEEP_ALL = 0; + +# Now END block will execute to test the removal of directories +print "# End of tests. Execute END blocks\n"; + diff --git a/t/posix.t b/t/posix.t new file mode 100644 index 0000000..07577a9 --- /dev/null +++ b/t/posix.t @@ -0,0 +1,80 @@ +#!/usr/local/bin/perl -w +# Test for File::Temp - POSIX functions + +use strict; +use Test::More tests => 7; + +use File::Temp qw/ :POSIX unlink0 /; +use FileHandle; +ok(1); + +# TMPNAM - scalar + +print "# TMPNAM: in a scalar context: \n"; +my $tmpnam = tmpnam(); + +# simply check that the file does not exist +# Not a 100% water tight test though if another program +# has managed to create one in the meantime. +ok( !(-e $tmpnam )); + +print "# TMPNAM file name: $tmpnam\n"; + +# TMPNAM list context +# Not strict posix behaviour +(my $fh, $tmpnam) = tmpnam(); + +print "# TMPNAM: in list context: $fh $tmpnam\n"; + +# File is opened - make sure it exists +ok( (-e $tmpnam )); + +# Unlink it - a possible NFS issue again if TMPDIR is not a local disk +my $status = unlink0($fh, $tmpnam); +if ($status) { + ok( $status ); +} else { + SKIP: { + skip("Skip test failed probably due to \$TMPDIR being on NFS",1); + } +} + +# TMPFILE + +$fh = tmpfile(); + +if (defined $fh) { + ok( $fh ); + print "# TMPFILE: tmpfile got FH $fh\n"; + + $fh->autoflush(1) if $] >= 5.006; + + # print something to it + my $original = "Hello a test\n"; + print "# TMPFILE: Wrote line: $original"; + print $fh $original + or die "Error printing to tempfile\n"; + + # rewind it + ok( seek($fh,0,0) ); + + # Read from it + my $line = <$fh>; + + print "# TMPFILE: Read line: $line"; + ok( $original, $line); + + close($fh); + +} else { + # Skip all the remaining tests + foreach (1..3) { + SKIP: { + skip("Skip test failed probably due to \$TMPDIR being on NFS",1); + } + } +} + + + + diff --git a/t/rmtree.t b/t/rmtree.t new file mode 100644 index 0000000..c5c98d7 --- /dev/null +++ b/t/rmtree.t @@ -0,0 +1,44 @@ +#!/usr/bin/perl + +use Test::More tests => 1; + +use File::Spec; +use File::Path; +use File::Temp; + +rmtree "testing"; +mkdir "testing" or die "mkdir failed: $!"; +chdir "testing"; +mkdir "tmp" or die "mkdir failed: $!"; + +my $tempdirstr; +{ + my $dir = File::Temp->newdir( DIR => "tmp" ); + $tempdirstr = "$dir"; + + mkdir "hide" or die "mkdir failed: $!"; + chdir "hide"; +} + +chdir File::Spec->updir; +$tempdirstr = File::Spec->rel2abs($tempdirstr); +ok !-d $tempdirstr or diag dircontent("tmp", $tempdirstr); + +# cleanup +chdir File::Spec->updir; +rmtree( "testing" ); + +exit; + +sub dircontent { + my $dir = shift; + my $tempdirstr = shift; + my $str = "Contents of $dir (should not contain \"$tempdirstr\"):\n"; + opendir(my $DH, $dir) or die "opendir failed; $!"; + my @contents = grep { $_ !~ /^\.+/; } readdir($DH); + closedir($DH); + for my $ls (@contents) { + $str .= " $ls\n"; + } + return $str; +} diff --git a/t/security.t b/t/security.t new file mode 100644 index 0000000..9f38d80 --- /dev/null +++ b/t/security.t @@ -0,0 +1,121 @@ +#!/usr/bin/perl -w +# Test for File::Temp - Security levels + +# Some of the security checking will not work on all platforms +# Test a simple open in the cwd and tmpdir foreach of the +# security levels + +use Test::More tests => 12; + +use strict; +use File::Spec; + +# Set up END block - this needs to happen before we load +# File::Temp since this END block must be evaluated after the +# END block configured by File::Temp +my @files; # list of files to remove +END { foreach (@files) { ok( !(-e $_) )} } + +use File::Temp qw/ tempfile unlink0 /; + +# The high security tests must currently be skipped on some platforms +my $skipplat = ( ( + # No sticky bits. + $^O eq 'MSWin32' || $^O eq 'NetWare' || $^O eq 'os2' || $^O eq 'dos' || $^O eq 'mpeix' || $^O eq 'MacOS' + ) ? 1 : 0 ); + +# Can not run high security tests in perls before 5.6.0 +my $skipperl = ($] < 5.006 ? 1 : 0 ); + +# Determine whether we need to skip things and why +my $skip = 0; +if ($skipplat) { + $skip = "Not supported on this platform"; +} elsif ($skipperl) { + $skip = "Perl version must be v5.6.0 for these tests"; + +} + +print "# We will be skipping some tests : $skip\n" if $skip; + +# start off with basic checking + +File::Temp->safe_level( File::Temp::STANDARD ); + +print "# Testing with STANDARD security...\n"; + +test_security(); + +SKIP: { + skip $skip, 8 if $skip; + + # Try medium + + File::Temp->safe_level( File::Temp::MEDIUM ); + + print "# Testing with MEDIUM security...\n"; + + # Now we need to start skipping tests + test_security(); + + # Try HIGH + + File::Temp->safe_level( File::Temp::HIGH ); + + print "# Testing with HIGH security...\n"; + + test_security(); +} + +exit; + +# Subroutine to open two temporary files. +# one is opened in the current dir and the other in the temp dir + +sub test_security { + + # Create the tempfile + my $template = "tmpXXXXX"; + my ($fh1, $fname1) = eval { tempfile ( $template, + DIR => File::Temp::_wrap_file_spec_tmpdir(), + UNLINK => 1, + ); + }; + + SKIP: { + if (defined $fname1) { + print "# fname1 = $fname1\n"; + ok( (-e $fname1) ); + push(@files, $fname1); # store for end block + } elsif (File::Temp->safe_level() != File::Temp::STANDARD) { + chomp($@); + my $msg = File::Temp::_wrap_file_spec_tmpdir() . " possibly insecure: $@"; + skip $msg, 2; # one here and one in END + } else { + ok(0); + } + } + + SKIP: { + # Explicitly + if ( $< < File::Temp->top_system_uid() ){ + skip("Skip Test inappropriate for root", 2); + return; + } + my ($fh2, $fname2) = eval { tempfile ($template, UNLINK => 1 ); }; + if (defined $fname2) { + print "# fname2 = $fname2\n"; + ok( (-e $fname2) ); + push(@files, $fname2); # store for end block + close($fh2); + } elsif (File::Temp->safe_level() != File::Temp::STANDARD) { + chomp($@); + my $msg = "current directory possibly insecure: $@"; + skip $msg, 2; # one here and one in END + } else { + ok(0); + } + } +} + +# vim: ts=2 sts=2 sw=2 et: diff --git a/t/seekable.t b/t/seekable.t new file mode 100644 index 0000000..5f07beb --- /dev/null +++ b/t/seekable.t @@ -0,0 +1,43 @@ +# -*- perl -*- +# Before `make install' is performed this script should be runnable with +# `make test'. After `make install' it should work as `perl File-Temp.t' + +######################### + +# change 'tests => 1' to 'tests => last_test_to_print'; + +use Test::More tests => 10; +BEGIN { use_ok('File::Temp') }; + +######################### + +# Insert your test code below, the Test::More module is use()ed here so read +# its man page ( perldoc Test::More ) for help writing this test script. + +# make sure we can create a tmp file... +$tmp = File::Temp->new; +isa_ok( $tmp, 'File::Temp' ); +isa_ok( $tmp, 'IO::Handle' ); +SKIP: { + skip "->isa is broken on 5.6.0", 1 if $] == 5.006000; + isa_ok( $tmp, 'IO::Seekable' ); +} + +# make sure the seek method is available... +# Note that we need a reasonably modern IO::Seekable +SKIP: { + skip "IO::Seekable is too old", 1 if IO::Seekable->VERSION <= 1.06; + ok( File::Temp->can('seek'), 'tmp can seek' ); +} + +# make sure IO::Handle methods are still there... +ok( File::Temp->can('print'), 'tmp can print' ); + +# let's see what we're exporting... +$c = scalar @File::Temp::EXPORT; +$l = join ' ', @File::Temp::EXPORT; +ok( $c == 9, "really exporting $c: $l" ); + +ok(defined eval { SEEK_SET() }, 'SEEK_SET defined by File::Temp') or diag $@; +ok(defined eval { SEEK_END() }, 'SEEK_END defined by File::Temp') or diag $@; +ok(defined eval { SEEK_CUR() }, 'SEEK_CUR defined by File::Temp') or diag $@; diff --git a/t/tempfile.t b/t/tempfile.t new file mode 100644 index 0000000..3cb08d2 --- /dev/null +++ b/t/tempfile.t @@ -0,0 +1,184 @@ +#!/usr/local/bin/perl -w +# Test for File::Temp - tempfile function + +use strict; +use Test::More tests => 28; +use File::Spec; +use Cwd qw/ cwd /; + +# Will need to check that all files were unlinked correctly +# Set up an END block here to do it + +# Arrays containing list of dirs/files to test +my (@files, @dirs, @still_there); + +# And a test for files that should still be around +# These are tidied up +END { + foreach (@still_there) { + ($_) = /(^.*)/; # untaint for testing under taint mode + ok( -f $_, "File $_ is still present" ); + ok( unlink( $_ ), "Unlink file" ); + ok( !(-f $_), "File is no longer present" ); + } +} + +# Loop over an array hoping that the files dont exist +END { foreach (@files) { ok( !(-e $_), "File $_ should not be present" )} } + +# And a test for directories +END { foreach (@dirs) { ok( !(-d $_), "Dir $_ should not be present" )} } + +# Need to make sure that the END blocks are setup before +# the ones that File::Temp configures since END blocks are evaluated +# in revers order and we need to check the files *after* File::Temp +# removes them +use File::Temp qw/ tempfile tempdir/; + +# Now we start the tests properly +ok(1, "Start test"); + + +# Tempfile +# Open tempfile in some directory, unlink at end +my ($fh, $tempfile) = tempfile( + UNLINK => 1, + SUFFIX => '.txt', + ); + +ok( (-f $tempfile), "Tempfile exists" ); +# Should still be around after closing +ok( close( $fh ), "Tempfile closed" ); +ok( (-f $tempfile), "Tempfile exists" ); +# Check again at exit +push(@files, $tempfile); + +# TEMPDIR test +# Create temp directory in current dir +my $template = 'tmpdirXXXXXX'; +print "# Template: $template\n"; +my $tempdir = tempdir( $template , + DIR => File::Spec->curdir, + CLEANUP => 1, + ); + +print "# TEMPDIR: $tempdir\n"; + +ok( (-d $tempdir), "Local tempdir exists" ); +push(@dirs, File::Spec->rel2abs($tempdir)); + +my $tempdir2 = tempdir( TEMPLATE => "customXXXXX", + DIR => File::Spec->curdir, + CLEANUP => 1, + ); + +print "# TEMPDIR2: $tempdir2\n"; + +like( $tempdir2, qr/custom/, "tempdir with TEMPLATE" ); +push(@dirs, File::Spec->rel2abs($tempdir)); + +# Create file in the temp dir +($fh, $tempfile) = tempfile( + DIR => $tempdir, + UNLINK => 1, + SUFFIX => '.dat', + ); + +print "# TEMPFILE: Created $tempfile\n"; + +ok( (-f $tempfile), "Local temp file exists with .dat extension"); +push(@files, File::Spec->rel2abs($tempfile)); + +# Test tempfile +# ..and again +($fh, $tempfile) = tempfile( + DIR => $tempdir, + ); + + +ok( (-f $tempfile ), "Local tempfile in tempdir exists"); +push(@files, File::Spec->rel2abs($tempfile)); + +# Test tempfile +# ..and another with changed permissions (read-only) +($fh, $tempfile) = tempfile( + DIR => $tempdir, + ); +chmod 0444, $tempfile; + +ok( (-f $tempfile ), "Local tempfile in tempdir exists read-only"); +push(@files, File::Spec->rel2abs($tempfile)); + +print "# TEMPFILE: Created $tempfile\n"; + +# and another (with template) + +($fh, $tempfile) = tempfile( 'helloXXXXXXX', + DIR => $tempdir, + UNLINK => 1, + SUFFIX => '.dat', + ); + +print "# TEMPFILE: Created $tempfile\n"; + +ok( (-f $tempfile), "Local tempfile in tempdir with .dat extension exists" ); +push(@files, File::Spec->rel2abs($tempfile)); + + +# and another (with TEMPLATE) + +($fh, $tempfile) = tempfile( TEMPLATE => 'goodbyeXXXXXXX', + DIR => $tempdir, + UNLINK => 1, + SUFFIX => '.dat', + ); + +print "# TEMPFILE: Created $tempfile\n"; + +ok( (-f $tempfile), "Local tempfile in tempdir with TEMPLATE" ); +push(@files, File::Spec->rel2abs($tempfile)); + +# Create a temporary file that should stay around after +# it has been closed +($fh, $tempfile) = tempfile( 'permXXXXXXX', UNLINK => 0 ); +print "# TEMPFILE: Created $tempfile\n"; +ok( -f $tempfile, "Long-lived temp file" ); +ok( close( $fh ), "Close long-lived temp file" ); +push( @still_there, File::Spec->rel2abs($tempfile) ); # check at END + +# Would like to create a temp file and just retrieve the handle +# but the test is problematic since: +# - We dont know the filename so we cant check that it is tidied +# correctly +# - The unlink0 required on unix for tempfile creation will fail +# on NFS +# Try to do what we can. +# Tempfile croaks on error so we need an eval +$fh = eval { tempfile( 'ftmpXXXXX', DIR => File::Temp::_wrap_file_spec_tmpdir() ) }; + +if ($fh) { + + # print something to it to make sure something is there + ok( print($fh "Test\n"), "Write to temp file" ); + + # Close it - can not check it is gone since we dont know the name + ok( close($fh), "Close temp file" ); + +} else { + SKIP: { + skip "Skip Failed probably due to NFS", 2; + } +} + +# Create temp directory and chdir to it; it should still be removed on exit. +$tempdir = tempdir(CLEANUP => 1); + +print "# TEMPDIR: $tempdir\n"; + +ok( (-d $tempdir), "Temp directory in temp dir" ); +chdir $tempdir or die $!; +push(@dirs, File::Spec->rel2abs($tempdir)); + +# Now END block will execute to test the removal of directories +print "# End of tests. Execute END blocks in directory ". cwd() ."\n"; + diff --git a/xt/author/00-compile.t b/xt/author/00-compile.t new file mode 100644 index 0000000..6a4605a --- /dev/null +++ b/xt/author/00-compile.t @@ -0,0 +1,60 @@ +use 5.006; +use strict; +use warnings; + +# this test was generated with Dist::Zilla::Plugin::Test::Compile 2.058 + +use Test::More 0.94; + +plan tests => 2; + +my @module_files = ( + 'File/Temp.pm' +); + + + +# no fake home requested + +my @switches = ( + -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; + + diag('Running: ', join(', ', map { my $str = $_; $str =~ s/'/\\'/g; q{'} . $str . q{'} } + $^X, @switches, '-e', "require q[$lib]")) + if $ENV{PERL_COMPILE_TEST_DEBUG}; + + my $pid = open3($stdin, '>&STDERR', $stderr, $^X, @switches, '-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: ', explain(\@warnings); + +BAIL_OUT("Compilation problems") if !Test::More->builder->is_passing; diff --git a/xt/author/changes_has_content.t b/xt/author/changes_has_content.t new file mode 100644 index 0000000..b729437 --- /dev/null +++ b/xt/author/changes_has_content.t @@ -0,0 +1,14 @@ +use strict; +use warnings; + +use Test::More; +plan skip_all => 'xt/release/changes_has_content.t is missing' if not -e 'xt/release/changes_has_content.t'; + +if (($ENV{TRAVIS_PULL_REQUEST} || '') eq 'false') { + chomp(my $branch_name = ($ENV{TRAVIS_BRANCH} || `git rev-parse --abbrev-ref HEAD`)); + $TODO = 'Changes need not have content for this release yet if this is only the master branch' + if ($branch_name || '') eq 'master'; +} + +do './xt/release/changes_has_content.t'; +die $@ if $@; diff --git a/xt/author/kwalitee.t b/xt/author/kwalitee.t new file mode 100644 index 0000000..c986546 --- /dev/null +++ b/xt/author/kwalitee.t @@ -0,0 +1,9 @@ +# this test was generated with Dist::Zilla::Plugin::Test::Kwalitee 2.12 +use strict; +use warnings; +use Test::More 0.88; +use Test::Kwalitee 1.21 'kwalitee_ok'; + +kwalitee_ok(); + +done_testing; diff --git a/xt/author/mojibake.t b/xt/author/mojibake.t new file mode 100644 index 0000000..5ef161e --- /dev/null +++ b/xt/author/mojibake.t @@ -0,0 +1,9 @@ +#!perl + +use strict; +use warnings qw(all); + +use Test::More; +use Test::Mojibake; + +all_files_encoding_ok(); diff --git a/xt/author/pod-coverage.t b/xt/author/pod-coverage.t new file mode 100644 index 0000000..66b3b64 --- /dev/null +++ b/xt/author/pod-coverage.t @@ -0,0 +1,7 @@ +#!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' }); diff --git a/xt/author/pod-no404s.t b/xt/author/pod-no404s.t new file mode 100644 index 0000000..eb9760c --- /dev/null +++ b/xt/author/pod-no404s.t @@ -0,0 +1,21 @@ +#!perl + +use strict; +use warnings; +use Test::More; + +foreach my $env_skip ( qw( + SKIP_POD_NO404S + AUTOMATED_TESTING +) ){ + plan skip_all => "\$ENV{$env_skip} is set, skipping" + if $ENV{$env_skip}; +} + +eval "use Test::Pod::No404s"; +if ( $@ ) { + plan skip_all => 'Test::Pod::No404s required for testing POD'; +} +else { + all_pod_files_ok(); +} diff --git a/xt/author/pod-spell.t b/xt/author/pod-spell.t new file mode 100644 index 0000000..c4eca1d --- /dev/null +++ b/xt/author/pod-spell.t @@ -0,0 +1,92 @@ +use strict; +use warnings; +use Test::More; + +# generated by Dist::Zilla::Plugin::Test::PodSpelling 2.007005 +use Test::Spelling 0.12; +use Pod::Wordlist; + + +add_stopwords(); +all_pod_files_spelling_ok( qw( examples lib script t xt ) ); +__DATA__ +APIs +Acklam +Astronomy +Avis +Ben +Brian +Christiansen +Council +Dagfinn +David +EXLOCK +Ed +Etheridge +File +Golden +Guillem +Ilmari +James +Jenness +John +Jover +Karen +Keenan +Kevin +Mannsåker +Mengue +Mowrey +NFS +Olivier +OpenBSD +POSIX +Particle +Peter +Physics +Rabbitson +Research +Rezic +Ryde +Slaven +Steinbrunner +TMPDIR +Temp +Tilly +Tim +TopSystemUID +UK +UNLINK +and +brian +btilly +chdir'ed +cmpstat +dagolden +destructor +dirname +dolmen +dsteinbrunner +eda +endeavour +et +ether +guillem +ilmari +irc +isa +jkeen +lib +newdir +numifies +pjacklam +ribasushi +slaven +the +tjenness +unix +unlink +unlinked +unlinking +user42 +xdg diff --git a/xt/author/pod-syntax.t b/xt/author/pod-syntax.t new file mode 100644 index 0000000..e563e5d --- /dev/null +++ b/xt/author/pod-syntax.t @@ -0,0 +1,7 @@ +#!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(); diff --git a/xt/author/portability.t b/xt/author/portability.t new file mode 100644 index 0000000..c531252 --- /dev/null +++ b/xt/author/portability.t @@ -0,0 +1,10 @@ +use strict; +use warnings; + +use Test::More; + +eval 'use Test::Portability::Files'; +plan skip_all => 'Test::Portability::Files required for testing portability' + if $@; + +run_tests(); diff --git a/xt/release/changes_has_content.t b/xt/release/changes_has_content.t new file mode 100644 index 0000000..af6ecad --- /dev/null +++ b/xt/release/changes_has_content.t @@ -0,0 +1,42 @@ +use Test::More tests => 2; + +note 'Checking Changes'; +my $changes_file = 'Changes'; +my $newver = '0.2306'; +my $trial_token = '-TRIAL'; +my $encoding = 'UTF-8'; + +SKIP: { + ok(-e $changes_file, "$changes_file file exists") + or skip 'Changes is missing', 1; + + ok(_get_changes($newver), "$changes_file has content for $newver"); +} + +done_testing; + +sub _get_changes +{ + my $newver = shift; + + # parse changelog to find commit message + open(my $fh, '<', $changes_file) or die "cannot open $changes_file: $!"; + my $changelog = join('', <$fh>); + if ($encoding) { + require Encode; + $changelog = Encode::decode($encoding, $changelog, Encode::FB_CROAK()); + } + close $fh; + + my @content = + grep { /^$newver(?:$trial_token)?(?:\s+|$)/ ... /^\S/ } # from newver to un-indented + split /\n/, $changelog; + shift @content; # drop the version line + + # drop unindented last line and trailing blank lines + pop @content while ( @content && $content[-1] =~ /^(?:\S|\s*$)/ ); + + # return number of non-blank lines + return scalar @content; +} + diff --git a/xt/release/cpan-changes.t b/xt/release/cpan-changes.t new file mode 100644 index 0000000..286005a --- /dev/null +++ b/xt/release/cpan-changes.t @@ -0,0 +1,10 @@ +use strict; +use warnings; + +# this test was generated with Dist::Zilla::Plugin::Test::CPAN::Changes 0.012 + +use Test::More 0.96 tests => 1; +use Test::CPAN::Changes; +subtest 'changes_ok' => sub { + changes_file_ok('Changes'); +}; diff --git a/xt/release/distmeta.t b/xt/release/distmeta.t new file mode 100644 index 0000000..c2280dc --- /dev/null +++ b/xt/release/distmeta.t @@ -0,0 +1,6 @@ +#!perl +# This file was automatically generated by Dist::Zilla::Plugin::MetaTests. + +use Test::CPAN::Meta; + +meta_yaml_ok();