public void SymbolicLink(PathName path, string value, bool force) { if (force) { var file = path.ExistsFile(); if (path.ExistsFile()) { path.DeleteFile(); } } var retval = Syscall.symlink(value, path.Full); UnixMarshal.ThrowExceptionForLastErrorIf(retval); }
public bool Extract(bool force) { var archivePath = Pogo.ArchivePath(this.uri); var extractPath = Pogo.SourcePath(this.uri); if (!archivePath.ExistsFile()) { throw PathNameErrors.FileNotFoundException(archivePath); } if (extractPath.ExistsDirectory()) { if (!force) { return(true); } Terminal.Write("clean ", extractPath.Name, ": "); PathNameTools.RemoveDirectory(extractPath); Terminal.ClearLine(); } if (extractPath.ExistsFile()) { throw PathNameErrors.EntityExistsButIsNotDirectory(extractPath); } PathName extractPathTmp = extractPath.Full + ".tmp"; if (extractPathTmp.ExistsDirectory()) { Terminal.Write("clean ", extractPathTmp.Name, ": "); PathNameTools.RemoveDirectory(extractPathTmp); Terminal.ClearLine(); } if (extractPathTmp.ExistsFile()) { throw PathNameErrors.EntityExistsButIsNotDirectory(extractPathTmp); } extractPathTmp.CreateDirectory(); Terminal.Write("extract ", archivePath.Name, ": "); var xtract = Bash.TarExtract(archivePath, extractPathTmp); Terminal.ClearLine(); var dirs = extractPathTmp.EnumerateDirectories().ToList(); var files = extractPathTmp.EnumerateFiles().ToList(); if (dirs.Count == 1 && files.Count == 0) { dirs.First().MoveDirectory(extractPath); extractPathTmp.DeleteDirectory(); } else { extractPathTmp.MoveDirectory(extractPath); } Terminal.WriteLine("extract ", xtract.Ok ? "OK: " : "FAIL: ", archivePath.Name); return(xtract.Ok); }