Logo Search packages:      
Sourcecode: icu version File versions

U_STABLE const char* U_EXPORT2 u_getDataDirectory ( void   )

Platform utilities isolates the platform dependencies of the libarary. For each platform which this code is ported to, these functions may have to be re-implemented. Return the ICU data directory. The data directory is where common format ICU data files (.dat files) are loaded from. Note that normal use of the built-in ICU facilities does not require loading of an external data file; unless you are adding custom data to ICU, the data directory does not need to be set.

The data directory is determined as follows: If u_setDataDirectory() has been called, that is it, otherwise if the ICU_DATA environment variable is set, use that, otherwise If a data directory was specifed at ICU build time

        #define ICU_DATA_DIR "path" 

use that, otherwise no data directory is available.

the data directory, or an empty string ("") if no data directory has been specified.

ICU 2.0

Definition at line 1190 of file putil.c.

References NULL.

    const char *path = NULL;
    char datadir_path_buffer[PATH_MAX];

    /* if we have the directory, then return it immediately */
    UMTX_CHECK(NULL, gDataDirectory, path);

    if(path) {
        return path;

    When ICU_NO_USER_DATA_OVERRIDE is defined, users aren't allowed to
    override ICU's data with the ICU_DATA environment variable. This prevents
    problems where multiple custom copies of ICU's specific version of data
    are installed on a system. Either the application must define the data
    directory with u_setDataDirectory, define ICU_DATA_DIR when compiling
    ICU, set the data with udata_setCommonData or trust that all of the
    required data is contained in ICU's data library that contains
    the entry point defined by U_ICUDATA_ENTRY_POINT.

    There may also be some platforms where environment variables
    are not allowed.
    /* First try to get the environment variable */
#   endif

    /* ICU_DATA_DIR may be set as a compile option.
     * U_ICU_DATA_DEFAULT_DIR is provided and is set by ICU at compile time
     * and is used only when data is built in archive mode eliminating the need
     * for ICU_DATA_DIR to be set. U_ICU_DATA_DEFAULT_DIR is set to the installation
     * directory of the data dat file. Users should use ICU_DATA_DIR if they want to
     * set their own path.
#if defined(ICU_DATA_DIR) || defined(U_ICU_DATA_DEFAULT_DIR)
    if(path==NULL || *path==0) {
        const char *prefix = getenv(ICU_DATA_DIR_PREFIX_ENV_VAR);
# endif
# ifdef ICU_DATA_DIR
# else
# endif
        if (prefix != NULL) {
            snprintf(datadir_path_buffer, PATH_MAX, "%s%s", prefix, path);
# endif

    if(path==NULL) {
        /* It looks really bad, set it to something. */
        path = "";

    return gDataDirectory;

Generated by  Doxygen 1.6.0   Back to index