【问题标题】:Setting the type/creator code programmatically以编程方式设置类型/创建者代码
【发布时间】:2011-02-22 04:12:17
【问题描述】:

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

FSCatalogInfo catInfo;
FSGetCatalogInfo(&fileRef, kFSCatInfoFinderInfo, &catInfo, NULL, NULL, NULL);
FileInfo *info = (FileInfo*)catInfo.finderInfo;
info->fileCreator = 'ar12';
info->fileType = 'rsrc';
FSSetCatalogInfo(&fileRef, kFSCatInfoFinderInfo, &catInfo);

我做错了什么,我应该怎么做?

【问题讨论】:

    标签: c macos macos-carbon


    【解决方案1】:

    您的代码 sn-p 对我来说很好用。标签和查找器标志未更改。

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-05-04
      • 1970-01-01
      • 2015-06-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多