diff -r 7831c84cc644 -r 33924ff4af50 project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/util/FileUtils.java --- a/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/util/FileUtils.java Mon Aug 20 21:05:57 2012 +0200 +++ b/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/util/FileUtils.java Wed Aug 22 01:30:56 2012 +0200 @@ -71,21 +71,14 @@ } } - public static File getDataPathFile(Context c) throws FileNotFoundException { - return new File(getCachePath(c), ROOT_DIR); + public static File getDataPathFile(Context c, String...subpath) throws FileNotFoundException { + File file = new File(getCachePath(c), ROOT_DIR); + for(String pathcomponent : subpath) { + file = new File(file, pathcomponent); + } + return file; } - // TODO Several callers are unaware that this may fail, so it throws an RTE now. - // Should be handled better though. - @Deprecated - public static String getDataPath(Context c) { - try { - return getDataPathFile(c).getAbsolutePath()+"/"; - } catch(FileNotFoundException e) { - throw new RuntimeException(e); - } - } - @TargetApi(8) private static class FroyoSDCardDir{ public static File getDownloadPath(Context c){ @@ -113,7 +106,7 @@ * @throws FileNotFoundException If the sdcard is not available or the subdirectory "dirName" does not exist */ public static File[] getFilesFromRelativeDir(Context c, String dirName) throws FileNotFoundException { - File f = new File(getDataPathFile(c), dirName); + File f = getDataPathFile(c, dirName); if(f.isDirectory()) { return f.listFiles(); @@ -160,9 +153,9 @@ * Get all files from directory dir which have the given suffix * @throws FileNotFoundException If the sdcard is not available or the subdirectory "dir" does not exist */ - public static ArrayList getFileNamesFromDirWithSuffix(Context c, String dir, String suffix, boolean removeSuffix) throws FileNotFoundException{ + public static List getFileNamesFromDirWithSuffix(Context c, String dir, String suffix, boolean removeSuffix) throws FileNotFoundException{ File[] files = FileUtils.getFilesFromRelativeDir(c, dir); - ArrayList ret = new ArrayList(); + List ret = new ArrayList(); for(File file : files){ String s = file.getName(); if(s.endsWith(suffix)){