-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIDirectory.cs
50 lines (44 loc) · 1.46 KB
/
IDirectory.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;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.IO;
namespace johnshope.Sync {
public enum ObjectClass { File, Directory }
public class FileOrDirectory {
public SyncJob Job { get; set; }
public FileOrDirectory Parent { get; set; }
public string RelativePath { get { if (Parent == null) return Name; else return Parent.RelativePath + "/" + Name; } }
public string Name;
public ObjectClass Class;
public DateTime Changed;
public DateTime ChangedUtc { get { return Changed.ToUniversalTime(); } set { Changed = value.ToLocalTime(); } }
public long Size;
}
public class DirectoryListing : KeyedCollection<string, FileOrDirectory> {
public DirectoryListing() : base() { }
public DirectoryListing(IEnumerable<FileOrDirectory> list): this() {
foreach (var e in list) {
try { Add(e); } catch { }
}
}
protected override string GetKeyForItem(FileOrDirectory item) {
return item.Name;
}
}
public interface IDirectory {
SyncJob Job { get; set; }
Uri Url { get; set; }
DirectoryListing List();
void WriteFile(Stream file, FileOrDirectory src);
Stream ReadFile(FileOrDirectory src);
void Delete(FileOrDirectory dest);
void DeleteFile(FileOrDirectory dest);
void DeleteDirectory(FileOrDirectory dest);
IDirectory CreateDirectory(FileOrDirectory src);
IDirectory Source { get; set; }
IDirectory Destination { get; set; }
}
}