* Convert file names to absolute paths in serialize()/deserialize() to avoid

names being interpreted relative to root on Mac OS X.
This commit is contained in:
hns 2006-06-13 10:46:50 +00:00
parent 9eb4285880
commit 0ccb0f1010

View file

@ -653,8 +653,8 @@ public class GlobalObject extends ImporterTopLevel implements PropertyRecorder {
"the serialization to"); "the serialization to");
} }
Object obj = args[0]; Object obj = args[0];
String filename = Context.toString(args[1]); File file = new File(Context.toString(args[1])).getAbsoluteFile();
FileOutputStream fos = new FileOutputStream(filename); FileOutputStream fos = new FileOutputStream(file);
Scriptable scope = ScriptableObject.getTopLevelScope(thisObj).getPrototype(); Scriptable scope = ScriptableObject.getTopLevelScope(thisObj).getPrototype();
// use a ScriptableOutputStream that unwraps Wrappers // use a ScriptableOutputStream that unwraps Wrappers
ScriptableOutputStream out = new ScriptableOutputStream(fos, scope) { ScriptableOutputStream out = new ScriptableOutputStream(fos, scope) {
@ -679,8 +679,8 @@ public class GlobalObject extends ImporterTopLevel implements PropertyRecorder {
throw Context.reportRuntimeError( throw Context.reportRuntimeError(
"Expected a filename to read the serialization from"); "Expected a filename to read the serialization from");
} }
String filename = Context.toString(args[0]); File file = new File(Context.toString(args[0])).getAbsoluteFile();
FileInputStream fis = new FileInputStream(filename); FileInputStream fis = new FileInputStream(file);
Scriptable scope = ScriptableObject.getTopLevelScope(thisObj).getPrototype(); Scriptable scope = ScriptableObject.getTopLevelScope(thisObj).getPrototype();
ObjectInputStream in = new ScriptableInputStream(fis, scope); ObjectInputStream in = new ScriptableInputStream(fis, scope);
Object deserialized = in.readObject(); Object deserialized = in.readObject();