30 #ifdef HAVE_SYS_MMAN_H
39 #include <mach-o/dyld.h>
42 #if __has_include(<sys/clonefile.h>)
43 #include <sys/clonefile.h>
45 #elif defined(__FreeBSD__)
46 #include <osreldate.h>
47 #if __FreeBSD_version >= 1300057
50 #include <machine/elf.h>
51 extern char **environ;
53 #elif defined(__DragonFly__)
54 #include <sys/mount.h>
55 #elif defined(__MVS__)
66 #if !defined(PATH_MAX)
70 #elif defined(__MVS__)
71 #define PATH_MAX _XOPEN_PATH_MAX
75 #include <sys/types.h>
76 #if !defined(__APPLE__) && !defined(__OpenBSD__) && !defined(__FreeBSD__) && \
77 !defined(__linux__) && !defined(__FreeBSD_kernel__) && !defined(_AIX)
78 #include <sys/statvfs.h>
79 #define STATVFS statvfs
80 #define FSTATVFS fstatvfs
81 #define STATVFS_F_FRSIZE(vfs) vfs.f_frsize
83 #if defined(__OpenBSD__) || defined(__FreeBSD__)
84 #include <sys/mount.h>
85 #include <sys/param.h>
86 #elif defined(__linux__)
87 #if defined(HAVE_LINUX_MAGIC_H)
88 #include <linux/magic.h>
90 #if defined(HAVE_LINUX_NFS_FS_H)
91 #include <linux/nfs_fs.h>
93 #if defined(HAVE_LINUX_SMB_H)
94 #include <linux/smb.h>
99 #include <sys/statfs.h>
105 #include <sys/vmount.h>
107 #include <sys/mount.h>
109 #define STATVFS statfs
110 #define FSTATVFS fstatfs
111 #define STATVFS_F_FRSIZE(vfs) static_cast<uint64_t>(vfs.f_bsize)
114 #if defined(__NetBSD__) || defined(__DragonFly__) || defined(__GNU__) || \
116 #define STATVFS_F_FLAG(vfs) (vfs).f_flag
118 #define STATVFS_F_FLAG(vfs) (vfs).f_flags
121 using namespace llvm;
129 #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || \
130 defined(__minix) || defined(__FreeBSD_kernel__) || defined(__linux__) || \
131 defined(__CYGWIN__) || defined(__DragonFly__) || defined(_AIX) || defined(__GNU__) || \
132 (defined(__sun__) && defined(__svr4__))
134 test_dir(
char ret[PATH_MAX],
const char *dir,
const char *bin)
137 char fullpath[PATH_MAX];
139 int chars = snprintf(fullpath, PATH_MAX,
"%s/%s", dir, bin);
142 if (chars >= PATH_MAX)
144 if (!realpath(fullpath,
ret))
146 if (stat(fullpath, &sb) != 0)
153 getprogpath(
char ret[PATH_MAX],
const char *bin)
160 if (test_dir(
ret,
"/", bin) == 0)
166 if (strchr(bin,
'/')) {
168 if (!getcwd(cwd, PATH_MAX))
170 if (test_dir(
ret, cwd, bin) == 0)
177 if ((pv = getenv(
"PATH")) ==
nullptr)
179 char *
s = strdup(pv);
183 for (
char *
t = strtok_r(
s,
":", &state);
t !=
nullptr;
184 t = strtok_r(
nullptr,
":", &state)) {
185 if (test_dir(
ret,
t, bin) == 0) {
193 #endif // __FreeBSD__ || __NetBSD__ || __FreeBSD_kernel__
197 std::string getMainExecutableImpl(
const char *argv0,
void *MainAddr) {
198 #if defined(__APPLE__)
202 char exe_path[PATH_MAX];
204 if (_NSGetExecutablePath(exe_path, &
size) == 0) {
205 char link_path[PATH_MAX];
206 if (realpath(exe_path, link_path))
209 #elif defined(__FreeBSD__)
214 char exe_path[PATH_MAX];
215 #if __FreeBSD_version >= 1300057
216 if (elf_aux_info(AT_EXECPATH, exe_path,
sizeof(exe_path)) == 0) {
217 char link_path[PATH_MAX];
218 if (realpath(exe_path, link_path))
225 char **
p = ::environ;
229 for (Elf_Auxinfo *aux = (Elf_Auxinfo *)
p; aux->a_type != AT_NULL; aux++) {
230 if (aux->a_type == AT_EXECPATH) {
231 char link_path[PATH_MAX];
232 if (realpath((
char *)aux->a_un.a_ptr, link_path))
238 if (getprogpath(exe_path, argv0) != NULL)
240 #elif defined(__NetBSD__) || defined(__OpenBSD__) || defined(__minix) || \
241 defined(__DragonFly__) || defined(__FreeBSD_kernel__) || defined(_AIX)
242 const char *curproc =
"/proc/curproc/file";
243 char exe_path[PATH_MAX];
245 ssize_t len = readlink(curproc, exe_path,
sizeof(exe_path));
249 len =
std::min(len, ssize_t(
sizeof(exe_path) - 1));
250 exe_path[len] =
'\0';
255 if (getprogpath(exe_path, argv0) != NULL)
257 #elif defined(__linux__) || defined(__CYGWIN__) || defined(__gnu_hurd__)
258 char exe_path[PATH_MAX];
259 const char *aPath =
"/proc/self/exe";
262 ssize_t len = readlink(aPath, exe_path,
sizeof(exe_path));
268 len =
std::min(len, ssize_t(
sizeof(exe_path) - 1));
269 exe_path[len] =
'\0';
275 #if _POSIX_VERSION >= 200112 || defined(__GLIBC__)
276 if (
char *
real_path = realpath(exe_path,
nullptr)) {
288 if (getprogpath(exe_path, argv0))
290 #elif defined(__sun__) && defined(__svr4__)
291 char exe_path[PATH_MAX];
292 const char *aPath =
"/proc/self/execname";
294 int fd = open(aPath, O_RDONLY);
297 if (
read(fd, exe_path,
sizeof(exe_path)) < 0)
302 if (getprogpath(exe_path, argv0) != NULL)
304 #elif defined(__MVS__)
307 char exe_path[PS_PATHBLEN];
308 pid_t pid = getpid();
310 memset(&buf, 0,
sizeof(buf));
311 buf.ps_pathptr = exe_path;
312 buf.ps_pathlen =
sizeof(exe_path);
315 if ((token = w_getpsent(token, &buf,
sizeof(buf))) <= 0)
317 if (buf.ps_pid != pid)
324 #elif defined(HAVE_DLFCN_H) && defined(HAVE_DLADDR)
327 int err = dladdr(MainAddr, &DLInfo);
333 char link_path[PATH_MAX];
334 if (realpath(DLInfo.dli_fname, link_path))
337 #error GetMainExecutable is not implemented on this host yet.
351 return UniqueID(fs_st_dev, fs_st_ino);
360 if (::STATVFS(
const_cast<char *
>(
Path.str().c_str()), &Vfs))
361 return std::error_code(errno, std::generic_category());
362 auto FrSize = STATVFS_F_FRSIZE(Vfs);
363 space_info SpaceInfo;
364 SpaceInfo.capacity =
static_cast<uint64_t>(Vfs.f_blocks) * FrSize;
365 SpaceInfo.free =
static_cast<uint64_t>(Vfs.f_bfree) * FrSize;
366 SpaceInfo.available =
static_cast<uint64_t>(Vfs.f_bavail) * FrSize;
373 const char *pwd = ::getenv(
"PWD");
379 result.append(pwd, pwd + strlen(pwd));
380 return std::error_code();
383 result.resize_for_overwrite(PATH_MAX);
386 if (::getcwd(
result.data(),
result.size()) ==
nullptr) {
388 if (errno != ENOMEM) {
390 return std::error_code(errno, std::generic_category());
399 return std::error_code();
406 if (::chdir(
p.begin()) == -1)
407 return std::error_code(errno, std::generic_category());
409 return std::error_code();
417 if (::mkdir(
p.begin(), Perms) == -1) {
418 if (errno != EEXIST || !IgnoreExisting)
419 return std::error_code(errno, std::generic_category());
422 return std::error_code();
434 if (::symlink(
t.begin(),
f.begin()) == -1)
435 return std::error_code(errno, std::generic_category());
437 return std::error_code();
447 if (::
link(
t.begin(),
f.begin()) == -1)
448 return std::error_code(errno, std::generic_category());
450 return std::error_code();
453 std::error_code
remove(
const Twine &path,
bool IgnoreNonExisting) {
455 StringRef p = path.toNullTerminatedStringRef(path_storage);
458 if (lstat(
p.begin(), &buf) != 0) {
459 if (errno != ENOENT || !IgnoreNonExisting)
460 return std::error_code(errno, std::generic_category());
461 return std::error_code();
469 if (!S_ISREG(buf.st_mode) && !S_ISDIR(buf.st_mode) && !S_ISLNK(buf.st_mode))
472 if (::
remove(
p.begin()) == -1) {
473 if (errno != ENOENT || !IgnoreNonExisting)
474 return std::error_code(errno, std::generic_category());
477 return std::error_code();
480 static bool is_local_impl(
struct STATVFS &Vfs) {
481 #if defined(__linux__) || defined(__GNU__)
482 #ifndef NFS_SUPER_MAGIC
483 #define NFS_SUPER_MAGIC 0x6969
485 #ifndef SMB_SUPER_MAGIC
486 #define SMB_SUPER_MAGIC 0x517B
488 #ifndef CIFS_MAGIC_NUMBER
489 #define CIFS_MAGIC_NUMBER 0xFF534D42
496 case NFS_SUPER_MAGIC:
497 case SMB_SUPER_MAGIC:
498 case CIFS_MAGIC_NUMBER:
503 #elif defined(__CYGWIN__)
506 #elif defined(__Fuchsia__)
509 #elif defined(__EMSCRIPTEN__)
512 #elif defined(__HAIKU__)
519 return !fstype.equals(
"nfs");
524 size_t BufSize = 2048u;
525 std::unique_ptr<char[]> Buf;
528 Buf = std::make_unique<char[]>(BufSize);
529 Ret = mntctl(MCTL_QUERY, BufSize, Buf.get());
532 BufSize = *
reinterpret_cast<unsigned int *
>(Buf.get());
541 char *CurObjPtr = Buf.get();
543 struct vmount *Vp =
reinterpret_cast<struct vmount *
>(CurObjPtr);
544 static_assert(
sizeof(Vfs.f_fsid) ==
sizeof(Vp->vmt_fsid),
545 "fsid length mismatch");
546 if (
memcmp(&Vfs.f_fsid, &Vp->vmt_fsid,
sizeof Vfs.f_fsid) == 0)
547 return (Vp->vmt_flags & MNT_REMOTE) == 0;
549 CurObjPtr += Vp->vmt_length;
554 #elif defined(__MVS__)
559 return !!(STATVFS_F_FLAG(Vfs) & MNT_LOCAL);
565 if (::STATVFS(
const_cast<char *
>(
Path.str().c_str()), &Vfs))
566 return std::error_code(errno, std::generic_category());
568 Result = is_local_impl(Vfs);
569 return std::error_code();
572 std::error_code
is_local(
int FD,
bool &Result) {
574 if (::FSTATVFS(FD, &Vfs))
575 return std::error_code(errno, std::generic_category());
577 Result = is_local_impl(Vfs);
578 return std::error_code();
588 if (::
rename(
f.begin(),
t.begin()) == -1)
589 return std::error_code(errno, std::generic_category());
591 return std::error_code();
597 if (::ftruncate(FD,
Size) == -1)
598 return std::error_code(errno, std::generic_category());
600 return std::error_code();
619 if (::
access(
P.begin(), convertAccessMode(
Mode)) == -1)
620 return std::error_code(errno, std::generic_category());
625 if (0 != stat(
P.begin(), &buf))
627 if (!S_ISREG(buf.st_mode))
631 return std::error_code();
640 return A.fs_st_dev ==
B.fs_st_dev &&
641 A.fs_st_ino ==
B.fs_st_ino;
645 file_status fsA, fsB;
646 if (std::error_code ec =
status(
A, fsA))
648 if (std::error_code ec =
status(
B, fsB))
651 return std::error_code();
656 if (PathStr.empty() || !PathStr.startswith(
"~"))
659 PathStr = PathStr.drop_front();
672 Path[0] = Storage[0];
673 Path.insert(
Path.begin() + 1, Storage.begin() + 1, Storage.end());
679 struct passwd *Entry =
nullptr;
681 Entry = ::getpwnam(
User.c_str());
690 Path.append(Entry->pw_dir, Entry->pw_dir + strlen(Entry->pw_dir));
701 expandTildeExpr(dest);
707 else if (S_ISREG(
Mode))
709 else if (S_ISBLK(
Mode))
711 else if (S_ISCHR(
Mode))
713 else if (S_ISFIFO(
Mode))
715 else if (S_ISSOCK(
Mode))
717 else if (S_ISLNK(
Mode))
722 static std::error_code fillStatus(
int StatRet,
const struct stat &
Status,
723 file_status &Result) {
725 std::error_code
EC(errno, std::generic_category());
734 #if defined(HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC)
735 atime_nsec =
Status.st_atimespec.tv_nsec;
736 mtime_nsec =
Status.st_mtimespec.tv_nsec;
737 #elif defined(HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC)
738 atime_nsec =
Status.st_atim.tv_nsec;
739 mtime_nsec =
Status.st_mtim.tv_nsec;
741 atime_nsec = mtime_nsec = 0;
747 Status.st_atime, atime_nsec,
Status.st_mtime, mtime_nsec,
750 return std::error_code();
753 std::error_code
status(
const Twine &Path, file_status &Result,
bool Follow) {
758 int StatRet = (Follow ? ::stat : ::lstat)(
P.begin(), &
Status);
759 return fillStatus(StatRet,
Status, Result);
762 std::error_code
status(
int FD, file_status &Result) {
764 int StatRet = ::fstat(FD, &
Status);
765 return fillStatus(StatRet,
Status, Result);
771 unsigned Mask = ::umask(0);
772 (void) ::umask(
Mask);
780 if (::chmod(
P.begin(), Permissions))
781 return std::error_code(errno, std::generic_category());
782 return std::error_code();
786 if (::fchmod(FD, Permissions))
787 return std::error_code(errno, std::generic_category());
788 return std::error_code();
792 TimePoint<> ModificationTime) {
793 #if defined(HAVE_FUTIMENS)
797 if (::futimens(FD, Times))
798 return std::error_code(errno, std::generic_category());
799 return std::error_code();
800 #elif defined(HAVE_FUTIMES)
803 std::chrono::time_point_cast<std::chrono::microseconds>(AccessTime));
805 sys::toTimeVal(std::chrono::time_point_cast<std::chrono::microseconds>(
807 if (::futimes(FD, Times))
808 return std::error_code(errno, std::generic_category());
809 return std::error_code();
810 #elif defined(__MVS__)
812 memset(&Attr, 0,
sizeof(Attr));
813 Attr.att_atimechg = 1;
815 Attr.att_mtimechg = 1;
817 if (::__fchattr(FD, &Attr,
sizeof(Attr)) != 0)
818 return std::error_code(errno, std::generic_category());
819 return std::error_code();
821 #warning Missing futimes() and futimens()
831 int prot = (
Mode ==
readonly) ? PROT_READ : (PROT_READ | PROT_WRITE);
832 #if defined(MAP_NORESERVE)
833 flags |= MAP_NORESERVE;
835 #if defined(__APPLE__)
846 #if defined(MAP_RESILIENT_CODESIGN)
847 flags |= MAP_RESILIENT_CODESIGN;
849 #if defined(MAP_RESILIENT_MEDIA)
850 flags |= MAP_RESILIENT_MEDIA;
853 #endif // #if defined (__APPLE__)
855 Mapping = ::mmap(
nullptr,
Size, prot, flags, FD,
Offset);
856 if (Mapping == MAP_FAILED)
857 return std::error_code(errno, std::generic_category());
858 return std::error_code();
862 uint64_t offset, std::error_code &ec)
867 copyFrom(mapped_file_region());
870 void mapped_file_region::unmapImpl() {
872 ::munmap(Mapping,
Size);
875 void mapped_file_region::dontNeedImpl() {
879 #if defined(__MVS__) || defined(_AIX)
881 #elif defined(POSIX_MADV_DONTNEED)
882 ::posix_madvise(Mapping,
Size, POSIX_MADV_DONTNEED);
884 ::madvise(Mapping,
Size, MADV_DONTNEED);
888 int mapped_file_region::alignment() {
894 bool follow_symlinks) {
896 DIR *directory = ::opendir(path_null.c_str());
898 return std::error_code(errno, std::generic_category());
900 it.IterationHandle =
reinterpret_cast<intptr_t>(directory);
903 it.CurrentEntry = directory_entry(path_null.str(), follow_symlinks);
908 if (
it.IterationHandle)
909 ::closedir(
reinterpret_cast<DIR *
>(
it.IterationHandle));
910 it.IterationHandle = 0;
911 it.CurrentEntry = directory_entry();
912 return std::error_code();
915 static file_type direntType(dirent* Entry) {
922 return typeForMode(DTTOIF(Entry->d_type));
925 return file_type::type_unknown;
931 dirent *CurDir = ::readdir(
reinterpret_cast<DIR *
>(It.IterationHandle));
932 if (CurDir ==
nullptr && errno != 0) {
933 return std::error_code(errno, std::generic_category());
934 }
else if (CurDir !=
nullptr) {
936 if ((
Name.size() == 1 &&
Name[0] ==
'.') ||
939 It.CurrentEntry.replace_filename(
Name, direntType(CurDir));
943 return std::error_code();
957 #if !defined(__FreeBSD__)
958 #define TRY_PROC_SELF_FD
961 #if !defined(F_GETPATH) && defined(TRY_PROC_SELF_FD)
962 static bool hasProcSelfFD() {
965 static const bool Result = (
::access(
"/proc/self/fd", R_OK) == 0);
1016 int OpenFlags = nativeOpenFlags(Disp, Flags, Access);
1022 auto Open = [&]() { return ::open(
P.begin(),
OpenFlags,
Mode); };
1024 return std::error_code(errno, std::generic_category());
1027 int r = fcntl(ResultFD, F_SETFD, FD_CLOEXEC);
1029 assert(r == 0 &&
"fcntl(F_SETFD, FD_CLOEXEC) failed");
1087 if ((Flags &
OF_Append) && lseek(ResultFD, 0, SEEK_END) == -1)
1088 return std::error_code(errno, std::generic_category());
1090 if (fstat(ResultFD, &Stat) == -1)
1091 return std::error_code(errno, std::generic_category());
1092 if (S_ISREG(Stat.st_mode)) {
1094 !Stat.st_tag.ft_txtflag && !Stat.st_tag.ft_ccsid &&
1097 if (
auto EC = llvm::enableAutoConversion(ResultFD))
1100 if (
auto EC = llvm::setFileTag(ResultFD, CCSID_IBM_1047,
true))
1104 if (
auto EC = llvm::disableAutoConversion(ResultFD))
1107 if (
auto EC = llvm::setFileTag(ResultFD, FT_BINARY,
false))
1114 return std::error_code();
1131 std::error_code
EC =
1138 return std::error_code();
1140 #if defined(F_GETPATH)
1143 char Buffer[PATH_MAX];
1144 if (::fcntl(ResultFD, F_GETPATH, Buffer) != -1)
1145 RealPath->
append(Buffer, Buffer + strlen(Buffer));
1147 char Buffer[PATH_MAX];
1148 #if defined(TRY_PROC_SELF_FD)
1149 if (hasProcSelfFD()) {
1151 snprintf(ProcPath,
sizeof(ProcPath),
"/proc/self/fd/%d", ResultFD);
1152 ssize_t CharCount = ::readlink(ProcPath, Buffer,
sizeof(Buffer));
1154 RealPath->
append(Buffer, Buffer + CharCount);
1161 if (::realpath(
P.begin(), Buffer) !=
nullptr)
1162 RealPath->
append(Buffer, Buffer + strlen(Buffer));
1163 #if defined(TRY_PROC_SELF_FD)
1167 return std::error_code();
1184 #if defined(__APPLE__)
1185 size_t Size = std::min<size_t>(Buf.
size(), INT32_MAX);
1191 if (ssize_t(NumRead) == -1)
1198 #if defined(__APPLE__)
1199 size_t Size = std::min<size_t>(Buf.
size(), INT32_MAX);
1207 if (lseek(FD,
Offset, SEEK_SET) == -1)
1217 std::error_code
tryLockFile(
int FD, std::chrono::milliseconds Timeout) {
1219 auto End = Start + Timeout;
1222 memset(&Lock, 0,
sizeof(Lock));
1223 Lock.l_type = F_WRLCK;
1224 Lock.l_whence = SEEK_SET;
1227 if (::fcntl(FD, F_SETLK, &Lock) != -1)
1228 return std::error_code();
1231 return std::error_code(
Error, std::generic_category());
1239 memset(&Lock, 0,
sizeof(Lock));
1240 Lock.l_type = F_WRLCK;
1241 Lock.l_whence = SEEK_SET;
1244 if (::fcntl(FD, F_SETLKW, &Lock) != -1)
1245 return std::error_code();
1247 return std::error_code(
Error, std::generic_category());
1252 Lock.l_type = F_UNLCK;
1253 Lock.l_whence = SEEK_SET;
1256 if (::fcntl(FD, F_SETLK, &Lock) != -1)
1257 return std::error_code();
1258 return std::error_code(errno, std::generic_category());
1267 template <
typename T>
1268 static std::error_code remove_directories_impl(
const T &Entry,
1269 bool IgnoreErrors) {
1271 directory_iterator Begin(Entry, EC,
false);
1272 directory_iterator End;
1273 while (Begin != End) {
1274 auto &Item = *Begin;
1276 if (!st && !IgnoreErrors)
1280 EC = remove_directories_impl(Item, IgnoreErrors);
1281 if (EC && !IgnoreErrors)
1286 if (EC && !IgnoreErrors)
1289 Begin.increment(EC);
1290 if (EC && !IgnoreErrors)
1293 return std::error_code();
1297 auto EC = remove_directories_impl(path, IgnoreErrors);
1298 if (EC && !IgnoreErrors)
1301 if (EC && !IgnoreErrors)
1303 return std::error_code();
1310 return std::error_code();
1315 expandTildeExpr(Storage);
1321 char Buffer[PATH_MAX];
1322 if (::realpath(
P.begin(), Buffer) ==
nullptr)
1323 return std::error_code(errno, std::generic_category());
1324 dest.
append(Buffer, Buffer + strlen(Buffer));
1325 return std::error_code();
1329 auto FChown = [&]() { return ::fchown(FD, Owner, Group); };
1332 return std::error_code(errno, std::generic_category());
1333 return std::error_code();
1341 char *RequestedDir = getenv(
"HOME");
1342 if (!RequestedDir) {
1343 struct passwd *pw = getpwuid(getuid());
1344 if (pw && pw->pw_dir)
1345 RequestedDir = pw->pw_dir;
1351 result.append(RequestedDir, RequestedDir + strlen(RequestedDir));
1356 #if defined(_CS_DARWIN_USER_TEMP_DIR) && defined(_CS_DARWIN_USER_CACHE_DIR)
1359 int ConfName = TempDir ? _CS_DARWIN_USER_TEMP_DIR
1360 : _CS_DARWIN_USER_CACHE_DIR;
1361 size_t ConfLen = confstr(ConfName,
nullptr, 0);
1365 ConfLen = confstr(ConfName,
Result.data(),
Result.size());
1366 }
while (ConfLen > 0 && ConfLen !=
Result.size());
1390 if (
const char *RequestedDir = getenv(
"XDG_CONFIG_HOME")) {
1392 result.append(RequestedDir, RequestedDir + strlen(RequestedDir));
1406 if (getDarwinConfDir(
false,
result)) {
1412 if (
const char *RequestedDir = getenv(
"XDG_CACHE_HOME")) {
1414 result.append(RequestedDir, RequestedDir + strlen(RequestedDir));
1425 static const char *getEnvTempDir() {
1428 const char *EnvironmentVariables[] = {
"TMPDIR",
"TMP",
"TEMP",
"TEMPDIR"};
1429 for (
const char *Env : EnvironmentVariables) {
1430 if (
const char *Dir = std::getenv(Env))
1437 static const char *getDefaultTempDir(
bool ErasedOnReboot) {
1451 if (ErasedOnReboot) {
1453 if (
const char *RequestedDir = getEnvTempDir()) {
1454 Result.append(RequestedDir, RequestedDir + strlen(RequestedDir));
1459 if (getDarwinConfDir(ErasedOnReboot, Result))
1462 const char *RequestedDir = getDefaultTempDir(ErasedOnReboot);
1463 Result.append(RequestedDir, RequestedDir + strlen(RequestedDir));
1477 std::string FromS =
From.str();
1478 std::string ToS = To.
str();
1479 #if __has_builtin(__builtin_available)
1480 if (__builtin_available(macos 10.12, *)) {
1487 if (!clonefile(FromS.c_str(), ToS.c_str(), 0))
1488 return std::error_code();
1498 return std::error_code(Errno, std::generic_category());
1507 if (!copyfile(FromS.c_str(), ToS.c_str(), NULL, COPYFILE_DATA))
1508 return std::error_code();
1509 return std::error_code(errno, std::generic_category());