How can I make OS X recognize drive letters?

Possible duplicate:
How can I make OS X recognize drive letters?

I know. Heresy. But I am attached. I have many configuration files that use absolute path names, which creates incompatibility between OS X and Windows. If I can get OS X (which I make the bet more flexible of the two) to recognize “Q: /foo/bar/bim.properties” as a valid absolute file name, it will save me some days of spelunking through stack traces and configuration files .

In the end, I need this bit of Java test code to print “SUCCESS!”. at startup:

import java.io. *;
class DriveLetterTest {
  static public void main (String ... args) {
    File f = new File ("S:");
    if (f.isDirectory ()) {
      System.out.println ("SUCCESS!");
    }
    else {
      System.out.println ("FAIL!");
    }
  }
}

Does anyone know how to do this?

0
source share
1 answer

If you do not want to change your configuration file for each OS, what are they intended for?

Each installation should have its own set of configuration files and use it accordingly.

But if you insist, you just need to determine the OS version, and if not Windows, ignore the letter:

Something along the lines of:

boolean isWindows = System.getProperty("os.name")
                     .toLowerCase().contains("windows"); 

String folder = "S:";
if( isWindows && folder.matches("\\w:") {
     folder = "/";
 } else if( isWindows && folder.matches("\\w:.+)) {
     folder = folder.substring(2);// ignoring the first two letters S:
 }

You get the idea

0
source

Source: https://habr.com/ru/post/1754858/


All Articles