Skip to content

Commit 503d135

Browse files
committed
doc: why expanduser used internally [skip ci]
1 parent fb3885b commit 503d135

File tree

7 files changed

+8
-2
lines changed

7 files changed

+8
-2
lines changed

+stdlib/+fileio/absolute_path.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
p string {mustBeScalarOrEmpty}
55
end
66

7-
% have to expand ~ first
7+
% have to expand ~ first (like C++ filesystem::path::absolute)
88
abspath = stdlib.fileio.expanduser(p);
99

1010
if isempty(abspath)

+stdlib/+fileio/is_absolute_path.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
apath string
55
end
66

7+
% leave expanduser() here to work like C++ filesystem::path::is_absolute()
78
apath = stdlib.fileio.expanduser(apath);
89

910
if ispc

+stdlib/+fileio/makedir.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ function makedir(direc)
44
direc (1,1) string {mustBeNonzeroLengthText}
55
end
66

7+
%% to avoid confusing making ./~/mydir
78
direc = stdlib.fileio.expanduser(direc);
89

910
if isfolder(direc)

+stdlib/+fileio/which.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
function exe = which(filename, fpath)
2-
2+
%% which like Python shutil.which, find executable in fpath or env var PATH
33
arguments
44
filename (1,1) string {mustBeNonzeroLengthText}
55
fpath (1,:) string = getenv('PATH')
@@ -28,6 +28,7 @@
2828
% path given
2929

3030
if isscalar(fpath)
31+
% PATH could have ~/ prefixed paths in it
3132
fpath = split(stdlib.fileio.expanduser(fpath), pathsep).';
3233
end
3334
fpath = fpath(strlength(fpath)>0);

+stdlib/+hdf5nc/h5create_group.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
if isa(file, 'H5ML.id')
1919
fid = file;
2020
else
21+
% avoid confusing creating file ./~/foo.h5
2122
file = stdlib.fileio.expanduser(file);
2223
dcpl = 'H5P_DEFAULT';
2324
if isfile(file)

+stdlib/+hdf5nc/h5save.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ function h5save(filename, varname, A, opts)
1212
mustBeReal(A)
1313
end
1414

15+
% avoid confusing creating file ./~/foo.h5
1516
filename = stdlib.fileio.expanduser(filename);
1617

1718
% coerce if needed

+stdlib/+hdf5nc/ncsave.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ function ncsave(filename, varname, A, opts)
1212
mustBeReal(A)
1313
end
1414

15+
% avoid creating confusing file ./~/foo.nc
1516
filename = stdlib.fileio.expanduser(filename);
1617

1718
if isempty(opts.dims)

0 commit comments

Comments
 (0)