mirror of
https://github.com/NixOS/nix.git
synced 2025-11-26 12:10:59 +01:00
EOF
This commit is contained in:
parent
89ab441fd2
commit
35e239af33
9 changed files with 70 additions and 74 deletions
|
|
@ -462,7 +462,8 @@ void readFull(int fd, unsigned char * buf, size_t count)
|
|||
if (errno == EINTR) continue;
|
||||
throw SysError("reading from file");
|
||||
}
|
||||
if (res == 0) throw EndOfFile("unexpected end-of-file");
|
||||
if (res == 0)
|
||||
throw EndOfFile("unexpected end-of-file (in readFull so deamon communication)");
|
||||
count -= res;
|
||||
buf += res;
|
||||
}
|
||||
|
|
@ -1167,7 +1168,7 @@ bool FileExist(const string FileName)
|
|||
}
|
||||
|
||||
//TODO Does this work on windows?
|
||||
bool IsDirectory(const string FileName)
|
||||
bool DirectoryExist(const string FileName)
|
||||
{
|
||||
const char* FileName_C = FileName.c_str();
|
||||
struct stat my_stat;
|
||||
|
|
@ -1175,6 +1176,17 @@ bool IsDirectory(const string FileName)
|
|||
return ((my_stat.st_mode & S_IFDIR) != 0);
|
||||
}
|
||||
|
||||
//TODO Does this work on windows?
|
||||
|
||||
bool IsSymlink(const string FileName)
|
||||
{
|
||||
const char* FileName_C = FileName.c_str();
|
||||
struct stat my_stat;
|
||||
if (lstat(FileName_C, &my_stat) != 0) return false;
|
||||
return (S_ISLNK(my_stat.st_mode) != 0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
string getCallingUserName()
|
||||
{
|
||||
|
|
@ -1280,26 +1292,14 @@ void symlinkPath(const Path & fromExisting, const Path & toNew)
|
|||
p_args.push_back(fromExisting);
|
||||
p_args.push_back(toNew);
|
||||
runProgram_AndPrintOutput("ln", true, p_args, "ln");
|
||||
|
||||
printMsg(lvlError, format("ln -sf %1% %2%") % fromExisting % toNew);
|
||||
}
|
||||
|
||||
void sharePath(const Path & fromExisting, const Path & toNew)
|
||||
{
|
||||
symlinkPath(fromExisting, toNew);
|
||||
//printMsg(lvlError, format("ln -sf %1% %2%") % fromExisting % toNew);
|
||||
}
|
||||
|
||||
void copyContents(const Path & from, const Path & to)
|
||||
{
|
||||
Strings p_args;
|
||||
p_args.push_back("-R");
|
||||
p_args.push_back(from + "/*");
|
||||
p_args.push_back(to);
|
||||
runProgram_AndPrintOutput("cp", true, p_args, "cp");
|
||||
|
||||
p_args.clear();
|
||||
p_args.push_back("-R");
|
||||
p_args.push_back(from + "/.*"); //Also copy the hidden files
|
||||
p_args.push_back(from + "/"); //the / makes sure it copys the contents of the dir, not just the symlink
|
||||
p_args.push_back(to);
|
||||
runProgram_AndPrintOutput("cp", true, p_args, "cp");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue