gpt4 book ai didi

objective-c - 以编程方式制作 mac 包/包

转载 作者:太空狗 更新时间:2023-10-30 03:25:27 26 4
gpt4 key购买 nike

通过终端,您可以使用命令 - “SetFile -a B 文件名”

以编程方式,我认为我应该通过[[NSFileManager defaultManager] createDirectoryAtPath:dirPath withIntermediateDirectories:NO attributes:attributes error:nil];

但我找不到哪个。

谢谢

最佳答案

能够以编程方式设置捆绑位仍然很有用,例如 iPhoto 这样做是为了使 iPhoto Library 文件夹显示为单个文件。

您可以使用 Carbon 文件管理器 API 以编程方式设置捆绑位。您需要确保您的应用链接到 Carbon 框架并导入 <Carbon/Carbon.h> header 。这些调用是 64 位安全的。

- (void)setBundleBitOfFile:(NSString*)path toBool:(BOOL)newValue
{
const char* pathFSR = [path fileSystemRepresentation];
FSRef ref;
OSStatus err = FSPathMakeRef((const UInt8*)pathFSR, &ref, /*isDirectory*/ NULL);

if (err == noErr)
{
struct FSCatalogInfo catInfo;
union FinderInfoTransmuter finderInfoPointers = { .bytes = catInfo.finderInfo };

err = FSGetCatalogInfo(&ref,
kFSCatInfoFinderInfo,
&catInfo,
/*outName*/ NULL,
/*FSSpec*/ NULL,
/*parentRef*/ NULL);

if (err == noErr)
{
if (newValue)
finderInfoPointers.finderInfo->finderFlags |= kHasBundle;
else
finderInfoPointers.finderInfo->finderFlags &= ~kHasBundle;

FSSetCatalogInfo(&ref,
kFSCatInfoFinderInfo,
&catInfo);
}
}
}

- (BOOL)bundleBitOfFile:(NSString*)path
{
BOOL value = NO;

const char* pathFSR = [path fileSystemRepresentation];
FSRef ref;
OSStatus err = FSPathMakeRef((const UInt8*)pathFSR, &ref, /*isDirectory*/ NULL);

if (err == noErr)
{
struct FSCatalogInfo catInfo;
union FinderInfoTransmuter finderInfoPointers = { .bytes = catInfo.finderInfo };

err = FSGetCatalogInfo(&ref,
kFSCatInfoFinderInfo,
&catInfo,
/*outName*/ NULL,
/*FSSpec*/ NULL,
/*parentRef*/ NULL);

if (err == noErr)
{
value = (BOOL)(((finderInfoPointers.finderInfo->finderFlags) & kHasBundle) == kHasBundle);
}
}

return value;
}

关于objective-c - 以编程方式制作 mac 包/包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2009687/

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