Sunday, October 22, 2017

#1 2017-09-26 03:42:44 pm

t.spoon
Member
From:: BFE, Massachusetts
Registered: 2013-01-13
Posts: 205

Get case sensitivity of mounted share?

Is there a way to get the case sensitivity setting (true or false) of a mounted share? Ideally it could be of any type - AFP, SMB, WebDAV, etc.

I was hoping it would just be in "properties" of the alias of the drive in Applescript, but it's not.

Googling this, I found the shell command "getattrlist" which looks promising - it has the property "VOL_CAP_FMT_CASE_SENSITIVE." When I found that, I thought I was done. But I just bumble my way through the shell, and the usage examples included in the man page are alien to me... I'm used to shell commands that are one line with a couple arguments and a few flags... this looks like an Objective C program? Any help from the ASObjC people, or any other way to find this info?


Applescript:

EXAMPLES
The following code prints the file type and creator of a file, assuming that the volume
supports the required attributes.

#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <sys/attr.h>
#include <sys/errno.h>
#include <unistd.h>
#include <sys/vnode.h>

typedef struct attrlist attrlist_t;

struct FInfoAttrBuf {
u_int32_t length;
fsobj_type_t objType;
char finderInfo[32];
} __attribute__((aligned(4), packed));
typedef struct FInfoAttrBuf FInfoAttrBuf;

static int FInfoDemo(const char *path)
{
int err;
attrlist_t attrList;
FInfoAttrBuf attrBuf;

memset(&attrList, 0, sizeof(attrList));
attrList.bitmapcount = ATTR_BIT_MAP_COUNT;
attrList.commonattr = ATTR_CMN_OBJTYPE | ATTR_CMN_FNDRINFO;

err = getattrlist(path, &attrList, &attrBuf, sizeof(attrBuf), 0);
if (err != 0) {
err = errno;
}

if (err == 0) {
assert(attrBuf.length == sizeof(attrBuf));

printf("Finder information for %s:\n", path);
switch (attrBuf.objType) {
case VREG:
printf("file type = '%.4s'\n", &attrBuf.finderInfo[0]);
printf("file creator = '%.4s'\n", &attrBuf.finderInfo[4]);
break;
case VDIR:
printf("directory\n");
break;
default:
printf("other object type, %d\n", attrBuf.objType);
break;
}
}

return err;
}


Hackintosh built February, 2012 |  Mac OS Sierra
GIGABYTE GA-Z68X-UD3H-B3 | Core i5 2500k | 16 GB DDR3 | GIGABYTE Geforce 1050 TI 4GB
250 GB Samsung 850 EVO | 4 TB RAID
Dell Ultrasharp U3011 | Dell Ultrasharp 2007FPb

Offline

 

#2 2017-09-26 08:18:17 pm

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 5158

Re: Get case sensitivity of mounted share?

This will do what you want:

Applescript:

use AppleScript version "2.4" -- Yosemite (10.10) or later
use framework "Foundation"
use scripting additions

set thePath to POSIX path of some item of (list disks) -- for testing
set theURL to current application's |NSURL|'s fileURLWithPath:thePath
set {theResult, theValue, theError} to theURL's getResourceValue:(reference) forKey:(current application's NSURLVolumeSupportsCaseSensitiveNamesKey) |error|:(reference)
if theResult is false then error theError's localizedDescription() as text
if theValue as boolean then
   display dialog thePath & " is case-sensitive"
else
   display dialog thePath & " is not case-sensitive"
end if


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/

Offline

 

#3 2017-09-27 02:49:34 pm

t.spoon
Member
From:: BFE, Massachusetts
Registered: 2013-01-13
Posts: 205

Re: Get case sensitivity of mounted share?

Thank you so much, Shane! Works Great.

In case anyone else finds this and just wants to get the answer for a specific disk, I made it so it asks instead of playing disk-roulette:

Applescript:

use AppleScript version "2.4" -- Yosemite (10.10) or later
use framework "Foundation"
use scripting additions

set thePath to POSIX path of alias (choose from list (list disks))
set theURL to current application's |NSURL|'s fileURLWithPath:thePath
set {theResult, theValue, theError} to theURL's getResourceValue:(reference) forKey:(current application's NSURLVolumeSupportsCaseSensitiveNamesKey) |error|:(reference)
if theResult is false then error theError's localizedDescription() as text
if theValue as boolean then
   display dialog thePath & " is case-sensitive"
else
   display dialog thePath & " is not case-sensitive"
end if


Hackintosh built February, 2012 |  Mac OS Sierra
GIGABYTE GA-Z68X-UD3H-B3 | Core i5 2500k | 16 GB DDR3 | GIGABYTE Geforce 1050 TI 4GB
250 GB Samsung 850 EVO | 4 TB RAID
Dell Ultrasharp U3011 | Dell Ultrasharp 2007FPb

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)