author | herrick |
Wed, 09 Oct 2019 10:58:20 -0400 | |
branch | JDK-8200758-branch |
changeset 58538 | 12c965587689 |
parent 57316 | 2891b3ae222d |
permissions | -rw-r--r-- |
57064
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
1 |
/* |
57106
ea870b9ce89a
8216492: Update copyright of all new jpackage fils to 2019
kcr
parents:
57064
diff
changeset
|
2 |
* Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved. |
57064
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
4 |
* |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. Oracle designates this |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
10 |
* |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
15 |
* accompanied this code). |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
16 |
* |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License version |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
20 |
* |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
22 |
* or visit www.oracle.com if you need additional information or have any |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
23 |
* questions. |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
24 |
*/ |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
25 |
|
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
26 |
#include "Macros.h" |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
27 |
#include "Package.h" |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
28 |
#include "Helpers.h" |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
29 |
|
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
30 |
|
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
31 |
Macros::Macros(void) { |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
32 |
} |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
33 |
|
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
34 |
Macros::~Macros(void) { |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
35 |
} |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
36 |
|
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
37 |
void Macros::Initialize() { |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
38 |
Package& package = Package::GetInstance(); |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
39 |
Macros& macros = Macros::GetInstance(); |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
40 |
|
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
41 |
// Public macros. |
58538
12c965587689
8231910: Expose the APPDIR variable to applications that use jpackage
herrick
parents:
57316
diff
changeset
|
42 |
macros.AddMacro(_T("$ROOTDIR"), package.GetPackageRootDirectory()); |
12c965587689
8231910: Expose the APPDIR variable to applications that use jpackage
herrick
parents:
57316
diff
changeset
|
43 |
macros.AddMacro(_T("$APPDIR"), package.GetPackageAppDirectory()); |
12c965587689
8231910: Expose the APPDIR variable to applications that use jpackage
herrick
parents:
57316
diff
changeset
|
44 |
macros.AddMacro(_T("$BINDIR"), package.GetPackageLauncherDirectory()); |
57064
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
45 |
} |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
46 |
|
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
47 |
Macros& Macros::GetInstance() { |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
48 |
static Macros instance; |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
49 |
return instance; |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
50 |
} |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
51 |
|
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
52 |
TString Macros::ExpandMacros(TString Value) { |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
53 |
TString result = Value; |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
54 |
|
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
55 |
for (std::map<TString, TString>::iterator iterator = FData.begin(); |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
56 |
iterator != FData.end(); |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
57 |
iterator++) { |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
58 |
|
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
59 |
TString name = iterator->first; |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
60 |
|
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
61 |
if (Value.find(name) != TString::npos) { |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
62 |
TString lvalue = iterator->second; |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
63 |
result = Helpers::ReplaceString(Value, name, lvalue); |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
64 |
result = ExpandMacros(result); |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
65 |
break; |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
66 |
} |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
67 |
} |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
68 |
|
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
69 |
return result; |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
70 |
} |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
71 |
|
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
72 |
void Macros::AddMacro(TString Key, TString Value) { |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
73 |
FData.insert(std::map<TString, TString>::value_type(Key, Value)); |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
diff
changeset
|
74 |
} |