gpt4 book ai didi

c - 以编程方式设置类型/创建者代码

转载 作者:行者123 更新时间:2023-12-04 06:33:52 24 4
gpt4 key购买 nike

我正在尝试设置类型/创建者代码,如下所示,但这会导致查找器标志和标签困惑。

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);
}

关于c - 以编程方式设置类型/创建者代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5073899/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com