File tree Expand file tree Collapse file tree 5 files changed +74
-30
lines changed Expand file tree Collapse file tree 5 files changed +74
-30
lines changed Original file line number Diff line number Diff line change 1717 strict = false ;
1818end
1919
20- [ s , r ] = fileAttribCompatible( file ) ;
20+ c = ' ' ;
2121
22- if s == 1
23- c = r .Name ;
24- elseif ~strict && ~stdlib .strempty(r )
25- c = stdlib .normalize(file );
26- else
27- c = ' ' ;
28- end
22+ try
23+ p = filePermissions(file );
24+ c = p .AbsolutePath ;
25+ if ischar(file )
26+ c = char(c );
27+ end
28+ catch e
29+ switch e .identifier
30+ case ' MATLAB:io:filesystem:filePermissions:CannotFindLocation'
31+ if ~strict && ~stdlib .strempty(file )
32+ c = stdlib .normalize(file );
33+ end
34+ case {' MATLAB:UndefinedFunction' , ' Octave:undefined-function' }
35+ [s , r ] = fileAttribCompatible(file );
36+ if s == 1
37+ c = r .Name ;
38+ elseif ~strict && ~stdlib .strempty(r )
39+ c = stdlib .normalize(file );
40+ end
41+ otherwise
42+ rethrow(e )
43+ end
2944
30- if isstring(file )
31- c = string(c );
45+ if isstring(file )
46+ c = string(c );
47+ end
3248end
3349
3450end
Original file line number Diff line number Diff line change 1616 return
1717end
1818
19- a = file_attributes(file );
2019
21- if ~isempty(a )
22- y = ~a .directory && (a .UserExecute || a .GroupExecute || a .OtherExecute );
20+ try
21+ a = filePermissions(file );
22+ if a .Type == matlab .io .FileSystemEntryType .File
23+ if ispc
24+ y = a .Readable ;
25+ else
26+ y = a .UserExecute || a .GroupExecute || a .OtherExecute ;
27+ end
28+ end
29+ catch e
30+ switch e .identifier
31+ case ' MATLAB:io:filesystem:filePermissions:CannotFindLocation'
32+ y = false ;
33+ case {' MATLAB:UndefinedFunction' , ' Octave:undefined-function' }
34+ a = file_attributes(file );
35+ y = ~isempty(a ) && ~a .directory && (a .UserExecute || a .GroupExecute || a .OtherExecute );
36+ otherwise
37+ rethrow(e )
38+ end
2339end
2440
2541end
2844% ! if isunix()
2945% ! assert(stdlib.is_exe([matlabroot, '/bin/octave']))
3046% ! end
31- % !assert (~stdlib.is_exe('.'))
47+ % !assert (~stdlib.is_exe('.'))
Original file line number Diff line number Diff line change 99
1010function y = is_readable(file )
1111
12- a = file_attributes(file );
13-
14- if isempty(a )
15- y = false ;
16- else
17- y = a .UserRead || a .GroupRead || a .OtherRead ;
12+ try
13+ a = filePermissions(file );
14+ y = a .Readable ;
15+ catch e
16+ switch e .identifier
17+ case ' MATLAB:io:filesystem:filePermissions:CannotFindLocation'
18+ y = false ;
19+ case {' MATLAB:UndefinedFunction' , ' Octave:undefined-function' }
20+ a = file_attributes(file );
21+ y = ~isempty(a ) && (a .UserRead || a .GroupRead || a .OtherRead );
22+ otherwise
23+ rethrow(e )
24+ end
1825end
1926
2027end
2128
22- % !assert (stdlib.is_readable('.'))
29+ % !assert (stdlib.is_readable('.'))
Original file line number Diff line number Diff line change 99
1010function y = is_writable(file )
1111
12- a = file_attributes(file );
13-
14- if isempty(a )
15- y = false ;
16- else
17- y = a .UserWrite || a .GroupWrite || a .OtherWrite ;
12+ try
13+ a = filePermissions(file );
14+ y = a .Writable ;
15+ catch e
16+ switch e .identifier
17+ case ' MATLAB:io:filesystem:filePermissions:CannotFindLocation'
18+ y = false ;
19+ case {' MATLAB:UndefinedFunction' , ' Octave:undefined-function' }
20+ a = file_attributes(file );
21+ y = ~isempty(a ) && (a .UserWrite || a .GroupWrite || a .OtherWrite );
22+ otherwise
23+ rethrow(e )
24+ end
1825end
1926
2027end
2128
22- % !assert (islogical(stdlib.is_writable('.')))
29+ % !assert (islogical(stdlib.is_writable('.')))
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments