代码之家  ›  专栏  ›  技术社区  ›  Brian Stewart

boost文件系统能否更改文件的只读属性?

  •  6
  • Brian Stewart  · 技术社区  · 15 年前

    有没有办法使用boost文件系统库将文件的属性从只读更改为读写?如果不是,在Windows上(使用Microsoft的C++)执行此操作的下一个最佳方法是什么?

    2 回复  |  直到 15 年前
        1
  •  8
  •   Sergey Podobry    15 年前

    我在boost库中找不到如何实现这一点。但您可以使用Windows API执行此操作:

    SetFileAttributes(lpFileName, GetFileAttributes(lpFileName) & ~FILE_ATTRIBUTE_READONLY);
    

    SetFileAttributes Function GetFileAttributes Function 更多信息。

        2
  •  2
  •   korbes    10 年前

    permissions(file_path, add_perms|owner_write|group_write|others_write);