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 .
19 #ifndef INCLUDED_JVMFWK_FWKUTIL_HXX
20 #define INCLUDED_JVMFWK_FWKUTIL_HXX
22 #include "sal/config.h"
23 #include "osl/mutex.hxx"
24 #include "rtl/bootstrap.hxx"
25 #include "rtl/instance.hxx"
26 #include "rtl/ustrbuf.hxx"
27 #include "rtl/byteseq.hxx"
28 #include "osl/thread.hxx"
29 #if OSL_DEBUG_LEVEL >=2
37 /** Returns the file URL of the directory where the framework library
38 (this library) resides.
40 OUString
getLibraryLocation();
42 /** provides a bootstrap class which already knows the values from the
46 public ::rtl::StaticWithInit
< const rtl::Bootstrap
*, Bootstrap
> {
47 const rtl::Bootstrap
* operator () () {
48 OUStringBuffer
buf(256);
49 buf
.append(getLibraryLocation());
50 buf
.appendAscii(SAL_CONFIGFILE("/jvmfwk3"));
51 OUString sIni
= buf
.makeStringAndClear();
52 ::rtl::Bootstrap
* bootstrap
= new ::rtl::Bootstrap(sIni
);
53 #if OSL_DEBUG_LEVEL >=2
54 OString o
= OUStringToOString( sIni
, osl_getThreadTextEncoding() );
55 fprintf(stderr
, "[Java framework] Using configuration file %s\n" , o
.getStr() );
61 struct FwkMutex
: public ::rtl::Static
<osl::Mutex
, FwkMutex
> {};
63 rtl::ByteSequence
encodeBase16(const rtl::ByteSequence
& rawData
);
64 rtl::ByteSequence
decodeBase16(const rtl::ByteSequence
& data
);
66 OUString
getPlatform();
69 OUString
getDirFromFile(const OUString
& usFilePath
);
71 /** Returns the file URL of the folder where the executable resides.
73 OUString
getExecutableDirectory();
74 /** Locates the plugin library and returns the file URL.
76 First tries to locate plugin relative to baseUrl (if relative);
77 vnd.sun.star.expand URLs are supported. If that fails, tries to
78 locate plugin relative to the executable. If that fails, and plugin
79 contains no slashes, tries to locate plugin in a platform-specific way
80 (e.g., LD_LIBRARY_PATH).
83 The base file URL relative to which the plugin argument is interpreted.
86 The argument is an absolute or relative URL or just the name of the plugin.
89 const OUString
& baseUrl
, const OUString
& plugin
);
99 /** checks if the URL is a file.
101 If it is a link to a file than
102 it is resolved. Assuming that the argument
103 represents a relative URL then FILE_INVALID
108 one of the values of FileStatus.
111 Errors occurred during determining if the file exists
113 FileStatus
checkFileURL(const OUString
& path
);
115 bool isAccessibilitySupportDesired();
117 OUString
buildClassPathFromDirectory(const OUString
& relPath
);
119 OUString
retrieveClassPath( OUString
const & macro
);
123 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */