Ticket #599 (new Task)
Identify a device by label, not drive letter (windows)
| Reported by: | bflorat | Owned by: | bflorat |
|---|---|---|---|
| Priority: | 5, normal | Milestone: | To Be Decided by Jajuk Team |
| Component: | Core | Version: | 1.3.10 |
| Keywords: | collection | Cc: |
Description
Under windows, identify a drive by partition label, not only the drive letter to allow using the same PATH (M:\music) for instance for different drives.
Get label: Runtime runtime = Runtime.getRuntime(); Process p = runtime.exec("cmd.exe /c dir d:"); BufferedReader? br = new BufferedReader?(new InputStreamReader?(p.getInputStream())); String volume = br.readLine(); Matcher matcher = Pattern.compile("(\\s)*Volume in drive \\w is (\\w|\\p{Punct})*").matcher(volume); if (matcher.find()) {
volume = volume.substring(matcher.start(), matcher.end()); volume = volume.replaceAll("(\\s)*Volume in drive \\w is ","");
} else if (Pattern.compile("Volume in drive \\w has no label").matcher(volume).find()) {
volume = null;
}
