public void OpenGlobalDosDeviceDirectory() { using (var directory = HandleMethods.OpenDirectoryObject(@"\Global??")) { directory.IsInvalid.Should().BeFalse(); } }
public void OpenCDriveSymbolicLink() { using (var link = HandleMethods.OpenSymbolicLinkObject(@"\??\C:")) { link.IsInvalid.Should().BeFalse(); } }
public void OpenRootDirectory() { using (var directory = HandleMethods.OpenDirectoryObject(@"\")) { directory.IsInvalid.Should().BeFalse(); } }
public void GetTargetForCDriveSymbolicLink() { using (var link = HandleMethods.OpenSymbolicLinkObject(@"\??\C:")) { string target = HandleMethods.GetSymbolicLinkTarget(link); target.Should().StartWith(@"\Device\"); } }
public void GetHandleTypeBasic() { string tempPath = FileMethods.GetTempPath(); using (var directory = DirectoryMethods.CreateDirectoryHandle(tempPath)) { string name = HandleMethods.GetObjectType(directory); name.Should().Be("File"); } }
public void GetRootDirectoryEntries() { using (var directory = HandleMethods.OpenDirectoryObject(@"\")) { IEnumerable <ObjectInformation> objects = HandleMethods.GetDirectoryEntries(directory); objects.Should().NotBeEmpty(); objects.Should().Contain(new ObjectInformation { Name = "Device", TypeName = "Directory" }); } }
public void GetHandleNameBasic() { string tempPath = FileMethods.GetTempPath(); using (var directory = DirectoryMethods.CreateDirectoryHandle(tempPath)) { // This will give back the NT path (\Device\HarddiskVolumen...) string name = HandleMethods.GetObjectName(directory); // Skip past the C:\ Paths.AddTrailingSeparator(name).Should().EndWith(tempPath.Substring(3)); } }
public void NoMoreFiles() { _info = null; if (_pending == null || _pending.Count == 0) { _lastEntryFound = true; } else { // Grab the next directory to parse var next = _pending.Dequeue(); HandleMethods.CloseHandle(_directory); _directory = next.Item1; _path = next.Item2; FindNextFile(); } }
public void QueryDosVolumePathBasic() { string tempPath = FileMethods.GetTempPath(); using (var directory = DirectoryMethods.CreateDirectoryHandle(tempPath)) { // This will give back the NT path (\Device\HarddiskVolumen...) string fullName = HandleMethods.GetObjectName(directory); string fileName = FileMethods.GetFileName(directory); string deviceName = fullName.Substring(0, fullName.Length - fileName.Length); string dosVolumePath = DeviceMethods.QueryDosVolumePath(deviceName); tempPath.Should().StartWith(dosVolumePath); tempPath.Should().Be(dosVolumePath + fileName + @"\"); } }
protected void Dispose(bool disposing) { HeapBuffer buffer = Interlocked.Exchange(ref _buffer, null); if (buffer != null) { StringBuffer.Cache.Release((StringBuffer)buffer); } var queue = Interlocked.Exchange(ref _pending, null); if (queue != null) { while (queue.Count > 0) { HandleMethods.CloseHandle(queue.Dequeue().Item1); } } HandleMethods.CloseHandle(_directory); }
public void GetPipeObjectInfo() { var fileHandle = FileMethods.CreateFileSystemIo( @"\\.\pipe\", 0, // We don't care about read or write, we're just getting metadata with this handle System.IO.FileShare.ReadWrite, System.IO.FileMode.Open, 0, FileFlags.OpenReparsePoint // To avoid traversing links | FileFlags.BackupSemantics); // To open directories string name = HandleMethods.GetObjectName(fileHandle); name.Should().Be(@"\Device\NamedPipe\"); string typeName = HandleMethods.GetObjectType(fileHandle); typeName.Should().Be(@"File"); string fileName = FileMethods.GetFileName(fileHandle); fileName.Should().Be(@"\"); }
public void GetPipeObjectInfoNoTrailingSlash() { var fileHandle = FileMethods.CreateFileSystemIo( @"\\.\pipe", 0, // We don't care about read or write, we're just getting metadata with this handle System.IO.FileShare.ReadWrite, System.IO.FileMode.Open, 0, FileFlags.OpenReparsePoint // To avoid traversing links | FileFlags.BackupSemantics); // To open directories string name = HandleMethods.GetObjectName(fileHandle); name.Should().Be(@"\Device\NamedPipe"); string typeName = HandleMethods.GetObjectType(fileHandle); typeName.Should().Be(@"File"); // Not sure why this is- probably the source of why so many other things go wrong Action action = () => FileMethods.GetFileName(fileHandle); action.ShouldThrow <ArgumentException>().And.HResult.Should().Be(unchecked ((int)0x80070057)); }
protected override bool ReleaseHandle() { HandleMethods.CloseHandle(handle); return(true); }