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 .
23 #include "unotools/bootstrap.hxx"
25 // ---------------------------------------------------------------------------------------
26 #include <rtl/ustring.hxx>
27 #include <rtl/ustrbuf.hxx>
28 #include <osl/file.hxx>
29 #include <osl/mutex.hxx>
30 #include <osl/diagnose.h>
31 // ---------------------------------------------------------------------------------------
32 #include <rtl/bootstrap.hxx>
33 #include <rtl/instance.hxx>
34 #include <osl/process.h> // for osl_getExecutableFile
35 #include "tools/getprocessworkingdir.hxx"
37 // ---------------------------------------------------------------------------------------
38 // #define this to a non-zero value, if remembering defaults is not supported properly
39 #define RTL_BOOTSTRAP_DEFAULTS_BROKEN 1
41 // ---------------------------------------------------------------------------------------
42 #define BOOTSTRAP_DATA_NAME SAL_CONFIGFILE("bootstrap")
44 #define BOOTSTRAP_ITEM_PRODUCT_KEY "ProductKey"
45 #define BOOTSTRAP_ITEM_PRODUCT_SOURCE "ProductSource"
46 #define BOOTSTRAP_ITEM_VERSIONFILE "Location"
47 #define BOOTSTRAP_ITEM_BUILDID "buildid"
48 #define BOOTSTRAP_ITEM_BUILDVERSION "BuildVersion"
50 #define BOOTSTRAP_ITEM_BASEINSTALLATION "BRAND_BASE_DIR"
51 #define BOOTSTRAP_ITEM_USERINSTALLATION "UserInstallation"
53 #define BOOTSTRAP_ITEM_USERDIR "UserDataDir"
55 #define BOOTSTRAP_DEFAULT_BASEINSTALL "$SYSBINDIR/.."
57 #define BOOTSTRAP_DIRNAME_USERDIR "user"
59 // ---------------------------------------------------------------------------------------
60 typedef char const * AsciiString
;
61 // ---------------------------------------------------------------------------------------
65 // ---------------------------------------------------------------------------------------
66 using ::rtl::OUString
;
67 using ::rtl::OUStringBuffer
;
70 // ---------------------------------------------------------------------------------------
71 // Implementation class: Bootstrap::Impl
72 // ---------------------------------------------------------------------------------------
76 rtl::OUString
makeImplName()
80 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("BRAND_BASE_DIR")),
82 return uri
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/program/" BOOTSTRAP_DATA_NAME
));
88 const OUString m_aImplName
;
89 public: // struct to cache the result of a path lookup
97 , status(DATA_UNKNOWN
)
100 public: // data members
102 PathData aBaseInstall_
;
105 PathData aUserInstall_
;
108 PathData aBootstrapINI_
;
109 PathData aVersionINI_
;
114 public: // construction and initialization
115 Impl() : m_aImplName(makeImplName())
123 OUString
getBootstrapValue(OUString
const& _sName
, OUString
const& _sDefault
) const;
124 sal_Bool
getVersionValue(OUString
const& _sName
, OUString
& _rValue
, OUString
const& _sDefault
) const;
126 OUString
getImplName() const { return m_aImplName
; }
128 private: // implementation
129 bool initBaseInstallationData(rtl::Bootstrap
& _rData
);
130 bool initUserInstallationData(rtl::Bootstrap
& _rData
);
135 class theImpl
: public rtl::Static
<Bootstrap::Impl
, theImpl
> {};
138 const Bootstrap::Impl
& Bootstrap::data()
140 return theImpl::get();
143 void Bootstrap::reloadData()
145 theImpl::get().initialize();
148 // ---------------------------------------------------------------------------------------
150 // ---------------------------------------------------------------------------------------
152 typedef Bootstrap::PathStatus PathStatus
;
154 sal_Unicode
const cURLSeparator
= '/';
156 // ---------------------------------------------------------------------------------------
157 // path status utility function
159 PathStatus
implCheckStatusOfURL(OUString
const& _sURL
, osl::DirectoryItem
& aDirItem
)
163 PathStatus eStatus
= Bootstrap::DATA_UNKNOWN
;
165 if (!_sURL
.isEmpty())
167 switch( DirectoryItem::get(_sURL
, aDirItem
) )
169 case DirectoryItem::E_None
: // Success
170 eStatus
= Bootstrap::PATH_EXISTS
;
173 case DirectoryItem::E_NOENT
: // No such file or directory<br>
174 eStatus
= Bootstrap::PATH_VALID
;
177 case DirectoryItem::E_INVAL
: // the format of the parameters was not valid<br>
178 case DirectoryItem::E_NAMETOOLONG
: // File name too long<br>
179 case DirectoryItem::E_NOTDIR
: // A component of the path prefix of path is not a directory<p>
180 eStatus
= Bootstrap::DATA_INVALID
;
183 // how to handle these ?
184 case DirectoryItem::E_LOOP
: // Too many symbolic links encountered<br>
185 case DirectoryItem::E_ACCES
: // permission denied<br>
186 // any other error - what to do ?
188 eStatus
= Bootstrap::DATA_UNKNOWN
;
193 eStatus
= Bootstrap::DATA_MISSING
;
197 // ---------------------------------------------------------------------------------------
200 bool implNormalizeURL(OUString
& _sURL
, osl::DirectoryItem
& aDirItem
)
204 OSL_PRECOND(aDirItem
.is(), "Opened DirItem required");
206 static const sal_uInt32 cosl_FileStatus_Mask
= osl_FileStatus_Mask_FileURL
;
208 FileStatus
aFileStatus(cosl_FileStatus_Mask
);
210 if (aDirItem
.getFileStatus(aFileStatus
) != DirectoryItem::E_None
)
213 OUString aNormalizedURL
= aFileStatus
.getFileURL();
215 if (aNormalizedURL
.isEmpty())
218 // #109863# sal/osl returns final slash for file URLs contradicting
220 if ( aNormalizedURL
.getStr()[aNormalizedURL
.getLength()-1] != cURLSeparator
)
221 _sURL
= aNormalizedURL
;
223 _sURL
= aNormalizedURL
.copy( 0, aNormalizedURL
.getLength()-1 );
227 // ---------------------------------------------------------------------------------------
229 bool implEnsureAbsolute(OUString
& _rsURL
) // also strips embedded dots !!
234 OSL_VERIFY(tools::getProcessWorkingDir(sBasePath
));
237 if ( File::E_None
== File::getAbsoluteFileURL(sBasePath
, _rsURL
, sAbsolute
))
244 OSL_FAIL("Could not get absolute file URL for URL");
249 // ---------------------------------------------------------------------------------------
252 bool implMakeAbsoluteURL(OUString
& _rsPathOrURL
)
259 // check if it already was normalized
260 if ( File::E_None
== File::getSystemPathFromFileURL(_rsPathOrURL
, sOther
) )
265 else if ( File::E_None
== File::getFileURLFromSystemPath(_rsPathOrURL
, sOther
) )
267 _rsPathOrURL
= sOther
;
273 return bURL
&& implEnsureAbsolute(_rsPathOrURL
);
275 // ---------------------------------------------------------------------------------------
276 #if OSL_DEBUG_LEVEL > 0
278 PathStatus
dbgCheckStatusOfURL(OUString
const& _sURL
)
282 DirectoryItem aDirItem
;
284 return implCheckStatusOfURL(_sURL
,aDirItem
);
286 // ---------------------------------------------------------------------------------------
290 PathStatus
checkStatusAndNormalizeURL(OUString
& _sURL
)
294 PathStatus eStatus
= Bootstrap::DATA_UNKNOWN
;
297 eStatus
= Bootstrap::DATA_MISSING
;
299 else if ( !implMakeAbsoluteURL(_sURL
) )
300 eStatus
= Bootstrap::DATA_INVALID
;
304 DirectoryItem aDirItem
;
306 eStatus
= implCheckStatusOfURL(_sURL
,aDirItem
);
308 if (eStatus
== Bootstrap::PATH_EXISTS
)
310 if (!implNormalizeURL(_sURL
,aDirItem
))
311 OSL_FAIL("Unexpected failure getting actual URL for existing object");
318 // ----------------------------------------------------------------------------------
319 // helpers to build and check a nested URL
321 PathStatus
getDerivedPath(
323 OUString
const& _aBaseURL
, PathStatus _aBaseStatus
,
324 OUString
const& _sRelativeURL
,
325 rtl::Bootstrap
& _rData
, OUString
const& _sBootstrapParameter
328 OUString sDerivedURL
;
329 OSL_PRECOND(!_rData
.getFrom(_sBootstrapParameter
,sDerivedURL
),"Setting for derived path is already defined");
330 OSL_PRECOND(!_sRelativeURL
.isEmpty() && _sRelativeURL
[0] != cURLSeparator
,"Invalid Relative URL");
332 PathStatus aStatus
= _aBaseStatus
;
334 // do we have a base path ?
335 if (!_aBaseURL
.isEmpty())
337 OSL_PRECOND(_aBaseURL
[_aBaseURL
.getLength()-1] != cURLSeparator
,"Unexpected: base URL ends in slash");
339 sDerivedURL
= rtl::OUStringBuffer(_aBaseURL
).append(cURLSeparator
).append(_sRelativeURL
).makeStringAndClear();
341 // a derived (nested) URL can only exist or have a lesser status, if the parent exists
342 if (aStatus
== Bootstrap::PATH_EXISTS
)
343 aStatus
= checkStatusAndNormalizeURL(sDerivedURL
);
345 else // the relative appendix must be valid
346 OSL_ASSERT(aStatus
!= Bootstrap::PATH_VALID
|| dbgCheckStatusOfURL(sDerivedURL
) == Bootstrap::PATH_VALID
);
348 _rData
.getFrom(_sBootstrapParameter
, _rURL
, sDerivedURL
);
350 OSL_ENSURE(sDerivedURL
== _rURL
,"Could not set derived URL via Bootstrap default parameter");
351 OSL_POSTCOND(RTL_BOOTSTRAP_DEFAULTS_BROKEN
||
352 (_rData
.getFrom(_sBootstrapParameter
,sDerivedURL
) && sDerivedURL
==_rURL
),"Use of default did not affect bootstrap value");
359 // if we have no data it can't be a valid path
360 OSL_ASSERT( aStatus
> Bootstrap::PATH_VALID
);
367 // ----------------------------------------------------------------------------------
370 PathStatus
getDerivedPath(
372 Bootstrap::Impl::PathData
const& _aBaseData
,
373 OUString
const& _sRelativeURL
,
374 rtl::Bootstrap
& _rData
, OUString
const& _sBootstrapParameter
377 return getDerivedPath(_rURL
,_aBaseData
.path
,_aBaseData
.status
,_sRelativeURL
,_rData
,_sBootstrapParameter
);
380 // ---------------------------------------------------------------------------------------
383 OUString
getExecutableBaseName()
385 OUString sExecutable
;
387 if (osl_Process_E_None
== osl_getExecutableFile(&sExecutable
.pData
))
389 // split the executable name
390 sal_Int32 nSepIndex
= sExecutable
.lastIndexOf(cURLSeparator
);
392 sExecutable
= sExecutable
.copy(nSepIndex
+ 1);
394 // ... and get the basename (strip the extension)
395 sal_Unicode
const cExtensionSep
= '.';
397 sal_Int32
const nExtIndex
= sExecutable
.lastIndexOf(cExtensionSep
);
398 sal_Int32
const nExtLength
= sExecutable
.getLength() - nExtIndex
- 1;
399 if (0 < nExtIndex
&& nExtLength
< 4)
400 sExecutable
= sExecutable
.copy(0,nExtIndex
);
403 OSL_TRACE("Cannot get executable name: osl_getExecutableFile failed");
408 // ----------------------------------------------------------------------------------
412 Bootstrap::PathStatus
updateStatus(Bootstrap::Impl::PathData
& _rResult
)
414 return _rResult
.status
= checkStatusAndNormalizeURL(_rResult
.path
);
416 // ---------------------------------------------------------------------------------------
419 Bootstrap::PathStatus
implGetBootstrapFile(rtl::Bootstrap
& _rData
, Bootstrap::Impl::PathData
& _rBootstrapFile
)
421 _rData
.getIniName(_rBootstrapFile
.path
);
423 return updateStatus(_rBootstrapFile
);
425 // ---------------------------------------------------------------------------------------
428 Bootstrap::PathStatus
implGetVersionFile(rtl::Bootstrap
& _rData
, Bootstrap::Impl::PathData
& _rVersionFile
)
430 OUString
const csVersionFileItem(RTL_CONSTASCII_USTRINGPARAM(BOOTSTRAP_ITEM_VERSIONFILE
));
432 _rData
.getFrom(csVersionFileItem
,_rVersionFile
.path
);
434 return updateStatus(_rVersionFile
);
436 // ---------------------------------------------------------------------------------------
439 static char const IS_MISSING
[] = "is missing";
440 static char const IS_INVALID
[] = "is corrupt";
441 static char const PERIOD
[] = ". ";
443 // ---------------------------------------------------------------------------------------
444 static void addFileError(OUStringBuffer
& _rBuf
, OUString
const& _aPath
, AsciiString _sWhat
)
446 OUString sSimpleFileName
= _aPath
.copy(1 +_aPath
.lastIndexOf(cURLSeparator
));
448 _rBuf
.appendAscii("The configuration file");
449 _rBuf
.appendAscii(" '").append(sSimpleFileName
).appendAscii("' ");
450 _rBuf
.appendAscii(_sWhat
).appendAscii(PERIOD
);
452 // ---------------------------------------------------------------------------------------
454 static void addMissingDirectoryError(OUStringBuffer
& _rBuf
, OUString
const& _aPath
)
456 _rBuf
.appendAscii("The configuration directory");
457 _rBuf
.appendAscii(" '").append(_aPath
).appendAscii("' ");
458 _rBuf
.appendAscii(IS_MISSING
).appendAscii(PERIOD
);
460 // ---------------------------------------------------------------------------------------
462 static void addUnexpectedError(OUStringBuffer
& _rBuf
, AsciiString _sExtraInfo
= NULL
)
464 if (NULL
== _sExtraInfo
)
465 _sExtraInfo
= "An internal failure occurred";
467 _rBuf
.appendAscii(_sExtraInfo
).appendAscii(PERIOD
);
469 // ---------------------------------------------------------------------------------------
471 static Bootstrap::FailureCode
describeError(OUStringBuffer
& _rBuf
, Bootstrap::Impl
const& _rData
)
473 Bootstrap::FailureCode eErrCode
= Bootstrap::INVALID_BOOTSTRAP_DATA
;
475 _rBuf
.appendAscii("The program cannot be started. ");
477 switch (_rData
.aUserInstall_
.status
)
479 case Bootstrap::PATH_EXISTS
:
480 switch (_rData
.aBaseInstall_
.status
)
482 case Bootstrap::PATH_VALID
:
483 addMissingDirectoryError(_rBuf
, _rData
.aBaseInstall_
.path
);
484 eErrCode
= Bootstrap::MISSING_INSTALL_DIRECTORY
;
487 case Bootstrap::DATA_INVALID
:
488 addUnexpectedError(_rBuf
,"The installation path is invalid");
491 case Bootstrap::DATA_MISSING
:
492 addUnexpectedError(_rBuf
,"The installation path is not available");
495 case Bootstrap::PATH_EXISTS
: // seems to be all fine (?)
496 addUnexpectedError(_rBuf
,"");
499 default: OSL_ASSERT(false);
500 addUnexpectedError(_rBuf
);
505 case Bootstrap::PATH_VALID
:
506 addMissingDirectoryError(_rBuf
, _rData
.aUserInstall_
.path
);
507 eErrCode
= Bootstrap::MISSING_USER_DIRECTORY
;
511 case Bootstrap::DATA_INVALID
:
512 if (_rData
.aVersionINI_
.status
== Bootstrap::PATH_EXISTS
)
514 addFileError(_rBuf
, _rData
.aVersionINI_
.path
, IS_INVALID
);
515 eErrCode
= Bootstrap::INVALID_VERSION_FILE_ENTRY
;
520 case Bootstrap::DATA_MISSING
:
521 switch (_rData
.aVersionINI_
.status
)
523 case Bootstrap::PATH_EXISTS
:
524 addFileError(_rBuf
, _rData
.aVersionINI_
.path
, "does not support the current version");
525 eErrCode
= Bootstrap::MISSING_VERSION_FILE_ENTRY
;
528 case Bootstrap::PATH_VALID
:
529 addFileError(_rBuf
, _rData
.aVersionINI_
.path
, IS_MISSING
);
530 eErrCode
= Bootstrap::MISSING_VERSION_FILE
;
534 switch (_rData
.aBootstrapINI_
.status
)
536 case Bootstrap::PATH_EXISTS
:
537 addFileError(_rBuf
, _rData
.aBootstrapINI_
.path
, IS_INVALID
);
539 if (_rData
.aVersionINI_
.status
== Bootstrap::DATA_MISSING
)
540 eErrCode
= Bootstrap::MISSING_BOOTSTRAP_FILE_ENTRY
;
542 eErrCode
= Bootstrap::INVALID_BOOTSTRAP_FILE_ENTRY
;
545 case Bootstrap::DATA_INVALID
: OSL_ASSERT(false);
546 case Bootstrap::PATH_VALID
:
547 addFileError(_rBuf
, _rData
.aBootstrapINI_
.path
, IS_MISSING
);
548 eErrCode
= Bootstrap::MISSING_BOOTSTRAP_FILE
;
552 addUnexpectedError(_rBuf
);
559 default: OSL_ASSERT(false);
560 addUnexpectedError(_rBuf
);
566 // ---------------------------------------------------------------------------------------
567 // ---------------------------------------------------------------------------------------
569 // ---------------------------------------------------------------------------------------
571 OUString
Bootstrap::getProductKey()
573 OUString
const csProductKeyItem(RTL_CONSTASCII_USTRINGPARAM(BOOTSTRAP_ITEM_PRODUCT_KEY
));
575 OUString
const sDefaultProductKey
= getExecutableBaseName();
577 return data().getBootstrapValue( csProductKeyItem
, sDefaultProductKey
);
579 // ---------------------------------------------------------------------------------------
581 OUString
Bootstrap::getProductKey(OUString
const& _sDefault
)
583 OUString
const csProductKeyItem(RTL_CONSTASCII_USTRINGPARAM(BOOTSTRAP_ITEM_PRODUCT_KEY
));
585 return data().getBootstrapValue( csProductKeyItem
, _sDefault
);
587 // ---------------------------------------------------------------------------------------
589 OUString
Bootstrap::getProductSource(OUString
const& _sDefault
)
591 OUString
const csProductSourceItem(RTL_CONSTASCII_USTRINGPARAM(BOOTSTRAP_ITEM_PRODUCT_SOURCE
));
593 OUString sProductSource
;
594 // read ProductSource from version.ini (versionrc)
595 data().getVersionValue( csProductSourceItem
, sProductSource
, _sDefault
);
596 return sProductSource
;
598 // ---------------------------------------------------------------------------------------
600 OUString
Bootstrap::getBuildVersion(OUString
const& _sDefault
)
602 OUString
const csBuildVersionItem(BOOTSTRAP_ITEM_BUILDVERSION
);
604 OUString sBuildVersion
;
605 // read ProductSource from version.ini (versionrc)
606 data().getVersionValue( csBuildVersionItem
, sBuildVersion
, _sDefault
);
607 return sBuildVersion
;
609 // ---------------------------------------------------------------------------------------
611 OUString
Bootstrap::getBuildIdData(OUString
const& _sDefault
)
613 OUString
const csBuildIdItem(RTL_CONSTASCII_USTRINGPARAM(BOOTSTRAP_ITEM_BUILDID
));
616 // read buildid from version.ini (versionrc), if it doesn't exist or buildid is empty
617 if ( data().getVersionValue( csBuildIdItem
, sBuildId
, _sDefault
) != sal_True
||
619 // read buildid from bootstrap.ini (bootstraprc)
620 sBuildId
= data().getBootstrapValue( csBuildIdItem
, _sDefault
);
624 // ---------------------------------------------------------------------------------------
626 Bootstrap::PathStatus
Bootstrap::locateBaseInstallation(OUString
& _rURL
)
628 Impl::PathData
const& aPathData
= data().aBaseInstall_
;
630 _rURL
= aPathData
.path
;
631 return aPathData
.status
;
633 // ---------------------------------------------------------------------------------------
635 PathStatus
Bootstrap::locateUserInstallation(OUString
& _rURL
)
637 Impl::PathData
const& aPathData
= data().aUserInstall_
;
639 _rURL
= aPathData
.path
;
640 return aPathData
.status
;
643 // ---------------------------------------------------------------------------------------
645 PathStatus
Bootstrap::locateUserData(OUString
& _rURL
)
647 OUString
const csUserDirItem(RTL_CONSTASCII_USTRINGPARAM(BOOTSTRAP_ITEM_USERDIR
));
649 rtl::Bootstrap
aData( data().getImplName() );
651 if ( aData
.getFrom(csUserDirItem
, _rURL
) )
653 return checkStatusAndNormalizeURL(_rURL
);
657 OUString
const csUserDir(RTL_CONSTASCII_USTRINGPARAM(BOOTSTRAP_DIRNAME_USERDIR
));
658 return getDerivedPath(_rURL
, data().aUserInstall_
,csUserDir
, aData
, csUserDirItem
);
661 // ---------------------------------------------------------------------------------------
663 PathStatus
Bootstrap::locateBootstrapFile(OUString
& _rURL
)
665 Impl::PathData
const& aPathData
= data().aBootstrapINI_
;
667 _rURL
= aPathData
.path
;
668 return aPathData
.status
;
670 // ---------------------------------------------------------------------------------------
672 PathStatus
Bootstrap::locateVersionFile(OUString
& _rURL
)
674 Impl::PathData
const& aPathData
= data().aVersionINI_
;
676 _rURL
= aPathData
.path
;
677 return aPathData
.status
;
679 // ---------------------------------------------------------------------------------------
681 Bootstrap::Status
Bootstrap::checkBootstrapStatus(rtl::OUString
& _rDiagnosticMessage
, FailureCode
& _rErrCode
)
683 Impl
const& aData
= data();
685 Status result
= aData
.status_
;
687 // maybe do further checks here
689 OUStringBuffer sErrorBuffer
;
690 if (result
!= DATA_OK
)
691 _rErrCode
= describeError(sErrorBuffer
,aData
);
694 _rErrCode
= NO_FAILURE
;
696 _rDiagnosticMessage
= sErrorBuffer
.makeStringAndClear();
701 // ---------------------------------------------------------------------------------------
702 // class Bootstrap::Impl
703 // ---------------------------------------------------------------------------------------
705 bool Bootstrap::Impl::initBaseInstallationData(rtl::Bootstrap
& _rData
)
707 OUString
const csBaseInstallItem( RTL_CONSTASCII_USTRINGPARAM(BOOTSTRAP_ITEM_BASEINSTALLATION
) );
708 OUString
const csBaseInstallDefault( RTL_CONSTASCII_USTRINGPARAM(BOOTSTRAP_DEFAULT_BASEINSTALL
) );
710 _rData
.getFrom(csBaseInstallItem
, aBaseInstall_
.path
, csBaseInstallDefault
);
712 bool bResult
= (PATH_EXISTS
== updateStatus(aBaseInstall_
));
714 implGetBootstrapFile(_rData
, aBootstrapINI_
);
718 // ---------------------------------------------------------------------------------------
720 bool Bootstrap::Impl::initUserInstallationData(rtl::Bootstrap
& _rData
)
722 OUString
const csUserInstallItem( RTL_CONSTASCII_USTRINGPARAM(BOOTSTRAP_ITEM_USERINSTALLATION
) );
724 if (_rData
.getFrom(csUserInstallItem
, aUserInstall_
.path
))
726 updateStatus(aUserInstall_
);
730 // should we do just this
731 aUserInstall_
.status
= DATA_MISSING
;
733 // .. or this - look for a single-user user directory ?
734 OUString
const csUserDirItem(RTL_CONSTASCII_USTRINGPARAM(BOOTSTRAP_ITEM_USERDIR
));
736 // look for $BASEINSTALLATION/user only if default UserDir setting is used
737 if (! _rData
.getFrom(csUserDirItem
, sDummy
))
739 OUString
const csUserDir(RTL_CONSTASCII_USTRINGPARAM(BOOTSTRAP_DIRNAME_USERDIR
));
741 if ( PATH_EXISTS
== getDerivedPath(sDummy
, aBaseInstall_
, csUserDir
, _rData
, csUserDirItem
) )
742 aUserInstall_
= aBaseInstall_
;
746 bool bResult
= (PATH_EXISTS
== aUserInstall_
.status
);
748 implGetVersionFile(_rData
, aVersionINI_
);
752 // ---------------------------------------------------------------------------------------
754 void Bootstrap::Impl::initialize()
756 rtl::Bootstrap
aData( m_aImplName
);
758 if (!initBaseInstallationData(aData
))
760 status_
= INVALID_BASE_INSTALL
;
762 else if (!initUserInstallationData(aData
))
764 status_
= INVALID_USER_INSTALL
;
766 if (aUserInstall_
.status
>= DATA_MISSING
)
768 switch (aVersionINI_
.status
)
772 status_
= MISSING_USER_INSTALL
;
777 status_
= INVALID_BASE_INSTALL
;
789 // ---------------------------------------------------------------------------------------
791 OUString
Bootstrap::Impl::getBootstrapValue(OUString
const& _sName
, OUString
const& _sDefault
) const
793 rtl::Bootstrap
aData( m_aImplName
);
796 aData
.getFrom(_sName
,sResult
,_sDefault
);
799 // ---------------------------------------------------------------------------------------
801 sal_Bool
Bootstrap::Impl::getVersionValue(OUString
const& _sName
, OUString
& _rValue
, OUString
const& _sDefault
) const
803 // try to open version.ini (versionrc)
806 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("BRAND_BASE_DIR")), uri
);
807 rtl::Bootstrap
aData( uri
+
808 OUString(RTL_CONSTASCII_USTRINGPARAM("/program/" SAL_CONFIGFILE("version"))) );
809 if ( aData
.getHandle() == NULL
)
810 // version.ini (versionrc) doesn't exist
814 aData
.getFrom(_sName
,_rValue
,_sDefault
);
817 // ---------------------------------------------------------------------------------------
821 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */