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 _OSL_FILE_PATH_HELPER_H_
21 #define _OSL_FILE_PATH_HELPER_H_
23 #include <sal/types.h>
24 #include <rtl/ustring.h>
32 /*******************************************
33 osl_systemPathRemoveSeparator
34 Removes the last separator from the
35 given system path if any and if the path
36 is not the root path '/'
38 @param ppustrPath [inout] a system path
39 if the path is not the root path
40 and the last character is a
41 path separator it will be cut off
42 ppustrPath must not be NULL and
43 must point to a valid rtl_uString
47 ******************************************/
49 void SAL_CALL
osl_systemPathRemoveSeparator(
50 /*inout*/ rtl_uString
* pustrPath
);
52 /*******************************************
53 osl_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 void SAL_CALL
osl_systemPathEnsureSeparator(
70 /*inout*/ rtl_uString
** ppustrPath
);
72 /*******************************************
73 osl_systemPathIsRelativePath
74 Returns true if the given path is a
75 relative path and so starts not with '/'
77 @param pustrPath [in] a system path
78 pustrPath must not be NULL
80 @returns sal_True if the given path
81 doesn't start with a separator
82 else sal_False will be returned
84 ******************************************/
86 sal_Bool SAL_CALL
osl_systemPathIsRelativePath(
87 const rtl_uString
* pustrPath
);
89 /******************************************
90 osl_systemPathMakeAbsolutePath
91 Append a relative path to a base path
93 @param pustrBasePath [in] a system
94 path that will be considered as
96 pustrBasePath must not be NULL
98 @param pustrRelPath [in] a system path
99 that will be considered as
101 pustrBasePath must not be NULL
103 @param ppustrAbsolutePath [out] the
104 resulting path which is a
105 concatination of the base and
107 if base path is empty the
108 resulting absolute path is the
110 if relative path is empty the
111 resulting absolute path is the
113 if base and relative path are
114 empty the resulting absolute
116 ppustrAbsolutePath must not be
117 NULL and *ppustrAbsolutePath
118 must be 0 or point to a valid
121 *****************************************/
123 void SAL_CALL
osl_systemPathMakeAbsolutePath(
124 const rtl_uString
* pustrBasePath
,
125 const rtl_uString
* pustrRelPath
,
126 rtl_uString
** ppustrAbsolutePath
);
128 /*****************************************
129 osl_systemPathGetFileOrLastDirectoryPart
130 Returns the file or the directory part
133 @param pustrPath [in] a system path,
136 @param ppustrFileOrDirPart [out] on
137 return receives the last part
138 of the given directory or the
140 if pustrPath is the root path
141 '/' an empty string will be
143 if pustrPath has a trailing
144 '/' the last part before the
145 '/' will be returned else
146 the part after the last '/'
151 ****************************************/
152 void SAL_CALL
osl_systemPathGetFileNameOrLastDirectoryPart(
153 const rtl_uString
* pustrPath
,
154 rtl_uString
** ppustrFileNameOrLastDirPart
);
157 /********************************************
158 osl_systemPathIsHiddenFileOrDirectoryEntry
159 Returns sal_True if the last part of
160 given system path is not '.' or '..'
161 alone and starts with a '.'
163 @param pustrPath [in] a system path,
166 @returns sal_True if the last part of
167 the given system path starts
168 with '.' or sal_False the last
169 part is '.' or '..' alone or
170 doesn't start with a dot
172 *********************************************/
174 sal_Bool SAL_CALL
osl_systemPathIsHiddenFileOrDirectoryEntry(
175 const rtl_uString
* pustrPath
);
178 /************************************************
179 osl_systemPathIsLocalOrParentDirectoryEntry
180 Returns sal_True if the last part of the given
181 system path is the local directory entry '.'
182 or the parent directory entry '..'
184 @param pustrPath [in] a system path,
187 @returns sal_True if the last part of the
188 given system path is '.' or '..'
191 ************************************************/
193 sal_Bool SAL_CALL
osl_systemPathIsLocalOrParentDirectoryEntry(
194 const rtl_uString
* pustrPath
);
197 /************************************************
199 Searches for a file name or path name in all
200 directories specified by a given path list.
201 Symbolic links in the resulting path will not be
202 resolved, it's up to the caller to do this.
204 @param pustrFilePath [in] a file name or
205 directory name to search for, the name must
206 be provided as system path not as a file URL
208 @param pustrSearchPathList [in] a ':'
209 separated list of paths in which to search for
210 the file or directory name
212 @ppustrPathFound [out] on success receives the
213 complete path of the file or directory found
216 @returns sal_True if the specified file or
217 directory was found else sal_False
218 ***********************************************/
220 sal_Bool SAL_CALL
osl_searchPath(
221 const rtl_uString
* pustrFilePath
,
222 const rtl_uString
* pustrSearchPathList
,
223 rtl_uString
** ppustrPathFound
);
231 #endif /* #ifndef _OSL_PATH_HELPER_H_ */
234 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */