File-Save-Home-0.09/0000755000076500007650000000000012062744052014025 5ustar jimkjimk00000000000000File-Save-Home-0.09/Changes0000644000076500007650000000446212062742726015334 0ustar jimkjimk00000000000000Changes for Perl extension File::Save::Home 0.09 Fri Dec 14 19:34:00 EXT 2012 Two spelling corrections reported by Xavier Guimard. 0.08 Wed Feb 22 22:14:24 EST 2006 Modified get_subhome_directory_status() and make_subhome_temp_directory() so that each takes an optional additional argument which is name of a valid directory which user wishes to use as a ''pseudo-home-directory'' in place of the output of get_home_directory(). Wrote t/05_pseudohome.t to test this revised functionality. Wrote t/06_Win32.t to make sure that this functionality works with File::HomeDir::my_home() on Windows. 0.07 Fri Feb 17 19:42:05 EST 2006 No change in functionality. At suggestion of Rob Rothenberg, expanded documentation, particularly in ''SEE ALSO'' section, to reference other CPAN distributions which try to locate a user's home directory. 0.06 Fri Nov 25 10:35:00 EST 2005 No change in functionality. New version prepared solely to accommodate change in name of String::MkVarName to String::PerlIdentifier. 0.05 Sat Nov 19 12:42:46 EST 2005 File::Save::Home's test suite now uses String::MkVarName v0.03 or later from CPAN, rather than a copy of that module stored under the t/ directory. Appropriate changes to Makefile.PL and t/*.t files made. 0.04 Sun Nov 13 08:46:00 EST 2005 Reworked restore_subhome_directory_status to use code from Perl Cookbook recipe 9.8, rmtree1, to remove directory and its contents. In test files, either eliminated chdir-ing to home directory entirely, or limited its scope to minimum necessary. 0.03 Sat Nov 12 21:38:00 2005 Forgot to include File::Temp under PREREQ_PM in Makefile.PL. 0.02 Sat Nov 12 21:15:00 2005 Reformulated in response to feedback on 0.01 from Michael Graham. First general release version. lib/File/Save/Home.pm exports seven functions on request: get_home_directory get_subhome_directory_status make_subhome_directory restore_subhome_directory_status conceal_target_file reveal_target_file make_subhome_temp_directory There are 4 files in the test suite: 01_test.t 02_multilevel.t 03_placefile.t 04_tempdir.t Underneath the t/ directory there is found package String::MkVarName, which exports one function: make_varname CPAN upload. 0.01 Mon Oct 31 09:55:38 2005 Original version; created by ExtUtils::ModuleMaker 0.43. File-Save-Home-0.09/lib/0000755000076500007650000000000012062744051014572 5ustar jimkjimk00000000000000File-Save-Home-0.09/lib/File/0000755000076500007650000000000012062744051015451 5ustar jimkjimk00000000000000File-Save-Home-0.09/lib/File/Save/0000755000076500007650000000000012062744051016347 5ustar jimkjimk00000000000000File-Save-Home-0.09/lib/File/Save/Home.pm0000644000076500007650000005336212062743011017601 0ustar jimkjimk00000000000000package File::Save::Home; require 5.006_001; use strict; use warnings; use Exporter (); our $VERSION = '0.09'; our @ISA = qw(Exporter); our @EXPORT_OK = qw( get_home_directory get_subhome_directory_status make_subhome_directory restore_subhome_directory_status conceal_target_file reveal_target_file make_subhome_temp_directory ); our %EXPORT_TAGS = ( subhome_status => [ qw| get_subhome_directory_status restore_subhome_directory_status | ], target => [ qw| conceal_target_file reveal_target_file | ], ); use Carp; use File::Path; use File::Spec::Functions qw| catdir catfile catpath splitdir splitpath |; use File::Temp qw| tempdir |; *ok = *Test::More::ok; use Cwd; use File::Find; #################### DOCUMENTATION ################### =head1 NAME File::Save::Home - Place file safely under user home directory =head1 VERSION This document refers to version 0.09, released December 14, 2012. =head1 SYNOPSIS use File::Save::Home qw( get_home_directory get_subhome_directory_status make_subhome_directory restore_subhome_directory_status conceal_target_file reveal_target_file make_subhome_temp_directory ); $home_dir = get_home_directory(); $desired_dir_ref = get_subhome_directory_status("desired/directory"); $desired_dir_ref = get_subhome_directory_status( "desired/directory", "pseudohome/directory", # two-argument version ); $desired_dir = make_subhome_directory($desired_dir_ref); restore_subhome_directory_status($desired_dir_ref); $target_ref = conceal_target_file( { dir => $desired_dir, file => 'file_to_be_checked', test => 0, } ); reveal_target_file($target_ref); $tmpdir = make_subhome_temp_directory(); $tmpdir = make_subhome_temp_directory( "pseudohome/directory", # optional argument version ); =head1 DESCRIPTION In the course of deploying an application on another user's system, you sometimes need to place a file in or underneath that user's home directory. Can you do so safely? This Perl extension provides several functions which try to determine whether you can, indeed, safely create directories and files underneath a user's home directory. Among other things, if you are placing a file in such a location only temporarily -- say, for testing purposes -- you can temporarily hide any already existing file with the same name and restore it to its original name and timestamps when you are done. =head1 USAGE =head2 C Analyzes environmental information to determine whether there exists on the system a 'HOME' or 'home-equivalent' directory. Takes no arguments. Returns that directory if it exists; Cs otherwise. On Win32, this directory is the one returned by the following function from the Fmodule: Win32->import( qw(CSIDL_LOCAL_APPDATA) ); $realhome = Win32::GetFolderPath( CSIDL_LOCAL_APPDATA() ); ... which translates to something like F. (For a further discussion of Win32, see below L.) On Unix-like systems, things are much simpler. We simply check the value of C<$ENV{HOME}>. We cannot do that on Win32 because C<$ENV{HOME}> is not defined there. =cut sub get_home_directory { my $realhome; if ($^O eq 'MSWin32') { require Win32; Win32->import( qw(CSIDL_LOCAL_APPDATA) ); # 0x001c $realhome = Win32::GetFolderPath( CSIDL_LOCAL_APPDATA() ); $realhome =~ s{ }{\ }g; return $realhome if (-d $realhome); $realhome =~ s|(.*?)\\Local Settings(.*)|$1$2|; return $realhome if (-d $realhome); croak "Unable to identify directory equivalent to 'HOME' on Win32: $!"; } else { # Unix-like systems $realhome = $ENV{HOME}; $realhome =~ s{ }{\ }g; return $realhome if (-d $realhome); croak "Unable to identify 'HOME' directory: $!"; } } =head2 C =head3 Single argument version Takes as argument a string holding the name of a directory, either single-level (C) or multi-level (C). Determines whether that directory already exists underneath the user's home or home-equivalent directory. Calls C internally, then tacks on the path passed as argument. =head3 Two-argument version Suppose you want to determine the name of a user's home directory by some other route than C. Suppose, for example, that you're on Win32 and want to use the C method supplied by CPAN distribution File::HomeDir -- a method which returns a different result from that of our C -- but you still want to use those File::Save::Home functions which normally call C internally. Or, suppose you want to supply an arbitrary path. You can now do so by supplying an I to C. This argument should be a valid path name for a directory to which you have write privileges. C will determine if the directory exists and, if so, determine whether the I argument is a subdirectory of the I argument. =head3 Both versions Whether you use the single argument version or the two-argument version, C returns a reference to a four-element hash whose keys are: =over 4 =item home The absolute path of the home directory. =item abs The absolute path of the specified directory. =item flag A Boolean value indicating whether that directory already exists (a true value) or not (C). =item top The uppermost subdirectory passed as the argument to this function. =back =cut sub get_subhome_directory_status { my $subdir = shift; my ($pseudohome, $home); $pseudohome = $_[0] if $_[0]; if (defined $pseudohome) { -d $pseudohome or croak "$pseudohome is not a valid directory: $!"; } $home = defined $pseudohome ? $pseudohome : get_home_directory(); my $dirname = "$home/$subdir"; my $subdir_top = (splitdir($subdir))[0]; if (-d $dirname) { return { home => $home, top => $subdir_top, abs => $dirname, flag => 1, }; } else { return { home => $home, top => $subdir_top, abs => $dirname, flag => undef, }; } } =head2 C Takes as argument the hash reference returned by C. Examines the first element in that array -- the directory name -- and creates the directory if it doesn't already exist. The function Cs if the directory cannot be created. =cut sub make_subhome_directory { my $desired_dir_ref = shift; my $dirname = $desired_dir_ref->{abs}; if (! -d $dirname) { mkpath $dirname or croak "Unable to create desired directory $dirname: $!"; } return $dirname; } =head2 C Undoes C, I if there was no specified directory under the user's home directory on the user's system before testing, any such directory created during testing is removed. On the other hand, if there I such a directory present before testing, it is left unchanged. =cut sub restore_subhome_directory_status { my $desired_dir_ref = shift; my $home = $desired_dir_ref->{home}; my $desired_dir = $desired_dir_ref->{abs}; my $subdir_top = $desired_dir_ref->{top}; if (! defined $desired_dir_ref->{flag}) { my $cwd = cwd(); find { bydepth => 1, no_chdir => 1, wanted => sub { if (! -l && -d _) { rmdir or warn "Couldn't rmdir $_: $!"; } else { unlink or warn "Couldn't unlink $_: $!"; } } } => ("$home/$subdir_top"); (! -d $desired_dir) ? return 1 : croak "Unable to restore directory created during test: $!"; } else { return 1; } } =head2 C =head3 Regular version: no arguments Creates a randomly named temporary directory underneath the home or home-equivalent directory returned by C. =head3 Optional argument version Creates a randomly named temporary directory underneath the directory supplied as the single argument. This version is analogous to the two-argument verion of L above. You could use it if, for example, you wanted to use Cmy_home()> to supply a value for the user's home directory instead of our C. =head3 Both versions In both versions, the temporary subdirectory is created by calling C $home, CLEANUP => 1)>. The function returns the directory path if successful; Cs otherwise. B Any temporary directory so created remains in existence for the duration of the program, but is deleted (along with all its contents) when the program exits. =cut sub make_subhome_temp_directory { my ($pseudohome, $home); $pseudohome = $_[0] if $_[0]; if (defined $pseudohome) { -d $pseudohome or croak "$pseudohome is not a valid directory: $!"; } $home = defined $pseudohome ? $pseudohome : get_home_directory(); # my $tdir = tempdir(DIR => get_home_directory(), CLEANUP => 1); my $tdir = tempdir(DIR => $home, CLEANUP => 1); return $tdir ? $tdir : croak "Unable to create temp dir under home: $!"; } =head2 C Determines whether file with specified name already exists in specified directory and, if so, temporarily hides it by renaming it with a F<.hidden> suffix and storing away its last access and modification times. Takes as argument a reference to a hash with these keys: =over 4 =item dir The directory in which the file is presumed to exist. =item file The targeted file, I the file to be temporarily hidden if it already exists. =item test Boolean value which, if turned on (C<1>), will cause the function, when called, to run two C tests. Defaults to off (C<0>). =back Returns a reference to a hash with these keys: =over 4 =item full The absolute path to the target file. =item hidden The absolute path to the now-hidden file. =item atime The last access time to the target file (C<(stat($file{full}))[8]>). =item modtime The last modification time to the target file (C<(stat($file{full}))[9]>). =item test The value of the key C in the hash passed by reference as an argument to this function. =back =cut sub conceal_target_file { my $arg_ref = shift; my $desired_dir = $arg_ref->{dir}; my $target_file = $arg_ref->{file}; my $test_flag = $arg_ref->{test}; my $target_file_hidden = $target_file . '.hidden'; my %targ; $targ{full} = catfile( $desired_dir, $target_file ); $targ{hidden} = catfile( $desired_dir, $target_file_hidden ); if (-f $targ{full}) { $targ{atime} = (stat($targ{full}))[8]; $targ{modtime} = (stat($targ{full}))[9]; rename $targ{full}, $targ{hidden} or croak "Unable to rename $targ{full}: $!"; if ($test_flag) { ok(! -f $targ{full}, "target file temporarily suppressed"); ok(-f $targ{hidden}, "target file now hidden"); } } else { if ($test_flag) { ok(! -f $targ{full}, "target file not found"); ok(1, "target file not found"); } } $targ{test} = $test_flag; return { %targ }; } =head2 C Used in conjunction with C to restore the original status of the file targeted by C, I renames the hidden file to its original name by removing the F<.hidden> suffix, thereby deleting any other file with the original name created between the calls tothe two functions. Cs if the hidden file cannot be renamed. Takes as argument the hash reference returned by C. If the value for the C key in the hash passed as an argument to C was true, then a call to C will run three C tests. =cut sub reveal_target_file { my $target_ref = shift;; if(-f $target_ref->{hidden} ) { rename $target_ref->{hidden}, $target_ref->{full}, or croak "Unable to rename $target_ref->{hidden}: $!"; if ($target_ref->{test}) { ok(-f $target_ref->{full}, "target file re-established"); ok(! -f $target_ref->{hidden}, "hidden target now gone"); ok( (utime $target_ref->{atime}, $target_ref->{modtime}, ($target_ref->{full}) ), "atime and modtime of target file restored"); } } else { if ($target_ref->{test}) { ok(1, "test not relevant"); ok(1, "test not relevant"); ok(1, "test not relevant"); } } } =head1 BUGS AND TODO So far tested only on Unix-like systems and Win32. =head1 SEE ALSO perl(1). ExtUtils::ModuleMaker::Auxiliary. ExtUtils::ModuleMaker::Utility. The latter two packages are part of the ExtUtils::ModuleMaker distribution available from the same author on CPAN. They and the ExtUtils::ModuleMaker test suite provide examples of the use of File::Save::Home. Two other distributions located on CPAN, File::HomeDir and File::HomeDir::Win32, may also be used to locate a suitable value for a user's home directory. It should be noted, however, that those modules and File::Save::Home each take a different approach to defining a home directory on Win32 systems. Hence, each may deliver a different result on a given system. I cannot say that one distribution's approach is any more or less correct than the other two's approaches. The following comments should be viewed as my subjective impressions; YMMV. File::HomeDir was originally written by Sean M Burke and is now maintained by Adam Kennedy. As of version 0.52 its interface provides three methods for the ''current user'': $home = File::HomeDir->my_home; $docs = File::HomeDir->my_documents; $data = File::HomeDir->my_data; When I ran these three methods on a Win2K Pro system running ActivePerl 8, I got these results: C:\WINNT\system32>perl -MFile::HomeDir -e "print File::HomeDir->my_home" C:\Documents and Settings\localuser C:\WINNT\system32>perl -MFile::HomeDir -e "print File::HomeDir->my_documents" C:\Documents and Settings\localuser\My Documents C:\WINNT\system32>perl -MFile::HomeDir -e "print File::HomeDir->my_data" C:\Documents and Settings\localuser\Local Settings\Application Data In contrast, when I ran the closest equivalent method in File::Save::Home, C, I got this result: C:\WINNT\system32>perl -MFile::Save::Home -e "print File::Save::Home->get_home_directory" C:\Documents and Settings\localuser\Local Settings\Application Data In other words, Cget_home_directory> gave the same result as Cmy_data>, I, as I might have expected, the same result as Cmy_home>. These results can be explained by peeking behind the curtains and looking at the source code for each module. =head2 File::HomeDir File::HomeDir's objective is to provide a value for a user's home directory on a wide variety of operating systems. When invoked, it detects the operating system you're on and calls a subclassed module. When used on a Win32 system, that subclass is called File::HomeDir::Windows (not to be confused with the separate CPAN distribution File::HomeDir::Win32). Cmy_home()> looks like this: sub my_home { my $class = shift; if ( $ENV{USERPROFILE} ) { return $ENV{USERPROFILE}; } if ( $ENV{HOMEDRIVE} and $ENV{HOMEPATH} ) { return File::Spec->catpath( $ENV{HOMEDRIVE}, $ENV{HOMEPATH}, '',); } Carp::croak("Could not locate current user's home directory"); } In other words, determine the current user's home directory simply by checking environmental variables analogous to the C<$ENV{HOME}> on Unix-like systems. A very straightforward approach! As mentioned above, File::Save::Home takes a different approach. It uses the Win32 module to, in effect, check a particular key in the registry. Win32->import( qw(CSIDL_LOCAL_APPDATA) ); $realhome = Win32::GetFolderPath( CSIDL_LOCAL_APPDATA() ); This approach was suggested to me in August 2005 by several members of Perlmonks. (See threads I (L) and I (L).) I adopted this approach in part because the people recommending it knew more about Windows than I did, and in part because File::HomeDir was not quite as mature as it has since become. But don't trust me; trust Microsoft! Here's their explanation for the use of CSIDL values in general and CSIDL_LOCAL_APPDATA() in particular: =over 4 =item * I =item * I =back (Source: L. Link valid as of Feb 18 2006. Thanks to Soren Andersen for reminding me of this citation.) It is interesting that the I File::HomeDir methods listed above, C and C both rely on using a Win32 module to peer into the registry, albeit in a slightly different manner from Cget_home_directory>. TIMTOWTDI. In an event, File::Save::Home has a number of useful methods I C which merit your consideration. And, as noted above, you can supply any valid directory as an optional additional argument to the two File::Save::Home functions which normally default to calling C internally. =head2 File::HomeDir::Win32 File::HomeDir::Win32 was originally written by Rob Rothenberg and is now maintained by Randy Kobes. According to Adam Kennedy (L), ''The functionality in File::HomeDir::Win32 is gradually being merged into File::HomeDir over time and will eventually be deprecated (although left in place for compatibility purposes).'' Because I have not yet fully installed File::HomeDir::Win32, I will defer further comparison between it and File::Save::Home to a later date. =head1 AUTHOR James E Keenan CPAN ID: JKEENAN jkeenan@cpan.org http://search.cpan.org/~jkeenan =head1 ACKNOWLEDGMENTS File::Save::Home has its origins in the maintenance revisions I was doing on CPAN distribution ExtUtils::ModuleMaker in the summer of 2005. After I made a presentation about that distribution to the Toronto Perlmongers on October 27, 2005, Michael Graham suggested that certain utility functions could be extracted to a separate Perl extension for more general applicability. This module is the implementation of Michael's suggestion. While I was developing those utility functions for ExtUtils::ModuleMaker, I turned to the Perlmonks for assistance with the problem of determining a suitable value for the user's home directory on Win32 systems. In the Perlmonks discussion threads referred to above I received helpful suggestions from monks CountZero, Tanktalus, xdg and holli, among others. Thanks to Rob Rothenberg for prodding me to expand the SEE ALSO section and to Adam Kennedy for responding to questions about File::HomeDir. =head1 COPYRIGHT Copyright (c) 2005-06 James E. Keenan. United States. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of the license can be found in the LICENSE file included with this module. =head1 DISCLAIMER OF WARRANTY BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE ''AS IS'' WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. =cut 1; File-Save-Home-0.09/LICENSE0000644000076500007650000005010110334523754015033 0ustar jimkjimk00000000000000Terms of Perl 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 General Public License (GPL) Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 675 Mass Ave, Cambridge, MA 02139, USA. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU 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. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), 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 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 show them these terms so they know 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. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. 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 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 derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 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 License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. 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. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary 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 License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 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 Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing 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 for copying, distributing or modifying the Program or works based on it. 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. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. 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 this 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 this License, you may choose any version ever published by the Free Software Foundation. 10. 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 11. 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. 12. 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 --------------------------------------------------------------------------- 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. Aggregation of this Package with a commercial distribution is always permitted provided that the use of this Package is embedded; that is, when no overt attempt is made to make this Package's interfaces visible to the end user of the commercial distribution. Such use shall not be construed as a distribution of this Package. 9. The name of the Copyright Holder may not be used to endorse or promote products derived from this software without specific prior written permission. 10. 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 File-Save-Home-0.09/Makefile.PL0000644000076500007650000000126610341627607016010 0ustar jimkjimk00000000000000 use ExtUtils::MakeMaker; # See lib/ExtUtils/MakeMaker.pm for details of how to influence # the contents of the Makefile that is written. WriteMakefile( NAME => 'File::Save::Home', VERSION_FROM => 'lib/File/Save/Home.pm', # finds \$VERSION AUTHOR => 'James E Keenan (jkeenan@cpan.org)', ABSTRACT => 'Place file safely under user home directory', PREREQ_PM => { 'Test::Simple' => 0.44, 'File::Spec' => 0, 'File::Path' => 0, 'Carp' => 0, 'File::Temp' => 0, 'String::PerlIdentifier' => 0, }, ); File-Save-Home-0.09/MANIFEST0000644000076500007650000000046212062744053015161 0ustar jimkjimk00000000000000Changes lib/File/Save/Home.pm LICENSE Makefile.PL MANIFEST MANIFEST.SKIP META.yml Module meta-data (added by MakeMaker) README t/01_test.t t/02_multilevel.t t/03_placefile.t t/04_tempdir.t t/05_pseudohome.t t/06_Win32.t META.json Module JSON meta-data (added by MakeMaker) File-Save-Home-0.09/MANIFEST.SKIP0000644000076500007650000000040710334523772015730 0ustar jimkjimk00000000000000^blib/ ^Makefile$ ^Makefile\.[a-z]+$ ^pm_to_blib$ CVS/.* ,v$ ^tmp/ \.old$ \.bak$ \.tmp$ \.swp$ ~$ ^# \.shar$ \.tar$ \.tgz$ \.tar\.gz$ \.zip$ \.DS_Store$ _uu$ \.svn cover_db/ coverage/ html/ research/ superseded/ svndiff/ ^Todo ^.cvsignore ^init ^results ^htmlify File-Save-Home-0.09/META.json0000644000076500007650000000205412062744052015447 0ustar jimkjimk00000000000000{ "abstract" : "Place file safely under user home directory", "author" : [ "James E Keenan (jkeenan@cpan.org)" ], "dynamic_config" : 1, "generated_by" : "ExtUtils::MakeMaker version 6.6302, CPAN::Meta::Converter version 2.120921", "license" : [ "unknown" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "File-Save-Home", "no_index" : { "directory" : [ "t", "inc" ] }, "prereqs" : { "build" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "configure" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "runtime" : { "requires" : { "Carp" : "0", "File::Path" : "0", "File::Spec" : "0", "File::Temp" : "0", "String::PerlIdentifier" : "0", "Test::Simple" : "0.44" } } }, "release_status" : "stable", "version" : "0.09" } File-Save-Home-0.09/META.yml0000644000076500007650000000113212062744052015273 0ustar jimkjimk00000000000000--- abstract: 'Place file safely under user home directory' author: - 'James E Keenan (jkeenan@cpan.org)' build_requires: ExtUtils::MakeMaker: 0 configure_requires: ExtUtils::MakeMaker: 0 dynamic_config: 1 generated_by: 'ExtUtils::MakeMaker version 6.6302, CPAN::Meta::Converter version 2.120921' license: unknown meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 name: File-Save-Home no_index: directory: - t - inc requires: Carp: 0 File::Path: 0 File::Spec: 0 File::Temp: 0 String::PerlIdentifier: 0 Test::Simple: 0.44 version: 0.09 File-Save-Home-0.09/README0000644000076500007650000000305012062743273014707 0ustar jimkjimk00000000000000README for Perl extension File::Save::Home This document refers to version 0.09 of File::Save::Home. This version was released December 14, 2012. To install this module on your system, place the tarball archive file in a temporary directory and call the following: % gunzip File-Save-Home-0.09.tar.gz % tar xf File-Save-Home-0.09.tar % cd File-Save-Home-0.09 % perl Makefile.PL % make % make test % make install If during installation you wish to view more information on test results, substitute the following for the sixth line in the sequence of commands above: % make test TEST=VERBOSE If you are installing this module over any earlier version, you may substitute the following for the last line in the sequence of commands above: % make install UNINST=1 If you are installing this module on a Win32 system with 'nmake', substitute 'nmake' for 'make' in the sequence of commands above. There is one CPAN module not in the Perl core distribution which is a prerequisite for File::Save::Home's test suite: String::PerlIdentifier, by the same author. This module is pure Perl and should install properly via the cpan utility. In sending e-mail to the maintainer, please put "File::Save::Home", or "File-Save-Home" in the subject line. Author: James E Keenan CPAN ID: JKEENAN jkeenan@cpan.org Copyright (c) 2005 James E. Keenan. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of the license can be found in the LICENSE file included with this module. File-Save-Home-0.09/t/0000755000076500007650000000000012062744051014267 5ustar jimkjimk00000000000000File-Save-Home-0.09/t/01_test.t0000644000076500007650000000324310341630067015734 0ustar jimkjimk00000000000000# t/01_test.t - check module loading use strict; use warnings; use Test::More tests => 13; use_ok('File::Save::Home', qw| get_home_directory get_subhome_directory_status make_subhome_directory restore_subhome_directory_status | ); use_ok('String::PerlIdentifier'); use_ok('Cwd'); my ($cwd, $homedir, @subdirs, $desired_dir_ref, $desired_dir ); ok($homedir = get_home_directory(), 'home directory is defined'); $cwd = cwd(); ok(chdir $homedir, "able to change to $homedir"); { local *DH; ok((opendir DH, $homedir), "able to open directory handle to $homedir"); @subdirs = grep {-d $_ and !($_ eq '.' or $_ eq '..') } readdir DH; ok(closedir DH, "able to close directory handle to $homedir"); } ok(chdir $cwd, "able to change back to $cwd"); if (@subdirs) { my $testdir = $subdirs[int(rand(@subdirs))]; $desired_dir_ref = get_subhome_directory_status($testdir); ok($desired_dir_ref->{flag}, "confirm existence of $testdir under $homedir"); } else { $desired_dir_ref = get_subhome_directory_status(make_varname()); ok(! defined $desired_dir_ref->{flag}, "random directory name under $homedir is undefined"); } $desired_dir_ref = get_subhome_directory_status(make_varname()); ok(! defined $desired_dir_ref->{flag}, "random directory name $desired_dir_ref->{abs} is undefined"); $desired_dir = make_subhome_directory($desired_dir_ref); ok(-d $desired_dir, "randomly named directory $desired_dir_ref->{abs} has been created"); ok(restore_subhome_directory_status($desired_dir_ref), "directory status restored"); ok(! -d $desired_dir, "randomly named directory $desired_dir_ref->{abs} has been deleted"); File-Save-Home-0.09/t/02_multilevel.t0000644000076500007650000000241410341630100017123 0ustar jimkjimk00000000000000# t/02_multilevel.t use strict; use warnings; use Test::More tests => 13; use_ok('File::Save::Home', qw| get_home_directory get_subhome_directory_status make_subhome_directory restore_subhome_directory_status conceal_target_file reveal_target_file | ); use_ok('String::PerlIdentifier'); my ($homedir, @subdirs, $desired_dir_ref, $desired_dir, $target_ref ); ok($homedir = get_home_directory(), 'home directory is defined'); # Test a multilevel directory my $topdir = make_varname(); my $nextdir = make_varname(); $desired_dir_ref = get_subhome_directory_status("$topdir/$nextdir"); ok(! defined $desired_dir_ref->{flag}, "random directory name $desired_dir_ref->{abs} is undefined"); $desired_dir = make_subhome_directory($desired_dir_ref); ok(-d $desired_dir, "randomly named directory $desired_dir_ref->{abs} has been created"); $target_ref = conceal_target_file( { dir => $desired_dir, file => 'file_to_be_checked', test => 1, } ); reveal_target_file($target_ref); ok(restore_subhome_directory_status($desired_dir_ref), "directory status restored"); ok(! -d $desired_dir, "randomly named directory $desired_dir_ref->{abs} has been deleted"); ok(! -d $topdir, "top directory $topdir has been deleted"); File-Save-Home-0.09/t/03_placefile.t0000644000076500007650000000311110341630117016671 0ustar jimkjimk00000000000000# t/03_placefile.t use strict; use warnings; use Test::More tests => 15; use_ok('File::Save::Home', qw| get_home_directory get_subhome_directory_status make_subhome_directory restore_subhome_directory_status conceal_target_file reveal_target_file | ); use_ok('String::PerlIdentifier'); my ($homedir, @subdirs, $desired_dir_ref, $desired_dir, $target_ref, $target ); ok($homedir = get_home_directory(), 'home directory is defined'); # Test a multilevel directory my $topdir = make_varname(); my $nextdir = make_varname(); $desired_dir_ref = get_subhome_directory_status("$topdir/$nextdir"); ok(! defined $desired_dir_ref->{flag}, "random directory name $desired_dir_ref->{abs} is undefined"); $desired_dir = make_subhome_directory($desired_dir_ref); ok(-d $desired_dir, "randomly named directory $desired_dir_ref->{abs} has been created"); $target = 'file_to_be_checked'; open my $FH, ">$desired_dir/$target" or die "Unable to open filehandle: $!"; print $FH "\n"; close $FH or die "Unable to close filehandle: $!"; ok(-f "$desired_dir/$target", "target file created for testing"); $target_ref = conceal_target_file( { dir => $desired_dir, file => $target, test => 1, } ); reveal_target_file($target_ref); ok(-f "$desired_dir/$target", "target file restored after testing"); ok(restore_subhome_directory_status($desired_dir_ref), "directory status restored"); ok(! -d $desired_dir, "randomly named directory $desired_dir_ref->{abs} has been deleted"); ok(! -d $topdir, "top directory $topdir has been deleted"); File-Save-Home-0.09/t/04_tempdir.t0000644000076500007650000000171710375477213016441 0ustar jimkjimk00000000000000# t/04_tempdir.t use strict; use warnings; use Test::More tests => 8; use_ok('File::Save::Home', qw| get_home_directory make_subhome_temp_directory | ); use_ok('File::Spec::Functions', qw| splitdir |); use_ok('Cwd'); my ($cwd, $homedir); $cwd = cwd(); ok($homedir = get_home_directory(), 'home directory is defined'); ok(chdir $homedir, "able to change to $homedir"); opendir my $DIRH, $homedir or die "Unable to open $homedir for reading: $!"; my %subdirs = map {$_, 1} grep { -d $_ and ! ($_ eq '.' or $_ eq '..') } readdir($DIRH); closedir $DIRH or die "Unable to close $homedir after reading: $!"; ok(chdir $cwd, "able to change to $cwd"); my $tmpdir = make_subhome_temp_directory(); ok( (-d $tmpdir), "$tmpdir exists"); my @homedirels = splitdir($homedir); my @tmpdirels = splitdir($tmpdir); shift(@tmpdirels) for @homedirels; ok(! exists $subdirs{$tmpdirels[0]}, "directory $tmpdirels[0] did not previously exist"); File-Save-Home-0.09/t/05_pseudohome.t0000644000076500007650000000264410375512314017136 0ustar jimkjimk00000000000000# t/05_pseudohome.t use strict; use warnings; use Test::More # tests => 9; qw(no_plan); use_ok('File::Save::Home', qw| get_subhome_directory_status make_subhome_temp_directory | ); use_ok('File::Temp', qw| tempdir |); use_ok('Cwd'); use_ok('String::PerlIdentifier'); my ($cwd, $pseudohome, $desired_dir_ref ); $cwd = cwd(); ok($pseudohome = tempdir( CLEANUP => 1 ), 'pseudo-home directory has been created'); ok(chdir $pseudohome, "able to change to $pseudohome"); $desired_dir_ref = get_subhome_directory_status( make_varname(), $pseudohome, ); ok(! defined $desired_dir_ref->{flag}, "random directory name $desired_dir_ref->{abs} is undefined"); ok(chdir $cwd, "able to change to $cwd"); eval { $desired_dir_ref = get_subhome_directory_status( make_varname(), make_varname(), ); }; like($@, qr/is\snot\sa\svalid\sdirectory/, "optional second argument must be a valid directory"); my ($newpseudohome, $tmpdir); ok($newpseudohome = tempdir( CLEANUP => 1 ), 'another pseudo-home directory has been created'); ok(chdir $newpseudohome, "able to change to $newpseudohome"); $tmpdir = make_subhome_temp_directory($newpseudohome); ok( (-d $tmpdir), "$tmpdir exists"); ok(chdir $cwd, "able to change to $cwd"); eval { $tmpdir = make_subhome_temp_directory(make_varname()); }; like($@, qr/is\snot\sa\svalid\sdirectory/, "optional argument must be a valid directory"); File-Save-Home-0.09/t/06_Win32.t0000644000076500007650000000362310377223753015677 0ustar jimkjimk00000000000000# t/06_Win32.t use strict; use warnings; use Test::More; if( $^O !~ /Win32/ ) { plan skip_all => 'Test irrelevant except on Win32'; } else { plan qw(no_plan); } like($^O, qr/Win32/, "You're on Windows -- the greatest operating system to come out of Redmond, Washington!"); SKIP: { eval { require File::HomeDir }; skip "File::HomeDir not found", 14 if $@; use_ok('File::Save::Home', qw| get_subhome_directory_status make_subhome_temp_directory | ); use_ok('File::Temp', qw| tempdir |); use_ok('Cwd'); use_ok('String::PerlIdentifier'); my ($cwd, $pseudohome, $desired_dir_ref ); $cwd = cwd(); ok($pseudohome = File::HomeDir->my_home(), 'pseudo-home directory has been created'); ok(chdir $pseudohome, "able to change to $pseudohome"); $desired_dir_ref = get_subhome_directory_status( make_varname(), $pseudohome, ); ok(! defined $desired_dir_ref->{flag}, "random directory name $desired_dir_ref->{abs} is undefined"); ok(chdir $cwd, "able to change to $cwd"); eval { $desired_dir_ref = get_subhome_directory_status( make_varname(), make_varname(), ); }; like($@, qr/is\snot\sa\svalid\sdirectory/, "optional second argument must be a valid directory"); my ($newpseudohome, $tmpdir); ok($newpseudohome = File::HomeDir->my_home(), 'another pseudo-home directory has been created'); ok(chdir $newpseudohome, "able to change to $newpseudohome"); $tmpdir = make_subhome_temp_directory($newpseudohome); ok( (-d $tmpdir), "$tmpdir exists"); ok(chdir $cwd, "able to change to $cwd"); eval { $tmpdir = make_subhome_temp_directory(make_varname()); }; like($@, qr/is\snot\sa\svalid\sdirectory/, "optional argument must be a valid directory"); }