< prev index next >
src/java.desktop/share/classes/com/sun/media/sound/SoftSynthesizer.java
Print this page
@@ -636,11 +636,11 @@
actions.add(new PrivilegedAction<InputStream>() {
public InputStream run() {
File javahome = new File(System.getProperties()
.getProperty("java.home"));
File libaudio = new File(new File(javahome, "lib"), "audio");
- if (libaudio.exists()) {
+ if (libaudio.isDirectory()) {
File foundfile = null;
File[] files = libaudio.listFiles();
if (files != null) {
for (int i = 0; i < files.length; i++) {
File file = files[i];
@@ -684,13 +684,13 @@
/*
* Look for a default.sf2
*/
for (File systemSoundFontDir : systemSoundFontsDir) {
- if (systemSoundFontDir.exists()) {
+ if (systemSoundFontDir.isDirectory()) {
File defaultSoundFont = new File(systemSoundFontDir, "default.sf2");
- if (defaultSoundFont.exists()) {
+ if (defaultSoundFont.isFile()) {
try {
return new FileInputStream(defaultSoundFont);
} catch (IOException e) {
// continue with lookup
}
@@ -706,11 +706,11 @@
public InputStream run() {
if (System.getProperties().getProperty("os.name")
.startsWith("Windows")) {
File gm_dls = new File(System.getenv("SystemRoot")
+ "\\system32\\drivers\\gm.dls");
- if (gm_dls.exists()) {
+ if (gm_dls.isFile()) {
try {
return new FileInputStream(gm_dls);
} catch (IOException e) {
}
}
@@ -726,11 +726,11 @@
*/
File userhome = new File(System.getProperty("user.home"),
".gervill");
File emg_soundbank_file = new File(userhome,
"soundbank-emg.sf2");
- if (emg_soundbank_file.exists()) {
+ if (emg_soundbank_file.isFile()) {
try {
return new FileInputStream(emg_soundbank_file);
} catch (IOException e) {
}
}
@@ -771,16 +771,18 @@
OutputStream out = AccessController
.doPrivileged((PrivilegedAction<OutputStream>) () -> {
try {
File userhome = new File(System
.getProperty("user.home"), ".gervill");
- if (!userhome.exists()) {
- userhome.mkdirs();
+ if (!userhome.isDirectory()) {
+ if (!userhome.mkdirs()) {
+ return null;
+ }
}
File emg_soundbank_file = new File(
userhome, "soundbank-emg.sf2");
- if (emg_soundbank_file.exists()) {
+ if (emg_soundbank_file.isFile()) {
return null;
}
return new FileOutputStream(emg_soundbank_file);
} catch (final FileNotFoundException ignored) {
}
< prev index next >