src/jdk.jpackager/share/native/library/common/GenericPlatform.cpp
author herrick
Mon, 05 Nov 2018 17:32:00 -0500
branchJDK-8200758-branch
changeset 57017 1b08af362a30
parent 56995 src/jdk.packager/share/native/library/common/GenericPlatform.cpp@3d5b13207b70
permissions -rw-r--r--
8213156:rename packages for jpackager Reviewed-by: almatvee, kcr
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
     1
/*
56854
aedce3eaaf17 8209377: Add proper copyright headers on all jdk.packager source files
kcr
parents: 56821
diff changeset
     2
 * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
aedce3eaaf17 8209377: Add proper copyright headers on all jdk.packager source files
kcr
parents: 56821
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
     4
 *
56854
aedce3eaaf17 8209377: Add proper copyright headers on all jdk.packager source files
kcr
parents: 56821
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
aedce3eaaf17 8209377: Add proper copyright headers on all jdk.packager source files
kcr
parents: 56821
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
aedce3eaaf17 8209377: Add proper copyright headers on all jdk.packager source files
kcr
parents: 56821
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
aedce3eaaf17 8209377: Add proper copyright headers on all jdk.packager source files
kcr
parents: 56821
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
aedce3eaaf17 8209377: Add proper copyright headers on all jdk.packager source files
kcr
parents: 56821
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    10
 *
56854
aedce3eaaf17 8209377: Add proper copyright headers on all jdk.packager source files
kcr
parents: 56821
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
aedce3eaaf17 8209377: Add proper copyright headers on all jdk.packager source files
kcr
parents: 56821
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aedce3eaaf17 8209377: Add proper copyright headers on all jdk.packager source files
kcr
parents: 56821
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
aedce3eaaf17 8209377: Add proper copyright headers on all jdk.packager source files
kcr
parents: 56821
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
aedce3eaaf17 8209377: Add proper copyright headers on all jdk.packager source files
kcr
parents: 56821
diff changeset
    15
 * accompanied this code).
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    16
 *
56854
aedce3eaaf17 8209377: Add proper copyright headers on all jdk.packager source files
kcr
parents: 56821
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
aedce3eaaf17 8209377: Add proper copyright headers on all jdk.packager source files
kcr
parents: 56821
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
aedce3eaaf17 8209377: Add proper copyright headers on all jdk.packager source files
kcr
parents: 56821
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aedce3eaaf17 8209377: Add proper copyright headers on all jdk.packager source files
kcr
parents: 56821
diff changeset
    20
 *
aedce3eaaf17 8209377: Add proper copyright headers on all jdk.packager source files
kcr
parents: 56821
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aedce3eaaf17 8209377: Add proper copyright headers on all jdk.packager source files
kcr
parents: 56821
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
aedce3eaaf17 8209377: Add proper copyright headers on all jdk.packager source files
kcr
parents: 56821
diff changeset
    23
 * questions.
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    24
 */
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    25
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    26
#include "GenericPlatform.h"
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    27
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    28
#include <fstream>
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    29
#include <locale>
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    30
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    31
#ifdef WINDOWS
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    32
#include <codecvt>
56982
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
    33
#endif // WINDOWS
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    34
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    35
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    36
GenericPlatform::GenericPlatform(void) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    37
}
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    38
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    39
GenericPlatform::~GenericPlatform(void) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    40
}
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    41
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    42
TString GenericPlatform::GetConfigFileName() {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    43
    TString result;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    44
    TString basedir = GetPackageAppDirectory();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    45
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    46
    if (basedir.empty() == false) {
56982
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
    47
        basedir = FilePath::IncludeTrailingSeparator(basedir);
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    48
        TString appConfig = basedir + GetAppName() + _T(".cfg");
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    49
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    50
        if (FilePath::FileExists(appConfig) == true) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    51
            result = appConfig;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    52
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    53
        else {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    54
            result = basedir + _T("package.cfg");
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    55
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    56
            if (FilePath::FileExists(result) == false) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    57
                result = _T("");
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    58
            }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    59
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    60
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    61
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    62
    return result;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    63
}
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    64
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    65
TString GenericPlatform::GetPackageAppDirectory() {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    66
#if defined(WINDOWS) || defined(LINUX)
56982
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
    67
    return FilePath::IncludeTrailingSeparator(
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
    68
            GetPackageRootDirectory()) + _T("app");
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
    69
#endif // WINDOWS || LINUX
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    70
#ifdef MAC
56982
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
    71
    return FilePath::IncludeTrailingSeparator(
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
    72
            GetPackageRootDirectory()) + _T("Java");
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    73
#endif
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    74
}
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    75
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    76
TString GenericPlatform::GetPackageLauncherDirectory() {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    77
#if defined(WINDOWS) || defined(LINUX)
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    78
    return GetPackageRootDirectory();
56982
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
    79
#endif // WINDOWS || LINUX
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    80
#ifdef MAC
56982
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
    81
    return FilePath::IncludeTrailingSeparator(
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
    82
            GetPackageRootDirectory()) + _T("MacOS");
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    83
#endif
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    84
}
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    85
56983
01decb67d4f0 8211744: Cannot run AWT application generated with jpackager
herrick
parents: 56982
diff changeset
    86
TString GenericPlatform::GetPackageRuntimeBinDirectory() {
01decb67d4f0 8211744: Cannot run AWT application generated with jpackager
herrick
parents: 56982
diff changeset
    87
#ifdef WINDOWS
01decb67d4f0 8211744: Cannot run AWT application generated with jpackager
herrick
parents: 56982
diff changeset
    88
    return FilePath::IncludeTrailingSeparator(GetPackageRootDirectory()) + _T("runtime\\bin");
01decb67d4f0 8211744: Cannot run AWT application generated with jpackager
herrick
parents: 56982
diff changeset
    89
#endif // WINDOWS
01decb67d4f0 8211744: Cannot run AWT application generated with jpackager
herrick
parents: 56982
diff changeset
    90
#ifdef LINUX
01decb67d4f0 8211744: Cannot run AWT application generated with jpackager
herrick
parents: 56982
diff changeset
    91
    return FilePath::IncludeTrailingSeparator(GetPackageRootDirectory()) + _T("runtime/bin");
01decb67d4f0 8211744: Cannot run AWT application generated with jpackager
herrick
parents: 56982
diff changeset
    92
#endif // LINUX
01decb67d4f0 8211744: Cannot run AWT application generated with jpackager
herrick
parents: 56982
diff changeset
    93
#ifdef MAC
01decb67d4f0 8211744: Cannot run AWT application generated with jpackager
herrick
parents: 56982
diff changeset
    94
    return FilePath::IncludeTrailingSeparator(GetPackageRootDirectory()) + _T("Plugins/Java.runtime/Contents/Home/bin");
01decb67d4f0 8211744: Cannot run AWT application generated with jpackager
herrick
parents: 56982
diff changeset
    95
#endif
01decb67d4f0 8211744: Cannot run AWT application generated with jpackager
herrick
parents: 56982
diff changeset
    96
}
01decb67d4f0 8211744: Cannot run AWT application generated with jpackager
herrick
parents: 56982
diff changeset
    97
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    98
std::list<TString> GenericPlatform::LoadFromFile(TString FileName) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    99
    std::list<TString> result;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   100
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   101
    if (FilePath::FileExists(FileName) == true) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   102
        std::wifstream stream(FileName.data());
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   103
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   104
#ifdef WINDOWS
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   105
        const std::locale empty_locale = std::locale::empty();
56982
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   106
#endif // WINDOWS
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   107
#ifdef POSIX
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   108
        const std::locale empty_locale = std::locale::classic();
56982
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   109
#endif // POSIX
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   110
#if defined(WINDOWS)
56982
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   111
        const std::locale utf8_locale =
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   112
                std::locale(empty_locale, new std::codecvt_utf8<wchar_t>());
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   113
        stream.imbue(utf8_locale);
56982
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   114
#endif // WINDOWS
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   115
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   116
        if (stream.is_open() == true) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   117
            while (stream.eof() == false) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   118
                std::wstring line;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   119
                std::getline(stream, line);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   120
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   121
                // # at the first character will comment out the line.
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   122
                if (line.empty() == false && line[0] != '#') {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   123
                    result.push_back(PlatformString(line).toString());
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   124
                }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   125
            }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   126
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   127
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   128
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   129
    return result;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   130
}
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   131
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   132
void GenericPlatform::SaveToFile(TString FileName, std::list<TString> Contents, bool ownerOnly) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   133
    TString path = FilePath::ExtractFilePath(FileName);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   134
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   135
    if (FilePath::DirectoryExists(path) == false) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   136
        FilePath::CreateDirectory(path, ownerOnly);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   137
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   138
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   139
    std::wofstream stream(FileName.data());
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   140
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   141
    FilePath::ChangePermissions(FileName.data(), ownerOnly);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   142
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   143
#ifdef WINDOWS
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   144
    const std::locale empty_locale = std::locale::empty();
56982
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   145
#endif // WINDOWS
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   146
#ifdef POSIX
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   147
    const std::locale empty_locale = std::locale::classic();
56982
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   148
#endif // POSIX
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   149
#if defined(WINDOWS)
56982
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   150
    const std::locale utf8_locale =
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   151
            std::locale(empty_locale, new std::codecvt_utf8<wchar_t>());
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   152
    stream.imbue(utf8_locale);
56982
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   153
#endif // WINDOWS || MAC
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   154
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   155
    if (stream.is_open() == true) {
56982
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   156
        for (std::list<TString>::const_iterator iterator =
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   157
                Contents.begin(); iterator != Contents.end(); iterator++) {
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   158
            TString line = *iterator;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   159
            stream << PlatformString(line).toUnicodeString() << std::endl;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   160
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   161
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   162
}
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   163
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   164
#if defined(WINDOWS) || defined(LINUX)
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   165
TString GenericPlatform::GetAppName() {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   166
    TString result = GetModuleFileName();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   167
    result = FilePath::ExtractFileName(result);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   168
#if defined(WINDOWS)
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   169
    result = FilePath::ChangeFileExt(result, _T(""));
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   170
#endif
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   171
    return result;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   172
}
56982
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   173
#endif // WINDOWS || LINUX
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   174
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   175
std::map<TString, TString> GenericPlatform::GetKeys() {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   176
    std::map<TString, TString> keys;
56982
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   177
    keys.insert(std::map<TString, TString>::value_type(CONFIG_VERSION,
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   178
            _T("app.version")));
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   179
    keys.insert(std::map<TString, TString>::value_type(CONFIG_MAINJAR_KEY,
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   180
            _T("app.mainjar")));
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   181
    keys.insert(std::map<TString, TString>::value_type(CONFIG_MAINMODULE_KEY,
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   182
            _T("app.mainmodule")));
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   183
    keys.insert(std::map<TString, TString>::value_type(CONFIG_MAINCLASSNAME_KEY,
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   184
            _T("app.mainclass")));
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   185
    keys.insert(std::map<TString, TString>::value_type(CONFIG_CLASSPATH_KEY,
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   186
            _T("app.classpath")));
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   187
    keys.insert(std::map<TString, TString>::value_type(CONFIG_MODULEPATH_KEY,
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   188
            _T("app.modulepath")));
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   189
    keys.insert(std::map<TString, TString>::value_type(APP_NAME_KEY,
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   190
            _T("app.name")));
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   191
    keys.insert(std::map<TString, TString>::value_type(CONFIG_APP_ID_KEY,
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   192
            _T("app.preferences.id")));
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   193
    keys.insert(std::map<TString, TString>::value_type(JVM_RUNTIME_KEY,
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   194
            _T("app.runtime")));
57017
1b08af362a30 8213156:rename packages for jpackager
herrick
parents: 56995
diff changeset
   195
    keys.insert(std::map<TString, TString>::value_type(JPACKAGER_APP_DATA_DIR,
56982
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   196
            _T("app.identifier")));
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   197
    keys.insert(std::map<TString, TString>::value_type(CONFIG_SPLASH_KEY,
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   198
            _T("app.splash")));
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   199
    keys.insert(std::map<TString, TString>::value_type(CONFIG_APP_MEMORY,
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   200
            _T("app.memory")));
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   201
    keys.insert(std::map<TString, TString>::value_type(CONFIG_APP_DEBUG,
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   202
            _T("app.debug")));
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   203
    keys.insert(std::map<TString,
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   204
            TString>::value_type(CONFIG_APPLICATION_INSTANCE,
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   205
            _T("app.application.instance")));
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   206
    keys.insert(std::map<TString,
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   207
            TString>::value_type(CONFIG_SECTION_APPLICATION,
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   208
            _T("Application")));
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   209
    keys.insert(std::map<TString,
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   210
            TString>::value_type(CONFIG_SECTION_JVMOPTIONS,
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   211
            _T("JVMOptions")));
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   212
    keys.insert(std::map<TString,
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   213
            TString>::value_type(CONFIG_SECTION_APPCDSJVMOPTIONS,
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   214
            _T("AppCDSJVMOptions")));
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   215
    keys.insert(std::map<TString,
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   216
            TString>::value_type(CONFIG_SECTION_APPCDSGENERATECACHEJVMOPTIONS,
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   217
            _T("AppCDSGenerateCacheJVMOptions")));
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   218
    keys.insert(std::map<TString,
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   219
            TString>::value_type(CONFIG_SECTION_ARGOPTIONS,
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   220
            _T("ArgOptions")));
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   221
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   222
    return keys;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   223
}
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   224
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   225
#ifdef DEBUG
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   226
DebugState GenericPlatform::GetDebugState() {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   227
    DebugState result = dsNone;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   228
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   229
    if (IsNativeDebuggerPresent() == true) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   230
        result = dsNative;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   231
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   232
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   233
    return result;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   234
}
56982
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56854
diff changeset
   235
#endif // DEBUG