public TSInterleavedFile(FileInfo fileInfo) { FileInfo = fileInfo; DFileInfo = null; _cdReader = null; Name = fileInfo.Name.ToUpper(); }
public void FileInfo() { FatFileSystem fs = FatFileSystem.FormatFloppy(new MemoryStream(), FloppyDiskType.HighDensity, "FLOPPY_IMG "); DiscFileInfo fi = fs.GetFileInfo(@"SOMEDIR\SOMEFILE.TXT"); Assert.IsNotNull(fi); }
public static Stream OpenPsPath(SessionState session, string filePath, FileAccess access, FileShare share) { var items = session.InvokeProvider.Item.Get(filePath); if (items.Count == 1) { FileInfo itemAsFile = items[0].BaseObject as FileInfo; if (itemAsFile != null) { return(itemAsFile.Open(FileMode.Open, access, share)); } DiscFileInfo itemAsDiscFile = items[0].BaseObject as DiscFileInfo; if (itemAsDiscFile != null) { return(itemAsDiscFile.Open(FileMode.Open, access)); } throw new FileNotFoundException("Path is not a file", filePath); } else if (items.Count > 1) { throw new IOException(string.Format(CultureInfo.InvariantCulture, "PowerShell path {0} is ambiguous", filePath)); } else { throw new FileNotFoundException("No such file", filePath); } }
public TSInterleavedFile(DiscFileInfo fileInfo, UdfReader reader) { DFileInfo = fileInfo; FileInfo = null; _cdReader = reader; Name = fileInfo.Name.ToUpper(); }
public TSStreamClipFile(FileInfo fileInfo) { FileInfo = fileInfo; DFileInfo = null; CdReader = null; Name = fileInfo.Name.ToUpper(); }
protected override void RenameItem(string path, string newName) { object obj = FindItemByPath(Utilities.NormalizePath(path), true, false); DiscFileSystemInfo fsiObj = obj as DiscFileSystemInfo; if (fsiObj == null) { WriteError(new ErrorRecord( new InvalidOperationException("Cannot move items to this location"), "BadParentForNewItem", ErrorCategory.InvalidArgument, newName)); return; } string newFullName = Path.Combine(Path.GetDirectoryName(fsiObj.FullName.TrimEnd('\\')), newName); if (obj is DiscDirectoryInfo) { DiscDirectoryInfo dirObj = (DiscDirectoryInfo)obj; dirObj.MoveTo(newFullName); } else { DiscFileInfo fileObj = (DiscFileInfo)obj; fileObj.MoveTo(newFullName); } }
private VfsEntry ResolveParent(DiscFileInfo file, VfsEntry root) { var targetEntryName = file.Name; var pathParts = file.FullName.Split(Path.DirectorySeparatorChar, StringSplitOptions.RemoveEmptyEntries); VfsEntry currentEntry = root; foreach (var part in pathParts) { if (part == targetEntryName) { break; } if (!currentEntry.TryGetChild(part, out var targetEntry)) { var targetPath = Path.Combine(currentEntry.FullPath, part); var targetDirectory = _isoReader.GetDirectoryInfo(targetPath); targetEntry = new Iso9960Directory(targetDirectory, this, currentEntry); } currentEntry = targetEntry; } return(currentEntry); }
public void MoveFile(NewFileSystemDelegate fsFactory) { DiscFileSystem fs = fsFactory(); DiscFileInfo fi = fs.GetFileInfo("foo.txt"); using (Stream s = fi.Create()) { for (int i = 0; i < 10; ++i) { s.Write(new byte[111], 0, 111); } } fi.Attributes = FileAttributes.Hidden | FileAttributes.System; fi.MoveTo("foo2.txt"); fi = fs.GetFileInfo("foo2.txt"); Assert.True(fi.Exists); Assert.Equal(1110, fi.Length); Assert.Equal(FileAttributes.Hidden | FileAttributes.System, fi.Attributes); fi = fs.GetFileInfo("foo.txt"); Assert.False(fi.Exists); }
public void FileInfo() { CDBuilder builder = new CDBuilder(); CDReader fs = new CDReader(builder.Build(), false); DiscFileInfo fi = fs.GetFileInfo(@"SOMEDIR\SOMEFILE.TXT"); Assert.NotNull(fi); }
public TSStreamClipFile(DiscFileInfo fileInfo, UdfReader reader) { DFileInfo = fileInfo; FileInfo = null; CdReader = reader; Name = fileInfo.Name.ToUpper(); }
public void Open_FileNotFound() { CDBuilder builder = new CDBuilder(); CDReader fs = new CDReader(builder.Build(), false); DiscFileInfo di = fs.GetFileInfo("foo.txt"); using (Stream s = di.Open(FileMode.Open)) { } }
public void Attributes_ChangeType(NewFileSystemDelegate fsFactory) { DiscFileSystem fs = fsFactory(); DiscFileInfo fi = fs.GetFileInfo("foo.txt"); using (Stream s = fi.Open(FileMode.Create)) { } Assert.Throws <ArgumentException>(() => fi.Attributes = fi.Attributes | FileAttributes.Directory); }
public void Open_DirExists(NewFileSystemDelegate fsFactory) { DiscFileSystem fs = fsFactory(); fs.CreateDirectory("FOO.TXT"); DiscFileInfo di = fs.GetFileInfo("foo.txt"); Assert.Throws <IOException>(() => di.Open(FileMode.Create)); }
private void WriteFileToArchive(string entryName, DiscFileInfo file) { var tmptext = entryName.Substring(0, 1) + ":" + entryName.Substring(1); Console.WriteLine("Collecting File: {0}", tmptext); using (var stream = file.Open(FileMode.Open, FileAccess.Read)) { WriteStreamToArchive(entryName, stream); } }
public TSPlaylistFile( BDROM bdrom, FileInfo fileInfo) { BDROM = bdrom; FileInfo = fileInfo; DFileInfo = null; CdReader = null; Name = fileInfo.Name.ToUpper(); }
public void Open_Read_Fail(NewFileSystemDelegate fsFactory) { DiscFileSystem fs = fsFactory(); DiscFileInfo di = fs.GetFileInfo("foo.txt"); using (Stream s = di.Open(FileMode.Create, FileAccess.Read)) { Assert.Throws <IOException>(() => s.WriteByte(1)); } }
public TSPlaylistFile( BDROM bdrom, DiscFileInfo fileInfo, UdfReader reader) { BDROM = bdrom; DFileInfo = fileInfo; FileInfo = null; CdReader = reader; Name = fileInfo.Name.ToUpper(); }
internal Iso9960File(DiscFileInfo file, VfsDevice device, VfsEntry parent = null) : base(SanitizeFileName(file.Name), device, parent) { _file = file; Attributes = file.Attributes; DateAccessed = file.LastAccessTimeUtc; DateCreated = file.CreationTimeUtc; DateModified = file.LastWriteTimeUtc; Size = file.Length; }
public void Attributes() { CDBuilder builder = new CDBuilder(); builder.AddFile("foo.txt", new byte[] { 1 }); CDReader fs = new CDReader(builder.Build(), false); DiscFileInfo fi = fs.GetFileInfo("foo.txt"); // Check default attributes Assert.AreEqual(FileAttributes.ReadOnly, fi.Attributes); }
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.AreEqual(fs.GetDirectoryInfo(@"SOMEDIR\ADIR"), fi.Parent); Assert.AreEqual(fs.GetDirectoryInfo(@"SOMEDIR\ADIR"), fi.Directory); }
public void Parent(NewFileSystemDelegate fsFactory) { DiscFileSystem fs = fsFactory(); fs.CreateDirectory(@"SOMEDIR\ADIR"); using (Stream s = fs.OpenFile(@"SOMEDIR\ADIR\FILE.TXT", FileMode.Create)) { } DiscFileInfo fi = fs.GetFileInfo(@"SOMEDIR\ADIR\FILE.TXT"); Assert.Equal(fs.GetDirectoryInfo(@"SOMEDIR\ADIR"), fi.Parent); Assert.Equal(fs.GetDirectoryInfo(@"SOMEDIR\ADIR"), fi.Directory); }
public void Open_FileNotFound(NewFileSystemDelegate fsFactory) { DiscFileSystem fs = fsFactory(); DiscFileInfo di = fs.GetFileInfo("foo.txt"); Assert.Throws <FileNotFoundException>(() => { using (Stream s = di.Open(FileMode.Open)) { } }); }
public void Open_Write(NewFileSystemDelegate fsFactory) { DiscFileSystem fs = fsFactory(); DiscFileInfo di = fs.GetFileInfo("foo.txt"); using (Stream s = di.Open(FileMode.Create, FileAccess.Write)) { Assert.True(s.CanWrite); Assert.False(s.CanRead); s.WriteByte(1); } }
/// <summary> /// /// </summary> /// <param name="A"></param> /// <param name="B"></param> /// <param name="Style"></param> /// <returns>True if A and B are equivalent.</returns> private static bool CompareFile(DiscFileInfo A, DiscFileInfo B, ComparisonStyle Style = ComparisonStyle.DateTimeOnly) { if (A == null || B == null) { return(A == B); } lock (A.FileSystem) lock (B.FileSystem) if (!A.Exists || !B.Exists) { return(false); } if (Style == ComparisonStyle.Journaled) { if (A.FileSystem is NtfsFileSystem) { lock (A.FileSystem) lock (B.FileSystem) { var An = A.FileSystem as NtfsFileSystem; var Bn = (NtfsFileSystem)(B.FileSystem); long Aid = (long)(An.GetFileId(A.FullName) & 0x0000ffffffffffff); long Bid = (long)(Bn.GetFileId(B.FullName) & 0x0000ffffffffffff); return(An.GetMasterFileTable()[Aid].LogFileSequenceNumber == Bn.GetMasterFileTable()[Bid].LogFileSequenceNumber); } } else { throw new ArgumentException("Journal comparison only functions on NTFS partitions.", "Style"); } } bool LenCheck, WriteCheck; lock (A.FileSystem) lock (B.FileSystem) { LenCheck = A.Length == B.Length; WriteCheck = A.LastWriteTimeUtc == B.LastWriteTimeUtc; } return(LenCheck && (Style == ComparisonStyle.NameOnly || (Style == ComparisonStyle.BinaryOnly ? FilesMatch(A, B) : (WriteCheck && (Style == ComparisonStyle.DateTimeOnly || FilesMatch(A, B)))))); }
public DirectoryEntryViewModel(DiscFileInfo fileInfo) { FileInfo = fileInfo; Name = fileInfo.Name; try { Size = fileInfo.Length; } catch (Exception e) { Debug.WriteLine(e); Size = null; } }
public void Open_FileNotFound() { CDBuilder builder = new CDBuilder(); CDReader fs = new CDReader(builder.Build(), false); DiscFileInfo di = fs.GetFileInfo("foo.txt"); Assert.Throws <FileNotFoundException>(() => { using (Stream s = di.Open(FileMode.Open)) { } }); }
public void Exists(NewFileSystemDelegate fsFactory) { DiscFileSystem fs = fsFactory(); DiscFileInfo fi = fs.GetFileInfo("foo.txt"); Assert.False(fi.Exists); using (Stream s = fi.Open(FileMode.Create)) { } Assert.True(fi.Exists); fs.CreateDirectory("dir.txt"); Assert.False(fs.GetFileInfo("dir.txt").Exists); }
public void DeleteFile(NewFileSystemDelegate fsFactory) { DiscFileSystem fs = fsFactory(); using (Stream s = fs.GetFileInfo("foo.txt").Open(FileMode.Create, FileAccess.ReadWrite)) { } Assert.Equal(1, fs.Root.GetFiles().Length); DiscFileInfo fi = fs.GetFileInfo("foo.txt"); fi.Delete(); Assert.Equal(0, fs.Root.GetFiles().Length); }
public void LastAccessTime(NewFileSystemDelegate fsFactory) { DiscFileSystem fs = fsFactory(); using (Stream s = fs.OpenFile("foo.txt", FileMode.Create)) { } DiscFileInfo fi = fs.GetFileInfo("foo.txt"); DateTime baseTime = DateTime.Now - TimeSpan.FromDays(2); fi.LastAccessTime = baseTime; using (Stream s = fs.OpenFile("foo.txt", FileMode.Open, FileAccess.Read)) { } Assert.True(baseTime < fi.LastAccessTime); }
public void LastWriteTime(NewFileSystemDelegate fsFactory) { DiscFileSystem fs = fsFactory(); using (Stream s = fs.OpenFile("foo.txt", FileMode.Create)) { } DiscFileInfo fi = fs.GetFileInfo("foo.txt"); DateTime baseTime = DateTime.Now - TimeSpan.FromMinutes(10); fi.LastWriteTime = baseTime; using (Stream s = fs.OpenFile("foo.txt", FileMode.Open)) { s.WriteByte(1); } Assert.True(baseTime < fi.LastWriteTime); }