public BF.Directory BuildDirectoryFromRawIndex() { BF.Directory returnDir = new BF.Directory(); returnDir.Name = mName; returnDir.ParentBigFile = mParentBigFile; if ((mIndices != null) && (mIndices.GetUpperBound(0) > 0)) { foreach (BF.Index nextIndex in mIndices) { returnDir.Directories.Add(nextIndex.BuildDirectoryFromRawIndex()); } } if ((mFiles != null) && (mFiles.GetUpperBound(0) > 0)) { foreach (BF.File currentFile in mFiles) { //if (returnDir.Filenames.Contains(currentFile.Name + "." + currentFile.FileExtension)) //{ // currentFile.Name = GetNextUnusedName(returnDir.Filenames, currentFile); //} returnDir.AddFile(currentFile); } } return(returnDir); }
public BF.Directory BuildDirectoryFromFileData() { BF.Directory returnDir = new Directory(); returnDir.Name = "BigFile"; //get all sub-files, recursively ArrayList allFiles = new ArrayList(); mFileCount = 0; allFiles = GetAllFilesRecursively(allFiles); mFileCount = allFiles.Count; //figure out where to put the file foreach (BF.File currentFile in allFiles) { BF.Directory targetDir = returnDir; string[] dirSplit = currentFile.DirectoryName.Split('\\'); //recursively get a pointer to the target directory for (int i = 0; i < dirSplit.GetUpperBound(0); i++) { //create subdirectory if necessary if (!(targetDir.DirectoryNames.Contains(dirSplit[i]))) { BF.Directory newDir = new BF.Directory(); newDir.Name = dirSplit[i]; targetDir.AddDirectory(newDir); } targetDir = (BF.Directory)(targetDir.Directories[(int)(targetDir.DirectoryNames[dirSplit[i]])]); } //add the file //if (targetDir.Filenames.Contains(currentFile.Name + "." + currentFile.FileExtension)) //{ // currentFile.Name = GetNextUnusedName(targetDir.Filenames, currentFile); //} targetDir.AddFile(currentFile); } return(returnDir); }