我试图如下所示设置类型/创建者代码,但这会导致查找器标志和标签弄乱。
FSCatalogInfo catInfo;
FSGetCatalogInfo(&fileRef, kFSCatInfoFinderInfo, &catInfo, NULL, NULL, NULL);
FileInfo *info = (FileInfo*)catInfo.finderInfo;
info->fileCreator = 'ar12';
info->fileType = 'rsrc';
FSSetCatalogInfo(&fileRef, kFSCatInfoFinderInfo, &catInfo);
我在做什么错,我应该怎么做?
您的代码段对我来说很好。标签和取景器标志未更改。
g5:fileinfotest toby$ touch the-file
g5:fileinfotest toby$ GetFileInfo the-file
file: "/Volumes/data/Users/toby/Documents/workspace/fileinfotest/the-file"
type: ""
creator: ""
attributes: avbstclinmedz
created: 02/23/2011 14:29:15
modified: 02/23/2011 14:29:15
g5:fileinfotest toby$ ./build/Debug/fileinfotest.app/Contents/MacOS/fileinfotest
g5:fileinfotest toby$ GetFileInfo the-file
file: "/Volumes/data/Users/toby/Documents/workspace/fileinfotest/the-file"
type: "EFGh"
creator: "ABCd"
attributes: avbstclinmedz
created: 02/23/2011 14:29:15
modified: 02/23/2011 14:29:15
代码:
FSCatalogInfo catInfo;
FSRef ref;
if(!FSPathMakeRef (
"/Volumes/data/Users/toby/Documents/workspace/fileinfotest/the-file",
&ref,
false
))
{
FSGetCatalogInfo(&ref, kFSCatInfoFinderInfo, &catInfo, NULL, NULL, NULL);
FileInfo *info = (FileInfo*)catInfo.finderInfo;
info->fileCreator = 'ABCd';
info->fileType = 'EFGh';
FSSetCatalogInfo(&ref, kFSCatInfoFinderInfo, &catInfo);
}