branch = "master"; String path = getRelativePath(rootDir, file).replace("\\", "/"); String mimeType = Files.getMimeType(file); FileInfo answer = new FileInfo(path, file.getName(), file.lastModified(), file.length(), file.isDirectory(), mimeType); if (file.isFile()) { String name = file.getName(); if (uris.size() > 0) { String[] namespaces = uris.toArray(new String[uris.size()]); answer.setXmlNamespaces(namespaces); if (icons != null && icons.length > 0) { File icon = icons[0]; String relativePath = getRelativePath(rootDir, icon); if (!relativePath.startsWith("/")) { relativePath = "/" + relativePath;
protected FileInfo doExists(Git git, File rootDir, String branch, String pathOrEmpty, final boolean caseSensitive) throws GitAPIException { checkoutBranch(git, branch); final String path = Strings.isBlank(pathOrEmpty) ? "/" : pathOrEmpty; File file = getFile(rootDir, path); File parent = file.getParentFile(); // need to list the files, so we can grab the actual file name File[] files = parent.listFiles(new FileFilter() { String match = new File(caseSensitive ? path : path.toLowerCase(Locale.US)).getName(); @Override public boolean accept(File pathname) { String name = caseSensitive ? pathname.getName() : pathname.getName().toLowerCase(Locale.US); return match.equals(name); } }); if (files != null && files.length == 1) { return FileInfo.createFileInfo(rootDir, files[0], branch); } return null; }
buffer.append("\": "); buffer.append(text); children.add(FileInfo.createFileInfo(rootDir, child, branch));
/** * Reads the file contents from the currently checked out branch */ protected FileContents doRead(Git git, File rootDir, String branch, String pathOrEmpty) throws IOException, GitAPIException { checkoutBranch(git, branch); String path = Strings.isBlank(pathOrEmpty) ? "/" : pathOrEmpty; File file = getFile(rootDir, path); if (file.isFile()) { String contents = IOHelper.readFully(file); return new FileContents(false, contents, null); } else { List<FileInfo> children = new ArrayList<FileInfo>(); if (file.exists()) { File[] files = file.listFiles(); for (File child : files) { if (!isIgnoreFile(child)) { children.add(FileInfo.createFileInfo(rootDir, child, branch)); } } } return new FileContents(file.isDirectory(), null, children); } }