bug 1174704 - Implement GetUserDataDirectoryHome for iOS. r=froydnj

--HG--
extra : commitid : C5Viq9XRj6g
extra : rebase_source : fa85f54dafe93e6d413ca9f8564c4f2f6ba8bc16
This commit is contained in:
Ted Mielczarek 2015-03-18 22:23:28 -04:00
Родитель 3073ae605d
Коммит cf604109d1
4 изменённых файлов: 48 добавлений и 0 удалений

Просмотреть файл

@ -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_

Просмотреть файл

@ -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;
}

Просмотреть файл

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

Просмотреть файл

@ -52,6 +52,9 @@
#ifdef XP_UNIX #ifdef XP_UNIX
#include <ctype.h> #include <ctype.h>
#endif #endif
#ifdef XP_IOS
#include "UIKitDirProvider.h"
#endif
#if defined(XP_MACOSX) #if defined(XP_MACOSX)
#define APP_REGISTRY_NAME "Application Registry" #define APP_REGISTRY_NAME "Application Registry"
@ -1235,6 +1238,14 @@ nsXREDirProvider::GetUserDataDirectoryHome(nsIFile** aFile, bool aLocal)
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
localDir = do_QueryInterface(dirFileMac, &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) #elif defined(XP_WIN)
nsString path; nsString path;
if (aLocal) { if (aLocal) {