Mercurial > hg > vamp-plugin-load-checker
comparison src/knownplugins.cpp @ 20:c1081e8d26a7
An attempt to accommodate 32-bit helper on 64-bit Windows
author | Chris Cannam |
---|---|
date | Tue, 01 Nov 2016 15:48:59 +0000 |
parents | c80c55cabfcd |
children | 6905d8b146f6 |
comparison
equal
deleted
inserted
replaced
19:c80c55cabfcd | 20:c1081e8d26a7 |
---|---|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ | 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ |
2 /* | 2 /* |
3 Copyright (c) 2016 Queen Mary, University of London | 3 Copyright (c) 2016 Queen Mary, University of London |
4 | 4 |
5 Permission is hereby granted, free of charge, to any person | 5 Permission is hereby granted, free of charge, to any person |
6 obtaining a copy of this software and associated documentation | 6 obtaining a copy of this software and associated documentation |
7 files (the "Software"), to deal in the Software without | 7 files (the "Software"), to deal in the Software without |
8 restriction, including without limitation the rights to use, copy, | 8 restriction, including without limitation the rights to use, copy, |
9 modify, merge, publish, distribute, sublicense, and/or sell copies | 9 modify, merge, publish, distribute, sublicense, and/or sell copies |
10 of the Software, and to permit persons to whom the Software is | 10 of the Software, and to permit persons to whom the Software is |
11 furnished to do so, subject to the following conditions: | 11 furnished to do so, subject to the following conditions: |
12 | 12 |
13 The above copyright notice and this permission notice shall be | 13 The above copyright notice and this permission notice shall be |
14 included in all copies or substantial portions of the Software. | 14 included in all copies or substantial portions of the Software. |
15 | 15 |
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | 16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
17 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | 17 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
18 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | 18 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
19 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY | 19 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY |
20 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF | 20 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF |
21 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | 21 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
22 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | 22 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
23 | 23 |
24 Except as contained in this notice, the names of the Centre for | 24 Except as contained in this notice, the names of the Centre for |
25 Digital Music and Queen Mary, University of London shall not be | 25 Digital Music and Queen Mary, University of London shall not be |
26 used in advertising or otherwise to promote the sale, use or other | 26 used in advertising or otherwise to promote the sale, use or other |
27 dealings in this Software without prior written authorization. | 27 dealings in this Software without prior written authorization. |
28 */ | 28 */ |
29 | 29 |
30 #include "knownplugins.h" | 30 #include "knownplugins.h" |
31 | 31 |
32 #include <sstream> | 32 #include <sstream> |
39 #define PATH_SEPARATOR ':' | 39 #define PATH_SEPARATOR ':' |
40 #endif | 40 #endif |
41 | 41 |
42 KnownPlugins::KnownPlugins(string helperExecutableName, | 42 KnownPlugins::KnownPlugins(string helperExecutableName, |
43 PluginCandidates::LogCallback *cb) : | 43 PluginCandidates::LogCallback *cb) : |
44 m_candidates(helperExecutableName) | 44 m_candidates(helperExecutableName), |
45 m_helperExecutableName(helperExecutableName) | |
45 { | 46 { |
46 m_candidates.setLogCallback(cb); | 47 m_candidates.setLogCallback(cb); |
47 | 48 |
48 m_known = { | 49 m_known = { |
49 { | 50 { |
73 for (const auto &k: m_known) { | 74 for (const auto &k: m_known) { |
74 m_candidates.scan(k.second.tag, k.second.path, k.second.descriptor); | 75 m_candidates.scan(k.second.tag, k.second.path, k.second.descriptor); |
75 } | 76 } |
76 } | 77 } |
77 | 78 |
79 bool | |
80 KnownPlugins::is32bit() const | |
81 { | |
82 return m_helperExecutableName.find("-32") != std::string::npos; | |
83 } | |
84 | |
78 string | 85 string |
79 KnownPlugins::getDefaultPath(PluginType type) | 86 KnownPlugins::getDefaultPath(PluginType type) |
80 { | 87 { |
81 switch (type) { | 88 switch (type) { |
82 | 89 |
118 vector<string> pathList; | 125 vector<string> pathList; |
119 string path; | 126 string path; |
120 | 127 |
121 char *cpath = getenv(var.c_str()); | 128 char *cpath = getenv(var.c_str()); |
122 if (cpath) path = cpath; | 129 if (cpath) path = cpath; |
130 | |
131 #ifdef _WIN32 | |
132 bool is32 = is32bit(); | |
133 #endif | |
123 | 134 |
124 if (path == "") { | 135 if (path == "") { |
125 | 136 |
126 path = getDefaultPath(type); | 137 path = getDefaultPath(type); |
127 | 138 |
135 path.replace(f, 5, home); | 146 path.replace(f, 5, home); |
136 } | 147 } |
137 } | 148 } |
138 | 149 |
139 #ifdef _WIN32 | 150 #ifdef _WIN32 |
140 const char *pfiles = getenv("ProgramFiles"); | 151 const char *pfiles = 0; |
141 if (!pfiles) pfiles = "C:\\Program Files"; | 152 if (is32) { |
142 { | 153 pfiles = getenv("ProgramFiles(x86)"); |
143 string::size_type f; | 154 } |
144 while ((f = path.find("%ProgramFiles%")) != string::npos && | 155 if (!pfiles) { |
145 f < path.length()) { | 156 pfiles = getenv("ProgramFiles"); |
146 path.replace(f, 14, pfiles); | 157 } |
158 if (!pfiles) { | |
159 if (is32) { | |
160 pfiles = "C:\\Program Files (x86)"; | |
161 } else { | |
162 pfiles = "C:\\Program Files"; | |
147 } | 163 } |
164 } | |
165 string::size_type f; | |
166 while ((f = path.find("%ProgramFiles%")) != string::npos && | |
167 f < path.length()) { | |
168 path.replace(f, 14, pfiles); | |
148 } | 169 } |
149 #endif | 170 #endif |
150 } | 171 } |
151 } | 172 } |
152 | 173 |