/// <summary> /// Creates a set of directories based on a treenode information. /// </summary> /// <param name="parentDirectory">Parent directory.</param> /// <param name="treeNode">Tree node to map.</param> public static void CreateDirectories(JDirectory parentDirectory, JStoreFileTreeNode treeNode) { //List<FileListViewItem> fileItems; JFile file; JDirectory childDirectory; List <JSoreFileItemInfo> fileItems = treeNode.Tag; // Create the files of the directory //fileItems = (List<FileListViewItem>)treeNode.Tag; foreach (JSoreFileItemInfo fileItem in fileItems) { file = new JFile(fileItem.fileName); file.Filters = fileItem.Filters; file.FileInfo = fileItem.Info; parentDirectory.AddFile(file); } // Create the subdirectories foreach (JStoreFileTreeNode node in treeNode.Nodes) { childDirectory = new JDirectory(node.DirName); parentDirectory.AddDirectory(childDirectory); CreateDirectories(childDirectory, node); } }
/// <summary> /// Creates a new storage. /// </summary> /// <param name="fileName">Name of the file.</param> /// <param name="version">Version of the storage.</param> /// <param name="name">Name of the storage.</param> /// <param name="filters">Filters used in the storage.</param> /// <param name="rootNode">Root node of the storage.</param> /// <param name="oldStorage">Old storage (it can contain some files used in the new storage).</param> /// <returns>A new storage.</returns> public static JStorageSource CreateStorage(string fileName, int version, string name, List <IJFilter> filters, JStoreFileTreeNode rootNode, JStorageSource oldStorage) { JDirectory rootDirectory; JStorageSource newStorage; // Create the directories from the treeview rootDirectory = new JDirectory("Root"); CreateDirectories(rootDirectory, rootNode); // Create the storage newStorage = new JStorageSource(name, version, filters, rootDirectory); // Write it newStorage.Write(fileName, oldStorage); return(newStorage); }
/// <summary> /// 打包并创建一个VFS文件 /// </summary> /// <param name="storepackerName">要保存的VFS文件名</param> /// <param name="rootNode">要打包的文件来源(本地磁盘的)</param> /// <param name="filters">加密列表,可为null</param> /// <returns></returns> public JStorageSource CreateJadStorePacker(string storepackerName, JStoreFileTreeNode rootNode, List <IJFilter> filters) { return(CreateStorage(storepackerName, 1, "", filters, rootNode, null)); }