Skip to content

Commit 7f47659

Browse files
committed
get_modtime: native functions
1 parent b5eeb49 commit 7f47659

File tree

11 files changed

+9
-16
lines changed

11 files changed

+9
-16
lines changed

+stdlib/cpu_arch.m

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
%% CPU_ARCH get the CPU architecture
2-
% optional: java
32

43
function a = cpu_arch()
54

+stdlib/device.m

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
%% DEVICE filesystem device index of path
2-
% optional: java
32

43
function i = device(path)
54
arguments

+stdlib/drop_slash.m

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
%% DROP_SLASH drop repeated and trailing slash
2-
% optional: mex
32
%
43
% on Windows, if leading double slash, do not drop
54

+stdlib/file_checksum.m

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
%% FILE_CHECKSUM compute hash of file
2-
% optional: java
32
%
43
% read in chunks to avoid excessive RAM use
54
%

+stdlib/filesystem_type.m

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
%% FILESYSTEM_TYPE tell type of filesystem
2-
% optional: java
32
%
43
% example outputs: NTFS, ext4, apfs, ...
54

+stdlib/get_modtime.m

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
%% GET_MODTIME get path modification time
2-
% requires: java
32
%
43
%%% Inputs
54
% * p: path to examine
@@ -11,13 +10,17 @@
1110
p {mustBeTextScalar}
1211
end
1312

13+
finf = dir(p);
14+
if isfolder(p)
15+
% find which index of the struct array has member name == '.'
16+
i = find(strcmp({finf.name}, '.'), 1);
17+
finf = finf(i);
18+
end
1419

15-
t = javaObject("java.io.File", p).lastModified() / 1000;
16-
17-
if t > 0
18-
t = datetime(t, ConvertFrom="PosixTime");
19-
else
20+
if isempty(finf)
2021
t = datetime.empty;
22+
else
23+
t = datetime(finf.datenum, ConvertFrom='datenum');
2124
end
2225

2326
end

+stdlib/get_username.m

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
%% GET_USERNAME tell username of current user
2-
% optional: java
32
%
43
function n = get_username()
54

+stdlib/hostname.m

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11

22
%% HOSTNAME get hostname of local machine
3-
% optional: java
43
%
54
% Ref: https://docs.oracle.com/javase/8/docs/api/java/net/InetAddress.html#getHostName--
65

+stdlib/is_admin.m

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
%% IS_ADMIN is the process run as root / admin
2-
% optional: mex
32

43
function y = is_admin()
54

+stdlib/ram_free.m

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
%% RAM_FREE get free physical RAM
2-
% optional: java
32
%
43
% get free physical RAM across operating systems
54
% https://docs.oracle.com/en/java/javase/21/docs/api/jdk.management/com/sun/management/OperatingSystemMXBean.html#getFreeMemorySize()

0 commit comments

Comments
 (0)