internal SMBFileInfo(string path, IFileSystem fileSystem, FileBasicInformation fileBasicInformation, FileStandardInformation fileStandardInformation, ISMBCredential credential) : this(path, fileSystem) { if (fileBasicInformation.CreationTime.Time.HasValue) { _creationTime = fileBasicInformation.CreationTime.Time.Value; _creationTimeUtc = CreationTime.ToUniversalTime(); } if (fileBasicInformation.LastAccessTime.Time.HasValue) { _lastAccessTime = fileBasicInformation.LastAccessTime.Time.Value; _lastAccessTimeUtc = LastAccessTime.ToUniversalTime(); } if (fileBasicInformation.LastWriteTime.Time.HasValue) { _lastWriteTime = fileBasicInformation.LastWriteTime.Time.Value; _lastWriteTimeUtc = LastWriteTime.ToUniversalTime(); } _attributes = (System.IO.FileAttributes)fileBasicInformation.FileAttributes; var parentPath = _fileSystem.Path.GetDirectoryName(path); _directory = _dirInfoFactory.FromDirectoryName(parentPath, credential); _directoryName = parentPath; _exists = _file.Exists(path); _isReadOnly = fileBasicInformation.FileAttributes.HasFlag(SMBLibrary.FileAttributes.ReadOnly); _length = fileStandardInformation.EndOfFile; }
internal SMBFileInfo(string path, IFileSystem fileSystem, FileBasicInformation fileBasicInformation, FileStandardInformation fileStandardInformation, ISMBCredential credential) : this(path, fileSystem) { if (fileBasicInformation.CreationTime.Time.HasValue) { _creationTime = fileBasicInformation.CreationTime.Time.Value; _creationTimeUtc = CreationTime.ToUniversalTime(); } if (fileBasicInformation.LastAccessTime.Time.HasValue) { _lastAccessTime = fileBasicInformation.LastAccessTime.Time.Value; _lastAccessTimeUtc = LastAccessTime.ToUniversalTime(); } if (fileBasicInformation.LastWriteTime.Time.HasValue) { _lastWriteTime = fileBasicInformation.LastWriteTime.Time.Value; _lastWriteTimeUtc = LastWriteTime.ToUniversalTime(); } _attributes = (System.IO.FileAttributes)fileBasicInformation.FileAttributes; var pathUri = new Uri(path); var parentUri = pathUri.AbsoluteUri.EndsWith('/') ? new Uri(pathUri, "..") : new Uri(pathUri, "."); var parentPathString = parentUri.IsUnc ? parentUri.LocalPath : parentUri.AbsoluteUri; _directory = _dirInfoFactory.FromDirectoryName(parentPathString, credential); _directoryName = Directory?.Name; _exists = _file.Exists(path); _isReadOnly = fileBasicInformation.FileAttributes.HasFlag(SMBLibrary.FileAttributes.ReadOnly); _length = fileStandardInformation.EndOfFile; }
internal SMBDirectoryInfo(string fileName, FileInformation fileInfo, IFileSystem fileSystem, ISMBCredentialProvider credentialProvider, ISMBCredential credential) : this(fileName, fileSystem, credentialProvider) { FileBasicInformation fileDirectoryInformation = (FileBasicInformation)fileInfo; if (fileDirectoryInformation.CreationTime.Time.HasValue) { _creationTime = fileDirectoryInformation.CreationTime.Time.Value; _creationTimeUtc = CreationTime.ToUniversalTime(); } if (fileDirectoryInformation.LastAccessTime.Time.HasValue) { _lastAccessTime = fileDirectoryInformation.LastAccessTime.Time.Value; _lastAccessTimeUtc = LastAccessTime.ToUniversalTime(); } if (fileDirectoryInformation.LastWriteTime.Time.HasValue) { _lastWriteTime = fileDirectoryInformation.LastWriteTime.Time.Value; _lastWriteTimeUtc = LastWriteTime.ToUniversalTime(); } _parent = _smbDirectory.GetParent(fileName, credential); _fileSystem = fileSystem; var pathRoot = _fileSystem.Path.GetPathRoot(fileName); if (pathRoot != fileName) { _root = _directoryInfoFactory.FromDirectoryName(pathRoot, credential); } else { _root = this; } _exists = _fileSystem.Directory.Exists(FullName); _extension = string.Empty; _name = _fullName.GetLastPathSegment().RemoveLeadingAndTrailingSeperators(); }