diff --git a/app/src/main/java/lightcontainer/storage/AppData.java b/app/src/main/java/lightcontainer/storage/AppData.java index ba10605..88b245e 100644 --- a/app/src/main/java/lightcontainer/storage/AppData.java +++ b/app/src/main/java/lightcontainer/storage/AppData.java @@ -129,4 +129,18 @@ public class AppData { return this.users.get(user.getName()).deleteFile(fileName); } } + + /** + * @param user The user who wants to add a storage for their file + * @param file The file that needs a new storage + * @param storage The storage to add + * @return True if the storage was added. False otherwise. + */ + public boolean addStorage(User user, File file, String storage) { + if (!this.users.containsKey(user.getName())) { + return false; + } else { + return this.users.get(user.getName()).addStorage(file, storage); + } + } } diff --git a/app/src/main/java/lightcontainer/storage/User.java b/app/src/main/java/lightcontainer/storage/User.java index 1623703..683fb07 100644 --- a/app/src/main/java/lightcontainer/storage/User.java +++ b/app/src/main/java/lightcontainer/storage/User.java @@ -69,4 +69,17 @@ public class User { return false; } } + + /** + * @param file The file that needs a storage + * @param storage The storage name + * @return True if the storage was added to the file. False otherwise. + */ + public boolean addStorage(File file, String storage) { + if (this.files.containsKey(file.getName())) { + return file.addStorage(storage); + } else { + return false; + } + } }