public FileSystem(MyDriveManager mdm) { super(); setMyDriveManager(mdm); super.setIdSeed(0); Root root = new Root(); this.addUsers(root); try { super.setFsRoot( new Directory(this.generateUniqueId(), PATH_DELIM, root.getUmask(), root, this)); } catch (InvalidFileNameException | InvalidMaskException e) { /* This exception should not occur it only exists to protect the method against * bad programming */ log.trace(e.getMessage()); e.printStackTrace(); } Directory home = new Directory(generateUniqueId(), HOME_DIR, root.getUmask(), root, getSlash()); addToSlash(home); Directory rootHomeDirectory = new Directory(generateUniqueId(), root.getUsername(), root.getUmask(), root, home); home.addFile(rootHomeDirectory); root.setHomeDirectory((Directory) home.getFileByName(ROOT_USER)); Guest guest = new Guest(); Directory guestHomeDirectory = new Directory(generateUniqueId(), guest.getUsername(), guest.getUmask(), guest, home); home.addFile(guestHomeDirectory); guest.setHomeDirectory((Directory) home.getFileByName(GUEST_USER)); addUsers(guest); }
/* Uniques Ids */ private int generateUniqueId() { Integer idSeed = super.getIdSeed(); super.setIdSeed(++idSeed); return idSeed; }