fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / desktop / win32 / source / loader.cxx
blob95327fcdbfadef539cc6e5f24ecc6ab79000c6d5
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <sal/config.h>
22 #define WIN32_LEAN_AND_MEAN
23 #if defined _MSC_VER
24 #pragma warning(push, 1)
25 #endif
26 #include <windows.h>
27 #include <shlwapi.h>
28 #if defined _MSC_VER
29 #pragma warning(pop)
30 #endif
32 #include <tools/pathutils.hxx>
34 #include "loader.hxx"
36 namespace desktop_win32 {
38 void getPaths(WCHAR * binPath, WCHAR * iniDirectory) {
39 if (!GetModuleFileNameW(NULL, iniDirectory, MAX_PATH)) {
40 LPWSTR buf = NULL;
41 FormatMessageW(
42 FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL,
43 GetLastError(), 0, reinterpret_cast< LPWSTR >(&buf), 0, NULL);
44 MessageBoxW(NULL, buf, NULL, MB_OK | MB_ICONERROR);
45 LocalFree(buf);
46 TerminateProcess(GetCurrentProcess(), 255);
48 WCHAR * iniDirEnd = tools::filename(iniDirectory);
49 WCHAR name[MAX_PATH + MY_LENGTH(L".bin")];
50 // hopefully std::size_t is large enough to not overflow
51 WCHAR * nameEnd = name;
52 for (WCHAR * p = iniDirEnd; *p != L'\0'; ++p) {
53 *nameEnd++ = *p;
55 if (!(nameEnd - name >= 4 && nameEnd[-4] == L'.' &&
56 (nameEnd[-3] == L'E' || nameEnd[-3] == L'e') &&
57 (nameEnd[-2] == L'X' || nameEnd[-2] == L'x') &&
58 (nameEnd[-1] == L'E' || nameEnd[-1] == L'e')))
60 *nameEnd = L'.';
61 nameEnd += 4;
63 nameEnd[-3] = 'b';
64 nameEnd[-2] = 'i';
65 nameEnd[-1] = 'n';
66 tools::buildPath(binPath, iniDirectory, iniDirEnd, name, nameEnd - name);
67 *iniDirEnd = L'\0';
72 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */