【问题标题】:Open file Error permission denied on macOS在 macOS 上打开文件错误权限被拒绝
【发布时间】:2019-07-07 02:40:20
【问题描述】:

您好,我使用桥接头包含一个 hpp

但总是输出“错误权限被拒绝”

我的派生数据是相对的 我尝试在 Debug-iPhonesimulator 中键入“chmod -R 777 ./”

显示代码:

bool CheckPath()
{
    FILE *pfile = fopen("./__viewtest.txt","w");
    if(pfile){
        fclose(pfile);
        return true;
    }
    printf("Error %s\n",strerror(errno));
    return false;
}

总是输出“错误权限被拒绝”

非常感谢

【问题讨论】:

    标签: iphone xcode macos


    【解决方案1】:

    我解决了

    #include <unistd.h>
    #include<iostream>
    
    std::string GetCurrentWorkingDir( void ) {
        char buff[FILENAME_MAX];
        getcwd( buff, FILENAME_MAX );
        std::string current_working_dir(buff);
        return current_working_dir;
    }
    
    bool CheckPath()
    {
        std::string sPath = GetCurrentWorkingDir();
        sPath += "Users/My/Desktop/WorkSpace/View/DerivedData/View/Build/Products/Debug-iphonesimulator/__viewtest.txt";
        FILE *pfile = fopen(sPath.c_str(),"w");
        if(pfile){
            fclose(pfile);
            return true;
        }
        printf(" %s, Path %s\n",strerror(errno), GetCurrentWorkingDir().c_str());
        return false;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-01-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-09-15
      • 1970-01-01
      • 2013-01-22
      相关资源
      最近更新 更多