Пример #1
0
        static void Main(string[] args)
        {
            SetupHelper.RegisterAssembly(typeof(Program).Assembly);

            MemoryStream dummyFileSystemData = new MemoryStream(Encoding.ASCII.GetBytes("MYFS"));

            VirtualDisk   dummyDisk = new DiscUtils.Raw.Disk(dummyFileSystemData, Ownership.None);
            VolumeManager volMgr    = new VolumeManager(dummyDisk);

            VolumeInfo volInfo = volMgr.GetLogicalVolumes()[0];

            DiscUtils.FileSystemInfo fsInfo = FileSystemManager.DetectFileSystems(volInfo)[0];

            DiscFileSystem fs = fsInfo.Open(volInfo);

            ShowDir(fs.Root, 4);
        }
Пример #2
0
        protected override void DoRun()
        {
            VolumeManager volMgr = new VolumeManager();

            foreach (string disk in _diskFiles.Values)
            {
                volMgr.AddDisk(VirtualDisk.OpenDisk(disk, _diskType.IsPresent ? _diskType.Value : null, FileAccess.Read, UserName, Password));
            }


            VolumeInfo volInfo = null;

            if (!string.IsNullOrEmpty(VolumeId))
            {
                volInfo = volMgr.GetVolume(VolumeId);
            }
            else if (Partition >= 0)
            {
                volInfo = volMgr.GetPhysicalVolumes()[Partition];
            }
            else
            {
                volInfo = volMgr.GetLogicalVolumes()[0];
            }


            DiscUtils.FileSystemInfo fsInfo = FileSystemManager.DetectDefaultFileSystems(volInfo)[0];


            using (DiscFileSystem fs = fsInfo.Open(volInfo))
            {
                using (Stream source = fs.OpenFile(_inFilePath.Value, FileMode.Open, FileAccess.Read))
                {
                    using (FileStream outFile = new FileStream(_outFilePath.Value, FileMode.Create, FileAccess.ReadWrite))
                    {
                        PumpStreams(source, outFile);
                    }

                    if (_hexDump.IsPresent)
                    {
                        source.Position = 0;
                        HexDump.Generate(source, Console.Out);
                    }
                }
            }
        }
Пример #3
0
        private void LoadContainer(string filePath)
        {
            disk = VirtualDisk.OpenDisk(filePath, FileAccess.ReadWrite);

            Debug.WriteLine(disk.Capacity + ", " + disk.DiskTypeInfo.Name);

            volume = VolumeManager.GetPhysicalVolumes(disk.Content)[0];

            fsInfo = FileSystemManager.DetectFileSystems(volume)[0];

            discFs = fsInfo.Open(volume);

            tmpFiles = new List <string>();

            Debug.WriteLine(fsInfo.Name + " - " + fsInfo.Description);

            fsHandler = new FileSystemHandler.FileSystemHandler(this);
        }
Пример #4
0
        private static string RedirectISO(string filename)
        {
            string _result = null;

            try
            {
                if (!string.IsNullOrEmpty(filename) && File.Exists(filename))
                {
                    List <string> _candidates = new List <string>();

                    // open the ISO file
                    VolumeManager volMgr = new VolumeManager();
                    volMgr.AddDisk(VirtualDisk.OpenDisk(filename, FileAccess.Read));

                    VolumeInfo volInfo = null;
                    volInfo = volMgr.GetLogicalVolumes()[0];

                    DiscUtils.FileSystemInfo fsInfo = FileSystemManager.DetectDefaultFileSystems(volInfo)[0];

                    using (DiscFileSystem _dfs = fsInfo.Open(volInfo))
                    {
                        foreach (string _fname in _dfs.GetFiles("", "*.*", SearchOption.AllDirectories))
                        {
                            string _fileExt = System.IO.Path.GetExtension(_fname).ToLowerInvariant();
                            if (_fileExt == ".ifo" || _fileExt == ".mpls")
                            {
                                _candidates.Add(_fname);
                            }
                        }

                        double _biggestDuration = 0d;
                        string _tmpBRResult     = "";
                        // select from the candidates the one that has the longest duration (if mpls skip files bigger than 10K)
                        foreach (string _cpath in _candidates)
                        {
                            string _cext = Path.GetExtension(_cpath).ToLowerInvariant();
                            string _tmp  = Helpers.GetUniqueFilename(_cext);
                            using (FileStream _fs = new FileStream(_tmp, FileMode.Create, FileAccess.Write))
                            {
                                using (Stream source = _dfs.OpenFile(_cpath, FileMode.Open, FileAccess.Read))
                                {
                                    source.CopyTo(_fs);
                                }
                            }

                            // if it is a DVD iso
                            if (_cext == ".ifo")
                            {
                                if (string.Compare(Path.GetFileNameWithoutExtension(_cpath), "video_ts", true) == 0)
                                {
                                    File.Delete(_tmp);
                                    // skip the menu
                                    continue;
                                }

                                // use first ifo that is not the menu
                                FileManager.AddToGarbageFiles(_tmp);
                                _result = _tmp;
                                break;
                            }

                            // if it is a BLURAY iso (choose biggest mpls file)
                            if (_cext == ".mpls")
                            {
                                long _length = new FileInfo(_tmp).Length;
                                if (Path.GetExtension(_cpath).ToLowerInvariant() == ".mpls" && _length > 10 * 1024)
                                {
                                    File.Delete(_tmp);
                                    continue; // take next one, this is too big and mediainfo will hang
                                }

                                if (GetDurationMilliseconds(_tmp) > _biggestDuration)
                                {
                                    // important.. add it to the garbage files
                                    //FileManager.AddToGarbageFiles(_tmp);
                                    //_result = _tmp;
                                    if (!string.IsNullOrEmpty(_tmpBRResult))
                                    {
                                        File.Delete(_tmpBRResult); // remove previous winner and remember the current one
                                    }
                                    _tmpBRResult = _tmp;
                                }
                                else
                                {
                                    File.Delete(_tmp);
                                }
                            }
                        }
                        if (string.IsNullOrEmpty(_result) && !string.IsNullOrEmpty(_tmpBRResult))
                        {
                            FileManager.AddToGarbageFiles(_tmpBRResult);
                            _result = _tmpBRResult;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Loggy.Logger.DebugException("ISO Processing", ex);
            }

            return(_result);
        }