Skip to content

Commit c39a26e

Browse files
committed
treat URLs mostly as not existing
1 parent c5b2b22 commit c39a26e

19 files changed

+52
-24
lines changed

+stdlib/absolute.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
expand_tilde (1,1) logical = true
2424
end
2525

26+
c = "";
27+
28+
if stdlib.is_url(p), return; end
29+
2630
if expand_tilde
2731
c = stdlib.expanduser(p);
2832
else

+stdlib/canonical.m

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,16 @@
1818
expand_tilde (1,1) logical = true
1919
end
2020

21+
c = "";
22+
23+
if stdlib.is_url(p), return; end
2124

2225
if expand_tilde
2326
e = stdlib.expanduser(p);
2427
else
2528
e = p;
2629
end
2730

28-
c = "";
29-
3031
if ~stdlib.len(e), return, end
3132

3233
if ispc && (startsWith(e, "\\") || startsWith(e, "//"))

+stdlib/create_symlink.m

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@
1414
link (1,1) string
1515
end
1616

17-
1817
ok = false;
1918

19+
if stdlib.is_url(target) || stdlib.is_url(link), return; end
20+
2021
if stdlib.exists(link), return, end
2122

2223
try
@@ -56,7 +57,7 @@
5657

5758
end
5859

59-
60+
%!assert (create_symlink("https://invalid", "https://invalid"), false)
6061
%!test
6162
%! if !ispc
6263
%! assert(create_symlink(tempname, tempname))

+stdlib/expanduser.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
p (1,1) string
1313
end
1414

15+
e = "";
16+
17+
if stdlib.is_url(p), return; end
18+
1519
e = stdlib.drop_slash(p);
1620

1721
L = stdlib.len(e);

+stdlib/extract_zstd.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ function extract_zstd(archive, out_dir)
77
out_dir (1,1) string
88
end
99

10+
assert(~stdlib.is_url(archive) && ~stdlib.is_url(out_dir), "archive and out_dir must not be URLs")
11+
1012
archive = stdlib.absolute(archive);
1113
out_dir = stdlib.absolute(out_dir);
1214

+stdlib/file_checksum.m

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
% read in chunks to avoid excessive RAM use
33
%
44
%%% Inputs
5-
% * file: file to hash
5+
% * file: file or to hash
66
% * method: "MD5", "SHA-1", "SHA-256", etc.
77
%%% Outputs
88
% * hash: string hash
@@ -15,6 +15,8 @@
1515
method (1,1) string
1616
end
1717

18+
assert(~stdlib.is_url(file), "file_checksum does not accept URLs")
19+
1820
if strcmp(method, "sha256") || strcmp(method, "SHA256")
1921
method = "SHA-256";
2022
end

+stdlib/file_size.m

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
% FILE_SIZE size in bytes of file
1+
%% FILE_SIZE size in bytes of file
2+
%
3+
%%% Inputs
4+
% * p: path to file
5+
%%% Outputs
6+
% * s: size in bytes, or empty if file does not exist
27

38
function s = file_size(p)
49
arguments
@@ -7,9 +12,9 @@
712

813
s = [];
914

10-
if ~isfile(p)
11-
return
12-
else
15+
if stdlib.is_url(p), return, end
16+
17+
if isfile(p)
1318
s = dir(p);
1419
if ~isempty(s)
1520
s = s.bytes;

+stdlib/filename.m

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
% FILENAME file name of path
1+
%% FILENAME file name of path
2+
%
3+
%%% Inputs
4+
% p: path to extract filename from
5+
%%% Outputs
26
% filename (including suffix) without directory
37

48
function f = filename(p)

+stdlib/get_modtime.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
%% GET_MODTIME get path modification time
2+
%
3+
%%% Inputs
4+
% * p: path to examine
5+
%%% Outputs
6+
% * t: modification time, or empty if path does not exist
27

38
function t = get_modtime(p)
49
arguments

+stdlib/hard_link_count.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
p (1,1) string
1010
end
1111

12-
if ispc || ~isfile(p)
12+
if ispc || stdlib.is_url(p) || ~isfile(p)
1313
c = [];
1414
return
1515
end

0 commit comments

Comments
 (0)