MAC OS X:如何确定文件系统是否区分大小写? [英] MAC OS X: How to determine if filesystem is case sensitive?
问题描述
我使用了 statfs(2) 系统调用来获取 Mac OS X 文件系统的许多特征,但它不会告诉我文件系统是否区分大小写.
I have used the statfs(2) system call to get many characteristics of a Mac OS X filesystem, but it doesn't tell me if the filesystem is case-sensitive or not.
我需要此信息,因为我正在开发的应用程序将移动许多文件,我想检测由于文件从大小写敏感文件系统移动到大小写而导致的潜在数据丢失-不敏感文件系统.
I need this information as the application I am developing will be moving many files around and I want to detect potential loss of data due to files being moved from a case-sensitive filesystem to a case-insensitive filesystem.
谁能建议一种检测方法?
Can anyone suggest a way of detecting this?
推荐答案
如果您已经在使用 stat(2)
,那么您可以轻松使用 pathconf(2)
带有 _PC_CASE_SENSITIVE
选择器(结果 0
= 不区分大小写,1
= 区分大小写.请注意,手册页已过期,但 >_PC_CASE_SENSITIVE
和 _PC_CASE_PRESERVING
被支持.按照惯例,如果文件系统不支持 _PC_CASE_SENSITIVE
选择器,那么它是区分大小写的.
If you're already using stat(2)
, then you can easily use pathconf(2)
with the _PC_CASE_SENSITIVE
selector (result 0
= case-insensitve, 1
= case-sensitive. Note that the man page is out of date, but the _PC_CASE_SENSITIVE
and _PC_CASE_PRESERVING
are supported. By convention, if a file system doesn't support _PC_CASE_SENSITIVE
selector then it is case-sensitive.
这篇关于MAC OS X:如何确定文件系统是否区分大小写?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!