Browse Source
Merge pull request #818 from trapexit/lchmod
optionally use lchmod depending on if on Linux or not (BSD)
pull/821/head
trapexit
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
7 additions and
2 deletions
-
src/fs_lchmod.hpp
|
@ -18,11 +18,12 @@ |
|
|
|
|
|
|
|
|
#pragma once
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
#include "fs_fchmodat.hpp"
|
|
|
|
|
|
#include "fs_lstat.hpp"
|
|
|
#include "fs_lstat.hpp"
|
|
|
|
|
|
|
|
|
#include <string>
|
|
|
#include <string>
|
|
|
|
|
|
|
|
|
|
|
|
#include <sys/stat.h>
|
|
|
|
|
|
|
|
|
#define MODE_BITS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO)
|
|
|
#define MODE_BITS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO)
|
|
|
|
|
|
|
|
|
namespace fs |
|
|
namespace fs |
|
@ -33,7 +34,11 @@ namespace fs |
|
|
lchmod(const char *pathname_, |
|
|
lchmod(const char *pathname_, |
|
|
const mode_t mode_) |
|
|
const mode_t mode_) |
|
|
{ |
|
|
{ |
|
|
return fs::fchmodat(AT_FDCWD,pathname_,mode_,AT_SYMLINK_NOFOLLOW); |
|
|
|
|
|
|
|
|
#if defined __linux__
|
|
|
|
|
|
return ::chmod(pathname_,mode_); |
|
|
|
|
|
#else
|
|
|
|
|
|
return ::lchmod(pathname_,mode_); |
|
|
|
|
|
#endif
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static |
|
|
static |
|
|