使用 matlab/octave fopen 创建新文件,其名称仅与现有文件的大小写不同
creating new file whose name only differs by case from existing file with matlab/octave fopen
是否可以在 MATLAB 或 Octave 中使用 fopen 来创建一个名称与现有文件仅大小写不同的文件?在 MacOS 10.11.6 上的 MATLAB R2016a 和 Octave 4.2.0 中,以下代码仅创建 FooBar.txt
并将 bar
写入其中(未创建 foobar.txt
):
fid = fopen('FooBar.txt', 'w');
fwrite(fid, 'foo', 'char');
fclose(fid);
fid = fopen('foobar.txt', 'w');
fwrite(fid, 'bar', 'char');
fclose(fid);
MATLAB 可以做到这一点,但仅限于 Linux。默认情况下,Windows 和 MacOS 不区分大小写。
NTFS 和 FAT(及其变体)是 case sensitive(符合 POSIX),但 Windows 内核不区分大小写。意思是,原则上 NTFS 可以保存两个名称仅大小写不同的文件,但是这些文件不能创建也不能用 Windows 区分,除非您在比大多数程序中常见的级别低得多的级别上进行系统调用(阅读:"hack")。
HFS+ 在 MacOS 上臭名昭著 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,我认为区分大小写不符合 Apple 的设计理念(另外,许多应用程序明确假设大小写 in 敏感,如果改变),所以我认为在未来的版本中启用对区分大小写的支持很可能会变得越来越难。
是否可以在 MATLAB 或 Octave 中使用 fopen 来创建一个名称与现有文件仅大小写不同的文件?在 MacOS 10.11.6 上的 MATLAB R2016a 和 Octave 4.2.0 中,以下代码仅创建 FooBar.txt
并将 bar
写入其中(未创建 foobar.txt
):
fid = fopen('FooBar.txt', 'w');
fwrite(fid, 'foo', 'char');
fclose(fid);
fid = fopen('foobar.txt', 'w');
fwrite(fid, 'bar', 'char');
fclose(fid);
MATLAB 可以做到这一点,但仅限于 Linux。默认情况下,Windows 和 MacOS 不区分大小写。
NTFS 和 FAT(及其变体)是 case sensitive(符合 POSIX),但 Windows 内核不区分大小写。意思是,原则上 NTFS 可以保存两个名称仅大小写不同的文件,但是这些文件不能创建也不能用 Windows 区分,除非您在比大多数程序中常见的级别低得多的级别上进行系统调用(阅读:"hack")。
HFS+ 在 MacOS 上臭名昭著 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,我认为区分大小写不符合 Apple 的设计理念(另外,许多应用程序明确假设大小写 in 敏感,如果改变),所以我认为在未来的版本中启用对区分大小写的支持很可能会变得越来越难。