Is it possible to use fopen in MATLAB or Octave to create a file with a name that only differs by case from an existing file? In MATLAB R2016a and Octave 4.2.0 on MacOS 10.11.6, the following code only creates FooBar.txt
and writes bar
to it (foobar.txt
is not created):
fid = fopen('FooBar.txt', 'w');
fwrite(fid, 'foo', 'char');
fclose(fid);
fid = fopen('foobar.txt', 'w');
fwrite(fid, 'bar', 'char');
fclose(fid);
MATLAB can do that, but only on Linux. By default, Windows and MacOS do not respect case.
NTFS and FAT (and variants) are case sensitive (for POSIX compliance), but the Windows kernel does not respect case. Meaning, in principle NTFS can hold two files with a name that differs only in case, but those files can not be created nor differentiated by Windows, unless you do system calls on a much lower level than is common in most programs (read: "hack").
HFS+ on MacOS infamously is case-insensitive. Meaning, although the MacOS kernel could handle it in principle, the file system cannot. Currently used in MacOS Sierra (10.12), the experimental APFS is case sensitive, but I believe system-wide support for it is disabled (...although I could be wrong here). Although it can be enabled, I believe case sensitivity does not align with Apple's design philosophies (plus, many apps explicitly assume case insensitivity and will break if that changes), so I think it more than likely that enabling support for case sensitivity will grow progressively harder in future version.