public void CheckReferenceDirectoryConstructorProvideAbsolutePathWithUnixPaths() { var path = new UPath(_unixCurDir, "..\\.."); var info = new DirectoryInfo(_curDir); var expected = Unixify(info.Parent.Parent.FullName).Replace('/', Path.DirectorySeparatorChar); Assert.AreEqual(expected, path.ToString()); }
public static DynValue CompileObject(UPath path, bool retry = false) { try { var script = ScriptObject.CreateScriptObject(ModuleSet, path, null); //script.Globals["mynumber"] = 7; //ToDo: Correct this to inject the AUTO object var res = script.CompileInject(""); // Check for existence and add individual script. This is borked. [why?] if (_bittyObjects.TryAdd(path.ToString(), new List <ScriptObject> { script })) { return(res); } if (_bittyObjects.TryGetValue(path.ToString(), out var list) == false) { throw new ScriptRuntimeException("Unable to query existing script objects."); } var newlist = list.ToList(); script.reference = list.Last().reference + 1; newlist.Add(script); if (_bittyObjects.TryUpdate(path.ToString(), newlist, list)) { return(res); } if (retry != false) { throw new ScriptRuntimeException("Unable to Compile Object due to thread contention."); } Log.Warning("A script compilation error occured due to thread contention, rerunning."); return(CompileObject(path, true)); } catch (ScriptRuntimeException ex) { Log.Warning("A script compilation error has occurred: {exception}", ex.DecoratedMessage); return(null); } }
public static ScriptObject FindObject(UPath path, int objref) { if (_bittyObjects.TryGetValue(path.ToString(), out var items)) { var found = items.FirstOrDefault(x => x.reference == objref); if (found == null && objref > 0) { return(FindObject(path, 0)); } return(found); } return(null); }
public void ParsePath(string path, UPathParseMode parseMode, string expectedPath, string expectedException) { if (expectedPath != null) { var p = new UPath(path, parseMode); p.ToString().Should().Be(expectedPath); bool result = UPath.TryParse(path, parseMode, out p); result.Should().BeTrue(); p.ToString().Should().Be(expectedPath); } else { Action a = () => { // ReSharper disable once ObjectCreationAsStatement new UPath(path, parseMode); }; a.ShouldThrow <UPathFormatException>().Where(x => x.Message.StartsWith(expectedException)); bool result = UPath.TryParse(path, parseMode, out var p); result.Should().BeFalse(); } }
PHPhotoItem GetFileInfo(UPath path) { var npath = path.ToString().ToUpperInvariant(); var n = _cachePhoto.Single(x => x.Key.IndexOf(npath) == 0); if (n.Key.Length == npath.Length) { return(n.Value); } else { return(new PHPhotoItem { Col = n.Value.Col }); } }
protected override bool FileExistsImpl(UPath path) { if (path == UPath.Root) { return(true); } Internal_FillCache(); EnterFileSystemShared(); try { var npath = path.ToString().ToUpperInvariant(); var res = _cachePhoto.Any(x => x.Key == npath); return(res); } finally { ExitFileSystemShared(); } }
protected override bool DirectoryExistsImpl(UPath path) { if (path == UPath.Root) { return(true); } Internal_FillCache(); EnterFileSystemShared(); try { var npath = path.ToString().ToUpperInvariant(); var res = _cachePhoto.Any(x => (x.Key.IndexOf(npath) == 0) && (x.Key.Length != npath.Length)); return(res); } finally { ExitFileSystemShared(); } }
protected override IEnumerable <UPath> EnumeratePathsImpl(UPath path, string searchPattern, SearchOption searchOption, SearchTarget searchTarget) { Internal_FillCache(); EnterFileSystemShared(); try { if (path == UPath.Root) { return(_cacheDir.Select(x => ((UPath)x.Key).ToAbsolute()).ToList()); } else { var npath = path.ToString().ToUpperInvariant(); return(_cachePhoto.Where(x => x.Key.IndexOf(npath) == 0).Select(x => ((UPath)x.Key).ToAbsolute()).ToList()); } } finally { ExitFileSystemShared(); } }
public void CheckReferenceDirectoryConstructorProvideAbsolutePath() { var path = new UPath(_curDir, "..\\.."); var info = new DirectoryInfo(_curDir); Assert.AreEqual(info.Parent.Parent.FullName, path.ToString()); }
public string GetScriptPath() => scriptPath.ToString();