1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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
24 #pragma warning(push, 1)
32 #include <tools/pathutils.hxx>
36 namespace desktop_win32
{
38 void getPaths(WCHAR
* binPath
, WCHAR
* iniDirectory
) {
39 if (!GetModuleFileNameW(NULL
, iniDirectory
, MAX_PATH
)) {
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
);
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
) {
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')))
66 tools::buildPath(binPath
, iniDirectory
, iniDirEnd
, name
, nameEnd
- name
);
72 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */