public void Extension()
        {
            CDBuilder builder = new CDBuilder();
            CDReader  fs      = new CDReader(builder.Build(), false);

            Assert.Equal("dir", fs.GetDirectoryInfo("fred.dir").Extension);
            Assert.Equal("", fs.GetDirectoryInfo("fred").Extension);
        }
        public void FullName()
        {
            CDBuilder builder = new CDBuilder();
            CDReader  fs      = new CDReader(builder.Build(), false);

            Assert.Equal(@"\", fs.Root.FullName);
            Assert.Equal(@"SOMEDIR\", fs.GetDirectoryInfo(@"SOMEDIR").FullName);
            Assert.Equal(@"SOMEDIR\CHILDDIR\", fs.GetDirectoryInfo(@"SOMEDIR\CHILDDIR").FullName);
        }
Beispiel #3
0
        public void Parent()
        {
            CDBuilder builder = new CDBuilder();

            builder.AddFile(@"SOMEDIR\ADIR\FILE.TXT", new byte[] { 1 });
            CDReader fs = new CDReader(builder.Build(), false);

            DiscFileInfo fi = fs.GetFileInfo(@"SOMEDIR\ADIR\FILE.TXT");

            Assert.Equal(fs.GetDirectoryInfo(@"SOMEDIR\ADIR"), fi.Parent);
            Assert.Equal(fs.GetDirectoryInfo(@"SOMEDIR\ADIR"), fi.Directory);
        }
Beispiel #4
0
        public void DirectoryInfo()
        {
            CDBuilder         builder = new CDBuilder();
            CDReader          fs      = new CDReader(builder.Build(), false);
            DiscDirectoryInfo fi      = fs.GetDirectoryInfo(@"SOMEDIR");

            Assert.NotNull(fi);
        }
        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);
        }
        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);
                    }
        }
        public void Exists()
        {
            CDBuilder builder = new CDBuilder();

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

            Assert.True(fs.GetDirectoryInfo(@"\").Exists);
            Assert.True(fs.GetDirectoryInfo(@"SOMEDIR").Exists);
            Assert.True(fs.GetDirectoryInfo(@"SOMEDIR\CHILDDIR").Exists);
            Assert.True(fs.GetDirectoryInfo(@"SOMEDIR\CHILDDIR\").Exists);
            Assert.False(fs.GetDirectoryInfo(@"NONDIR").Exists);
            Assert.False(fs.GetDirectoryInfo(@"SOMEDIR\NONDIR").Exists);
        }
 private void Recursive_CreateDirs(CDReader cd, string dir, Stream fileStreamFrom, Stream fileStreamTo)
 {
     foreach (string directory in cd.GetDirectories(dir))
     {
         Directory.CreateDirectory(TempPath + @"\" + directory);
         if (cd.GetDirectoryInfo(directory).GetFiles().Length > 0)
         {
             foreach (string file in cd.GetFiles(directory))
             {
                 fileStreamFrom = cd.OpenFile(file, FileMode.Open);
                 fileStreamTo   = File.Open(TempPath + @"\" + file, FileMode.OpenOrCreate);
                 fileStreamFrom.CopyTo(fileStreamTo);
                 fileStreamFrom.Close();
                 fileStreamTo.Close();
             }
         }
         if (cd.GetDirectories(directory).Length > 0)
         {
             Recursive_CreateDirs(cd, directory, fileStreamFrom, fileStreamTo);
         }
     }
 }
        public void Attributes()
        {
            // Start time rounded down to whole seconds
            DateTime start = DateTime.UtcNow;

            start = new DateTime(start.Year, start.Month, start.Day, start.Hour, start.Minute, start.Second);

            CDBuilder builder = new CDBuilder();

            builder.AddDirectory("Foo");
            CDReader fs  = new CDReader(builder.Build(), false);
            DateTime end = DateTime.UtcNow;

            DiscDirectoryInfo di = fs.GetDirectoryInfo("Foo");

            Assert.Equal(FileAttributes.Directory | FileAttributes.ReadOnly, di.Attributes);
            Assert.True(di.CreationTimeUtc >= start);
            Assert.True(di.CreationTimeUtc <= end);
            Assert.True(di.LastAccessTimeUtc >= start);
            Assert.True(di.LastAccessTimeUtc <= end);
            Assert.True(di.LastWriteTimeUtc >= start);
            Assert.True(di.LastWriteTimeUtc <= end);
        }