-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a3c1efe
commit c34d964
Showing
5 changed files
with
55 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 5 additions & 20 deletions
25
src/main/java/io/github/biligoldenwater/midiplayer/modules/GetMidis.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,22 @@ | ||
package io.github.biligoldenwater.midiplayer.modules; | ||
|
||
import io.github.biligoldenwater.midiplayer.MidiPlayer; | ||
|
||
import java.io.File; | ||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
public class GetMidis { | ||
public static List<File> getMidis(String path) { | ||
public static List<File> getMidis(File path) { | ||
List<File> midis = new ArrayList<>(); | ||
File musics = new File(path); | ||
|
||
if(musics.exists() && !musics.isDirectory()){ | ||
if (!musics.delete()){ | ||
MidiPlayer.getInstance().getLogger().warning("Fail to delete a same name file for musics folder."); | ||
} | ||
} | ||
|
||
if(!musics.exists()){ | ||
if (!musics.mkdir()){ | ||
MidiPlayer.getInstance().getLogger().warning("Fail to create musics folder."); | ||
} | ||
} | ||
|
||
String[] musicNames = musics.list(); | ||
File[] musicNames = path.listFiles(); | ||
|
||
if (musicNames == null || musicNames.length < 1){ | ||
return midis; | ||
} | ||
|
||
for(String fileName : musicNames){ | ||
midis.add(new File(path+"\\"+fileName)); | ||
} | ||
Collections.addAll(midis, musicNames); | ||
|
||
return midis; | ||
} | ||
} |