File tree Expand file tree Collapse file tree 4 files changed +23
-3
lines changed Expand file tree Collapse file tree 4 files changed +23
-3
lines changed Original file line number Diff line number Diff line change 1+ function name = handle2filename(fileHandle )
2+ % HANDLE2FILENAME Convert a file handle to a filename
3+ arguments
4+ fileHandle (1 ,1 ) {mustBeInteger }
5+ end
6+
7+ if fileHandle >= 0
8+ name = stdlib .posix(fopen(fileHandle ));
9+ else
10+ name = string .empty ;
11+ end
12+
13+ end
Original file line number Diff line number Diff line change 11function p = posix(p )
22%% posix(file)
3- % convert a path to a Posix path separated with "/" even on Windows.
3+ % convert a path to a Posix string path separated with "/" even on Windows.
44% If Windows path also have escaping "\" this breaks
55arguments
66 p string
77end
88
9+ p = string(p );
10+
911if ispc
1012 p = strrep(p , " \" , " /" );
1113end
Original file line number Diff line number Diff line change 66
77[~ , p ] = fileparts(path );
88
9- p = stdlib .posix(p );
10-
119end
Original file line number Diff line number Diff line change @@ -336,6 +336,13 @@ function test_get_permissions(tc)
336336tc .verifyThat(p , StartsWithSubstring(" r" ))
337337end
338338
339+ function test_handle2filename(tc )
340+ tc .verifyEqual(stdlib .handle2filename(0 ), ' "' + " stdin" + ' "' )
341+ tc .verifyEqual(stdlib .handle2filename(1 ), ' "' + " stdout" + ' "' )
342+ tc .verifyEqual(stdlib .handle2filename(2 ), ' "' + " stderr" + ' "' )
343+ tc .verifyEmpty(stdlib .handle2filename(fopen(tempname )))
344+ end
345+
339346function test_java_version(tc )
340347v = stdlib .java_version();
341348L = strlength(v );
You can’t perform that action at this time.
0 commit comments