Skip to content

Commit 1d68fd0

Browse files
committed
sys.disk_available: simplify
1 parent 8d66d66 commit 1d68fd0

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

+stdlib/+sys/disk_available.m

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
function [t, cmd] = disk_available(p)
22

3-
t = uint64([]);
3+
t = [];
44

55
if ispc()
66
dl = extractBefore(stdlib.absolute(p), 2);
7-
cmd = "pwsh -c (Get-Volume -DriveLetter " + dl + ").SizeRemaining";
7+
cmd = sprintf('pwsh -c "(Get-Volume -DriveLetter ''%s'').SizeRemaining"', dl);
88
elseif ismac()
99
cmd = sprintf('df -k "%s" | awk ''NR==2 {print $4*1024}''', p);
1010
else
@@ -14,8 +14,10 @@
1414
if stdlib.exists(p)
1515
[s, t] = system(cmd);
1616
if s == 0
17-
t = uint64(str2double(t));
17+
t = str2double(t);
1818
end
1919
end
2020

21+
t = uint64(t);
22+
2123
end

+stdlib/+sys/disk_capacity.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
function [t, cmd] = disk_capacity(p)
22

3-
t = uint64([]);
3+
t = [];
44

55
if ispc()
66
dl = extractBefore(stdlib.absolute(p), 2);

0 commit comments

Comments
 (0)