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 .
20 #ifndef INCLUDED_SAL_OSL_UNX_FILE_PATH_HELPER_HXX
21 #define INCLUDED_SAL_OSL_UNX_FILE_PATH_HELPER_HXX
23 #include "file_path_helper.h"
25 #include <rtl/ustring.hxx>
30 /*******************************************
31 systemPathRemoveSeparator
32 Removes the last separator from the
33 given system path if any and if the path
34 is not the root path '/'
36 @param ppustrPath [inout] a system path
37 if the path is not the root path
38 and the last character is a
39 path separator it will be cut off
40 ppustrPath must not be NULL and
41 must point to a valid rtl_uString
45 ******************************************/
47 inline void systemPathRemoveSeparator(/*inout*/ rtl::OUString
& Path
)
49 osl_systemPathRemoveSeparator(Path
.pData
);
52 /*******************************************
53 systemPathEnsureSeparator
54 Adds a trailing path separator to the
55 given system path if not already there
56 and if the path is not the root path '/'
58 @param pustrPath [inout] a system path
59 if the path is not the root path
60 '/' and has no trailing separator
61 a separator will be added
62 ppustrPath must not be NULL and
63 must point to a valid rtl_uString
67 ******************************************/
69 inline void systemPathEnsureSeparator(/*inout*/ rtl::OUString
& Path
)
71 osl_systemPathEnsureSeparator(&Path
.pData
);
74 /*******************************************
75 systemPathIsRelativePath
76 Returns true if the given path is a
77 relative path and so starts not with '/'
79 @param pustrPath [in] a system path
80 pustrPath must not be NULL
82 @returns sal_True if the given path
83 doesn't start with a separator
84 else sal_False will be returned
86 ******************************************/
88 inline bool systemPathIsRelativePath(const rtl::OUString
& Path
)
90 return osl_systemPathIsRelativePath(Path
.pData
);
93 /******************************************
94 systemPathMakeAbsolutePath
95 Append a relative path to a base path
97 @param pustrBasePath [in] a system
98 path that will be considered as
100 pustrBasePath must not be NULL
102 @param pustrRelPath [in] a system path
103 that will be considered as
105 pustrBasePath must not be NULL
107 @param ppustrAbsolutePath [out] the
108 resulting path which is a
109 concatination of the base and
111 if base path is empty the
112 resulting absolute path is the
114 if relative path is empty the
115 resulting absolute path is the
117 if base and relative path are
118 empty the resulting absolute
120 ppustrAbsolutePath must not be
121 NULL and *ppustrAbsolutePath
122 must be 0 or point to a valid
125 *****************************************/
127 inline void systemPathMakeAbsolutePath(
128 const rtl::OUString
& BasePath
,
129 const rtl::OUString
& RelPath
,
130 rtl::OUString
& AbsolutePath
)
132 osl_systemPathMakeAbsolutePath(
133 BasePath
.pData
, RelPath
.pData
, &AbsolutePath
.pData
);
136 /********************************************
137 systemPathIsHiddenFileOrDirectoryEntry
138 Returns sal_True if the last part of
139 given system path is not '.' or '..'
140 alone and starts with a '.'
142 @param pustrPath [in] a system path,
145 @returns sal_True if the last part of
146 the given system path starts
147 with '.' or sal_False the last
148 part is '.' or '..' alone or
149 doesn't start with a dot
151 *********************************************/
153 inline bool systemPathIsHiddenFileOrDirectoryEntry(
154 const rtl::OUString
& Path
)
156 return osl_systemPathIsHiddenFileOrDirectoryEntry(Path
.pData
);
159 /************************************************
161 ***********************************************/
163 inline bool searchPath(
164 const rtl::OUString
& ustrFilePath
,
165 const rtl::OUString
& ustrSearchPathList
,
166 rtl::OUString
& ustrPathFound
)
168 return osl_searchPath(
170 ustrSearchPathList
.pData
,
171 &ustrPathFound
.pData
);
176 #endif /* #ifndef _OSL_PATH_HELPER_HXX_ */
178 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */