summaryrefslogtreecommitdiff
path: root/systems/texlive/tlnet/tlpkg/TeXLive/TLUtils.pm
diff options
context:
space:
mode:
Diffstat (limited to 'systems/texlive/tlnet/tlpkg/TeXLive/TLUtils.pm')
-rw-r--r--systems/texlive/tlnet/tlpkg/TeXLive/TLUtils.pm43
1 files changed, 40 insertions, 3 deletions
diff --git a/systems/texlive/tlnet/tlpkg/TeXLive/TLUtils.pm b/systems/texlive/tlnet/tlpkg/TeXLive/TLUtils.pm
index 16adc71ad1..5ee8d9e6cc 100644
--- a/systems/texlive/tlnet/tlpkg/TeXLive/TLUtils.pm
+++ b/systems/texlive/tlnet/tlpkg/TeXLive/TLUtils.pm
@@ -1,4 +1,4 @@
-# $Id: TLUtils.pm 62822 2022-03-20 08:34:54Z siepo $
+# $Id: TLUtils.pm 63002 2022-04-11 14:04:37Z siepo $
# TeXLive::TLUtils.pm - the inevitable utilities for TeX Live.
# Copyright 2007-2022 Norbert Preining, Reinhard Kotucha
# This file is licensed under the GNU General Public License version 2
@@ -8,7 +8,7 @@ use strict; use warnings;
package TeXLive::TLUtils;
-my $svnrev = '$Revision: 62822 $';
+my $svnrev = '$Revision: 63002 $';
my $_modulerevision = ($svnrev =~ m/: ([0-9]+) /) ? $1 : "unknown";
sub module_revision { return $_modulerevision; }
@@ -815,6 +815,43 @@ computing the disk space.
sub diskfree {
my $td = shift;
+ my ($output, $retval);
+ if (win32()) {
+ # the powershell one-liner only works from win8 on.
+ my @winver = Win32::GetOSVersion();
+ if ($winver[1]<=6 && $winver[2]<=1) {
+ return -1;
+ }
+ my $avl;
+ if ($td =~ /^[a-zA-Z]:/) {
+ my $drv = substr($td,0,1);
+ # ea ignore: error action ignore: no output at all
+ my $cmd = "powershell -nologo -noninteractive -noprofile -command " .
+ "\"get-psdrive -name $drv -ea ignore |select-object free |format-wide\"";
+ ($output, $retval) = run_cmd($cmd);
+ # ignore exit code, just parse the output, which should
+ # consist of empty lines and a number surrounded by spaces
+ my @lines = split(/\r*\n/, $output);
+ foreach (@lines) {
+ chomp $_;
+ if ($_ !~ /^\s*$/) {
+ $_ =~ s/^\s*//;
+ $_ =~ s/\s*$//;
+ $avl = $_;
+ last;
+ }
+ }
+ if ($avl !~ /^[0-9]+$/) {
+ return (-1);
+ } else {
+ return (int($avl/(1024*1024)));
+ }
+ } else {
+ # maybe UNC drive; do not try to handle this
+ return -1;
+ }
+ }
+ # now windows case has been taken care of
return (-1) if (! $::progs{"df"});
# drop final /
$td =~ s!/$!!;
@@ -832,7 +869,7 @@ sub diskfree {
$td .= "/" if ($td !~ m!/$!);
return (-1) if (! -e $td);
debug("Checking for free diskspace in $td\n");
- my ($output, $retval) = run_cmd("df -P \"$td\"", POSIXLY_CORRECT => 1);
+ ($output, $retval) = run_cmd("df -P \"$td\"", POSIXLY_CORRECT => 1);
if ($retval == 0) {
# Output format should be this:
# Filesystem 512-blocks Used Available Capacity Mounted on