I created a case-insensitive file system in OSX (using OSXFuse). But when I tried to check the case insensitiveness of my volume, using NSURLVolumeSupportsCaseSensitiveNamesKey
, it reported it as case sensitive. My question is, what do I need to do on OSX so that when I check the case sensitivity using NSURLVolumeSupportsCaseSensitiveNamesKey
, it will correctly report my file system as case insensitive?
Bellow are more details on what I did:
This is how I used NSURLVolumeSupportsCaseSensitiveNamesKey
to check for case insensitivity:
NSString *path = @"/Volumes/MyVolume";
NSURL *file_system = [NSURL fileURLWithPath:path isDirectory:YES];
NSNumber *case_sensitive_fs;
BOOL has_case_sensitive_resource = [file_system getResourceValue:&case_sensitive_fs
forKey:NSURLVolumeSupportsCaseSensitiveNamesKey
error:NULL];
if (!has_case_sensitive_resource) {
LOG("Has no case sensitive resource");
} else {
if ([case_sensitive_fs intValue] ==1) {
LOG("This is case sensitive file system");
} else {
LOG("This is case insensitive file system");
}
}
Note that when I used getattrlist
, it correctly reported that my file system was case insensitive:
typedef struct volume_capabilities_result {
u_int32_t length;
vol_capabilities_attr_t volume_capability;
} VolumeCapabilitiesResult;
//...
struct attrlist list = { 0 };
list.bitmapcount = ATTR_BIT_MAP_COUNT;
list.reserved = 0;
list.volattr = ATTR_VOL_INFO | ATTR_VOL_CAPABILITIES;
VolumeCapabilitiesResult volumeCapResult;
int result = getattrlist("/Volumes/MyVolume", &list, &volumeCapResult, sizeof(volumeCapResult), 0);
if (result != -1 &&
(volumeCapResult.volume_capability.valid[VOL_CAPABILITIES_FORMAT] & VOL_CAP_FMT_CASE_SENSITIVE) != 0) {
bool case_senstive = (volumeCapResult.volume_capability.capabilities[VOL_CAPABILITIES_FORMAT] &
VOL_CAP_FMT_CASE_SENSITIVE) != 0;
if (case_senstive) {
LOG("getattrlist said we are case sensitive");
} else {
LOG("getattrlist said we are case insensitive");
}
}
I believe getattrlist
reported it correctly because I used osxfuse to implement the fuse_operations.init as follow:
void fuse_init(void* user_data, struct fuse_conn_info* conn) {
conn->want |= FUSE_CAP_CASE_INSENSITIVE;
}
Are you sure your path is correct in the first code snippet, i.e. the missing slash at the beginning?
Otherwise than that, this code seems to work for me.