Mac .pref 文件十六进制路径
我试图在几个 .pref 文件中输入文件路径,但该字段需要某种十六进制序列而不是字符串。如何将我的路径转换为这种十六进制格式?
Mac OS 10.6.7
以下是文件位置的示例:
<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 00120015 55736572 732f7263 68617265 7474652f 696e626f 78000013 00012f00 00150002 0010ffff 0000> 0010ffff 0000>
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 00120015 55736572 732f7263 68617265 7474652f 696e626f 78000013 00012f00 00150002 0010ffff 0000>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
它是别名
'alis'
数据,在过去 20 年或更长时间里,它一直是 Mac OS 中以持久方式引用文件的标准方式。 ;-)AliasHandle
等。所有这些都可以在Aliases.h
中找到,它位于CoreServices
伞式框架的CarbonCore.framework
中。请注意,属性列表编辑器(或 Xcode)向您显示
NSData
的十六进制表示形式。数据告诉我们,您没有更改硬盘驱动器的名称(它似乎仍然是“Macintosh HD”),并且别名的路径是/Users/rcharette/inbox
“newfangled”名称是书签数据,在 10.6 中引入。
我相信,有几个围绕别名的高级包装器,即 Nathan Day 的
NDalias
。否则,以下是我的,
NSString
上的一个类别,以NSURL
中可用的新书签 API 为模型(需要 10.6)。 (此代码应适用于 10.3+):MDBookmarks.h:
MDBookmarks.m:
—
否则,如果您需要 10.6,请在
NSURL
中查看较新的 API。It's alias
'alis'
data, which has been the standard way to refer to files in a persistent manner in Mac OS for the last 20 years or more. ;-) TheAliasHandle
et. al are found inAliases.h
, which is in theCarbonCore.framework
of theCoreServices
umbrella framework.Note that it is Property List Editor (or Xcode) that's showing you a hexadecimal representation of
NSData
. The data tells us that you haven't changed the name of your hard drive (it appears to still be "Macintosh HD") and that the path of the alias was to/Users/rcharette/inbox
The "newfangled" name for this is bookmark data, which was introduced in 10.6.
There are a couple of high-level wrappers around aliases, Nathan Day's
NDAlias
, I believe.Otherwise, the following is mine, a category on
NSString
modeled after the new bookmark APIs available inNSURL
(which require 10.6). (This code should work on 10.3+):MDBookmarks.h:
MDBookmarks.m:
—
Otherwise, if you can require 10.6, then check out the newer APIs in
NSURL
.首选项文件中的路径有时采用 Base64 编码。您可以使用 openssl 对值进行反/编码:
Decode:
echo; | openssl enc -d -base64
编码:
echo; | openssl enc -e -base64
Paths in preference files are sometimes base64 encoded. You can use openssl to de/encode the values:
Decode:
echo <encoded-path> | openssl enc -d -base64
Encode:
echo <path> | openssl enc -e -base64