update dev300-m58
[ooovba.git] / sal / osl / all / loadmodulerelative.cxx
blobd3a97b5967058ab4d7424a442fc96fa57ba9bbb7
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: loadmodulerelative.cxx,v $
10 * $Revision: 1.3 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sal.hxx"
34 #include "sal/config.h"
36 #include <cstddef>
38 #include "osl/diagnose.h"
39 #include "osl/module.h"
40 #include "osl/module.hxx"
41 #include "osl/thread.h"
42 #include "rtl/malformeduriexception.hxx"
43 #include "rtl/uri.hxx"
44 #include "rtl/ustring.h"
45 #include "rtl/ustring.hxx"
46 #include "sal/types.h"
48 extern "C" {
50 oslModule SAL_CALL osl_loadModuleRelative(
51 oslGenericFunction const baseModule, rtl_uString * const relativePath,
52 sal_Int32 const mode)
54 ::rtl::OUString base;
55 if (!::osl::Module::getUrlFromAddress(baseModule, base)) {
56 OSL_TRACE("osl::Module::getUrlFromAddress failed");
57 return NULL;
59 ::rtl::OUString abs;
60 try {
61 abs = ::rtl::Uri::convertRelToAbs(base, relativePath);
62 } catch (::rtl::MalformedUriException & e) {
63 (void) e; // avoid warnings
64 OSL_TRACE(
65 "rtl::MalformedUriException <%s>",
66 rtl::OUStringToOString(e.getMessage(), osl_getThreadTextEncoding()).
67 getStr());
68 //TODO: let some OSL_TRACE variant take care of text conversion?
69 return NULL;
71 return ::osl_loadModule(abs.pData, mode);