File: | home/maarten/src/libreoffice/core/unotest/source/cpp/directories.cxx |
Warning: | line 36, column 5 Array access (from variable 'pWorkdirRoot') results in a null pointer dereference |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
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> | |||
14 | #include <unotest/directories.hxx> | |||
15 | ||||
16 | namespace { | |||
17 | ||||
18 | OUString getFileURLFromSystemPath(OUString const & path) { | |||
19 | OUString url; | |||
20 | osl::FileBase::RC e = osl::FileBase::getFileURLFromSystemPath(path, url); | |||
21 | CPPUNIT_ASSERT_EQUAL(osl::FileBase::E_None, e)( CppUnit::assertEquals( (osl::FileBase::E_None), (e), CppUnit ::SourceLine( "/home/maarten/src/libreoffice/core/unotest/source/cpp/directories.cxx" , 21 ), "" ) ); | |||
22 | if (!url.endsWith("/")) { | |||
23 | url += "/"; | |||
24 | } | |||
25 | return url; | |||
26 | } | |||
27 | ||||
28 | } | |||
29 | ||||
30 | test::Directories::Directories() { | |||
31 | const char* pSrcRoot = getenv( "SRC_ROOT" ); | |||
32 | CPPUNIT_ASSERT_MESSAGE("SRC_ROOT env variable not set", pSrcRoot != nullptr)( CppUnit::Asserter::failIf( !(pSrcRoot != nullptr), CppUnit:: Message( "assertion failed", "Expression: " "pSrcRoot != nullptr" , CppUnit::message_to_string("SRC_ROOT env variable not set") ), CppUnit::SourceLine( "/home/maarten/src/libreoffice/core/unotest/source/cpp/directories.cxx" , 32 ) ) ); | |||
| ||||
33 | CPPUNIT_ASSERT_MESSAGE("SRC_ROOT env variable not set", pSrcRoot[0] != 0)( CppUnit::Asserter::failIf( !(pSrcRoot[0] != 0), CppUnit::Message ( "assertion failed", "Expression: " "pSrcRoot[0] != 0", CppUnit ::message_to_string("SRC_ROOT env variable not set") ), CppUnit ::SourceLine( "/home/maarten/src/libreoffice/core/unotest/source/cpp/directories.cxx" , 33 ) ) ); | |||
34 | const char* pWorkdirRoot = getenv( "WORKDIR_FOR_BUILD" ); | |||
35 | CPPUNIT_ASSERT_MESSAGE("$WORKDIR_FOR_BUILD env variable not set", pWorkdirRoot != nullptr)( CppUnit::Asserter::failIf( !(pWorkdirRoot != nullptr), CppUnit ::Message( "assertion failed", "Expression: " "pWorkdirRoot != nullptr" , CppUnit::message_to_string("$WORKDIR_FOR_BUILD env variable not set" ) ), CppUnit::SourceLine( "/home/maarten/src/libreoffice/core/unotest/source/cpp/directories.cxx" , 35 ) ) ); | |||
36 | CPPUNIT_ASSERT_MESSAGE("$WORKDIR_FOR_BUILD env variable not set", pWorkdirRoot[0] != 0)( CppUnit::Asserter::failIf( !(pWorkdirRoot[0] != 0), CppUnit ::Message( "assertion failed", "Expression: " "pWorkdirRoot[0] != 0" , CppUnit::message_to_string("$WORKDIR_FOR_BUILD env variable not set" ) ), CppUnit::SourceLine( "/home/maarten/src/libreoffice/core/unotest/source/cpp/directories.cxx" , 36 ) ) ); | |||
| ||||
37 | m_aSrcRootPath = OUString::createFromAscii( pSrcRoot ); | |||
38 | m_aSrcRootURL = getFileURLFromSystemPath(m_aSrcRootPath); | |||
39 | ||||
40 | m_aWorkdirRootPath = OUString::createFromAscii( pWorkdirRoot ); | |||
41 | m_aWorkdirRootURL = getFileURLFromSystemPath(m_aWorkdirRootPath); | |||
42 | } | |||
43 | ||||
44 | OUString test::Directories::getURLFromSrc(const OUString& rPath) const | |||
45 | { | |||
46 | return m_aSrcRootURL + rPath; | |||
47 | } | |||
48 | ||||
49 | OUString test::Directories::getPathFromSrc(const OUString& rPath) const | |||
50 | { | |||
51 | return m_aSrcRootPath + rPath; | |||
52 | } | |||
53 | ||||
54 | OUString test::Directories::getURLFromWorkdir(const OUString& rPath) const | |||
55 | { | |||
56 | return m_aWorkdirRootURL + rPath; | |||
57 | } | |||
58 | ||||
59 | OUString test::Directories::getPathFromWorkdir(const OUString& rPath) const | |||
60 | { | |||
61 | return m_aWorkdirRootPath + rPath; | |||
62 | } | |||
63 | ||||
64 | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |