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 "shlxtmsi.hxx"
28 #include <systools/win32/uwinapi.h>
29 #include "../tools/seterror.hxx"
31 extern "C" __declspec(dllexport
) UINT __stdcall
CheckInstallDirectory(MSIHANDLE handle
)
33 std::wstring sInstallPath
= GetMsiPropertyW(handle
, L
"INSTALLLOCATION");
34 std::wstring sOfficeHostnamePath
= GetMsiPropertyW(handle
, L
"OFFICEDIRHOSTNAME");
36 // MessageBoxW(NULL, sInstallPath.c_str(), L"DEBUG", MB_OK);
38 // unsetting all properties
40 UnsetMsiPropertyW( handle
, L
"DIRECTORY_NOT_EMPTY" );
42 // 1. Searching for file setup.ini
44 std::wstring sSetupIniPath
= sInstallPath
+ sOfficeHostnamePath
+ L
"\\program\\setup.ini";
46 WIN32_FIND_DATAW data
;
47 HANDLE hdl
= FindFirstFileW(sSetupIniPath
.c_str(), &data
);
49 // std::wstring mystr = L"Searching for " + sSetupIniPath;
50 // MessageBoxW(NULL, mystr.c_str(), L"DEBUG", MB_OK);
52 if ( IsValidHandle(hdl
) )
54 // setup.ini found -> directory cannot be used for installation.
55 SetMsiPropertyW( handle
, L
"DIRECTORY_NOT_EMPTY", L
"1" );
56 SetMsiErrorCode( MSI_ERROR_DIRECTORY_NOT_EMPTY
);
57 // std::wstring notEmptyStr = L"Directory is not empty. Please choose another installation directory.";
58 // std::wstring notEmptyTitle = L"Directory not empty";
59 // MessageBoxW(NULL, notEmptyStr.c_str(), notEmptyTitle.c_str(), MB_OK);
66 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */