Is fullfile(0,0) undocumented behavior or bug?

조회 수: 1 (최근 30일)
Naor Movshovitz
Naor Movshovitz 2017년 4월 18일
댓글: Walter Roberson 2017년 4월 19일
What is the purpose, if any, of non-char inputs to fullfile?
>> fullfile(0)
> In fullfile>refinePath (line 93)
In fullfile (line 38)
Warning: Inputs must be character arrays or cell arrays of strings.
ans =
0
>> fullfile(0,0)
ans =
\
>> fullfile(0,0,0)
ans =
\ \
>> fullfile(0,0,0,0)
ans =
\ \ \
etc. This is the behavior in R2014b and R2016b on Windows 7 (only versions I tested).

채택된 답변

Jan
Jan 2017년 4월 18일
편집: Jan 2017년 4월 18일
This is a bug. fullfile should contain a test, if all inputs are strings or character vectors. This happens for 1 input directly, but for multiple inputs, file sepearators are appended at first such that the elements are converted to character vectors implicitely.
I assume the warning is not correct also, but only a hard error is sufficient to stop the user driving fullfile beyond its purpose.
  댓글 수: 3
Jan
Jan 2017년 4월 18일
uigetfile should be accompanied by a check of a abortion under all circumstances:
[fname, pname] = uigetfile;
if isequal(fname,0) || isequal(pname,0)
disp('User pressed cancel')
...
Omitting this test would be a crude programming style.
Walter Roberson
Walter Roberson 2017년 4월 19일
More generally, isnumeric(fname) instead of comparing to 0.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 File Name Construction에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by