From 06535ec153bfe829b36f65992a38f89bc85a46fb Mon Sep 17 00:00:00 2001 From: Vladimir Weinstein Date: Wed, 10 Oct 2001 01:13:01 +0000 Subject: [PATCH] ICU-1268 placeholder for ures_openDirect() X-SVN-Rev: 6141 --- icu4c/source/common/unicode/ures.h | 17 ++++++++++++++ icu4c/source/common/uresbund.c | 37 ++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/icu4c/source/common/unicode/ures.h b/icu4c/source/common/unicode/ures.h index 7675f1c8193..e13a8c09e2c 100644 --- a/icu4c/source/common/unicode/ures.h +++ b/icu4c/source/common/unicode/ures.h @@ -218,6 +218,23 @@ U_CAPI UResourceBundle* U_EXPORT2 ures_open(const char* path, /* NULL if n UErrorCode* status); +/** This function does not care what kind of localeID is passed in. It simply opens a bundle with + * that name + * @param path : string containing the full path pointing to the directory + * where the resources reside followed by the package name + * e.g. "/usr/resource/my_app/resources/guimessages" on a Unix system. + * if NULL, ICU default data files will be used. + * @param locale: specifies the locale for which we want to open the resource + * if NULL, the default locale will be used. If strlen(locale) == 0 + * root locale will be used. + * + * @param status : fills in the outgoing error code. Either U_ZERO_ERROR or U_MISSING_RESOURCE_ERROR + * @return a newly allocated resource bundle or NULL if it doesn't exist. + * @see ures_close + * @draft + */ +U_CAPI UResourceBundle* ures_openDirect(const char* path, const char* locale, UErrorCode* status); + /** *Opens a UResourceBundle, from which users can extract strings by using *their corresponding keys. This version of open requires the path diff --git a/icu4c/source/common/uresbund.c b/icu4c/source/common/uresbund.c index 556e4f336f6..7cd6cc0b8e3 100644 --- a/icu4c/source/common/uresbund.c +++ b/icu4c/source/common/uresbund.c @@ -1139,6 +1139,43 @@ U_CAPI UResourceBundle* U_EXPORT2 ures_openU(const UChar* myPath, return r; } +/** + * Opens a resource bundle without "canonicalizing" the locale name. No fallback will be performed + * or sought. + */ +U_CFUNC UResourceBundle* ures_openDirect(const char* path, const char* localeID, UErrorCode* status) { + UResourceBundle *r = (UResourceBundle *)uprv_malloc(sizeof(UResourceBundle)); + if(r == NULL) { + *status = U_MEMORY_ALLOCATION_ERROR; + return NULL; + } + + r->fHasFallback = FALSE; + r->fIsTopLevel = TRUE; + ures_setIsStackObject(r, FALSE); + r->fIndex = -1; + r->fData = entryOpen(path, localeID, status); + if(U_FAILURE(*status)) { + uprv_free(r); + return NULL; + } + if(r->fData->fBogus != U_ZERO_ERROR) { + entryClose(r->fData); + uprv_free(r); + *status = U_MISSING_RESOURCE_ERROR; + return NULL; + } + + r->fKey = NULL; + r->fVersion = NULL; + r->fResData.data = r->fData->fData.data; + r->fResData.pRoot = r->fData->fData.pRoot; + r->fResData.rootRes = r->fData->fData.rootRes; + r->fRes = r->fResData.rootRes; + r->fSize = res_countArrayItems(&(r->fResData), r->fRes); + return r; +} + U_CFUNC void ures_setIsStackObject( UResourceBundle* resB, UBool state) { if(state) { resB->fMagic1 = 0;