public void CreateExisting(NewFileSystemDelegate fsFactory)
        {
            DiscFileSystem fs = fsFactory();

            DiscDirectoryInfo dirInfo = fs.GetDirectoryInfo("SOMEDIR");

            dirInfo.Create();
            dirInfo.Create();

            Assert.AreEqual(1, fs.Root.GetDirectories().Length);
        }
Exemple #2
0
        internal static void CreateDirectoryTree(DiscDirectoryInfo source, DiscDirectoryInfo destination)
        {
            try
            {
                if (source == null)
                    throw new ArgumentNullException("source");
                if (destination == null)
                    throw new ArgumentNullException("destination");
                if (destination.Exists) return;

                if (!destination.Parent.Exists)
                    CreateDirectoryTree(source.Parent, destination.Parent);

                destination.Create();
                destination.Attributes = source.Attributes;
                if (destination.FileSystem is NtfsFileSystem)
                {
                    var D = (NtfsFileSystem) destination.FileSystem;
                    var S = (NtfsFileSystem) source.FileSystem;
                    D.SetSecurity(destination.FullName, S.GetSecurity(source.FullName));

                    D.SetFileStandardInformation(destination.FullName, S.GetFileStandardInformation(source.FullName));
                }
                else
                {
                    destination.CreationTimeUtc = source.CreationTimeUtc;
                    destination.LastWriteTimeUtc = source.LastWriteTimeUtc;
                    destination.LastAccessTimeUtc = source.LastAccessTimeUtc;
                }
            }
            catch (Exception e)
            {
                throw;
            }
        }
        public void CreateInvalid_Characters(NewFileSystemDelegate fsFactory)
        {
            DiscFileSystem fs = fsFactory();

            DiscDirectoryInfo dirInfo = fs.GetDirectoryInfo("SOME\0DIR");

            dirInfo.Create();
        }
        public void CreateInvalid_Long(NewFileSystemDelegate fsFactory)
        {
            DiscFileSystem fs = fsFactory();

            DiscDirectoryInfo dirInfo = fs.GetDirectoryInfo(new String('X', 256));

            dirInfo.Create();
        }
        public void CreateRecursive(NewFileSystemDelegate fsFactory)
        {
            DiscFileSystem fs = fsFactory();

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

            dirInfo.Create();

            Assert.AreEqual(1, fs.Root.GetDirectories().Length);
            Assert.AreEqual(1, fs.GetDirectoryInfo(@"SOMEDIR").GetDirectories().Length);
            Assert.AreEqual("CHILDDIR", fs.GetDirectoryInfo(@"SOMEDIR").GetDirectories()[0].Name);
        }
        public void Exists(NewFileSystemDelegate fsFactory)
        {
            DiscFileSystem fs = fsFactory();

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

            dirInfo.Create();

            Assert.IsTrue(fs.GetDirectoryInfo(@"\").Exists);
            Assert.IsTrue(fs.GetDirectoryInfo(@"SOMEDIR").Exists);
            Assert.IsTrue(fs.GetDirectoryInfo(@"SOMEDIR\CHILDDIR").Exists);
            Assert.IsTrue(fs.GetDirectoryInfo(@"SOMEDIR\CHILDDIR\").Exists);
            Assert.IsFalse(fs.GetDirectoryInfo(@"NONDIR").Exists);
            Assert.IsFalse(fs.GetDirectoryInfo(@"SOMEDIR\NONDIR").Exists);
        }