merged tag ooo/DEV300_m102
[LibreOffice.git] / sal / osl / os2 / file_path_helper.h
blob88b8ccbe9b6a1a70623eb9841d2d3adf18537fd3
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 #ifndef _OSL_FILE_PATH_HELPER_H_
29 #define _OSL_FILE_PATH_HELPER_H_
32 #ifndef _SAL_TYPES_H_
33 #include <sal/types.h>
34 #endif
36 #ifndef _RTL_USTRING_H_
37 #include <rtl/ustring.h>
38 #endif
41 #ifdef __cplusplus
42 extern "C"
44 #endif
47 /*******************************************
48 osl_systemPathRemoveSeparator
49 Removes the last separator from the
50 given system path if any and if the path
51 is not the root path '/'
53 @param ppustrPath [inout] a system path
54 if the path is not the root path
55 and the last character is a
56 path separator it will be cut off
57 ppustrPath must not be NULL and
58 must point to a valid rtl_uString
60 @returns nothing
62 ******************************************/
64 void SAL_CALL osl_systemPathRemoveSeparator(
65 /*inout*/ rtl_uString* pustrPath);
67 /*******************************************
68 osl_systemPathEnsureSeparator
69 Adds a trailing path separator to the
70 given system path if not already there
71 and if the path is not the root path '/'
73 @param pustrPath [inout] a system path
74 if the path is not the root path
75 '/' and has no trailing separator
76 a separator will be added
77 ppustrPath must not be NULL and
78 must point to a valid rtl_uString
80 @returns nothing
82 ******************************************/
84 void SAL_CALL osl_systemPathEnsureSeparator(
85 /*inout*/ rtl_uString** ppustrPath);
87 /*******************************************
88 osl_systemPathIsRelativePath
89 Returns true if the given path is a
90 relative path and so starts not with '/'
92 @param pustrPath [in] a system path
93 pustrPath must not be NULL
95 @returns sal_True if the given path
96 doesn't start with a separator
97 else sal_False will be returned
99 ******************************************/
101 sal_Bool SAL_CALL osl_systemPathIsRelativePath(
102 const rtl_uString* pustrPath);
104 /******************************************
105 osl_systemPathIsAbsolutePath
106 Returns true if the given path is an
107 absolute path and so starts with a '/'
109 @param pustrPath [in] a system path
110 pustrPath must not be NULL
112 @returns sal_True if the given path
113 start's with a separator else
114 sal_False will be returned
116 *****************************************/
118 sal_Bool SAL_CALL osl_systemPathIsAbsolutePath(
119 const rtl_uString* pustrPath);
121 /******************************************
122 osl_systemPathMakeAbsolutePath
123 Append a relative path to a base path
125 @param pustrBasePath [in] a system
126 path that will be considered as
127 base path
128 pustrBasePath must not be NULL
130 @param pustrRelPath [in] a system path
131 that will be considered as
132 relative path
133 pustrBasePath must not be NULL
135 @param ppustrAbsolutePath [out] the
136 resulting path which is a
137 concatination of the base and
138 the relative path
139 if base path is empty the
140 resulting absolute path is the
141 relative path
142 if relative path is empty the
143 resulting absolute path is the
144 base path
145 if base and relative path are
146 empty the resulting absolute
147 path is also empty
148 ppustrAbsolutePath must not be
149 NULL and *ppustrAbsolutePath
150 must be 0 or point to a valid
151 rtl_uString
153 *****************************************/
155 void SAL_CALL osl_systemPathMakeAbsolutePath(
156 const rtl_uString* pustrBasePath,
157 const rtl_uString* pustrRelPath,
158 rtl_uString** ppustrAbsolutePath);
160 /*****************************************
161 osl_systemPathGetParent
162 Replaces the last occurrance of a path
163 separator with '\0' and returns the
164 position where the '/' was replaced
166 @param pustrPath [inout] a system
167 path, the last separator of
168 this path will be replaced by
169 a '\0'
170 if the path is the root path
171 '/' or the path is considered
172 as to have no parent, e.g.
173 '/NoParent' or 'NoParent' or
174 the path is empty no
175 replacement will be made
176 pustrPath must not be NULL
178 @returns the position of the last path
179 separator that was replaced
180 or 0 if no replacement took
181 place
183 ****************************************/
185 sal_Int32 SAL_CALL osl_systemPathGetParent(
186 /*inout*/ rtl_uString* pustrPath);
188 /*****************************************
189 osl_systemPathGetFileOrLastDirectoryPart
190 Returns the file or the directory part
191 of the given path
193 @param pustrPath [in] a system path,
194 must not be NULL
196 @param ppustrFileOrDirPart [out] on
197 return receives the last part
198 of the given directory or the
199 file name
200 if pustrPath is the root path
201 '/' an empty string will be
202 returned
203 if pustrPath has a trailing
204 '/' the last part before the
205 '/' will be returned else
206 the part after the last '/'
207 will be returned
209 @returns nothing
211 ****************************************/
212 void SAL_CALL osl_systemPathGetFileNameOrLastDirectoryPart(
213 const rtl_uString* pustrPath,
214 rtl_uString** ppustrFileNameOrLastDirPart);
217 /********************************************
218 osl_systemPathIsHiddenFileOrDirectoryEntry
219 Returns sal_True if the last part of
220 given system path is not '.' or '..'
221 alone and starts with a '.'
223 @param pustrPath [in] a system path,
224 must not be NULL
226 @returns sal_True if the last part of
227 the given system path starts
228 with '.' or sal_False the last
229 part is '.' or '..' alone or
230 doesn't start with a dot
232 *********************************************/
234 sal_Bool SAL_CALL osl_systemPathIsHiddenFileOrDirectoryEntry(
235 const rtl_uString* pustrPath);
238 /************************************************
239 osl_systemPathIsLocalOrParentDirectoryEntry
240 Returns sal_True if the last part of the given
241 system path is the local directory entry '.'
242 or the parent directory entry '..'
244 @param pustrPath [in] a system path,
245 must not be NULL
247 @returns sal_True if the last part of the
248 given system path is '.' or '..'
249 else sal_False
251 ************************************************/
253 sal_Bool SAL_CALL osl_systemPathIsLocalOrParentDirectoryEntry(
254 const rtl_uString* pustrPath);
257 /************************************************
258 osl_searchPath
259 Searches for a file name or path name in all
260 directories specified by a given path list.
261 Symbolic links in the resulting path will not be
262 resolved, it's up to the caller to do this.
264 @param pustrFilePath [in] a file name or
265 directory name to search for, the name must
266 be provided as system path not as a file URL
268 @param pustrSearchPathList [in] a ':'
269 separated list of paths in which to search for
270 the file or directory name
272 @ppustrPathFound [out] on success receives the
273 complete path of the file or directory found
274 as a system path
276 @returns sal_True if the specified file or
277 directory was found else sal_False
278 ***********************************************/
280 sal_Bool SAL_CALL osl_searchPath(
281 const rtl_uString* pustrFilePath,
282 const rtl_uString* pustrSearchPathList,
283 rtl_uString** ppustrPathFound);
286 #ifdef __cplusplus
288 #endif
291 #endif /* #ifndef _OSL_PATH_HELPER_H_ */