-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathFile.js
executable file
·76 lines (72 loc) · 2.21 KB
/
File.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
function File(szName,szContent){
this.name = szName;
this.content = szContent;
this.position = 0;
this.length = szContent.length;
this.fileType = "File";
this.accessGroup = [];
this.acl = new acl();
//Set default permissions for a new file.
this.acl.setUserRead(true);
this.acl.setUserWrite(true);
this.acl.setUserExecute(true);
this.acl.setGroupRead(true);
this.acl.setGroupWrite(true);
this.acl.setOtherRead(true);
//this.accessGroup.push(OS.Users["Super"]);
this.accessGroup.push(CurrentUserSingleton.getInstance());
this.fileOwner = CurrentUserSingleton.getInstance(); //The person who is currently logged in gets to be the file owner.
//Added date object to file definition.
this.date = new Date(); //new Date(); creates a date object with the current date/time.
this.setDate = function (ObjDate){
this.date = ObjDate;
}
this.accessDate = function(){
return this.date;
}
this.isName = function (szName) {
return this.name === szName;
}
this.accessName = function(){
return this.name;
}
this.accessContent = function(){
return this.content;
}
this.accessPosition = function(){
return this.position;
}
this.accessLength = function(){
return this.length;
}
this.mutatePosition = function(nPosition) {
this.position = nPosition;
}
this.mutateContent = function(szNewContent){
this.content = szNewContent;
}
this.getKind = function(){
return this.fileType;
}
this.getOwner = function(){
return this.fileOwner;
}
this.setOwner = function(newOwner){
this.fileOwner = newOwner;
}
//I have a feeling this function will not work, becuase of the bad usage of this?>
this.removeFromAccessGroup = function(userObject){
var aGroup = this.accessGroup;
this.accessGroup.forEach(function(element,index,array)
{
if(element.getUserName == userObject.getUserName)
{
aGroup.splice(index, 1);
}
});
return aGroup;
}
this.addToAccessGroup = function (userObject){
this.accessGroup.push(userObject);
}
}