【问题标题】:c copy file permissions from another filec 从另一个文件复制文件权限
【发布时间】:2013-05-16 19:52:28
【问题描述】:

复制文件的unix文件权限并将其设置到另一个文件的最简单方法是什么?有没有办法将文件的权限存储到变量中,然后使用该变量将这些权限设置到另一个文件?

【问题讨论】:

    标签: c unix permissions chmod


    【解决方案1】:

    当然。使用stat()chmod()(可能需要root)。

    #include <sys/stat.h>
    
    struct stat st;
    stat("/foo/bar.txt", &st);
    chmod("/baz/quirk.jpg", st.st_mode);
    

    【讨论】:

      猜你喜欢
      • 2011-05-18
      • 2012-06-13
      • 1970-01-01
      • 2011-12-19
      • 2022-10-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-11-12
      相关资源
      最近更新 更多