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 .
25 #define WIN32_LEAN_AND_MEAN
28 #include <tools/pathutils.hxx>
30 #define MY_LENGTH(s) (sizeof (s) / sizeof *(s) - 1)
31 #define MY_STRING(s) (s), MY_LENGTH(s)
35 wchar_t * getBrandPath(wchar_t * path
) {
36 DWORD n
= GetModuleFileNameW(nullptr, path
, MAX_PATH
);
37 if (n
== 0 || n
>= MAX_PATH
) {
40 return tools::filename(path
);
44 if (fwrite("\0\0", 1, 2, stdout
) != 2) {
50 wchar_t const * frontBegin
, wchar_t const * frontEnd
,
51 wchar_t const * backBegin
, std::size_t backLength
)
53 wchar_t path
[MAX_PATH
];
54 wchar_t * end
= tools::buildPath(
55 path
, frontBegin
, frontEnd
, backBegin
, backLength
);
59 std::size_t n
= (end
- path
) * sizeof (wchar_t);
60 if (fwrite(path
, 1, n
, stdout
) != n
) {
67 int wmain(int argc
, wchar_t ** argv
, wchar_t **) {
68 if (argc
== 2 && wcscmp(argv
[1], L
"c++") == 0) {
69 wchar_t path
[MAX_PATH
];
70 wchar_t * pathEnd
= getBrandPath(path
);
71 writePath(path
, pathEnd
, MY_STRING(L
""));
72 } else if (argc
== 2 && wcscmp(argv
[1], L
"java") == 0) {
73 if (fwrite("1", 1, 1, stdout
) != 1) {
76 wchar_t path
[MAX_PATH
];
77 wchar_t * pathEnd
= getBrandPath(path
);
78 writePath(path
, pathEnd
, MY_STRING(L
"classes\\libreoffice.jar"));
80 writePath(path
, pathEnd
, MY_STRING(L
""));
87 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */