-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBackupFile.cs
50 lines (45 loc) · 1.48 KB
/
BackupFile.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using System;
using System.Collections.Generic;
using System.IO;
namespace SimpleBackup
{
/// <summary>
/// Stores file info
/// </summary>
public struct BackupFile
{
public string name;
public ulong fileSize;
public DateTime lastModified;
public BackupFile(string name, ulong fileSize, DateTime lastModified)
{
this.name = name;
this.fileSize = fileSize;
this.lastModified = lastModified;
}
public override bool Equals(object obj)
{
if (obj != null && obj.GetType() == typeof(BackupFile))
{
BackupFile fileData = (BackupFile)obj;
if (Path.GetFileName(fileData.name) == Path.GetFileName(name) && fileData.fileSize == fileSize && fileData.lastModified == lastModified)
{
return true;
}
}
return false;
}
public override int GetHashCode()
{
int hashCode = -1200454722;
hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(name);
hashCode = hashCode * -1521134295 + fileSize.GetHashCode();
hashCode = hashCode * -1521134295 + lastModified.GetHashCode();
return hashCode;
}
public override string ToString()
{
return "Name: " + name + ", File Size:" + fileSize + ", Last Modified: " + lastModified;
}
}
}