1 package com.tapina.robe.swi.os;
2
3 import com.tapina.robe.swi.OS;
4
5 import java.util.Date;
6
7 /***
8 * This class represents a directory entry.
9 */
10 public class DirectoryEntry {
11 public static final int ATTRIBUTE_OWNER_READ = 0x01;
12 public static final int ATTRIBUTE_OWNER_WRITE = 0x02;
13 public static final int ATTRIBUTE_LOCKED = 0x08;
14 public static final int ATTRIBUTE_OTHERS_READ = 0x10;
15 public static final int ATTRIBUTE_OTHERS_WRITE = 0x10;
16 public static final int ATTRIBUTE_HIDDEN = 0x10;
17 public static final int TYPE_NOT_FOUND = 0;
18 public static final int TYPE_FILE = 1;
19 public static final int TYPE_DIRECTORY = 2;
20 public static final int TYPE_IMAGE = 3;
21
22 int loadAddress;
23 int execAddress;
24 int length;
25 int attributes;
26 int objectType;
27 int internalName;
28 Date timestamp;
29 String name;
30
31 public DirectoryEntry() {
32 }
33
34 public DirectoryEntry(int loadAddress, int execAddress, int length, int attributes, int objectType, int internalName, Date timestamp, String name) {
35 this.loadAddress = loadAddress;
36 this.execAddress = execAddress;
37 this.length = length;
38 this.attributes = attributes;
39 this.objectType = objectType;
40 this.internalName = internalName;
41 this.timestamp = timestamp;
42 this.name = name;
43 }
44
45 public DirectoryEntry(String name, Date date, long length, int attributes, int type) {
46 this.length = (int) length;
47 this.attributes = attributes;
48 this.objectType = type;
49 this.internalName = name.hashCode();
50 this.timestamp = date;
51 this.name = name;
52 long fiveByteTime = OS.convertTo5ByteTime(date);
53 this.execAddress = (int) (fiveByteTime & 0xffffffff);
54 this.loadAddress = (int) ((fiveByteTime & 0xff00000000L) >> 32) | 0xfffffd00;
55 }
56
57 public DirectoryEntry(String name, int loadAddress, int execAddress, int attributes) {
58 this.attributes = attributes;
59 this.internalName = name.hashCode();
60 final long fiveByteTime = (execAddress | ((long) loadAddress << 32)) & 0xffffffffffL;
61 this.timestamp = OS.convertToDate(fiveByteTime);
62 this.name = name;
63 this.execAddress = execAddress;
64 this.loadAddress = loadAddress;
65 }
66
67 public int getLoadAddress() {
68 return loadAddress;
69 }
70
71 public void setLoadAddress(int loadAddress) {
72 this.loadAddress = loadAddress;
73 }
74
75 public int getExecAddress() {
76 return execAddress;
77 }
78
79 public void setExecAddress(int execAddress) {
80 this.execAddress = execAddress;
81 }
82
83 public int getLength() {
84 return length;
85 }
86
87 public void setLength(int length) {
88 this.length = length;
89 }
90
91 public int getAttributes() {
92 return attributes;
93 }
94
95 public void setAttributes(int attributes) {
96 this.attributes = attributes;
97 }
98
99 public int getObjectType() {
100 return objectType;
101 }
102
103 public void setObjectType(int objectType) {
104 this.objectType = objectType;
105 }
106
107 public int getInternalName() {
108 return internalName;
109 }
110
111 public void setInternalName(int internalName) {
112 this.internalName = internalName;
113 }
114
115 public Date getTimestamp() {
116 return timestamp;
117 }
118
119 public void setTimestamp(Date timestamp) {
120 this.timestamp = timestamp;
121 }
122
123 public String getName() {
124 return name;
125 }
126
127 public void setName(String name) {
128 this.name = name;
129 }
130 }