File tree Expand file tree Collapse file tree 3 files changed +17
-15
lines changed Expand file tree Collapse file tree 3 files changed +17
-15
lines changed Original file line number Diff line number Diff line change 1- function [t , cmd ] = disk_available(p )
1+ function [t , cmd ] = disk_available(file )
22
33t = [];
44
55if ispc()
6- cmd = sprintf(' pwsh -c ([System.IO.DriveInfo]''%s'' ).AvailableFreeSpace' , stdlib .absolute( p ) );
7- % r = stdlib.root_name(stdlib.absolute(p ));
6+ cmd = sprintf(' pwsh -c ([System.IO.DriveInfo][System.IO.Path]::GetFullPath( ''%s'' )) .AvailableFreeSpace' , file );
7+ % r = stdlib.root_name(stdlib.absolute(file ));
88 % cmd = sprintf('pwsh -c (Get-CimInstance -ClassName Win32_LogicalDisk -Filter \"DeviceID=''%s''\").FreeSpace', r);
99 % slower
10- % dl = extractBefore(stdlib.absolute(p ), 2);
10+ % dl = extractBefore(stdlib.absolute(file ), 2);
1111 % cmd = sprintf('pwsh -c "(Get-Volume -DriveLetter ''%s'').SizeRemaining"', dl);
1212 % slowest
1313elseif ismac()
14- cmd = sprintf(' df -k "%s " | awk '' NR==2 {print $4*1024}'' ' , p );
14+ cmd = sprintf(' df -k "%s " | awk '' NR==2 {print $4*1024}'' ' , file );
1515else
16- cmd = sprintf(' df -B1 "%s " | awk '' NR==2 {print $4}'' ' , p );
16+ cmd = sprintf(' df -B1 "%s " | awk '' NR==2 {print $4}'' ' , file );
1717end
1818
19- if stdlib .exists(p )
19+ if stdlib .exists(file )
2020 [s , t ] = system(cmd );
2121 if s == 0
2222 t = str2double(t );
Original file line number Diff line number Diff line change 1- function [t , cmd ] = disk_capacity(p )
1+ function [t , cmd ] = disk_capacity(file )
22
33t = [];
44
55if ispc()
6- cmd = sprintf(' pwsh -c ([System.IO.DriveInfo]''%s'' ).TotalSize' , stdlib .absolute( p ) );
7- % dl = extractBefore(stdlib.absolute(p ), 2);
6+ cmd = sprintf(' pwsh -c ([System.IO.DriveInfo][System.IO.Path]::GetFullPath( ''%s'' )) .TotalSize' , file );
7+ % dl = extractBefore(stdlib.absolute(file ), 2);
88 % cmd = sprintf('pwsh -c "(Get-Volume -DriveLetter ''%s'').Size"', dl);
99 % slower
1010elseif ismac()
11- cmd = sprintf(' df -k "%s " | awk '' NR==2 {print $2*1024}'' ' , p );
11+ cmd = sprintf(' df -k "%s " | awk '' NR==2 {print $2*1024}'' ' , file );
1212else
13- cmd = sprintf(' df -B1 "%s " | awk '' NR==2 {print $2}'' ' , p );
13+ cmd = sprintf(' df -B1 "%s " | awk '' NR==2 {print $2}'' ' , file );
1414end
1515
16- if stdlib .exists(p )
16+ if stdlib .exists(file )
1717 [s , t ] = system(cmd );
1818 if s == 0
1919 t = str2double(t );
Original file line number Diff line number Diff line change 66t = ' ' ;
77
88if ispc()
9- dl = extractBefore(stdlib .absolute(file ), 2 );
10- cmd = sprintf(' pwsh -c "(Get-Volume -DriveLetter ''%s'' ).FileSystem"' , dl );
9+ cmd = sprintf(' pwsh -c ([System.IO.DriveInfo][System.IO.Path]::GetFullPath(''%s'' )).DriveFormat' , file );
10+ % dl = extractBefore(stdlib.absolute(file), 2);
11+ % cmd = sprintf('pwsh -c "(Get-Volume -DriveLetter ''%s'').FileSystem"', dl);
12+ % slower
1113elseif ismac()
1214 cmd = sprintf(' df -aHY "%s " | awk '' NR==2 {print $2}'' ' , file );
1315else
You can’t perform that action at this time.
0 commit comments