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 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; }
public bool Equals(ImageReferenceElement other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(string.Equals(Directory, other.Directory) && string.Equals(FileName, other.FileName) && string.Equals(CompletePath, other.CompletePath) && Size == other.Size && CreationTime.Equals(other.CreationTime) && LastWriteTime.Equals(other.LastWriteTime) && LastAccessTime.Equals(other.LastAccessTime)); }
public override int GetHashCode() { unchecked { int hashCode = Directory?.GetHashCode() ?? 0; hashCode = (hashCode * 397) ^ (FileName?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ (CompletePath?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ Size.GetHashCode(); hashCode = (hashCode * 397) ^ CreationTime.GetHashCode(); hashCode = (hashCode * 397) ^ LastWriteTime.GetHashCode(); hashCode = (hashCode * 397) ^ LastAccessTime.GetHashCode(); return(hashCode); } }
public override int GetHashCode() { unchecked { int hashCode = Directory != null?Directory.GetHashCode() : 0; hashCode = (hashCode * 397) ^ (FileName != null ? FileName.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (CompletePath != null ? CompletePath.GetHashCode() : 0); hashCode = (hashCode * 397) ^ Size.GetHashCode(); hashCode = (hashCode * 397) ^ CreationTime.GetHashCode(); hashCode = (hashCode * 397) ^ LastWriteTime.GetHashCode(); hashCode = (hashCode * 397) ^ LastAccessTime.GetHashCode(); return(hashCode); } }
public override int GetHashCode() { int hash = 1; if (Uuid.Length != 0) { hash ^= Uuid.GetHashCode(); } if (Attributes != 0) { hash ^= Attributes.GetHashCode(); } if (CreationTime != 0L) { hash ^= CreationTime.GetHashCode(); } if (LastAccessTime != 0L) { hash ^= LastAccessTime.GetHashCode(); } if (LastWriteTime != 0L) { hash ^= LastWriteTime.GetHashCode(); } if (Length != 0UL) { hash ^= Length.GetHashCode(); } if (Checksum.Length != 0) { hash ^= Checksum.GetHashCode(); } if (Id.Length != 0) { hash ^= Id.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
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(); }
protected override void Execute(NativeActivityContext context) { try { string filepath = FilePath.Get(context); var fileInfo = new FileInfo(filepath); FileName.Set(context, fileInfo.Name); FileExtension.Set(context, fileInfo.Extension); FileSize.Set(context, fileInfo.Length); CreationTime.Set(context, fileInfo.CreationTime); LastAccessTime.Set(context, fileInfo.LastAccessTime); LastWriteTime.Set(context, fileInfo.LastWriteTime); } catch (Exception ex) { Log.Logger.LogData(ex.Message + " in activity File_GetInformation", LogLevel.Error); if (!ContinueOnError) { context.Abort(); } } }
public override string ToString() { var sb = new StringBuilder(); sb.AppendLine("LXATTRB"); sb.AppendLine($"Format: 0x{Format:X}"); sb.AppendLine($"Version: 0x{Version:X}"); sb.AppendLine($"Mode: 0x{Mode:X}"); sb.AppendLine($"Uid/Gid: 0x{Uid:X}/0x{Gid:X}"); sb.AppendLine($"Device Id: 0x{DeviceId:X}"); //convert to seconds so we can use it later. //.net has no API for adding nanoseconds that works, so this is what we get var lastAccessSubSec = (LastAccessNanoSeconds / 1e+9).ToString(CultureInfo.InvariantCulture); var modifiedSubsec = (ModifiedNanoSeconds / 1e+9).ToString(CultureInfo.InvariantCulture); var inodeChangeSubsec = (InodeChangedNanoSeconds / 1e+9).ToString(CultureInfo.InvariantCulture); sb.AppendLine($"Last Access Time: {LastAccessTime.ToUniversalTime():yyyy-MM-dd HH:mm:ss}.{(lastAccessSubSec.Length>2 ? lastAccessSubSec.Substring(2) : "0000000")}"); sb.AppendLine($"Modified Time: {ModifiedTime.ToUniversalTime():yyyy-MM-dd HH:mm:ss}.{modifiedSubsec.Substring(2)}"); sb.AppendLine($"Inode Changed: {InodeChanged.ToUniversalTime():yyyy-MM-dd HH:mm:ss}.{inodeChangeSubsec.Substring(2)}"); return(sb.ToString()); }
protected override void Execute(NativeActivityContext context) { try { string folderpath = FolderPath.Get(context); if (Directory.Exists(folderpath)) { var folderInfo = new FileInfo(folderpath); var dirInfo = new DirectoryInfo(folderpath); FolderName.Set(context, folderInfo.Name); // FolderCount.Set(context, folderInfo.Extension); // FileCount.Set(context, folderInfo.Length); FolderCount.Set(context, dirInfo.GetDirectories().Length); FileCount.Set(context, dirInfo.GetFiles().Length); CreationTime.Set(context, folderInfo.CreationTime); LastAccessTime.Set(context, folderInfo.LastAccessTime); LastWriteTime.Set(context, folderInfo.LastWriteTime); } else if (!Directory.Exists(folderpath)) { Log.Logger.LogData("Folder does not exist in path - " + folderpath + " in activity Folder_GetInformation", LogLevel.Error); if (!ContinueOnError) { context.Abort(); } } } catch (Exception ex) { Log.Logger.LogData(ex.Message + " in activity Folder_GetInformation", LogLevel.Error); if (!ContinueOnError) { context.Abort(); } } }
/// <summary> /// Returns a byte array representing the current <see cref="SftpFileAttributes"/>. /// </summary> /// <returns> /// A byte array representing the current <see cref="SftpFileAttributes"/>. /// </returns> public byte[] GetBytes() { var stream = new SshDataStream(4); uint flag = 0; if (IsSizeChanged && IsRegularFile) { flag |= 0x00000001; } if (IsUserIdChanged || IsGroupIdChanged) { flag |= 0x00000002; } if (IsPermissionsChanged) { flag |= 0x00000004; } if (IsLastAccessTimeChanged || IsLastWriteTimeChanged) { flag |= 0x00000008; } if (IsExtensionsChanged) { flag |= 0x80000000; } stream.Write(flag); if (IsSizeChanged && IsRegularFile) { stream.Write((ulong)Size); } if (IsUserIdChanged || IsGroupIdChanged) { stream.Write((uint)UserId); stream.Write((uint)GroupId); } if (IsPermissionsChanged) { stream.Write(Permissions); } if (IsLastAccessTimeChanged || IsLastWriteTimeChanged) { var time = (uint)(LastAccessTime.ToFileTime() / 10000000 - 11644473600); stream.Write(time); time = (uint)(LastWriteTime.ToFileTime() / 10000000 - 11644473600); stream.Write(time); } if (IsExtensionsChanged) { foreach (var item in Extensions) { // TODO: we write as ASCII but read as UTF8 !!! stream.Write(item.Key, SshData.Ascii); stream.Write(item.Value, SshData.Ascii); } } return(stream.ToArray()); }
public bool Equals(DuplicateFileModel other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(LastWriteTime.Equals(other.LastWriteTime) && LastAccessTimeUtc.Equals(other.LastAccessTimeUtc) && LastAccessTime.Equals(other.LastAccessTime) && CreationTimeUtc.Equals(other.CreationTimeUtc) && CreationTime.Equals(other.CreationTime) && LastWriteTimeUtc.Equals(other.LastWriteTimeUtc) && string.Equals(FullName, other.FullName) && string.Equals(Name, other.Name) && string.Equals(HashValue, other.HashValue) && string.Equals(UniqueIdHashValue, other.UniqueIdHashValue) && IsMaster == other.IsMaster && Equals(DuplicateFiles, other.DuplicateFiles) && FileSize == other.FileSize); }
internal virtual string GetCsvLine() { return(GetItemType() + ",\"" + GetVolumeUserName() + "\",\"" + GetPath() + "\",\"" + Name + "\",\"" + Attributes.ToString() + "\"," + CreationTime.ToString() + ",\"" + Description + "\",\"" + Keywords + "\"," + LastAccessTime.ToString() + "," + LastWriteTime.ToString()); }
public void OnBeforeSerialize() { _filePath = FilePath; _lastAccessTime = LastAccessTime.ToString("O"); _expiresAt = ExpiresAt != null?ExpiresAt.Value.ToString("O") : null; }