private void FindPathRecursive(ReadOnlySpan <byte> path, out SaveEntryKey key) { var parser = new PathParser(path); key = new SaveEntryKey(parser.GetCurrent(), 0); while (!parser.IsFinished()) { key.Parent = DirectoryTable.GetOffsetFromKey(ref key); parser.TryGetNext(out key.Name); } }
private bool FindPathRecursive(ReadOnlySpan <byte> path, out SaveEntryKey key) { var parser = new PathParser(path); key = new SaveEntryKey(parser.GetCurrent(), 0); while (!parser.IsFinished()) { key.Parent = DirectoryTable.GetIndexFromKey(ref key).Index; if (key.Parent < 0) { return(false); } parser.TryGetNext(out key.Name); } return(true); }
private void CreateDirectoryRecursive(ReadOnlySpan <byte> path) { var parser = new PathParser(path); var key = new SaveEntryKey(parser.GetCurrent(), 0); int parentIndex = CreateParentDirectoryRecursive(ref parser, ref key); int index = DirectoryTable.GetIndexFromKey(ref key).Index; TableEntry <SaveFindPosition> dirEntry = default; // Directory already exists. Do nothing. if (index >= 0) { return; } index = DirectoryTable.Add(ref key, ref dirEntry); LinkDirectoryToParent(parentIndex, index); }
private void CreateFileRecursive(ReadOnlySpan <byte> path, ref SaveFileInfo fileInfo) { var parser = new PathParser(path); var key = new SaveEntryKey(parser.GetCurrent(), 0); int parentIndex = CreateParentDirectoryRecursive(ref parser, ref key); int index = FileTable.GetIndexFromKey(ref key).Index; TableEntry <SaveFileInfo> fileEntry = default; // File already exists. Update file info. if (index >= 0) { FileTable.GetValue(index, out fileEntry); fileEntry.Value = fileInfo; FileTable.SetValue(index, ref fileEntry); return; } fileEntry.Value = fileInfo; index = FileTable.Add(ref key, ref fileEntry); LinkFileToParent(parentIndex, index); }