SDL: check that SD card is writable before writing there on fresh install

This commit is contained in:
pelya
2016-05-17 12:36:27 +03:00
parent 723e0524ac
commit 2bc39e57ba
4 changed files with 20 additions and 4 deletions

View File

@@ -441,6 +441,14 @@ class Settings
for( String s: fileList )
if( s.toUpperCase().startsWith(DataDownloader.DOWNLOAD_FLAG_FILENAME.toUpperCase()) )
Globals.DataDir = SdcardAppPath.getPath(p);
try {
new File(Globals.DataDir).mkdirs();
new FileOutputStream( new File(Globals.DataDir, ".nomedia") ).close();
} catch (Exception e) {
Globals.DownloadToSdcard = false; // SD card not writable
Globals.DataDir = p.getFilesDir().getAbsolutePath();
}
}
}
@@ -795,6 +803,14 @@ class Settings
continue;
StatFs stat = new StatFs(path.getPath());
long size = (long)stat.getAvailableBlocks() * stat.getBlockSize() / 1024 / 1024;
try {
path.mkdirs();
new FileOutputStream( new File(path, ".nomedia") ).close();
} catch (Exception e) {
size = -1; // Not writable
}
if( size > maxSize )
{
maxSize = size;