mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-11 20:35:50 +00:00
Bug 785124 - Pt 7 - Fix nsIncrementalDownload to work on sdcard. r=jduell
This fixes the nsIncrementalDownload to work on the sdcard on the B2G emulator.
This commit is contained in:
parent
9139c75270
commit
4ecee878ca
@ -40,7 +40,30 @@ static nsresult
|
||||
WriteToFile(nsIFile *lf, const char *data, uint32_t len, int32_t flags)
|
||||
{
|
||||
PRFileDesc *fd;
|
||||
nsresult rv = lf->OpenNSPRFileDesc(flags, 0600, &fd);
|
||||
int32_t mode = 0600;
|
||||
nsresult rv;
|
||||
#if defined(MOZ_WIDGET_GONK)
|
||||
// The sdcard on a B2G phone looks like:
|
||||
// d---rwx--- system sdcard_rw 1970-01-01 01:00:00 sdcard
|
||||
// On the emulator, xpcshell fails when using 0600 mode to open the file,
|
||||
// and 0660 works.
|
||||
nsCOMPtr<nsIFile> parent;
|
||||
rv = lf->GetParent(getter_AddRefs(parent));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
uint32_t parentPerm;
|
||||
rv = parent->GetPermissions(&parentPerm);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
if ((parentPerm & 0700) == 0) {
|
||||
// Parent directory has no owner-write, so try to use group permissions
|
||||
// instead of owner permissions.
|
||||
mode = 0660;
|
||||
}
|
||||
#endif
|
||||
rv = lf->OpenNSPRFileDesc(flags, mode, &fd);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user