首先,这与古代技术有关。我正在处理的程序端口是在Metrowerks代码战士9中维护的,目标是PPC。
用于MSL的FSRefParentAndFilename_fopen函数
FILE * FSRefParentAndFilename_fopen(
const FSRefPtr theParentRef,
ConstHFSUniStr255Param theName,
const char *open_mode);我需要一个ConstHFSUniStr255Param,它是指向HFSUniStr255的指针。我有一个包含文件名的CFString,我的问题是如何转换为HFSUniStr255?
struct HFSUniStr255 {
UInt16 length;
UniChar unicode[255];
};到目前为止,我已经:
HFSUniStr255 HFSString;
FSGetDataForkName(&HFSString);
HFSString.length=(uint16)CFStringGetLength(fileName);
HFSString.unicode=?发布于 2014-09-14 14:49:44
您可以使用以下代码片段:
HFSString.length=(uint16)CFStringGetLength(fileName);
CFStringGetCharacters(filename, CFRangeMake(0, CFStringGetLength(filename)), HFSString.unicode);但是,请确保您的文件名是有效的,特别是它的长度小于255个Unicode字符。否则,您将不得不面对缓冲区溢出的后果。
https://stackoverflow.com/questions/25834347
复制相似问题