Skip to content

Commit c1974fe

Browse files
committed
unlink: mex optional
1 parent 30eb08f commit c1974fe

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

+stdlib/unlink.m

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
%% UNLINK delete file or empty directory
2-
% requires: mex
2+
% optional: mex
33
%
44
% Matlab or GNU Octave delete() has trouble with not being able to delete
5-
% open files on Windows, this function overcomes that.
6-
% Also, this function returns boolean success status, which factory
5+
% open files on Windows. This MEX function overcomes that limitation.
6+
% This function returns a boolean success status, which
77
% delete() does not.
88
%
99
%%% Inputs
@@ -13,6 +13,17 @@
1313
%
1414
% This function is written in C++ using STL <filesystem>
1515

16-
function unlink(~)
17-
error("buildtool mex")
16+
function ok = unlink(apath)
17+
arguments
18+
apath (1,1) string
19+
end
20+
21+
%% fallback for if MEX not compiled
22+
try
23+
delete(apath);
24+
ok = true;
25+
catch
26+
ok = false;
27+
end
28+
1829
end

0 commit comments

Comments
 (0)