sla*_*ais 1 c++ linux file-locking
如何使用C++以编程方式锁定/解锁或以其他方式阻止/启用编辑Linux上的源文件.
我希望能够锁定源文件,这样如果我在编辑器中打开它,它将不允许我保存回相同的源文件.
我想可能将权限更改为只读(并在以后将其更改为读写):我如何从C++中执行此操作?
试试man fchmod:
NAME
chmod, fchmod - change permissions of a file
SYNOPSIS
#include <sys/types.h>
#include <sys/stat.h>
int chmod(const char *path, mode_t mode);
int fchmod(int fildes, mode_t mode);