public static IEnumerable<NPath> Move(this IEnumerable<NPath> self, NPath dest) { if (dest.IsRelative) throw new ArgumentException("When moving multiple files, the destination cannot be a relative path"); dest.EnsureDirectoryExists(); return self.Select(p => p.Move(dest.Combine(p.FileName))).ToArray(); }
static Il2CppDependencies() { NPath path = CommonPaths.Il2CppRoot.ParentContaining("il2cpp-dependencies"); if (path != null) { string[] append = new string[] { "il2cpp-dependencies" }; _root = path.Combine(append); } }
public void Write(NPath outputDir) { string[] append = new string[] { "driver.cpp" }; using (SourceCodeWriter writer = new SourceCodeWriter(outputDir.Combine(append))) { this.WriteIncludes(writer); this.WriteMainInvoker(writer); this.WriteEntryPoint(writer); this.WritePlatformSpecificEntryPoints(writer); } }
static Paths() { string environmentVariable = Environment.GetEnvironmentVariable("IL2CPP_UNITY_ROOT"); if (!string.IsNullOrEmpty(environmentVariable)) { _unityRoot = Extensions.ToNPath(environmentVariable); } else { _unityRoot = (CommonPaths.Il2CppRoot == null) ? null : CommonPaths.Il2CppRoot.ParentContaining("build.pl"); } }
public static string HashOfFile(NPath path) { string str; using (MD5 md = MD5.Create()) { using (FileStream stream = File.OpenRead(path.ToString())) { str = HashToString(md.ComputeHash(stream)); } } return str; }
static TizenSDKUtilities() { if (PlatformUtils.IsLinux()) { SDKDirectory = new NPath(NPath.HomeDirectory + "/tizen-2.4.0-linux"); } else { if (!PlatformUtils.IsOSX()) { throw new NotSupportedException("Building Tizen on Windows is not supported."); } SDKDirectory = new NPath(NPath.HomeDirectory + "/tizen-2.4.0-macosx"); } }
public static bool ForgivingCleanDirectory(NPath directory) { try { if (directory.Exists("")) { directory.Delete(DeleteMode.Normal); } return true; } catch (Exception) { if (!Enumerable.Any<NPath>(directory.Files(true))) { return true; } } return false; }
public override Shell.ExecuteResult RunAndMakeExecuteResult(string executable) { bool flag; Shell.ExecuteResult result; string[] append = new string[] { "AppxManifest.xml" }; NPath path = new NPath(Path.GetDirectoryName(executable)).Combine(append); if (!File.Exists(executable)) { throw new ArgumentException(string.Format("Specified executable (\"{0}\") does not exist!", executable)); } if (!path.Exists("")) { throw new ArgumentException(string.Format("AppX manifest was not found next to the executable at \"{0}\"!", path)); } WinRTManifest.AddActivatableClasses(path); using (Mutex mutex = new Mutex(true, @"Global\WinRTRunnerBuild", out flag)) { if (!flag) { mutex.WaitOne(); } try { MakeSureRunnerIsBuilt(); Shell.ExecuteArgs executeArgs = new Shell.ExecuteArgs { Executable = WinRTRunnerExecutablePath.ToString(), Arguments = path.InQuotes(), WorkingDirectory = WinRTRunnerExecutablePath.Parent.ToString() }; using (TinyProfiler.Section("Run WinRT Application", "")) { result = Shell.Execute(executeArgs, null); } } finally { mutex.ReleaseMutex(); } } return result; }
NPath CopyWithDeterminedDestination(NPath absoluteDestination, Func<NPath,bool> fileFilter) { if (absoluteDestination.IsRelative) throw new ArgumentException ("absoluteDestination must be absolute"); if (FileExists()) { if (!fileFilter(absoluteDestination)) return null; absoluteDestination.EnsureParentDirectoryExists(); File.Copy(ToString(), absoluteDestination.ToString(), true); return absoluteDestination; } if (DirectoryExists()) { absoluteDestination.EnsureDirectoryExists(); foreach (var thing in Contents()) thing.CopyWithDeterminedDestination(absoluteDestination.Combine(thing.RelativeTo(this)), fileFilter); return absoluteDestination; } throw new ArgumentException("Copy() called on path that doesnt exist: " + ToString()); }
public NPath Copy(NPath dest, Func<NPath, bool> fileFilter) { ThrowIfRelative(); if (dest.IsRelative) dest = Parent.Combine(dest); if (dest.DirectoryExists()) return CopyWithDeterminedDestination(dest.Combine(FileName), fileFilter); return CopyWithDeterminedDestination (dest, fileFilter); }
public override void CustomizeSelf(AsmDefCSharpProgram program) { NiceIO.NPath path = program.MainSourcePath.Combine("external/libwebp.js"); program.NativeProgram.Libraries.Add(c => ((DotsRuntimeNativeProgramConfiguration)c).CSharpConfig.PlatformBuildConfig is WebBuildConfig, new PostJsLibrary(path)); }
public void GenerateSupportFilesIfNeeded(NPath outputDir) { }
static bool AlwaysTrue(NPath p) { return true; }
public NPath ParentContaining(NPath needle) { ThrowIfRelative(); var candidate = this; while (true) { if (candidate.Exists(needle)) return candidate; if (candidate.IsEmpty()) return null; candidate = candidate.Parent; } }
public NPath EnsureDirectoryExists(NPath append) { var combined = Combine(append); if (combined.DirectoryExists()) return combined; combined.EnsureParentDirectoryExists(); combined.CreateDirectory(); return combined; }
public bool Exists(NPath append) { return FileExists(append) || DirectoryExists(append); }
public NPath RelativeTo(NPath path) { if (!IsChildOf(path)) throw new ArgumentException("Path.RelativeTo() was invoked with two paths that are unrelated. invoked on: " + ToString() + " asked to be made relative to: " + path); return new NPath(_elements.Skip(path._elements.Length).ToArray(), true, null); }
private TempFile(NPath path) { this.Path = path; }
public void AddIncludeDirectory(NPath includeDirectory) { this._extraIncludeDirectories.Add(includeDirectory); }
public static void AddActivatableClasses(NPath manifestPath) { if (<>f__am$cache0 == null) {
public static NPath CreateTempDirectory(string myprefix) { var random = new Random(); while (true) { var candidate = new NPath(Path.GetTempPath() + "/" + myprefix + "_" + random.Next()); if (!candidate.Exists()) return candidate.CreateDirectory(); } }
public bool DirectoryExists(NPath append) { return Directory.Exists(Combine(append).ToString()); }
public NPath Move(NPath dest) { ThrowIfRelative(); if (dest.IsRelative) return Move(Parent.Combine(dest)); if (dest.DirectoryExists()) return Move(dest.Combine(FileName)); if (FileExists()) { dest.EnsureParentDirectoryExists(); File.Move(ToString(), dest.ToString()); return dest; } if (DirectoryExists()) { Directory.Move(ToString(), dest.ToString()); return dest; } throw new ArgumentException("Move() called on a path that doesn't exist: " + ToString()); }
public static string Execute(NiceIO.NPath filename, string arguments, Dictionary <string, string> envVars = null) { return(Execute(filename.ToString(), arguments, envVars)); }
public bool IsChildOf(NPath potentialBasePath) { if ((IsRelative && !potentialBasePath.IsRelative) || !IsRelative && potentialBasePath.IsRelative) throw new ArgumentException("You can only call IsChildOf with two relative paths, or with two absolute paths"); if (IsEmpty()) return false; if (Equals(potentialBasePath)) return true; return Parent.IsChildOf(potentialBasePath); }
public NPath CreateFile(NPath file) { if (!file.IsRelative) throw new ArgumentException("You cannot call CreateFile() on an existing path with a non relative argument"); return Combine(file).CreateFile(); }
public IEnumerable<NPath> CopyFiles(NPath destination, bool recurse, Func<NPath, bool> fileFilter = null) { destination.EnsureDirectoryExists(); return Files(recurse).Where(fileFilter ?? AlwaysTrue).Select(file => file.Copy(destination.Combine(file.RelativeTo(this)))).ToArray(); }
public NPath CreateDirectory(NPath directory) { if (!directory.IsRelative) throw new ArgumentException("Cannot call CreateDirectory with an absolute argument"); return Combine(directory).CreateDirectory(); }
private MonoInstall(string installName) { this._installRoot = FindInstallRoot(installName); }
public NPath Copy(NPath dest) { return Copy(dest, p => true); }
public bool FileExists(NPath append) { return File.Exists(Combine(append).ToString()); }
public void AddSearchDirectory(NPath path) { this._resolver.AddSearchDirectory(path); }