Skip to content

Commit 7f345b1

Browse files
committed
diskfree => disk_available, add disk_capacity()
1 parent e0f7053 commit 7f345b1

File tree

4 files changed

+28
-10
lines changed

4 files changed

+28
-10
lines changed
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
%% DISKFREE disk free space
2-
% returns disk free space in bytes
1+
%% DISK_AVAILABLE disk available space (bytes)
32
%
4-
% example: diskfree('/')
3+
% example: stdlib.disk_available('/')
54
%
65
% Ref: https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/io/File.html#getUsableSpace()
76

8-
function f = diskfree(d)
7+
function f = disk_available(d)
98
arguments
109
d (1,1) string
1110
end
@@ -14,4 +13,4 @@
1413

1514
end
1615

17-
%!assert (diskfree('.') > 0)
16+
%!assert (disk_available('.') > 0)

+stdlib/disk_capacity.m

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
%% DISK_CAPACITY disk total capacity (bytes)
2+
%
3+
% example: stdlib.disk_capacity('/')
4+
5+
function f = disk_capacity(d)
6+
arguments
7+
d (1,1) string
8+
end
9+
10+
f = javaFileObject(d).getTotalSpace();
11+
12+
end
13+
14+
%!assert (disk_capacity('.') > 0)

Readme.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
[![ci](https://github.com/geospace-code/matlab-stdlib/actions/workflows/ci.yml/badge.svg)](https://github.com/geospace-code/matlab-stdlib/actions/workflows/ci.yml)
66
[![ci-nojvm](https://github.com/geospace-code/matlab-stdlib/actions/workflows/ci-nojvm.yml/badge.svg)](https://github.com/geospace-code/matlab-stdlib/actions/workflows/ci-nojvm.yml)
77

8-
Matlab or GNU Octave users coming from other languages often notice the missing functionality contained within this user-developed, unofficial "stdlib" standard library of functions.
9-
These system, filesystem, and HDF5 / HDF4 / NetCDF functions are useful across several of our own and others projects.
8+
Matlab or
9+
[GNU Octave](./Readme_octave.md)
10+
users coming from other languages will benefit from the functionality contained within this user-developed, unofficial "stdlib" standard library of functions.
11+
These system, filesystem, and HDF5 / HDF4 / NetCDF functions are used across numerous projects.
1012

1113
Matlab ≥ R2021a has full functionality.
1214
Matlab R2019b is the minimum required due to use of

test/TestJava.m

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,12 @@ function test_checkRAM(tc)
132132
end
133133

134134

135-
function test_diskfree(tc)
136-
tc.assertTrue(isnumeric(stdlib.diskfree('/')))
137-
tc.assertTrue(stdlib.diskfree('/') > 0, 'diskfree')
135+
function test_disk_available(tc)
136+
tc.assertGreaterThan(stdlib.disk_available('/'), 0)
137+
end
138+
139+
function test_disk_capacity(tc)
140+
tc.assertGreaterThan(stdlib.disk_capacity('/'), 0)
138141
end
139142

140143
end

0 commit comments

Comments
 (0)