Exemplo n.º 1
0
        public IsoFile SetIso(string IsoFile)
        {
            var    IsoFileStream = (Stream)File.OpenRead(IsoFile);
            string DetectedFormat;

            switch (DetectedFormat = new FormatDetector().Detect(IsoFileStream))
            {
            case "Cso":
                IsoFileStream = new CsoProxyStream(new Cso(IsoFileStream));
                break;

            case "Iso":
                break;

            default:
                throw (new InvalidDataException("Can't set an ISO for '" + DetectedFormat + "'"));
            }
            //"../../../TestInput/cube.iso"
            var Iso = new IsoFile(IsoFileStream, IsoFile);
            var Umd = new HleIoDriverIso(Iso);

            HleState.HleIoManager.SetDriver("disc:", Umd);
            HleState.HleIoManager.SetDriver(":", Umd);
            return(Iso);
        }
Exemplo n.º 2
0
        public void IsoConstructorTest()
        {
            var csoName     = "../../../TestInput/test.cso";
            var cso         = new Cso(File.OpenRead(csoName));
            var iso         = new IsoFile(new CompressedIsoProxyStream(cso), csoName);
            var contentNode = iso.Root.Locate("path/content.txt");
            var lines       = contentNode.Open().ReadAllContentsAsString().Split('\n');

            foreach (var line in lines)
            {
                iso.Root.Locate(line);
            }
        }
Exemplo n.º 3
0
        public void IsoConstructorTest()
        {
            var CsoName     = "../../../TestInput/test.cso";
            var Cso         = new Cso(File.OpenRead(CsoName));
            var Iso         = new IsoFile(new CsoProxyStream(Cso), CsoName);
            var ContentNode = Iso.Root.Locate("path/content.txt");
            var Lines       = ContentNode.Open().ReadAllContentsAsString().Split('\n');

            foreach (var Line in Lines)
            {
                Iso.Root.Locate(Line);
            }
        }
Exemplo n.º 4
0
        public IsoFile GetIsoFile(string filePath)
        {
            var info = new FileInfo(filePath);

            var file = new IsoFile
            {
                Name      = info.Name,
                Extension = info.Extension.ToLower(),
                Created   = info.CreationTime,
                Modified  = info.LastWriteTime,
                Size      = Convert.ToDecimal(info.Length)
            };

            return(file);
        }
Exemplo n.º 5
0
        public static string FixVideoFileIfNecessary()
        {
            Java.IO.File videoFile = new Java.IO.File(Path.Combine(Environment.ExternalStorageDirectory.ToString(), "video_to_fix.mp4"));

            using (IDataSource channel = new FileDataSourceImpl(videoFile.AbsolutePath)) {
                IsoFile isoFile = new IsoFile(channel);

                IList trackBoxes = isoFile.MovieBox.GetBoxes(Java.Lang.Class.FromType(typeof(TrackBox)));

                bool hasError = true;

                foreach (TrackBox trackBox in trackBoxes)
                {
                    TimeToSampleBox.Entry firstEntry = trackBox.MediaBox.MediaInformationBox.SampleTableBox.TimeToSampleBox.Entries[0];

                    if (firstEntry.Delta > 10000)
                    {
                        hasError         = true;
                        firstEntry.Delta = 3000;
                    }
                }

                if (hasError)
                {
                    Movie movie = new Movie();

                    foreach (TrackBox trackBox in trackBoxes)
                    {
                        movie.AddTrack(new Mp4TrackImpl(channel.ToString() + "[" + trackBox.TrackHeaderBox.TrackId + "]", trackBox));
                    }

                    movie.Matrix = isoFile.MovieBox.MovieHeaderBox.Matrix;

                    using IContainer outt = new DefaultMp4Builder().Build(movie);

                    string filePath = Path.Combine(Environment.ExternalStorageDirectory.ToString(), "fixedVideo.mp4");

                    using FileChannel fileChannel = new RandomAccessFile(filePath, "rw").Channel;
                    outt.WriteContainer(fileChannel);

                    return(filePath);
                }
            }

            return(videoFile.AbsolutePath);
        }
Exemplo n.º 6
0
        public void InsertShouldCallDbSetAdd()
        {
            // Arrange
            var isoFinderEntitiesMock = new Mock <IsoFinderEntities>();
            var dbSetMock             = new Mock <DbSet <IsoFile> >();
            var isoFile = new IsoFile {
                Id = 1
            };

            dbSetMock.Setup(s => s.Add(It.IsAny <IsoFile>())).Returns(isoFile).Verifiable();
            isoFinderEntitiesMock.Setup(pb => pb.Set <IsoFile>()).Returns(dbSetMock.Object);
            var isoFileRepository = new GenericRepository <IsoFile>(isoFinderEntitiesMock.Object);

            // Act
            isoFileRepository.Insert(isoFile);

            // Assert
            dbSetMock.VerifyAll();
        }
Exemplo n.º 7
0
        public void UpdateShouldAttachAndCallSetModified()
        {
            // Arrange
            var isoFinderEntitiesMock = new Mock <IIsoFinderEntities>();
            var dbSetMock             = new Mock <DbSet <IsoFile> >();
            var isoFile = new IsoFile {
                Id = 1
            };

            dbSetMock.Setup(s => s.Attach(It.IsAny <IsoFile>())).Verifiable();
            isoFinderEntitiesMock.Setup(pb => pb.GetSet <IsoFile>()).Returns(dbSetMock.Object);
            isoFinderEntitiesMock.Setup(pb => pb.SetModified(isoFile)).Verifiable();
            var isoFileRepository = new GenericRepository <IsoFile>(isoFinderEntitiesMock.Object);

            // Act
            isoFileRepository.Update(isoFile);

            // Assert
            dbSetMock.VerifyAll();
        }
Exemplo n.º 8
0
        public void DeleteWithEntityAlreadyAddedShouldCallDbSetRemove()
        {
            // Arrange
            var isoFinderEntitiesMock = new Mock <IIsoFinderEntities>();
            var dbSetMock             = new Mock <DbSet <IsoFile> >();
            var isoFile = new IsoFile {
                Id = 1
            };

            dbSetMock.Setup(s => s.Remove(It.IsAny <IsoFile>())).Returns(isoFile).Verifiable();
            isoFinderEntitiesMock.Setup(pb => pb.GetSet <IsoFile>()).Returns(dbSetMock.Object);
            isoFinderEntitiesMock.Setup(pb => pb.GetState(isoFile)).Returns(EntityState.Added);
            var isoFileRepository = new GenericRepository <IsoFile>(isoFinderEntitiesMock.Object);

            // Act
            isoFileRepository.Delete(isoFile);

            // Assert
            dbSetMock.VerifyAll();
        }
Exemplo n.º 9
0
        public void GetShouldReturnDbSetFind()
        {
            // Arrange
            var isoFinderEntitiesMock = new Mock <IsoFinderEntities>();
            var dbSetMock             = new Mock <DbSet <IsoFile> >();
            var isoFile = new IsoFile {
                Id = 1
            };

            dbSetMock.Setup(s => s.Find(It.IsAny <object[]>())).Returns(isoFile).Verifiable();
            isoFinderEntitiesMock.Setup(pb => pb.Set <IsoFile>()).Returns(dbSetMock.Object);
            var     isoFileRepository = new GenericRepository <IsoFile>(isoFinderEntitiesMock.Object);
            IsoFile result;

            // Act
            result = isoFileRepository.Get(1);

            // Assert
            Assert.IsNotNull(result);
            dbSetMock.VerifyAll();
        }
Exemplo n.º 10
0
 public HleIoDriverIso(IsoFile Iso)
 {
     this.Iso = Iso;
 }