标签: cfurl-encoding

从CFURLRef或CFStringRef转换为std :: string

如何将a转换CFURLRef为C++ std::string

我还可以从转换CFURLRefCFStringRef方式:

CFStringRef CFURLGetString ( CFURLRef anURL );
Run Code Online (Sandbox Code Playgroud)

但现在我有同样的问题.我怎样才能转换CFStringRefstd::string

c++ macos stdstring cfstring cfurl-encoding

7
推荐指数
2
解决办法
7203
查看次数

在swift中获取文件的别名路径

我在解析mac上的别名链接时遇到问题.我正在检查文件是否是别名然后我想要接收原始路径.相反,我只获得了一个文件ID.想法?

func isFinderAlias(path:String) -> Bool? {

    var isAlias:Bool? = false // Initialize result var.

    // Create a CFURL instance for the given filesystem path.
    // This should never fail, because the existence isn't verified at this point.
    // Note: No need to call CFRelease(fUrl) later, because Swift auto-memory-manages CoreFoundation objects.
    print("path before \(path)");
    let fUrl = CFURLCreateWithFileSystemPath(nil, path, CFURLPathStyle.CFURLPOSIXPathStyle, false)
    print("path furl \(fUrl)");
    // Allocate void pointer - no need for initialization,
    // it will be assigned to by CFURLCopyResourcePropertyForKey() …
Run Code Online (Sandbox Code Playgroud)

macos cfurl-encoding swift

5
推荐指数
2
解决办法
1181
查看次数

架构x86_64的未定义符号:"_ CFBundleCopyResourceURL",

尝试使用Qt访问Mac .app包中的resources文件夹的文件路径.这是我的代码:

CFURLRef appUrlRef;


appUrlRef = CFBundleCopyResourceURL(CFBundleGetMainBundle(), CFSTR("AFE-MP-512"),NULL,NULL);
CFStringRef filePathRef = CFURLCopyPath(appUrlRef);



qDebug() << filePathRef;

// Release references
CFRelease(filePathRef);
CFRelease(appUrlRef);
Run Code Online (Sandbox Code Playgroud)

我唯一拥有的是表单上的按钮来运行代码.尝试编译时出现以下错误:

Undefined symbols for architecture x86_64:
  "_CFBundleCopyResourceURL", referenced from:
      MainWindow::on_pushButton_clicked() in mainwindow.o
  "_CFBundleGetMainBundle", referenced from:
      MainWindow::on_pushButton_clicked() in mainwindow.o
  "_CFRelease", referenced from:
      MainWindow::on_pushButton_clicked() in mainwindow.o
  "_CFURLCopyPath", referenced from:
      MainWindow::on_pushButton_clicked() in mainwindow.o
  "___CFConstantStringClassReference", referenced from:
      CFString in mainwindow.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [ProgramLaunch.app/Contents/MacOS/ProgramLaunch] …
Run Code Online (Sandbox Code Playgroud)

c++ qt app-bundle cfurl-encoding

0
推荐指数
1
解决办法
1401
查看次数

标签 统计

cfurl-encoding ×3

c++ ×2

macos ×2

app-bundle ×1

cfstring ×1

qt ×1

stdstring ×1

swift ×1