/// <summary> /// Constructs a new FileTree from the given path and SGAs. /// Set an EntryPoint name to only add files from SGAs which belong to an EntryPoint with the specified name. /// </summary> /// <param name="path"></param> /// <param name="sgas"></param> /// <param name="epName"></param> public FileTree(string path, IEnumerable <SGAFile> sgas, string epName = null) { if (!path.EndsWith('\\')) { path += '\\'; } m_basePath = path; m_rootNode = new FSNodeDir(path, this); foreach (SGAFile sga in sgas) { foreach (SGAEntryPoint ep in sga) { if (epName != null && string.Compare(ep.Name, epName, true) != 0) { continue; } foreach (SGAStoredDirectory sgasd in ep.StoredDirectories.Values) { string dirpath = sgasd.GetPath(); FSNodeDir dirnode = m_rootNode.TryAddDirFromRelativePath(dirpath); if (sgasd.StoredFiles.Values.Count > 0) { dirnode.HasVirtual = true; } foreach (SGAStoredFile sgasf in sgasd.StoredFiles.Values) { FSNodeFile file = dirnode.GetFile(sgasf.Name); if (file == null) { new FSNodeVirtualFile(sgasf.Name, sgasf, this) { Parent = dirnode }; } else if (!(file is FSNodeVirtualFile)) { dirnode.RemoveChild(file); new FSNodeVirtualFile(sgasf.Name, sgasf, this) { Parent = dirnode }; } } } } } SetupWatcher(path); SetupConsumerThread(); }