为什么 [ fopen() / open() / fstream file ] 在 Mac OS X 上打开文件失败?

2am*_*2am 2 c c++ macos file

我正在尝试在 Mac OS X 上打开 tga 文件,过去一个小时我一直在摆弄这个问题,但没有成功。我只想打开 .tga 文件。这是我到目前为止所尝试过的,

    int filedesc = open("/Users/x2am/Desktop/1177.tga", O_RDONLY);
    if(filedesc < 0)
            printf("%s ",strerror(errno));
Run Code Online (Sandbox Code Playgroud)

输出> 不允许操作

    FILE* fp = fopen("/Users/x2am/Desktop/1177.tga", "rb");
    if(fp == NULL) printf("file not loaded");
Run Code Online (Sandbox Code Playgroud)

输出> 文件未加载

   filename = L"/Users/x2am/Desktop/1177.tga";
   std::string narrow(filename.begin(), filename.end());
   fstream file(narrow.c_str(), ios::in | ios::binary);
   if (!file.good()) printf("file not loaded");
Run Code Online (Sandbox Code Playgroud)

输出> 文件未加载

考虑到 open() 的输出,不知何故该操作是不允许的。

这是我在图像上执行的获取信息。

在此输入图像描述

该应用程序是沙盒的, 在此输入图像描述

现在我想我已经尽力了。是不是有什么看不见的东西就在我的面前,而我却错过了?非常感谢任何帮助:)

2am*_*2am 5

这个问题确实是由于苹果沙箱造成的。这又引出了一个问题,苹果沙箱:是友还是敌?将文件放入 /Users/USER/Library/Container/com.xxx.xxx/Data/ 后,它就起作用了。非常感谢@SHR 的回答:)