private boolean createFile(String rawPath, boolean tmp) { String parent = new File(rawPath).getParent(); boolean created = createFolder(parent); if (!created) { return false; } VFolder folder = (VFolder) findFSObject(parent); VFile file = new VFile(rawPath, folder); folder.addChild(file); if (!tmp) { markAccessedFile(file.getPath()); } return true; }
public boolean createFolder(String rawPath) { String[] tokens = tokenize(new File(rawPath).getAbsolutePath()); VFolder parent = root; for (String name : tokens) { if (!parent.isReadPermission() || !parent.isWritePermission() || parent.isDeleted()) { return false; } VFolder folder = null; if (!parent.hasChild(name)) { String path = null; if (isUnixStyle() || !parent.isRoot()) { path = parent.getPath() + File.separator + name; } else { // this means we are in Windows, and that we are considering a direct child of the root path = name; } folder = new VFolder(path, parent); } else { FSObject child = parent.getChild(name); if (!child.isFolder()) { return false; } folder = (VFolder) child; } parent.addChild(folder); parent = folder; } markAccessedFile(parent.getPath()); return true; }