core-services

Is FSGetVolumeInfo the recommended alternative to NSWorkspace's deprecated mountedLocalVolumePaths method?

岁酱吖の 提交于 2020-02-22 05:10:25
问题 I need to get a list of mounted local volumes on Mac OS X. Previously, the Cocoa class NSWorkspace had a mountedLocalVolumePaths method for getting the array of mount points for such volumes. Since Lion, this is now deprecated, with no hint in the documentation about what we should use instead. The only other Apple-specific API I have found which provides this information is the FSGetVolumeInfo function from the CoreServices.framework. This enumerates the mounted volumes if you pass

How to move a symlink to the trash?

我的梦境 提交于 2019-12-30 22:54:21
问题 I don't see any options for the FSPathMoveObjectToTrashSync() function for not following links. Here is what I have tried Create a link and a file [ 21:32:41 /tmp ] $ touch my_file [ 21:32:45 /tmp ] $ ln -s my_file my_link [ 21:32:52 /tmp ] $ la total 8 drwxrwxrwt 12 root wheel 408 17 Maj 21:32 . drwxr-xr-x@ 6 root wheel 204 9 Sep 2009 .. -rw-r--r-- 1 neoneye wheel 0 17 Maj 21:32 my_file lrwxr-xr-x 1 neoneye wheel 7 17 Maj 21:32 my_link -> my_file Move the link to the trash OSStatus status =

Full URL from FSCopyURLForVolume

↘锁芯ラ 提交于 2019-12-25 09:08:06
问题 I am running into an issue getting the full url for a file with FSCopyURLForVolume . I am using the code from this issue Determine AFP share from a file URL but it isn't giving me the full url. For example: With a path like: /Volume/server/html/index.html All I get back is url to the base mount: nfs://real_server_name/vol Leaf directories and the file names are left off, the full path is available in the files info so there has to be a way to get this information. EDIT: After some more

JXA: Accessing CFString constants from CoreServices

廉价感情. 提交于 2019-12-21 20:18:28
问题 JXA, with its built-in ObjC bridge, exposes enumeration and constants from the Foundation framework automatically via the $ object; e.g.: $.NSUTF8StringEncoding // -> 4 However, there are also useful CFString constants in lower-level APIs that aren't automatically imported, namely the kUTType* constants in CoreServices that define frequently-used UTI values, such as kUTTypeHTML for UTI "public.html" . While you can import them with ObjC.import('CoreServices') , their string value isn't

How to use UCKeyTranslate

情到浓时终转凉″ 提交于 2019-12-21 17:35:13
问题 Given a key-code for a key pressed without modifiers, I want to produce the result of pressing the shift+key. Example: For a standard US keyboard <shift>+<period> gives >. The relevant function is UCKeytranslate, but I need a bit of help getting the details right. The snippet below is a full program ready to run in XCode. The intent of the program is given <period> to produce the character >. The result of the program is: Keyboard: <TSMInputSource 0x10051a930> KB Layout: U.S. (id=0) Layout:

Mac .pref File Hex Path

久未见 提交于 2019-12-11 22:24:13
问题 I'm trying to enter a file path into a few .pref files, but instead of a String, the field wants some sort of Hexadecimal sequence. How can I convert my path into this Hex format? Mac OS 10.6.7 Here is an example of a file location: <00000000 009e0003 00010000 c94bbb14 0000482b 00000000 000d3ad2 000dfc12 0000c950 e4db0000 00000920 fffe0000 00000000 0000ffff ffff0001 0008000d 3ad2000c 9ce1000e 000c0005 0069006e 0062006f 0078000f 001a000c 004d0061 00630069 006e0074 006f0073 00680020 00480044

Is FSGetVolumeInfo the recommended alternative to NSWorkspace's deprecated mountedLocalVolumePaths method?

北城以北 提交于 2019-12-05 15:07:49
I need to get a list of mounted local volumes on Mac OS X. Previously, the Cocoa class NSWorkspace had a mountedLocalVolumePaths method for getting the array of mount points for such volumes. Since Lion, this is now deprecated, with no hint in the documentation about what we should use instead. The only other Apple-specific API I have found which provides this information is the FSGetVolumeInfo function from the CoreServices.framework. This enumerates the mounted volumes if you pass kFSInvalidVolumeRefNum for the volume parameter and 1..N for the volumeIndex . It returns the volume name (as a

JXA: Accessing CFString constants from CoreServices

流过昼夜 提交于 2019-12-04 13:05:37
JXA , with its built-in ObjC bridge, exposes enumeration and constants from the Foundation framework automatically via the $ object; e.g.: $.NSUTF8StringEncoding // -> 4 However, there are also useful CFString constants in lower-level APIs that aren't automatically imported, namely the kUTType* constants in CoreServices that define frequently-used UTI values, such as kUTTypeHTML for UTI "public.html" . While you can import them with ObjC.import('CoreServices') , their string value isn't (readily) accessible, presumably because its type is CFString[Ref] : ObjC.import('CoreServices') // import

How to use UCKeyTranslate

亡梦爱人 提交于 2019-12-04 07:47:33
Given a key-code for a key pressed without modifiers, I want to produce the result of pressing the shift+key. Example: For a standard US keyboard <shift>+<period> gives >. The relevant function is UCKeytranslate, but I need a bit of help getting the details right. The snippet below is a full program ready to run in XCode. The intent of the program is given <period> to produce the character >. The result of the program is: Keyboard: <TSMInputSource 0x10051a930> KB Layout: U.S. (id=0) Layout: 0x0000000102802000 Status: -50 UnicodeString: 97 String: a Done Program ended with exit code: 0 The part

How to move a symlink to the trash?

与世无争的帅哥 提交于 2019-12-01 18:23:45
I don't see any options for the FSPathMoveObjectToTrashSync() function for not following links. Here is what I have tried Create a link and a file [ 21:32:41 /tmp ] $ touch my_file [ 21:32:45 /tmp ] $ ln -s my_file my_link [ 21:32:52 /tmp ] $ la total 8 drwxrwxrwt 12 root wheel 408 17 Maj 21:32 . drwxr-xr-x@ 6 root wheel 204 9 Sep 2009 .. -rw-r--r-- 1 neoneye wheel 0 17 Maj 21:32 my_file lrwxr-xr-x 1 neoneye wheel 7 17 Maj 21:32 my_link -> my_file Move the link to the trash OSStatus status = FSPathMoveObjectToTrashSync( "/tmp/my_link", NULL, kFSFileOperationDefaultOptions ); NSLog(@"status: %i