LibreOffice Module setup_native (master) 1
checkdirectory.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#include "shlxtmsi.hxx"
21
22#include <malloc.h>
23#include <assert.h>
24
25#include <queue>
26#include <stdio.h>
27
28#include <systools/win32/uwinapi.h>
29#include "../tools/seterror.hxx"
30
31extern "C" __declspec(dllexport) UINT __stdcall CheckInstallDirectory(MSIHANDLE handle)
32{
33 std::wstring sInstallPath = GetMsiPropertyW(handle, L"INSTALLLOCATION");
34 std::wstring sOfficeHostnamePath = GetMsiPropertyW(handle, L"OFFICEDIRHOSTNAME");
35
36 // MessageBoxW(NULL, sInstallPath.c_str(), L"DEBUG", MB_OK);
37
38 // unsetting all properties
39
40 UnsetMsiPropertyW(handle, L"DIRECTORY_NOT_EMPTY");
41
42 // 1. Searching for file setup.ini
43
44 std::wstring sSetupIniPath = sInstallPath + sOfficeHostnamePath + L"\\program\\setup.ini";
45
46 WIN32_FIND_DATAW data;
47 HANDLE hdl = FindFirstFileW(sSetupIniPath.c_str(), &data);
48
49 // std::wstring mystr = L"Searching for " + sSetupIniPath;
50 // MessageBoxW(NULL, mystr.c_str(), L"DEBUG", MB_OK);
51
52 if (IsValidHandle(hdl))
53 {
54 // setup.ini found -> directory cannot be used for installation.
55 SetMsiPropertyW(handle, L"DIRECTORY_NOT_EMPTY", L"1");
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);
60 FindClose(hdl);
61 }
62
63 return ERROR_SUCCESS;
64}
65
66/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
__declspec(dllexport) UINT __stdcall CheckInstallDirectory(MSIHANDLE handle)
static bool IsValidHandle(HANDLE handle)
void SetMsiErrorCode(int nErrorCode)
Definition: seterror.cxx:49
#define MSI_ERROR_DIRECTORY_NOT_EMPTY
Definition: seterror.hxx:29
static std::wstring GetMsiPropertyW(MSIHANDLE handle, const std::wstring &sProperty)
Definition: shlxtmsi.hxx:29
static void SetMsiPropertyW(MSIHANDLE handle, const std::wstring &sProperty, const std::wstring &sValue)
Definition: shlxtmsi.hxx:47
static void UnsetMsiPropertyW(MSIHANDLE handle, const std::wstring &sProperty)
Definition: shlxtmsi.hxx:52