예제 #1
0
        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;
        }
예제 #2
0
        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;
        }
예제 #3
0
        /* ----------------------------------------------------------------- */
        ///
        /// CreateNewPacket
        ///
        /// <summary>
        /// 送信用の新しいパケットを生成します。
        /// </summary>
        ///
        /* ----------------------------------------------------------------- */
        private byte[] CreateNewPacket()
        {
            var dest = new byte[_MinimumPacketSize];

            dest[0] = (byte)(_ClientLeapIndicator | _ClientVersion << 3 | _ClientMode);

            var timestamp = Timestamp.Convert(CreationTime.ToUniversalTime());
            var bytes     = BitConverter.GetBytes(IPAddress.HostToNetworkOrder(timestamp));

            Array.ConstrainedCopy(bytes, 0, dest, 40, 8);

            return(dest);
        }
예제 #4
0
        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();
        }
예제 #5
0
 public override string ToString()
 {
     return($"{CreationTime.ToUniversalTime():yyyy-MM-dd HH:mm:ss.fffffff}, OS Major: {OsMajor}, OS Minor: {OsMinor}, OS Build: {OsBuild}");
 }