Feature/json
# Conflicts: # control/GameStateManager.java # image/Images.java # main/Window.java # model/gameState/MenuState.java
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
package audio.io;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import audio.Song;
|
||||
|
||||
public class DirScanner {
|
||||
|
||||
public static List<Song> scanDirectories(File f)
|
||||
{
|
||||
List<Song> songs = new ArrayList<Song>();
|
||||
|
||||
if(!f.isDirectory())
|
||||
return songs;
|
||||
|
||||
FileFilter dirs = new FileFilter()
|
||||
{
|
||||
public boolean accept(File e) {
|
||||
if(e.isDirectory())
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
};
|
||||
FileFilter csf = new FileFilter()
|
||||
{
|
||||
public boolean accept(File e) {
|
||||
if(e.isFile() && e.getName().endsWith(".csf"))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
for(File file : f.listFiles(dirs))
|
||||
{
|
||||
for(File file2 : file.listFiles(csf))
|
||||
{
|
||||
try {
|
||||
Song s = JSONReader.readSong(file2);
|
||||
songs.add(s);
|
||||
} catch (IOException e1) {
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return songs;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user