From 87f08dbac512a5b4aff5617fb26ca687bd370c32 Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Fri, 18 Sep 2009 19:36:14 +0000 Subject: TLUtils: add dir_creatable in addition to dir_writable. On Vista/W7 in c:/ one can create directories, but not files! TLUtils: use dir_creatable in texdir_check, since that is what we need for parent and parent install-tl: on w32 if %ProgramFiles% is not writable fall back to c:\texlive\NNNN git-svn-id: svn://tug.org/texlive/trunk@15364 c570f23f-e606-0410-a88d-b1316a301751 --- Master/install-tl | 8 ++++++-- Master/tlpkg/TeXLive/TLUtils.pm | 27 +++++++++++++++++++++++++-- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/Master/install-tl b/Master/install-tl index c609051e6ae..5aef80d493c 100755 --- a/Master/install-tl +++ b/Master/install-tl @@ -995,8 +995,12 @@ sub set_texlive_default_dirs { if (win32) { my $prog = getenv('ProgramFiles'); $tex_prefix ||= $prog . '/texlive'; - # if default is not writable, user has to pick another place manually - # USERPROFILE isn't an option, it is copied around on roaming setups + if (!TeXLive::TLUtils::texdir_check("$tex_prefix/$texlive_release")) { + # the default location is not writable, switch to C:\texlive + $tex_prefix = "c:/texlive"; + } + # we don't use USERPROFILE here because that will be copied back and + # forth on roaming profiles } else { $tex_prefix||='/usr/local/texlive'; } diff --git a/Master/tlpkg/TeXLive/TLUtils.pm b/Master/tlpkg/TeXLive/TLUtils.pm index ba48ed0586e..7e158279d46 100644 --- a/Master/tlpkg/TeXLive/TLUtils.pm +++ b/Master/tlpkg/TeXLive/TLUtils.pm @@ -51,6 +51,7 @@ C -- utilities used in the TeX Live infrastructure TeXLive::TLUtils::basename($path); TeXLive::TLUtils::dirname_and_basename($path); TeXLive::TLUtils::dir_writable($path); + TeXLive::TLUtils::dir_creatable($path); TeXLive::TLUtils::mkdirhier($path); TeXLive::TLUtils::rmtree($root, $verbose, $safe); TeXLive::TLUtils::copy($file, $target_dir); @@ -113,6 +114,7 @@ BEGIN { &basename &dirname_and_basename &dir_writable + &dir_creatable &mkdirhier &rmtree © @@ -522,6 +524,27 @@ sub dirname_and_basename { } +=item C + +Tests whether its argument is a directory where we can create a directory. + +=cut + +sub dir_creatable { + $path=shift; + return 0 unless -d $path; + $path =~ s!\\!/!g if win32; + $path =~ s!/$!!g; + my $i = 0; + while (-e $path . "/" . $i) { $i++; } + my $d = $path."/".$i; + return 0 unless mkdir $d; + return 0 unless -d $d; + rmdir $d; + return 1; +} + + =item C Tests whether its argument is writable by trying to write to @@ -2592,8 +2615,8 @@ sub texdir_check { my ($texdir) = shift; # PATH/texlive/2008 my $texdirparent = dirname($texdir); # PATH/texlive my $texdirpparent = dirname($texdirparent); # PATH - if ( (dir_writable($texdirpparent)) || - ( (-d $texdirparent) && (dir_writable($texdirparent)) ) || + if ( (dir_creatable($texdirpparent)) || + ( (-d $texdirparent) && (dir_creatable($texdirparent)) ) || ( (-d $texdir) && (dir_writable($texdir)) ) ) { return 1; } -- cgit v1.2.3