/* * Adds the given file to the given path, relative to this directory. */ public void Add(string relativePath, PackedFile file, bool overwrite = false) { VirtualDirectory current = this; char[] splitAt = { Path.DirectorySeparatorChar }; var parts = relativePath.Split(splitAt); for (int i = 0; i < parts.Count() - 1; i++) { current = current.GetSubdirectory(parts[i]); } file.Parent = current; current.Add(file, overwrite); }
/* * Adds the given file to the given path, relative to this directory. */ public void Add(string relativePath, PackedFile file, bool overwrite = false) { char[] splitAt = { Path.DirectorySeparatorChar }; string baseDir = Path.GetDirectoryName(relativePath); string[] dirs = baseDir != null?baseDir.Split(splitAt, StringSplitOptions.RemoveEmptyEntries) : new string[0]; VirtualDirectory current = this; if (dirs.Length > 0) { foreach (string dir in dirs) { current = current.GetSubdirectory(dir); } } file.Parent = current; current.Add(file, overwrite); }