summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenoit Lamarche <benoitlamarche@google.com>2015-01-28 11:36:34 +0100
committerBenoit Lamarche <benoitlamarche@google.com>2015-01-28 12:14:21 +0100
commit73890c412de49c8db37c26666c7acc4e7f3a41f1 (patch)
tree42fa17c6c5bce4c7b0148446bdb6d2e20a9de0e5
parentcd249c047652f968e9f46352b93dcefbcb8abda1 (diff)
downloadtoolchain_jack-73890c412de49c8db37c26666c7acc4e7f3a41f1.zip
toolchain_jack-73890c412de49c8db37c26666c7acc4e7f3a41f1.tar.gz
toolchain_jack-73890c412de49c8db37c26666c7acc4e7f3a41f1.tar.bz2
Use getVDir before createVDir in PrefixedVFS
When using directly createVDir we may have a CannotCreateFileException because we don'te have write permissions, even if the VDir already exists. Using getVDir first allows to get a CannotCreateFileException only if we don't have writ epermissions and the VDir does not already exist. Change-Id: Ie3e3969ca383a8d365228474a812183c41bd7f21
-rw-r--r--sched/src/com/android/sched/vfs/PrefixedFS.java13
1 files changed, 11 insertions, 2 deletions
diff --git a/sched/src/com/android/sched/vfs/PrefixedFS.java b/sched/src/com/android/sched/vfs/PrefixedFS.java
index 018c6f2..af1c14b 100644
--- a/sched/src/com/android/sched/vfs/PrefixedFS.java
+++ b/sched/src/com/android/sched/vfs/PrefixedFS.java
@@ -41,9 +41,18 @@ public class PrefixedFS extends BaseVFS<BaseVDir, BaseVFile> implements VFS {
private final BaseVDir rootDir;
@SuppressWarnings("unchecked")
- public PrefixedFS(@Nonnull VFS vfs, @Nonnull VPath prefix) throws CannotCreateFileException {
+ public PrefixedFS(@Nonnull VFS vfs, @Nonnull VPath prefix) throws CannotCreateFileException,
+ NotDirectoryException {
this.vfs = (BaseVFS<BaseVDir, BaseVFile>) vfs;
- rootDir = this.vfs.getRootDir().createVDir(prefix);
+
+ BaseVDir rootDir;
+ // let's try to get the VDir before creating it because we not have write permissions.
+ try {
+ rootDir = this.vfs.getRootDir().getVDir(prefix);
+ } catch (NoSuchFileException e) {
+ rootDir = this.vfs.getRootDir().createVDir(prefix);
+ }
+ this.rootDir = rootDir;
}
@Override