The EXIST function is reporting that a file exists when it does not. I'm trying to test the existence of the file '/license/license.json', which does not exist on my file system. The file 'license.json' is in my path, but the directory '/license' does not exist on my system.
>> exist('/license', 'dir')ans = 0>> exist('/license/license.json', 'file')ans = 2>> which('/license/license.json')/Users/brian/apps/copilot/license/license.json>> which('license.json')/Users/brian/apps/copilot/license/license.json
Am I misunderstanding the use of EXIST? Why is it ignoring the leading slash in an absolute path?
UPDATE: a workaround to check the existence of a file given its absolute path is provided by OCDER below:
FileLoc = dir('/license/license.json')IsFileThere = ~isempty(FileLoc) && any(~[FileLoc.isdir]);
Best Answer