VirtualFile (ApplyPatchContext context, final String[] pathNameComponents, final int lastComponentToFind) { VirtualFile patchedDir = context.getBaseDir(); for (int i = context.getSkipTopDirs(); i < lastComponentToFind; i++) { VirtualFile nextChild; if (pathNameComponents[i].equals("..")) { nextChild = patchedDir.getParent(); } else { nextChild = patchedDir.findChild(pathNameComponents[i]); } if (nextChild == null) { if (context.isCreateDirectories()) { try { nextChild = patchedDir.createChildDirectory(null, pathNameComponents[i]); } catch (IOException e) { return null; } } else { return null; } } patchedDir = nextChild; } return patchedDir; }