bug 1174704 - Implement GetUserDataDirectoryHome for iOS. r=froydnj

This commit is contained in:
Ted Mielczarek 2015-03-18 22:23:28 -04:00
parent 94337e6cfe
commit f0b352a2e0
4 changed files with 48 additions and 0 deletions

View File

@ -0,0 +1,13 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef TOOLKIT_XRE_UIKITDIRPROVIDER_H_
#define TOOLKIT_XRE_UIKITDIRPROVIDER_H_
#include "nsString.h"
bool GetUIKitDirectory(bool aLocal, nsACString& aUserDir);
#endif // TOOLKIT_XRE_UIKITDIRPROVIDER_H_

View File

@ -0,0 +1,19 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include <Foundation/Foundation.h>
#include "UIKitDirProvider.h"
bool GetUIKitDirectory(bool aLocal, nsACString& aUserDir)
{
NSSearchPathDirectory directory = aLocal ? NSCachesDirectory : NSApplicationSupportDirectory;
NSArray* paths = NSSearchPathForDirectoriesInDomains(directory, NSUserDomainMask, YES);
if ([paths count] == 0) {
return false;
}
aUserDir = [[paths objectAtIndex:0] UTF8String];
return true;
}

View File

@ -40,6 +40,11 @@ elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
'MacLaunchHelper.mm',
'nsNativeAppSupportCocoa.mm',
]
elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'uikit':
UNIFIED_SOURCES += [
'nsNativeAppSupportDefault.cpp',
'UIKitDirProvider.mm',
]
elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'qt':
EXPORTS += ['nsQAppInstance.h']
SOURCES += [

View File

@ -52,6 +52,9 @@
#ifdef XP_UNIX
#include <ctype.h>
#endif
#ifdef XP_IOS
#include "UIKitDirProvider.h"
#endif
#if defined(XP_MACOSX)
#define APP_REGISTRY_NAME "Application Registry"
@ -1235,6 +1238,14 @@ nsXREDirProvider::GetUserDataDirectoryHome(nsIFile** aFile, bool aLocal)
NS_ENSURE_SUCCESS(rv, rv);
localDir = do_QueryInterface(dirFileMac, &rv);
#elif defined(XP_IOS)
nsAutoCString userDir;
if (GetUIKitDirectory(aLocal, userDir)) {
rv = NS_NewNativeLocalFile(userDir, true, getter_AddRefs(localDir));
} else {
rv = NS_ERROR_FAILURE;
}
NS_ENSURE_SUCCESS(rv, rv);
#elif defined(XP_WIN)
nsString path;
if (aLocal) {