MCPcopy Create free account
hub / github.com/MyGUI/mygui / prepare

Method prepare

Tools/LayoutEditor/Application.cpp:255–355  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

253 }
254
255 void Application::prepare()
256 {
257 // устанавливаем локаль из переменной окружения
258 // без этого не будут открываться наши файлы
259 mLocale = ::setlocale(LC_ALL, "");
260 // erase everything after '_' to get language name
261 mLocale.erase(std::find(mLocale.begin(), mLocale.end(), '_'), mLocale.end());
262 if (mLocale == "ru")
263 mLocale = "Russian";
264 else if (mLocale == "en")
265 mLocale = "English";
266
267#if MYGUI_PLATFORM == MYGUI_PLATFORM_WIN32
268
269 // при дропе файл может быть запущен в любой дирректории
270 wchar_t buff[MAX_PATH];
271 ::GetModuleFileNameW(0, buff, MAX_PATH);
272
273 std::wstring dir = buff;
274 size_t pos = dir.find_last_of(L"\\/");
275 if (pos != dir.npos)
276 {
277 // устанавливаем правильную дирректорию
278 ::SetCurrentDirectoryW(dir.substr(0, pos + 1).c_str());
279 }
280
281 // имена могут содержать пробелы, необходимо
282 //склеивать и проверять файлы на существование
283 std::wifstream stream;
284 std::wstring tmp;
285 std::wstring delims = L" ";
286 std::wstring source = GetCommandLineW();
287 size_t start = source.find_first_not_of(delims);
288 while (start != source.npos)
289 {
290 size_t end = source.find_first_of(delims, start);
291 if (end != source.npos)
292 {
293 tmp += source.substr(start, end - start);
294
295 // имена могут быть в ковычках
296 if (tmp.size() > 2)
297 {
298 if ((tmp[0] == L'"') && (tmp[tmp.size() - 1] == L'"'))
299 {
300 tmp = tmp.substr(1, tmp.size() - 2);
301 }
302 }
303
304 #if MYGUI_COMPILER == MYGUI_COMPILER_MSVC && !defined(STLPORT)
305 stream.open(tmp.c_str());
306 #else
307 stream.open(MyGUI::UString(tmp).asUTF8_c_str());
308 #endif
309 if (stream.is_open())
310 {
311 if (tmp.size() > 4 && tmp.substr(tmp.size() - 4) != L".exe")
312 mParams.push_back(tmp);

Callers

nothing calls this directly

Calls 15

UStringFunction · 0.85
find_last_ofMethod · 0.80
substrMethod · 0.80
find_first_not_ofMethod · 0.80
find_first_ofMethod · 0.80
asUTF8_c_strMethod · 0.80
eraseMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
c_strMethod · 0.45
sizeMethod · 0.45
openMethod · 0.45

Tested by

no test coverage detected