-
Notifications
You must be signed in to change notification settings - Fork 0
/
rclone-fs.js
executable file
·106 lines (88 loc) · 2.23 KB
/
rclone-fs.js
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
const {RTime, RUnsupportedTime} = require('./utils');
class RObject {
constructor (obj) {
this.path = obj.Path;
this.name = obj.Name;
this.size = obj.Size;
this.mimetype = obj.MimeType;
this.isdir = obj.IsDir;
if(obj.ModTime) {
this.rtime = new RTime(obj.ModTime);
} else {
this.rtime = new RUnsupportedTime(obj.ModTime);
}
this.related = undefined;
}
parentOf(other_object) {
return other_object.path.startsWith(`${this.path}/`);
}
toJSON() {
return {
Path: this.path,
Name: this.name,
Size: this.size,
MimeType: this.mimetype,
IsDir: this.isdir,
ModTime: this.rtime.toJSON(),
};
}
toString() {
return `${this.constructor.name} {path: ${this.path}, isdir: ${this.isdir}}`;
}
}
class RFile extends RObject {
get type() {
return "file";
}
equals(other_object) {
if(other_object === undefined) {
return false;
}
return (other_object.constructor === RFile && this.path === other_object.path && this.size === other_object.size && this.rtime.equals(other_object.rtime));
}
}
class RDeletedFile extends RFile {
get type() {
return "deleted file";
}
equals(other_object) {
if(other_object === undefined) {
return true;
}
return (other_object.constructor === RDeletedFile && this.path === other_object.path);
}
}
class RDirectory extends RObject {
get type() {
return "directory";
}
equals(other_object) {
if(other_object === undefined) {
return false;
}
return (other_object.constructor === RDirectory && this.path === other_object.path);
}
}
class RDeletedDirectory extends RDirectory {
get type() {
return "deleted directory";
}
equals(other_object) {
if(other_object === undefined) {
return true;
}
return (other_object.constructor === RDeletedDirectory && this.path === other_object.path);
}
}
function fsobject_creator(raw_object) {
if(raw_object.IsDir) {
return new RDirectory(raw_object);
} else {
return new RFile(raw_object);
}
}
exports.fsobject_creator = fsobject_creator;
exports.RFile = RFile;
exports.RDirectory = RDirectory;
exports.RDeletedDirectory = RDeletedDirectory;
exports.RDeletedFile = RDeletedFile;