19 package org.sleuthkit.autopsy.coreutils;
22 import java.io.IOException;
24 import java.util.concurrent.TimeUnit;
25 import java.util.logging.Level;
26 import org.apache.commons.lang3.SystemUtils;
40 if (xdgSupported == null) {
42 if (SystemUtils.IS_OS_LINUX) {
44 xdgSupported = Runtime.getRuntime().exec(
new String[]{
"which",
"xdg-open"}).getInputStream().read() != -1;
45 }
catch (IOException ex) {
46 LOGGER.log(Level.WARNING,
"There was an error running 'which xdg-open' ", ex);
68 if (instance == null) {
69 instance =
new Desktop(java.awt.Desktop.getDesktop());
92 private void xdgOpen(String path)
throws IOException {
93 Process process = Runtime.getRuntime().exec(
new String[]{
"xdg-open", path});
95 process.waitFor(XDG_TIMEOUT_SECS, TimeUnit.SECONDS);
96 }
catch (InterruptedException ex) {
97 throw new IOException(
"xdg-open timed out", ex);
99 int exitCode = process.exitValue();
101 throw new IOException(
"Received non-zero exit code from xdg-open: " + exitCode);
111 public void browse(URI uri)
throws IOException {
125 public void open(File file)
throws IOException {
127 xdgOpen(file.getAbsolutePath());
139 public void edit(File file)
throws IOException {
141 xdgOpen(file.getAbsolutePath());
static Boolean xdgSupported
void xdgOpen(String path)
static boolean isXdgSupported()
static final Logger LOGGER
static final long XDG_TIMEOUT_SECS
final java.awt.Desktop awtDesktop
Desktop(java.awt.Desktop awtDesktop)
synchronized static Logger getLogger(String name)
static boolean isDesktopSupported()
static Desktop getDesktop()