public int AddFolder(string path) { string[] parts = path.Split('\\'); int parentIndex = -1; int folderID = 0; for (int x = 0; x < parts.Length; x++) { folderID = folderIndex.GetFolderID(parts[x], parentIndex); if (folderID == -1) { // Create this folder. FolderEntry entry = new FolderEntry(); entry.Name = parts[x]; entry.ParentFolderIndex = parentIndex; folderIndex.Entries.Add(entry); folderIndex.TotalEntries++; parentIndex = folderID; } else { parentIndex = folderID; } } return(folderID); }
public FolderEntry LocateFolderByPath(string path) { path = FixPath(path); if (path == "") { return(this.rootFolder); } string[] parts = path.Split('\\'); FolderEntry currentEntry = this.rootFolder; // TODO: Consolidate the redundant code between this method and the Add method. for (int x = 0; x < parts.Length; x++) { int index = currentEntry.FolderEntries.IndexOf(parts[x]); if (index > -1) { currentEntry = currentEntry.FolderEntries[index]; } else { return(null); } } return(currentEntry); }
/// <summary> /// Parses a full path containing the folder and filename, and creates /// the appropriate folder and file entries in the heirarchy. /// </summary> public FileEntry Add(string filename) { string fullPath = filename; string[] parts = fullPath.Split('\\'); FolderEntry currentEntry = this.rootFolder; for (int x = 0; x < parts.Length - 1; x++) // Last part should be a filename. { int index = currentEntry.FolderEntries.IndexOf(parts[x]); if (index == -1) { FolderEntry entry = new FolderEntry(parts[x], currentEntry); currentEntry.FolderEntries.Add(entry); currentEntry = entry; } else { currentEntry = currentEntry.FolderEntries[index]; } } FileEntry file = new FileEntry(parts[parts.Length - 1], currentEntry); currentEntry.FileEntries.Add(file); return(file); }
public void Read(BinaryReader reader) { TotalEntries = reader.ReadInt32(); for (int x = 0; x < TotalEntries; x++) { FolderEntry entry = new FolderEntry(); entry.Read(reader); Entries.Add(entry); } }
/// <summary> /// Returns all folders in the specified path. /// </summary> public string[] GetFolderList(string path) { FolderEntry entry = fileSystem.LocateFolderByPath(FixPath(path)); if (entry == null) { return(null); } return(entry.FolderEntries.GetItems()); }
public FileEntry(string filename, FolderEntry parentFolder) { name = Path.GetFileNameWithoutExtension(filename); if (filename.IndexOf('.') > -1) { extension = Path.GetExtension(filename).Substring(1); } else { extension = ""; } this.parentFolder = parentFolder; }
/// <summary> /// Returns all folders in the specified path. /// </summary> public string[] GetFolderList(string path) { FolderEntry entry = tagList.LocateFolderByPath(FixPath(path)); if (entry == null) { return(null); } return(RemoveStringsFromArray( entry.FolderEntries.GetItems(), new string[] { path + "\\", path })); //return entry.FolderEntries.GetItems(); }
/// <summary> /// Returns all files in the specified path with the specified extension. /// </summary> public string[] GetFileList(string path, string extension) { FolderEntry entry = fileSystem.LocateFolderByPath(FixPath(path)); if (entry != null) { return(entry.FileEntries.GetItems(extension)); } else { return(null); } }
/// <summary> /// Returns all files in the specified path with the specified extension. /// </summary> public string[] GetFileList(string path, string extension) { FolderEntry entry = tagList.LocateFolderByPath(FixPath(path)); if (entry == null) { return(null); } // Remove any files that exist in the ITagLibrary // return RemoveStringsFromArray( // entry.FileEntries.GetItems(extension), extractedTags.GetFileList(path)); return(RemoveStringsFromArray( entry.FileEntries.GetItems(extension), null)); }
public FileEntry LocateFileByPath(string path) { path = FixPath(path); string folder = Path.GetDirectoryName(path); FolderEntry folderEntry = LocateFolderByPath(folder); foreach (FileEntry fileEntry in folderEntry.FileEntries) { string entryLower = fileEntry.FullPath.ToLower(); string pathLower = path.ToLower(); if (entryLower == pathLower) { return(fileEntry); } } return(null); }
public void Add(FolderEntry folder) { InnerList.Add(folder); }
public FolderEntry(string name, FolderEntry parentFolder) { this.name = name; this.parentFolder = parentFolder; }