diff options
author | Narayan Kamath <narayan@google.com> | 2014-02-14 14:54:00 +0000 |
---|---|---|
committer | Narayan Kamath <narayan@google.com> | 2014-02-17 15:36:51 +0000 |
commit | 5fecee2da855e92afbcba3a231f4685a56f17967 (patch) | |
tree | 83cd797baec23ac0777cc00919a22a1061bdda86 /luni | |
parent | 71eec8821710d08047ac1bff44fa5b5362ae39cb (diff) | |
download | libcore-5fecee2da855e92afbcba3a231f4685a56f17967.zip libcore-5fecee2da855e92afbcba3a231f4685a56f17967.tar.gz libcore-5fecee2da855e92afbcba3a231f4685a56f17967.tar.bz2 |
Remove use of file absolute paths.
An absolute path is derived from a relative path by
appending the value of "user.dir" to it. "user.dir" is
populated by the VM by calling getcwd(3). All apps
forked from zygote end up with a "user.dir" (and a current
working directory) value of "/".
This, along with change 417621196b855 (which prevents
"user.dir" from being changed by apps) will make file handling
a lot more consistent. In particular 417621196 ensures that
- The output of getAbsolutePath can never change for a given
relative path.
- File.getPath() and File.getAbsolutePath() become interchangeable
wrt. lower level (Libcore.os) APIs.
Change-Id: I5598a2b1c5de65b59d69324f98656ffe031290f0
Diffstat (limited to 'luni')
-rw-r--r-- | luni/src/main/java/java/io/FileInputStream.java | 2 | ||||
-rw-r--r-- | luni/src/main/java/java/io/FileOutputStream.java | 2 | ||||
-rw-r--r-- | luni/src/main/java/java/io/RandomAccessFile.java | 2 |
3 files changed, 3 insertions, 3 deletions
diff --git a/luni/src/main/java/java/io/FileInputStream.java b/luni/src/main/java/java/io/FileInputStream.java index b2e620f..644f749 100644 --- a/luni/src/main/java/java/io/FileInputStream.java +++ b/luni/src/main/java/java/io/FileInputStream.java @@ -75,7 +75,7 @@ public class FileInputStream extends InputStream { if (file == null) { throw new NullPointerException("file == null"); } - this.fd = IoBridge.open(file.getAbsolutePath(), O_RDONLY); + this.fd = IoBridge.open(file.getPath(), O_RDONLY); this.shouldClose = true; guard.open("close"); } diff --git a/luni/src/main/java/java/io/FileOutputStream.java b/luni/src/main/java/java/io/FileOutputStream.java index e04ab5f..f5ba11e 100644 --- a/luni/src/main/java/java/io/FileOutputStream.java +++ b/luni/src/main/java/java/io/FileOutputStream.java @@ -85,7 +85,7 @@ public class FileOutputStream extends OutputStream { throw new NullPointerException("file == null"); } this.mode = O_WRONLY | O_CREAT | (append ? O_APPEND : O_TRUNC); - this.fd = IoBridge.open(file.getAbsolutePath(), mode); + this.fd = IoBridge.open(file.getPath(), mode); this.shouldClose = true; this.guard.open("close"); } diff --git a/luni/src/main/java/java/io/RandomAccessFile.java b/luni/src/main/java/java/io/RandomAccessFile.java index a60da3e..6e88fe0 100644 --- a/luni/src/main/java/java/io/RandomAccessFile.java +++ b/luni/src/main/java/java/io/RandomAccessFile.java @@ -115,7 +115,7 @@ public class RandomAccessFile implements DataInput, DataOutput, Closeable { throw new IllegalArgumentException("Invalid mode: " + mode); } this.mode = flags; - this.fd = IoBridge.open(file.getAbsolutePath(), flags); + this.fd = IoBridge.open(file.getPath(), flags); // if we are in "rws" mode, attempt to sync file+metadata if (syncMetadata) { |