projects
/
org.ibex.core.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
b0ec2e1
)
update org.ibex.js.Directory for new api
author
brian
<brian@brianweb.net>
Tue, 6 Jul 2004 06:28:41 +0000
(06:28 +0000)
committer
brian
<brian@brianweb.net>
Tue, 6 Jul 2004 06:28:41 +0000
(06:28 +0000)
darcs-hash:
20040706062841
-24bed-
07f6fd6f121e8032c414f21e2cae6f6b55ab4c90
.gz
src/org/ibex/js/Directory.java
patch
|
blob
|
history
diff --git
a/src/org/ibex/js/Directory.java
b/src/org/ibex/js/Directory.java
index
1728e5b
..
bad28fa
100644
(file)
--- a/
src/org/ibex/js/Directory.java
+++ b/
src/org/ibex/js/Directory.java
@@
-43,8
+43,8
@@
public class Directory extends JS {
* Create the directory object. Existing directories will be
* preserved; if a file is present it will be obliterated.
*/
* Create the directory object. Existing directories will be
* preserved; if a file is present it will be obliterated.
*/
- // FIXME: Update this for new API
- /*public Directory(File f) throws IOException {
+
+ public Directory(File f) throws IOException {
this.f = f;
if (!f.exists()) new Directory(new File(f.getParent()));
if (!f.isDirectory()) destroy(f);
this.f = f;
if (!f.exists()) new Directory(new File(f.getParent()));
if (!f.isDirectory()) destroy(f);
@@
-60,34
+60,34
@@
public class Directory extends JS {
f.delete();
}
f.delete();
}
- public void put(Object key0, Object val) throws JSExn {
+ public void put(JS key0, JS val) throws JSExn {
try {
if (key0 == null) return;
String key = toString(key0);
File f2 = new File(f.getAbsolutePath() + File.separatorChar + FileNameEncoder.encode(key));
destroy(f2);
if (val == null) return;
try {
if (key0 == null) return;
String key = toString(key0);
File f2 = new File(f.getAbsolutePath() + File.separatorChar + FileNameEncoder.encode(key));
destroy(f2);
if (val == null) return;
- if (val instanceof JS) {
- Directory d2 = new Directory(f2);
- Enumeration e = ((JS)val).keys();
- while(e.hasMoreElements()) {
- String k = (String)e.nextElement();
- Object v = ((JS)val).get(k);
- d2.put(k, v);
- }
- } else {
+ if (val instanceof JSPrimitive) {
OutputStream out = new FileOutputStream(f2);
Writer w = new OutputStreamWriter(out);
w.write(toString(val));
w.flush();
out.close();
OutputStream out = new FileOutputStream(f2);
Writer w = new OutputStreamWriter(out);
w.write(toString(val));
w.flush();
out.close();
+ } else {
+ Directory d2 = new Directory(f2);
+ Enumeration e = ((JS)val).keys();
+ while(e.hasMoreElements()) {
+ JS k = (JS)e.nextElement();
+ JS v = val.get(k);
+ d2.put(k, v);
+ }
}
} catch (IOException ioe) {
throw new JSExn.IO(ioe);
}
}
}
} catch (IOException ioe) {
throw new JSExn.IO(ioe);
}
}
- public Object get(Object key0) throws JSExn {
+ public JS get(JS key0) throws JSExn {
try {
if (key0 == null) return null;
String key = toString(key0);
try {
if (key0 == null) return null;
String key = toString(key0);
@@
-99,7
+99,7
@@
public class Directory extends JS {
Reader r = new InputStreamReader(new FileInputStream(f2));
while(true) {
int numread = r.read(chars, numchars, chars.length - numchars);
Reader r = new InputStreamReader(new FileInputStream(f2));
while(true) {
int numread = r.read(chars, numchars, chars.length - numchars);
- if (numread == -1) return new String(chars, 0, numchars);
+ if (numread == -1) return JS.S(new String(chars, 0, numchars));
numchars += numread;
}
} catch (IOException ioe) {
numchars += numread;
}
} catch (IOException ioe) {
@@
-114,5
+114,5
@@
public class Directory extends JS {
public boolean hasMoreElements() { return i < elements.length; }
public Object nextElement() { return FileNameEncoder.decode(elements[i++]); }
};
public boolean hasMoreElements() { return i < elements.length; }
public Object nextElement() { return FileNameEncoder.decode(elements[i++]); }
};
- }*/
+ }
}
}