/// <summary> /// /// </summary> /// <returns></returns> public override int GetHashCode() { unchecked { int hashCode = (Code != null ? Code.GetHashCode() : 0); hashCode = (hashCode * 397) ^ Existed.GetHashCode(); hashCode = (hashCode * 397) ^ (Text != null ? Text.GetHashCode() : 0); hashCode = (hashCode * 397) ^ LastWriteTime.GetHashCode(); hashCode = (hashCode * 397) ^ (Owner != null ? Owner.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Editor != null ? Editor.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Title != null ? Title.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Version != null ? Version.GetHashCode() : 0); hashCode = (hashCode * 397) ^ Published.GetHashCode(); hashCode = (hashCode * 397) ^ (Locker != null ? Locker.GetHashCode() : 0); 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(); }
public override ListViewItem ToListViewItem() { ListViewItem lvi = new ListViewItem(); lvi.Text = Name; lvi.Tag = this; lvi.ImageIndex = Win32.GetFolderIconIndex("", Win32.FileIconSize.Small); lvi.SubItems.Add(string.Empty); lvi.SubItems.Add(CreationTime.ToString("g")); lvi.SubItems.Add(LastWriteTime.ToString("g")); lvi.SubItems.Add(Attributes.ToString()); lvi.SubItems.Add(Keywords); lvi.SubItems.Add(Extension); lvi.SubItems.Add(GetVolumeUserName()); lvi.SubItems.Add(GetPath()); lvi.SubItems.Add(string.Empty); return(lvi); }
/// <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()); }
protected async override Task <Action <AsyncCodeActivityContext> > ExecuteAsync(AsyncCodeActivityContext context, CancellationToken token) { var folder = Folder.Get(context); var patterns = SearchPattern?.GetAsArray <string>(context) ?? new[] { "*" }; var lastWriteTime = LastWriteTime?.Get(context) ?? DateTime.Now; int filesDeleted = 0; int foldersDeleted = 0; await Task.Run(() => { foreach (var p in patterns) { foreach (var f in Directory.EnumerateFiles(folder, p, SearchOption.AllDirectories).Reverse()) { try { if (File.GetLastWriteTime(f) > lastWriteTime) { continue; } File.Delete(f); filesDeleted++; } catch (Exception e) { Trace.WriteLine($"{f}: {e.Message}"); } } } if (DeleteEmptyFolders) { foreach (var f in Directory.EnumerateDirectories(folder, "*", SearchOption.AllDirectories).Reverse()) { if (Directory.EnumerateFileSystemEntries(f, "*").Any()) { continue; } try { Directory.Delete(f); foldersDeleted++; } catch (Exception e) { Trace.WriteLine($"{f}: {e.Message}"); } } } }).ConfigureAwait(false); return(ctx => { Result.Set(ctx, new CleanUpFolderResult { FilesDeleted = filesDeleted, FoldersDeleted = foldersDeleted }); }); }
public string ToString(string sep) { return(string.Join(sep, new string[] { Name, FileSize.ToString(), LastWriteTime.ToString(), HashString, FileVersion, ProductVersion, BuildDateTime.ToString(), LinkerVersion })); }
/// <summary> /// /// </summary> /// <param name="other"></param> /// <returns></returns> protected bool Equals(WikiPage other) { return(string.Equals(Code, other.Code) && Existed.Equals(other.Existed) && string.Equals(Text, other.Text) && LastWriteTime.Equals(other.LastWriteTime) && string.Equals(Owner, other.Owner) && string.Equals(Editor, other.Editor) && string.Equals(Title, other.Title) && string.Equals(Version, other.Version) && Published.Equals(other.Published) && string.Equals(Locker, other.Locker)); }
public bool Equals(IncludeCacheEntry other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(File == other.File && ParsedSuccessfully == other.ParsedSuccessfully && LastWriteTime.Equals(other.LastWriteTime) && BaseDirectory == other.BaseDirectory && Equals(Types, other.Types) && Equals(Includes, other.Includes)); }