LibreOffice Module unotest (master) 1
directories.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
10#include <sal/config.h>
11
12#include <cppunit/TestAssert.h>
13#include <osl/file.hxx>
15
16namespace
17{
18OUString getFileURLFromSystemPath(OUString const& path)
19{
20 OUString url;
21 osl::FileBase::RC e = osl::FileBase::getFileURLFromSystemPath(path, url);
22 CPPUNIT_ASSERT_EQUAL(osl::FileBase::E_None, e);
23 if (!url.endsWith("/"))
24 {
25 url += "/";
26 }
27 return url;
28}
29}
30
32{
33 const char* pSrcRoot = getenv("SRC_ROOT");
34 CPPUNIT_ASSERT_MESSAGE("SRC_ROOT env variable not set", pSrcRoot != nullptr);
35 CPPUNIT_ASSERT_MESSAGE("SRC_ROOT env variable not set", pSrcRoot[0] != 0);
36 const char* pWorkdirRoot = getenv("WORKDIR_FOR_BUILD");
37 CPPUNIT_ASSERT_MESSAGE("$WORKDIR_FOR_BUILD env variable not set", pWorkdirRoot != nullptr);
38 CPPUNIT_ASSERT_MESSAGE("$WORKDIR_FOR_BUILD env variable not set", pWorkdirRoot[0] != 0);
39 m_aSrcRootPath = OUString::createFromAscii(pSrcRoot);
40 m_aSrcRootURL = getFileURLFromSystemPath(m_aSrcRootPath);
41
42 m_aWorkdirRootPath = OUString::createFromAscii(pWorkdirRoot);
43 m_aWorkdirRootURL = getFileURLFromSystemPath(m_aWorkdirRootPath);
44}
45
46OUString test::Directories::getURLFromSrc(std::u16string_view rPath) const
47{
48 return m_aSrcRootURL + rPath;
49}
50
51OUString test::Directories::getPathFromSrc(std::u16string_view rPath) const
52{
53 return m_aSrcRootPath + rPath;
54}
55
56OUString test::Directories::getURLFromWorkdir(std::u16string_view rPath) const
57{
58 return m_aWorkdirRootURL + rPath;
59}
60
61OUString test::Directories::getPathFromWorkdir(std::u16string_view rPath) const
62{
63 return m_aWorkdirRootPath + rPath;
64}
65
66/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OUString getPathFromSrc(std::u16string_view rPath) const
Definition: directories.cxx:51
OUString m_aSrcRootURL
Definition: directories.hxx:25
OUString getURLFromWorkdir(std::u16string_view rPath) const
Definition: directories.cxx:56
OUString m_aWorkdirRootPath
Definition: directories.hxx:28
OUString getURLFromSrc(std::u16string_view rPath) const
Definition: directories.cxx:46
OUString getPathFromWorkdir(std::u16string_view rPath) const
Definition: directories.cxx:61
OUString m_aWorkdirRootURL
Definition: directories.hxx:27
OUString m_aSrcRootPath
Definition: directories.hxx:26