Ejemplo n.º 1
0
        private void ParseCd(DiscDirectoryInfo pathDir = null)
        {
            if (pathDir == null)
            {
                pathDir = GetDirectoryInfo("\\");
                Range <long, long> r = PathToClusters("\\").First();
                directoryMembers.Add(new DirectoryMemberInformation(pathDir.FullName, r.Offset, r.Count.RoundToSector(),
                                                                    0, false)
                {
                    Added = true
                });
            }

            foreach (DiscDirectoryInfo dir in pathDir.GetDirectories())
            {
                DirectoryRecord rec    = dir.Entry.Record;
                long            offset = rec.LocationOfExtent;
                long            count  = rec.DataLength;
                directoryMembers.Add(new DirectoryMemberInformation(dir.FullName, offset, count.RoundToSector(), 0, false));
                ParseCd(dir);
            }
            foreach (DiscFileInfo f in pathDir.GetFiles())
            {
                ReaderDirectory rdr = f.Entry.Parent;

                // Fetch all cluster information from the parent
                IEnumerable <ReaderDirEntry> entries = rdr.GetEntriesByName(f.Entry.FileName);

                long offset = f.Entry.Record.LocationOfExtent;
                long count  = entries.Sum(e => e.Record.DataLength);

                directoryMembers.Add(new DirectoryMemberInformation(f.FullName, offset, count.RoundToSector(), count, true));
            }
        }
Ejemplo n.º 2
0
 void ExtractDirectory(DiscDirectoryInfo Dinfo, string RootPath, string PathinISO)
 {
     if (!string.IsNullOrWhiteSpace(PathinISO))
     {
         PathinISO += "\\" + Dinfo.Name;
     }
     RootPath += "\\" + Dinfo.Name;
     AppendDirectory(RootPath);
     foreach (DiscDirectoryInfo dinfo in Dinfo.GetDirectories())
     {
         ExtractDirectory(dinfo, RootPath, PathinISO);
     }
     foreach (DiscFileInfo finfo in Dinfo.GetFiles())
     {
         using (Stream FileStr = finfo.OpenRead())
         {
             using (FileStream Fs = File.Create(RootPath + "\\" + finfo.Name)) // Here you can Set the BufferSize Also e.g. File.Create(RootPath + "\\" + finfo.Name, 4 * 1024)
             {
                 metroProgressBar1.Increment(1);
                 metroLabel2.Text = metroProgressBar1.Value.ToString() + " %";
                 metroLabel2.Refresh();
                 metroTextBox1.Text = finfo.Name.ToString();
                 metroTextBox1.Refresh();
                 FileStr.CopyTo(Fs, 8 * 1024); // Buffer Size is 4 * 1024 but you can modify it in your code as per your need
             }
         }
     }
 }
Ejemplo n.º 3
0
        void ExtractDirectory(DiscDirectoryInfo Dinfo, string RootPath, string PathinISO)
        {
            if (!string.IsNullOrWhiteSpace(PathinISO))
            {
                PathinISO += "\\" + Dinfo.Name;
            }
            RootPath += "\\" + Dinfo.Name;
            AppendDirectory(RootPath);
            foreach (DiscDirectoryInfo dinfo in Dinfo.GetDirectories())
            {
                ExtractDirectory(dinfo, RootPath, PathinISO);
            }
            var test = Dinfo.GetFiles();

            foreach (DiscFileInfo finfo in test)
            {
                using (Stream FileStr = finfo.OpenRead())
                {
                    using (FileStream Fs = File.Create(RootPath + "\\" + finfo.Name))
                    {
                        Progress_Bar.Increment(1 / test.Length);
                        Progress_Number.Text = Progress_Bar.Value.ToString() + " %";
                        Progress_Number.Refresh();
                        FileStr.CopyTo(Fs, 8 * 1024);
                    }
                }
            }
        }
Ejemplo n.º 4
0
 public void ExtractDirectory(DiscDirectoryInfo Dinfo, string RootPath, string PathinISO)
 {
     if (!string.IsNullOrWhiteSpace(PathinISO))
     {
         PathinISO += "\\" + Dinfo.Name;
     }
     RootPath += "\\" + Dinfo.Name;
     AppendDirectory(RootPath);
     foreach (DiscDirectoryInfo dinfo in Dinfo.GetDirectories())
     {
         ExtractDirectory(dinfo, RootPath, PathinISO);
     }
     foreach (DiscFileInfo finfo in Dinfo.GetFiles())
     {
         using (Stream FileStr = finfo.OpenRead())
         {
             char[] charsToRemove = { ';', '1' };
             string fileName      = finfo.Name.TrimEnd(charsToRemove);
             using (FileStream Fs = File.Create(RootPath + "\\" + fileName))
             {
                 FileStr.CopyTo(Fs, 4 * 1024);
                 Console.WriteLine(fileName + " was extracted.");
             }
         }
     }
 }
Ejemplo n.º 5
0
 /**************************************************************************************************************
  * Extract ISO 9660
  *************************************************************************************************************/
 private void ExtractDirectoryISO9660(DiscDirectoryInfo Dinfo, string RootPath, string PathinISO)
 {
     try
     {
         if (!string.IsNullOrWhiteSpace(PathinISO))
         {
             PathinISO += "\\" + Dinfo.Name;
         }
         RootPath += "\\" + Dinfo.Name;
         AppendDirectoryISO9660(RootPath);
         foreach (DiscDirectoryInfo dinfo in Dinfo.GetDirectories())
         {
             ExtractDirectoryISO9660(dinfo, RootPath, PathinISO);
         }
         foreach (DiscFileInfo finfo in Dinfo.GetFiles())
         {
             using (Stream FileStr = finfo.OpenRead())
             {
                 using (FileStream Fs = File.Create(RootPath + "\\" + finfo.Name)) // Here you can Set the BufferSize Also e.g. File.Create(RootPath + "\\" + finfo.Name, 4 * 1024)
                 {
                     FileStr.CopyTo(Fs, 4 * 1024);                                 // Buffer Size is 4 * 1024 but you can modify it in your code as per your need
                 }
             }
         }
     }
     catch (Exception oEx)
     {
         BootmanLog.LogError(LogTextBox, "Error Extracting ISO: " + oEx.Message);
     }
 }
Ejemplo n.º 6
0
 void BrowseDirectory(DiscDirectoryInfo Dinfo, string RootPath, string PathinISO, DiscDirectoryInfo ComparingNode)
 {
     if (Dinfo.FullName == ComparingNode.FullName)
     {
         metroListView1.Items.Clear();
         foreach (DiscDirectoryInfo dinfo in Dinfo.GetDirectories())
         {
             ListViewItem.ListViewSubItem[] subItems = null;
             ListViewItem item = null;
             item = new ListViewItem(dinfo.Name, 0);
             subItems = new ListViewItem.ListViewSubItem[]
                       {new ListViewItem.ListViewSubItem(item, "Directory"),
            new ListViewItem.ListViewSubItem(item,
         dinfo.LastAccessTime.ToShortDateString())};
             item.SubItems.AddRange(subItems);
             metroListView1.Items.Add(item);
             currentFolder = Dinfo;
             textBox1.Text = Dinfo.FullName;
             //DiscDirectoryInfo nodeDirInfo;
             //for (int i = 0; i<treeView1.Nodes.Count; i++)
             //{
             //    nodeDirInfo = (DiscDirectoryInfo)treeView1.Nodes[i].Tag;
             //    if (nodeDirInfo.FullName == Dinfo.FullName)
             //        treeView1.Nodes[i].Expand();
             //    else treeView1.Nodes[0].NextVisibleNode.Expand();
             //}
                
         }
         foreach (DiscFileInfo finfo in Dinfo.GetFiles())
         {
             ListViewItem.ListViewSubItem[] subItems = null;
             ListViewItem item = null;
             item = new ListViewItem(finfo.Name, 1);
             subItems = new ListViewItem.ListViewSubItem[]
                       { new ListViewItem.ListViewSubItem(item, "File"),
            new ListViewItem.ListViewSubItem(item,
         finfo.LastAccessTime.ToShortDateString())};
             item.SubItems.AddRange(subItems);
             metroListView1.Items.Add(item);
         }
     } else
     {
         foreach (DiscDirectoryInfo dinfo in Dinfo.GetDirectories())
         {
             if (dinfo.FullName == ComparingNode.FullName)
             {
                 metroListView1.Items.Clear();
                 BrwsDirectory(dinfo, RootPath, PathinISO, ComparingNode);
             }
             BrowseDirectory(dinfo, RootPath, PathinISO, ComparingNode);
         }
     }
     
 }
        public void SimpleSearch()
        {
            CDBuilder builder = new CDBuilder();

            builder.AddFile(@"SOMEDIR\CHILDDIR\GCHILDIR\FILE.TXT", new byte[0]);
            CDReader fs = new CDReader(builder.Build(), false);

            DiscDirectoryInfo di = fs.GetDirectoryInfo(@"SOMEDIR\CHILDDIR");

            DiscFileInfo[] fis = di.GetFiles("*.*", SearchOption.AllDirectories);
        }
Ejemplo n.º 8
0
 private static void ShowDir(DiscDirectoryInfo dirInfo, int indent)
 {
     Console.WriteLine("{0}{1,-50} [{2}]", new String(' ', indent), dirInfo.FullName, dirInfo.CreationTimeUtc);
     foreach (DiscDirectoryInfo subDir in dirInfo.GetDirectories())
     {
         ShowDir(subDir, indent + 0);
     }
     foreach (DiscFileInfo file in dirInfo.GetFiles())
     {
         Console.WriteLine("{0}{1,-50} [{2}]", new String(' ', indent), file.FullName, file.CreationTimeUtc);
     }
 }
Ejemplo n.º 9
0
        /// <summary>
        /// The recursive files.
        /// </summary>
        /// <param name="path">
        /// The path.
        /// </param>
        /// <returns>
        /// </returns>
        private static List <DiscUtilFile> RecursiveFiles(DiscDirectoryInfo path)
        {
            var returnFiles = new List <DiscUtilFile>();

            foreach (DiscFileInfo file in path.GetFiles())
            {
                var newFile = new DiscUtilFile();
                newFile.FileName = file.FullName;
                newFile.FileSize = file.Length;
                returnFiles.Add(newFile);
            }

            return(returnFiles);
        }
Ejemplo n.º 10
0
 private void EnumerateDirectory(DiscDirectoryInfo parent, string basePath, bool recurse, bool namesOnly)
 {
     foreach (var dir in parent.GetDirectories())
     {
         WriteItemObject(namesOnly ? dir.Name : (object)dir, MakePath(basePath, dir.Name), true);
         if (recurse)
         {
             EnumerateDirectory(dir, MakePath(basePath, dir.Name), recurse, namesOnly);
         }
     }
     foreach (var file in parent.GetFiles())
     {
         WriteItemObject(namesOnly ? file.Name : (object)file, MakePath(basePath, file.Name), false);
     }
 }
Ejemplo n.º 11
0
        private string[] GetFiles(DiscDirectoryInfo directory)
        {
            List <string> result = new List <string>();

            foreach (DiscFileInfo file in directory.GetFiles())
            {
                result.Add(file.FullName);
            }

            foreach (DiscDirectoryInfo dir in directory.GetDirectories())
            {
                result.AddRange(GetFiles(dir));
            }

            return(result.ToArray());
        }
Ejemplo n.º 12
0
        public void AppleTestZip()
        {
            using (FileStream fs = File.OpenRead(Path.Combine("..", "..", "..", "Iso9660", "Data", "apple-test.zip")))
                using (Stream iso = ZipUtilities.ReadFileFromZip(fs))
                    using (CDReader cr = new CDReader(iso, false))
                    {
                        DiscDirectoryInfo dir = cr.GetDirectoryInfo("sub-directory");
                        Assert.NotNull(dir);
                        Assert.Equal("sub-directory", dir.Name);

                        DiscFileInfo[] file = dir.GetFiles("apple-test.txt");
                        Assert.Equal(1, file.Length);
                        Assert.Equal(21, file[0].Length);
                        Assert.Equal("apple-test.txt", file[0].Name);
                        Assert.Equal(dir, file[0].Directory);
                    }
        }
Ejemplo n.º 13
0
        private IEnumerable <string> GetFilesFromDir(string path, DiscDirectoryInfo directory)
        {
            foreach (var subDir in directory.GetDirectories())
            {
                foreach (var file in GetFilesFromDir(Path.Combine(path, subDir.Name), subDir))
                {
                    yield return(file);
                }
            }
            var fileList = directory.GetFiles();

            if (!fileList.Any())
            {
                Console.WriteLine($"Folder '{path}' exists but contains no files");
            }
            foreach (var file in fileList)
            {
                yield return(Path.Combine(path, file.Name));
            }
        }
Ejemplo n.º 14
0
        private static Task CompTree(DiscDirectoryInfo A, DiscDirectoryInfo B, DiscDirectoryInfo Out,
                                     CopyQueue WriteQueue, ComparisonStyle Style = ComparisonStyle.DateTimeOnly)

        {
            if (WriteQueue == null)
            {
                throw new ArgumentNullException("WriteQueue");
            }
            List <Task> tasks = new List <Task>();

            DiscFileSystem Alock = A.FileSystem;
            DiscFileSystem Block = B.FileSystem;
            DiscFileSystem Olock = Out.FileSystem;

            ParallelQuery <DiscFileInfo> BFiles;

            lock (Block)
                BFiles = B.GetFiles("*.*", SearchOption.AllDirectories).ToArray().AsParallel();
            BFiles = BFiles.Where(file =>
                                  !ExcludeFiles.Contains(file.FullName.ToUpperInvariant())
                                  ).AsParallel();
            BFiles = ExclusionRules.Aggregate(BFiles, (current, rule) => current.Where(file => !rule.IsMatch(file.FullName)));

            BFiles = BFiles.Where(file =>
            {
                DiscFileInfo Atmp;
                lock (Alock)
                    Atmp = Alock.GetFileInfo(file.FullName);
                return(!CompareFile(Atmp, file, Style));
            }).ToArray().AsParallel();

            foreach (var file in BFiles)
            {
                DiscFileInfo outFile;
                lock (Olock)
                    outFile = Out.FileSystem.GetFileInfo(Path.Combine(Out.FullName, file.FullName));
                WriteQueue.Add(file, outFile);
            }

            return(Task.Factory.StartNew(() => Task.WaitAll(tasks.ToArray()), TaskCreationOptions.AttachedToParent));
        }
Ejemplo n.º 15
0
        private long GetDiscDirectorySize(DiscDirectoryInfo directoryInfo)
        {
            long size = 0;

            DiscFileInfo[] pathFiles = directoryInfo.GetFiles();
            foreach (DiscFileInfo pathFile in pathFiles)
            {
                if (pathFile.Extension.ToUpper() == "SSIF")
                {
                    continue;
                }
                size += pathFile.Length;
            }

            DiscDirectoryInfo[] pathChildren = directoryInfo.GetDirectories();
            foreach (DiscDirectoryInfo pathChild in pathChildren)
            {
                size += GetDiscDirectorySize(pathChild);
            }
            return(size);
        }
Ejemplo n.º 16
0
        private void CopyDirectory(DiscDirectoryInfo source, DirectoryInfo target, bool recurse)
        {
            if (recurse)
            {
                foreach (var childDiscDirectory in source.GetDirectories())
                {
                    DirectoryInfo childDirectory = target.CreateSubdirectory(childDiscDirectory.Name);
                    CopyDirectory(childDiscDirectory, childDirectory, recurse);
                }
            }

            Console.WriteLine("{0}", source.Name);

            foreach (var childFile in source.GetFiles())
            {
                using (Stream sourceStream = childFile.OpenRead())
                    using (Stream targetStream = File.OpenWrite(Path.Combine(target.FullName, childFile.Name)))
                    {
                        sourceStream.CopyTo(targetStream);
                    }
            }
        }
Ejemplo n.º 17
0
        private static void ExtractIsoDirectory(DiscDirectoryInfo directoryInfo, string dstDir)
        {
            if (!Directory.Exists(dstDir))
            {
                Directory.CreateDirectory(dstDir);
            }

            foreach (DiscDirectoryInfo subDirInfo in directoryInfo.GetDirectories())
            {
                ExtractIsoDirectory(subDirInfo, Path.Join(dstDir, subDirInfo.Name));
            }

            foreach (DiscFileInfo fileInfo in directoryInfo.GetFiles())
            {
                string filePath = Path.Join(dstDir, fileInfo.Name);
                using (Stream srcStream = fileInfo.OpenRead()) {
                    using (Stream dstStream = File.Create(filePath)) {
                        srcStream.CopyTo(dstStream);
                    }
                }
            }
        }
Ejemplo n.º 18
0
        private static void Gather(Media medium, DiscDirectoryInfo ddi, FilesystemMetadataEntity parent)
        {
            IDatabaseDriver dbDriver = AzusaContext.GetInstance().DatabaseDriver;

            FilesystemMetadataEntity dirEntity = new FilesystemMetadataEntity();

            dirEntity.FullName    = ddi.FullName;
            dirEntity.IsDirectory = true;
            dirEntity.MediaId     = medium.Id;
            dirEntity.Modified    = ddi.LastWriteTime;
            dirEntity.ParentId    = parent != null ? parent.Id : -1;
            dbDriver.AddFilesystemInfo(dirEntity);

            foreach (DiscDirectoryInfo subdir in ddi.GetDirectories())
            {
                Gather(medium, subdir, dirEntity);
            }

            foreach (DiscFileInfo file in ddi.GetFiles())
            {
                FilesystemMetadataEntity fileEntity = new FilesystemMetadataEntity();
                fileEntity.FullName    = file.FullName;
                fileEntity.IsDirectory = false;
                fileEntity.MediaId     = medium.Id;
                fileEntity.Modified    = file.LastWriteTime;
                fileEntity.ParentId    = dirEntity.Id;
                fileEntity.Size        = file.Length;

                int    readSize = (int)Math.Min(2048, file.Length);
                byte[] buffer   = new byte[readSize];
                Stream inStream = file.OpenRead();
                readSize = inStream.Read(buffer, 0, readSize);
                inStream.Close();
                Array.Resize(ref buffer, readSize);
                fileEntity.Header = buffer;

                dbDriver.AddFilesystemInfo(fileEntity);
            }
        }
Ejemplo n.º 19
0
        private List <string> ScanDiscDirectory(DiscDirectoryInfo directory)
        {
            List <string> tfsFiles = new List <string>();

            var files          = directory.GetFiles();
            var subDirectories = directory.GetDirectories();

            foreach (var file in files)
            {
                if (file.Extension.ToLower() == "tfs;1")
                {
                    tfsFiles.Add(file.FullName);
                }
            }

            foreach (var subDirectory in subDirectories)
            {
                tfsFiles.AddRange(ScanDiscDirectory(subDirectory));
            }

            return(tfsFiles);
        }
Ejemplo n.º 20
0
        // public static void ExtractISO(string IsoFilePath, string ExtractionPath)
        // {
        //     using (FileStream ISOStream = File.Open(IsoFilePath, FileMode.Open))
        //     {
        //         CDReader Reader = new CDReader(ISOStream, true, true);
        //         ExtractDirectory(Reader.Root, ExtractionPath + Path.GetFileNameWithoutExtension(IsoFilePath) + "\\", "");
        //         Reader.Dispose();
        //     }
        // }


        private static void ExtractDirectory(DiscDirectoryInfo ddi, string RootPath, string PathinISO)
        {
            if (!string.IsNullOrWhiteSpace(PathinISO))
            {
                PathinISO += "\\" + ddi.Name;
            }
            RootPath += "\\" + ddi.Name;
            AppendDirectory(RootPath);
            foreach (DiscDirectoryInfo dinfo in ddi.GetDirectories())
            {
                ExtractDirectory(dinfo, RootPath, PathinISO);
            }
            foreach (DiscFileInfo finfo in ddi.GetFiles())
            {
                using (Stream FileStr = finfo.OpenRead())
                {
                    using (FileStream Fs = File.Create(RootPath + "\\" + finfo.Name)) // Here you can Set the BufferSize Also e.g. File.Create(RootPath + "\\" + finfo.Name, 4 * 1024)
                    {
                        FileStr.CopyTo(Fs, 4 * 1024);                                 // Buffer Size is 4 * 1024 but you can modify it in your code as per your need
                    }
                }
            }
        }
Ejemplo n.º 21
0
        public BDROM(
            string path)
        {
            //
            // Locate BDMV directories.
            //
            if ((new FileInfo(path).Attributes & FileAttributes.Directory) != FileAttributes.Directory)
            {
                IsImage  = true;
                IoStream = File.Open(path, FileMode.Open, FileAccess.Read, FileShare.Read);
                CdReader = new UdfReader(IoStream);
            }

            if (!IsImage)
            {
                DirectoryBDMV = GetDirectoryBDMV(path);
            }
            else
            {
                DiscDirectoryBDMV = GetDiscDirectoryBDMV();
            }

            if ((!IsImage && DirectoryBDMV == null) || (IsImage && DiscDirectoryBDMV == null))
            {
                throw new Exception("Unable to locate BD structure.");
            }

            if (IsImage)
            {
                DiscDirectoryRoot = DiscDirectoryBDMV.Parent;

                DiscDirectoryBDJO     = GetDiscDirectory("BDJO", DiscDirectoryBDMV, 0);
                DiscDirectoryCLIPINF  = GetDiscDirectory("CLIPINF", DiscDirectoryBDMV, 0);
                DiscDirectoryPLAYLIST = GetDiscDirectory("PLAYLIST", DiscDirectoryBDMV, 0);
                DiscDirectorySNP      = GetDiscDirectory("SNP", DiscDirectoryRoot, 0);
                DiscDirectorySTREAM   = GetDiscDirectory("STREAM", DiscDirectoryBDMV, 0);
                DiscDirectorySSIF     = GetDiscDirectory("SSIF", DiscDirectorySTREAM, 0);
                DiscDirectoryMETA     = GetDiscDirectory("META", DiscDirectoryBDMV, 0);
            }
            else
            {
                DirectoryRoot = DirectoryBDMV.Parent;

                DirectoryBDJO     = GetDirectory("BDJO", DirectoryBDMV, 0);
                DirectoryCLIPINF  = GetDirectory("CLIPINF", DirectoryBDMV, 0);
                DirectoryPLAYLIST = GetDirectory("PLAYLIST", DirectoryBDMV, 0);
                DirectorySNP      = GetDirectory("SNP", DirectoryRoot, 0);
                DirectorySTREAM   = GetDirectory("STREAM", DirectoryBDMV, 0);
                DirectorySSIF     = GetDirectory("SSIF", DirectorySTREAM, 0);
                DirectoryMETA     = GetDirectory("META", DirectoryBDMV, 0);
            }

            if ((!IsImage & (DirectoryCLIPINF == null || DirectoryPLAYLIST == null)) || (IsImage & (DiscDirectoryCLIPINF == null || DiscDirectoryPLAYLIST == null)))
            {
                throw new Exception("Unable to locate BD structure.");
            }

            //
            // Initialize basic disc properties.
            //
            if (IsImage)
            {
                VolumeLabel = CdReader.VolumeLabel;
                Size        = (ulong)GetDiscDirectorySize(DiscDirectoryRoot);

                var          indexFiles = DiscDirectoryBDMV?.GetFiles();
                DiscFileInfo indexFile  = null;

                for (int i = 0; i < indexFiles?.Length; i++)
                {
                    if (indexFiles[i].Name.ToLower() == "index.bdmv")
                    {
                        indexFile = indexFiles[i];
                        break;
                    }
                }

                if (indexFile != null)
                {
                    using (var indexStream = indexFile.OpenRead())
                    {
                        ReadIndexVersion(indexStream);
                    }
                }

                if (null != GetDiscDirectory("BDSVM", DiscDirectoryRoot, 0))
                {
                    IsBDPlus = true;
                }
                if (null != GetDiscDirectory("SLYVM", DiscDirectoryRoot, 0))
                {
                    IsBDPlus = true;
                }
                if (null != GetDiscDirectory("ANYVM", DiscDirectoryRoot, 0))
                {
                    IsBDPlus = true;
                }

                if (DiscDirectoryBDJO != null &&
                    DiscDirectoryBDJO.GetFiles().Length > 0)
                {
                    IsBDJava = true;
                }

                if (DiscDirectorySNP != null &&
                    (DiscDirectorySNP.GetFiles("*.mnv").Length > 0 || DiscDirectorySNP.GetFiles("*.MNV").Length > 0))
                {
                    IsPSP = true;
                }

                if (DiscDirectorySSIF != null &&
                    DiscDirectorySSIF.GetFiles().Length > 0)
                {
                    Is3D = true;
                }

                DiscFileInfo[] discFiles = DiscDirectoryRoot.GetFiles("FilmIndex.xml");
                if (discFiles != null && discFiles.Length > 0)
                {
                    IsDBOX = true;
                }

                if (DiscDirectoryMETA != null)
                {
                    DiscFileInfo[] metaFiles = DiscDirectoryMETA.GetFiles("bdmt_eng.xml", SearchOption.AllDirectories);
                    if (metaFiles != null && metaFiles.Length > 0)
                    {
                        ReadDiscTitle(metaFiles[0].OpenText());
                    }
                }

                //
                // Initialize file lists.
                //

                if (DiscDirectoryPLAYLIST != null)
                {
                    DiscFileInfo[] files = DiscDirectoryPLAYLIST.GetFiles("*.mpls");
                    if (files.Length == 0)
                    {
                        files = DiscDirectoryPLAYLIST.GetFiles("*.MPLS");
                    }
                    foreach (DiscFileInfo file in files)
                    {
                        PlaylistFiles.Add(file.Name.ToUpper(), new TSPlaylistFile(this, file, CdReader));
                    }
                }

                if (DiscDirectorySTREAM != null)
                {
                    DiscFileInfo[] files = DiscDirectorySTREAM.GetFiles("*.m2ts");
                    if (files.Length == 0)
                    {
                        files = DiscDirectoryPLAYLIST.GetFiles("*.M2TS");
                    }
                    foreach (DiscFileInfo file in files)
                    {
                        StreamFiles.Add(file.Name.ToUpper(), new TSStreamFile(file, CdReader));
                    }
                }

                if (DiscDirectoryCLIPINF != null)
                {
                    DiscFileInfo[] files = DiscDirectoryCLIPINF.GetFiles("*.clpi");
                    if (files.Length == 0)
                    {
                        files = DiscDirectoryPLAYLIST.GetFiles("*.CLPI");
                    }
                    foreach (DiscFileInfo file in files)
                    {
                        StreamClipFiles.Add(file.Name.ToUpper(), new TSStreamClipFile(file, CdReader));
                    }
                }

                if (DiscDirectorySSIF != null)
                {
                    DiscFileInfo[] files = DiscDirectorySSIF.GetFiles("*.ssif");
                    if (files.Length == 0)
                    {
                        files = DiscDirectorySSIF.GetFiles("*.SSIF");
                    }
                    foreach (DiscFileInfo file in files)
                    {
                        InterleavedFiles.Add(file.Name.ToUpper(), new TSInterleavedFile(file, CdReader));
                    }
                }
            }
            else
            {
                VolumeLabel = GetVolumeLabel(DirectoryRoot);
                Size        = (ulong)GetDirectorySize(DirectoryRoot);

                var      indexFiles = DirectoryBDMV.GetFiles();
                FileInfo indexFile  = null;

                for (int i = 0; i < indexFiles.Length; i++)
                {
                    if (indexFiles[i].Name.ToLower() == "index.bdmv")
                    {
                        indexFile = indexFiles[i];
                        break;
                    }
                }

                if (indexFile != null)
                {
                    using (var indexStream = indexFile.OpenRead())
                    {
                        ReadIndexVersion(indexStream);
                    }
                }

                if (null != GetDirectory("BDSVM", DirectoryRoot, 0))
                {
                    IsBDPlus = true;
                }
                if (null != GetDirectory("SLYVM", DirectoryRoot, 0))
                {
                    IsBDPlus = true;
                }
                if (null != GetDirectory("ANYVM", DirectoryRoot, 0))
                {
                    IsBDPlus = true;
                }

                if (DirectoryBDJO != null &&
                    DirectoryBDJO.GetFiles().Length > 0)
                {
                    IsBDJava = true;
                }

                if (DirectorySNP != null &&
                    (DirectorySNP.GetFiles("*.mnv").Length > 0 || DirectorySNP.GetFiles("*.MNV").Length > 0))
                {
                    IsPSP = true;
                }

                if (DirectorySSIF != null &&
                    DirectorySSIF.GetFiles().Length > 0)
                {
                    Is3D = true;
                }

                if (File.Exists(Path.Combine(DirectoryRoot.FullName, "FilmIndex.xml")))
                {
                    IsDBOX = true;
                }

                if (DirectoryMETA != null)
                {
                    FileInfo[] metaFiles = DirectoryMETA.GetFiles("bdmt_eng.xml", SearchOption.AllDirectories);
                    if (metaFiles != null && metaFiles.Length > 0)
                    {
                        ReadDiscTitle(metaFiles[0].OpenText());
                    }
                }

                //
                // Initialize file lists.
                //

                if (DirectoryPLAYLIST != null)
                {
                    FileInfo[] files = DirectoryPLAYLIST.GetFiles("*.mpls");
                    if (files.Length == 0)
                    {
                        files = DirectoryPLAYLIST.GetFiles("*.MPLS");
                    }
                    foreach (FileInfo file in files)
                    {
                        PlaylistFiles.Add(
                            file.Name.ToUpper(), new TSPlaylistFile(this, file));
                    }
                }

                if (DirectorySTREAM != null)
                {
                    FileInfo[] files = DirectorySTREAM.GetFiles("*.m2ts");
                    if (files.Length == 0)
                    {
                        files = DirectoryPLAYLIST.GetFiles("*.M2TS");
                    }
                    foreach (FileInfo file in files)
                    {
                        StreamFiles.Add(
                            file.Name.ToUpper(), new TSStreamFile(file));
                    }
                }

                if (DirectoryCLIPINF != null)
                {
                    FileInfo[] files = DirectoryCLIPINF.GetFiles("*.clpi");
                    if (files.Length == 0)
                    {
                        files = DirectoryPLAYLIST.GetFiles("*.CLPI");
                    }
                    foreach (FileInfo file in files)
                    {
                        StreamClipFiles.Add(
                            file.Name.ToUpper(), new TSStreamClipFile(file));
                    }
                }

                if (DirectorySSIF != null)
                {
                    FileInfo[] files = DirectorySSIF.GetFiles("*.ssif");
                    if (files.Length == 0)
                    {
                        files = DirectorySSIF.GetFiles("*.SSIF");
                    }
                    foreach (FileInfo file in files)
                    {
                        InterleavedFiles.Add(
                            file.Name.ToUpper(), new TSInterleavedFile(file));
                    }
                }
            }
        }
Ejemplo n.º 22
0
 private void EnumerateDirectory(DiscDirectoryInfo parent, string basePath, bool recurse, bool namesOnly)
 {
     foreach (var dir in parent.GetDirectories())
     {
         WriteItemObject(namesOnly ? dir.Name : (object)dir, MakePath(basePath, dir.Name), true);
         if (recurse)
         {
             EnumerateDirectory(dir, MakePath(basePath, dir.Name), recurse, namesOnly);
         }
     }
     foreach (var file in parent.GetFiles())
     {
         WriteItemObject(namesOnly ? file.Name : (object)file, MakePath(basePath, file.Name), false);
     }
 }