Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/151.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 如何将CFString转换为HFSUniStr255?_C++_C_Macos_Macos Carbon_Codewarrior - Fatal编程技术网

C++ 如何将CFString转换为HFSUniStr255?

C++ 如何将CFString转换为HFSUniStr255?,c++,c,macos,macos-carbon,codewarrior,C++,C,Macos,Macos Carbon,Codewarrior,首先,这与古代技术有关。我正在使用的程序端口在Metrowerks Codewarrior 9中维护,目标是PPC 用于MSL C的FSRefParentAndFilename\u fopen函数 FILE * FSRefParentAndFilename_fopen( const FSRefPtr theParentRef, ConstHFSUniStr255Param theName, const char *open_mode); 我需要一个consthfsunistr255参数,它是指

首先,这与古代技术有关。我正在使用的程序端口在Metrowerks Codewarrior 9中维护,目标是PPC

用于MSL C的FSRefParentAndFilename\u fopen函数

FILE * FSRefParentAndFilename_fopen(
const FSRefPtr theParentRef,
ConstHFSUniStr255Param theName,
const char *open_mode);
我需要一个consthfsunistr255参数,它是指向HFSUniStr255的指针。 我有一个包含文件名的CFString,我的问题是如何转换为HFSUniStr255

struct HFSUniStr255 {
UInt16 length;
UniChar unicode[255];
};
到目前为止,我已经:

HFSUniStr255 HFSString;
FSGetDataForkName(&HFSString);
HFSString.length=(uint16)CFStringGetLength(fileName);
HFSString.unicode=?

您可以使用以下代码段:

HFSString.length=(uint16)CFStringGetLength(fileName);
CFStringGetCharacters(filename, CFRangeMake(0, CFStringGetLength(filename)), HFSString.unicode);
但是,请确保文件名有效,尤其是其长度小于255个Unicode字符。否则,您将不得不面对缓冲区溢出的后果