Bug 765498 - Device Storage - Gaia - ensure /sdcard is backed by a file system. r=dhylands

--HG--
extra : rebase_source : c36eaa86566f7b7bd6eeefbcbc0622ec99a33816
This commit is contained in:
Doug Turner 2012-07-18 11:31:05 -07:00
parent 9ec92252b8
commit e1404f76ef

View File

@ -25,6 +25,10 @@
// Microsoft's API Name hackery sucks
#undef CreateEvent
#ifdef MOZ_WIDGET_GONK
#include "nsIVolumeService.h"
#endif
using namespace mozilla::dom;
using namespace mozilla::dom::devicestorage;
@ -270,15 +274,26 @@ nsDOMDeviceStorage::SetRootFileForType(const nsAString& aType, const PRInt32 aIn
NS_ASSERTION(dirService, "Must have directory service");
#ifdef MOZ_WIDGET_GONK
// check that /sdcard exists, if it doesn't go no further.
NS_NewLocalFile(NS_LITERAL_STRING("/sdcard"), false, getter_AddRefs(f));
bool check = false;
f->Exists(&check);
if (!check) {
mFile = nsnull;
mFile = nsnull;
nsCOMPtr<nsIVolumeService> vs = do_GetService(NS_VOLUMESERVICE_CONTRACTID);
if (!vs) {
return typeResult;
}
nsCOMPtr<nsIVolume> v;
vs->GetVolumeByPath(NS_LITERAL_STRING("/sdcard"), getter_AddRefs(v));
if (!v) {
return typeResult;
}
PRInt32 state;
v->GetState(&state);
if (state != nsIVolume::STATE_MOUNTED) {
return typeResult;
}
f = nsnull;
#endif
// Picture directory