diff options
Diffstat (limited to 'sched/src/com/android/sched/util/file/Directory.java')
-rw-r--r-- | sched/src/com/android/sched/util/file/Directory.java | 44 |
1 files changed, 40 insertions, 4 deletions
diff --git a/sched/src/com/android/sched/util/file/Directory.java b/sched/src/com/android/sched/util/file/Directory.java index 0ea2f60..0af9fe9 100644 --- a/sched/src/com/android/sched/util/file/Directory.java +++ b/sched/src/com/android/sched/util/file/Directory.java @@ -45,10 +45,46 @@ public class Directory extends FileOrDirectory { NotDirectoryException, FileAlreadyExistsException, CannotCreateFileException { + + this(new File(name), new DirectoryLocation(name), hooks, existence, permissions, change); + } + + public Directory(@CheckForNull Directory workingDirectory, + @Nonnull String string, + @CheckForNull RunnableHooks runnableHooks, + @Nonnull Existence existence, + int permissions, + @Nonnull ChangePermission change) + throws NotDirectoryException, + WrongPermissionException, + CannotSetPermissionException, + NoSuchFileException, + FileAlreadyExistsException, + CannotCreateFileException { + this(getFileFromWorkingDirectory(workingDirectory, string), + new DirectoryLocation(string), + runnableHooks, + existence, + permissions, + change); + } + + private Directory(@Nonnull File file, + @Nonnull DirectoryLocation location, + @CheckForNull RunnableHooks hooks, + @Nonnull Existence existence, + int permissions, + @Nonnull ChangePermission change) + throws WrongPermissionException, + CannotSetPermissionException, + NoSuchFileException, + NotDirectoryException, + FileAlreadyExistsException, + CannotCreateFileException { super(hooks); - this.file = new File(name); - this.location = new DirectoryLocation(name); + this.file = file; + this.location = location; if (existence == Existence.MAY_EXIST) { if (file.exists()) { @@ -60,7 +96,7 @@ public class Directory extends FileOrDirectory { switch (existence) { case MUST_EXIST: - Directory.check(file, (DirectoryLocation) location); + Directory.check(file, location); FileOrDirectory.checkPermissions(file, location, permissions); break; case NOT_EXIST: @@ -127,4 +163,4 @@ public class Directory extends FileOrDirectory { public String getPath() { return file.getPath(); } -}
\ No newline at end of file +} |