Example usage for org.apache.commons.lang SystemUtils IS_OS_WINDOWS

List of usage examples for org.apache.commons.lang SystemUtils IS_OS_WINDOWS

Introduction

In this page you can find the example usage for org.apache.commons.lang SystemUtils IS_OS_WINDOWS.

Prototype

boolean IS_OS_WINDOWS

To view the source code for org.apache.commons.lang SystemUtils IS_OS_WINDOWS.

Click Source Link

Document

Is true if this is Windows.

The field will return false if OS_NAME is null.

Usage

From source file:com.vmware.identity.interop.accountmanager.WinUserInfo4Native.java

public WinUserInfo4Native() {
    super(SystemUtils.IS_OS_WINDOWS ? W32APITypeMapper.UNICODE : null);
}

From source file:gmgen.util.MiscUtilities.java

/**
 *  Returns if the specified path name is an absolute path or URL.
 *
 *@param  path  a path//  ww w. j av a2 s.  com
 *@return       The absolute path
 *@since        GMGen 3.3
 */
public static boolean isAbsolutePath(String path) {
    if (isURL(path)) {
        return true;
    } else if (path.startsWith("~/") || path.startsWith("~" + File.separator) || path.equals("~")) {
        return true;
    } else if (SystemUtils.IS_OS_WINDOWS) {
        if ((path.length() == 2) && (path.charAt(1) == ':')) {
            return true;
        }

        if ((path.length() > 2) && (path.charAt(1) == ':') && (path.charAt(2) == '\\')) {
            return true;
        }

        if (path.startsWith("\\\\")) {
            return true;
        }
    } else if (SystemUtils.IS_OS_UNIX) {
        // nice and simple
        if ((path.length() > 0) && (path.charAt(0) == '/')) {
            return true;
        }
    }

    return false;
}

From source file:com.gs.obevo.util.inputreader.ConsoleInputReader.java

private boolean isWindows() {
    return SystemUtils.IS_OS_WINDOWS;
}

From source file:gndata.lib.srv.LocalFileTest.java

@Before
public void setUp() throws Exception {
    // create directories
    File testDirs = testFileFolderChild.toFile();
    FileUtils.forceMkdir(testDirs);//from  www .  ja  v  a 2  s.c o  m
    File parallelDir = testParallelFolder.toFile();
    FileUtils.forceMkdir(parallelDir);

    // create testfiles
    File testFile = testFileFolder.resolve(testFileName).toFile();
    FileUtils.write(testFile, "This is a normal test file");

    File testHiddenFile = testFileFolder.resolve("." + testFileName).toFile();
    FileUtils.write(testHiddenFile, "This is a hidden test file");

    //Set hidden attribute for Win OS systems
    if (SystemUtils.IS_OS_WINDOWS) {
        Files.setAttribute(Paths.get(testHiddenFile.getPath()), "dos:hidden", true);
    }

    localFile = new LocalFile(testLocalFilePath);

    localHiddenFile = new LocalFile(testFileFolder.resolve("." + testFileName));

    localDir = new LocalFile(testFileFolder);
}

From source file:com.kurento.test.selenium.MixerTst.java

private WebDriver createDriver(Class<? extends WebDriver> driverClass) {
    WebDriver driver = null;/*from ww w  . ja v  a  2 s.  c o m*/
    if (driverClass.equals(FirefoxDriver.class)) {
        driver = new FirefoxDriver();

    } else if (driverClass.equals(ChromeDriver.class)) {
        String chromedriver = null;
        if (SystemUtils.IS_OS_MAC || SystemUtils.IS_OS_LINUX) {
            chromedriver = "chromedriver";
        } else if (SystemUtils.IS_OS_WINDOWS) {
            chromedriver = "chromedriver.exe";
        }
        System.setProperty("webdriver.chrome.driver",
                new File("target/webdriver/" + chromedriver).getAbsolutePath());
        ChromeOptions options = new ChromeOptions();
        driver = new ChromeDriver(options);
    }
    return driver;
}

From source file:com.theoryinpractise.clojure.ClojureSwankMojo.java

public void execute() throws MojoExecutionException {
    StringBuilder sb = new StringBuilder();
    sb.append("(do ");
    sb.append("(swank.swank/start-server");
    sb.append(" :host \"").append(swankHost).append("\"");
    sb.append(" :port ");
    sb.append(Integer.toString(port));
    sb.append(" :encoding \"").append(encoding).append("\"");
    sb.append(" :dont-close true");
    sb.append("))");
    String swankLoader = sb.toString();

    if (SystemUtils.IS_OS_WINDOWS) {
        swankLoader = windowsEscapeCommandLineArg(swankLoader);
    }/*from  w  ww . j  a  va2 s.  co m*/

    List<String> args = new ArrayList<String>();
    if (replScript != null && new File(replScript).exists()) {
        args.add("-i");
        args.add(replScript);
    }

    args.add("-e");
    args.add("(require (quote swank.swank))");
    args.add("-e");
    args.add(swankLoader);

    callClojureWith(getSourceDirectories(SourceDirectory.TEST, SourceDirectory.COMPILE), outputDirectory,
            getRunWithClasspathElements(), "clojure.main", args.toArray(new String[args.size()]));

}

From source file:net.erdfelt.android.sdkfido.local.LocalAndroidPlatforms.java

/**
 * Attempt to find the local java sdk using the most common environment variables.
 * /*from  ww  w. java2s. c om*/
 * @return the local android java sdk directory
 * @throws IOException
 *             if unable to load the default local java sdk
 */
public static File findLocalJavaSdk() throws IOException {
    StringBuilder err = new StringBuilder();
    err.append("Unable to find the Local Android Java SDK Folder.");

    // Check Environment Variables First
    String envKeys[] = { "ANDROID_HOME", "ANDROID_SDK_ROOT" };
    for (String envKey : envKeys) {
        File sdkHome = getEnvironmentVariableDir(err, envKey);
        if (sdkHome == null) {
            continue; // skip, not found on that key
        }
        LocalAndroidPlatforms platforms = new LocalAndroidPlatforms(sdkHome);
        if (platforms.valid()) {
            return sdkHome;
        }
    }

    // Check Path for possible android.exe (or similar)
    List<String> searchBins = new ArrayList<String>();
    if (SystemUtils.IS_OS_WINDOWS) {
        searchBins.add("adb.exe");
        searchBins.add("emulator.exe");
        searchBins.add("android.exe");
    } else {
        searchBins.add("adb");
        searchBins.add("emulator");
        searchBins.add("android");
    }

    String pathParts[] = StringUtils.split(System.getenv("PATH"), File.pathSeparatorChar);
    for (String searchBin : searchBins) {
        err.append("\nSearched PATH for ").append(searchBin);
        for (String pathPart : pathParts) {
            File pathDir = new File(pathPart);
            LOG.fine("Searching Path: " + pathDir);
            File bin = new File(pathDir, searchBin);
            if (bin.exists() && bin.isFile() && bin.canExecute()) {
                File homeDir = bin.getParentFile().getParentFile();
                LOG.fine("Possible Home Dir: " + homeDir);
                LocalAndroidPlatforms platforms = new LocalAndroidPlatforms(homeDir);
                if (platforms.valid) {
                    return homeDir;
                }
            }
        }
        err.append(", not found.");
    }

    throw new FileNotFoundException(err.toString());
}

From source file:com.asakusafw.bulkloader.testutil.UnitTestUtil.java

public static void setUpBeforeClass() throws Exception {
    targetDir.mkdir();/*  www  . j  a v a 2s  .  co m*/
    if (!SystemUtils.IS_OS_WINDOWS) {
        ProcessBuilder pb = new ProcessBuilder("chmod", "777", targetDir.getAbsolutePath());
        pb.start();
    }
}

From source file:com.ecyrd.jspwiki.util.ProviderConverter.java

protected String mangleName(String pagename) {
    pagename = TextUtil.urlEncode(pagename, "UTF-8");

    pagename = TextUtil.replaceString(pagename, "/", "%2F");

    if (SystemUtils.IS_OS_WINDOWS) {
        String pn = pagename.toLowerCase();
        for (int i = 0; i < WINDOWS_DEVICE_NAMES.length; i++) {
            if (WINDOWS_DEVICE_NAMES[i].equals(pn)) {
                pagename = "$$$" + pagename;
            }/*from w  w  w .j  a  v  a 2s .  c o  m*/
        }
    }

    return pagename;
}

From source file:jp.ikedam.jenkins.plugins.extensible_choice_parameter.FilenameChoiceListProviderJenkinsTest.java

@Test
public void testGetBaseDir() {
    // relative path
    {/*from w  w w.  j ava2  s. c  o m*/
        String path = "path/relative";
        File test = FilenameChoiceListProvider.getBaseDir(path);
        File expect = new File(Jenkins.getInstance().getRootDir(), path);
        assertEquals("relative path must start from JENKINS_HOME", expect, test);
    }

    // absolute path
    {
        String path = (SystemUtils.IS_OS_WINDOWS) ? "C:\\path\\abosolute" : "/path/absolute";
        File test = FilenameChoiceListProvider.getBaseDir(path);
        File expect = new File(path);
        assertEquals("absolute path must be treat as is.", expect, test);
    }
}