Skip to content

Commit 676ff4b

Browse files
committed
add stdlib.[canonical,expanduser]
require Matlab >= R2020b python: better test for working
1 parent 2eaaa86 commit 676ff4b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+565
-436
lines changed

+stdlib/+fileio/absolute_path.m

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,4 @@
11
function abspath = absolute_path(p)
2-
%% absolute_path(p)
3-
% path need not exist, but absolute path is returned
4-
%
5-
% NOTE: some network file systems are not resolvable by Matlab Java
6-
% subsystem, but are sometimes still valid--so return
7-
% unmodified path if this occurs.
8-
%
9-
%%% Inputs
10-
% * p: path to make absolute
11-
%%% Outputs
12-
% * abspath: absolute path, if determined
132

143
arguments
154
p string {mustBeScalarOrEmpty}

+stdlib/+fileio/expanduser.m

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,4 @@
11
function expanded = expanduser(p)
2-
%% expanduser(path)
3-
% expands tilde ~ into user home directory
4-
%
5-
% Useful for Matlab functions like h5read() and some Computer Vision toolbox functions
6-
% that can't handle ~
7-
%
8-
%%% Inputs
9-
% * p: path to expand, if tilde present
10-
%%% Outputs
11-
% * expanded: expanded path
12-
%
13-
% See also ABSOLUTE_PATH
142

153
arguments
164
p string

+stdlib/+fileio/extract_zstd.m

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
function extract_zstd(archive, out_dir)
2-
%% extract_zstd(archive, out_dir)
3-
% extract a zstd file "archive" to "out_dir"
4-
% out_dir need not exist yet, but its parent must
5-
% We do this with CMake to avoid problems with old system tar.
6-
% For our user audience, CMake is at least as likely to be installed as Zstd.
72

83
arguments
94
archive (1,1) string {mustBeFile}

+stdlib/+fileio/is_absolute_path.m

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,10 @@
11
function isabs = is_absolute_path(apath)
2-
%% is_absolute_path(apath)
3-
% true if path is absolute. Path need not yet exist.
4-
% even if path has inside ".." it's still considered absolute
5-
% e.g. Python
6-
% os.path.isabs("/foo/../bar") == True
72

83
arguments
94
apath string
105
end
116

12-
import stdlib.fileio.expanduser
13-
14-
apath = expanduser(apath);
7+
apath = stdlib.fileio.expanduser(apath);
158

169
if ispc
1710
i = strlength(apath) < 3;
@@ -24,4 +17,4 @@
2417
isabs = startsWith(apath, "/");
2518
end
2619

27-
end % function
20+
end

+stdlib/+fileio/is_exe.m

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
11
function ok = is_exe(file)
2-
%% is_exe(file)
3-
% is a file executable, as per its filesystem attributes
4-
% does not actually try to run the file.
5-
%%% Inputs
6-
% * file: filename
7-
%%% Outputs
8-
% * ok: boolean logical
92

103
arguments
114
file string {mustBeScalarOrEmpty}

+stdlib/+fileio/makedir.m

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
function makedir(direc)
2-
%% makedir(direc)
3-
% malformed paths can be "created" but are not accessible.
4-
% This function works around that bug in Matlab mkdir().
2+
53
arguments
64
direc (1,1) string {mustBeNonzeroLengthText}
75
end

+stdlib/+fileio/md5sum.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@
2424

2525
assert(strlength(hash)==32, 'md5 hash is 32 characters')
2626

27-
end % function
27+
end

+stdlib/+fileio/path_tail.m

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,16 @@
11
function last = path_tail(apath)
2-
%% path_tail(apath)
3-
% get last part of directory path
4-
% if filename, return filename with suffix
2+
53
arguments
64
apath string {mustBeScalarOrEmpty}
75
end
86

9-
import stdlib.fileio.absolute_path
10-
11-
if isempty(apath)
12-
last = string.empty;
13-
return
14-
end
15-
167
if strlength(apath) == 0
178
last = "";
189
return
1910
end
2011

21-
[~, name, ext] = fileparts(absolute_path(apath));
12+
[~, name, ext] = fileparts(stdlib.fileio.absolute_path(apath));
2213

2314
last = append(name, ext);
2415

25-
end % function
16+
end

+stdlib/+fileio/posix.m

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
function ppath = posix(file)
2-
%% posix(file)
3-
% convert a path or sequence of path components to a Posix path separated
4-
% with "/" even on Windows.
5-
% If Windows path also have escaping "\" this breaks
2+
63
arguments
74
file string
85
end
@@ -14,4 +11,4 @@
1411
ppath = strrep(ppath, "\", "/");
1512
end
1613

17-
end % function
14+
end

+stdlib/+fileio/private/mustBeFile.m

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)