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_
33 #include <sal/types.h>
36 #ifndef _RTL_USTRING_H_
37 #include <rtl/ustring.h>
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
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
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_systemPathMakeAbsolutePath
106 Append a relative path to a base path
108 @param pustrBasePath [in] a system
109 path that will be considered as
111 pustrBasePath must not be NULL
113 @param pustrRelPath [in] a system path
114 that will be considered as
116 pustrBasePath must not be NULL
118 @param ppustrAbsolutePath [out] the
119 resulting path which is a
120 concatination of the base and
122 if base path is empty the
123 resulting absolute path is the
125 if relative path is empty the
126 resulting absolute path is the
128 if base and relative path are
129 empty the resulting absolute
131 ppustrAbsolutePath must not be
132 NULL and *ppustrAbsolutePath
133 must be 0 or point to a valid
136 *****************************************/
138 void SAL_CALL
osl_systemPathMakeAbsolutePath(
139 const rtl_uString
* pustrBasePath
,
140 const rtl_uString
* pustrRelPath
,
141 rtl_uString
** ppustrAbsolutePath
);
143 /*****************************************
144 osl_systemPathGetFileOrLastDirectoryPart
145 Returns the file or the directory part
148 @param pustrPath [in] a system path,
151 @param ppustrFileOrDirPart [out] on
152 return receives the last part
153 of the given directory or the
155 if pustrPath is the root path
156 '/' an empty string will be
158 if pustrPath has a trailing
159 '/' the last part before the
160 '/' will be returned else
161 the part after the last '/'
166 ****************************************/
167 void SAL_CALL
osl_systemPathGetFileNameOrLastDirectoryPart(
168 const rtl_uString
* pustrPath
,
169 rtl_uString
** ppustrFileNameOrLastDirPart
);
172 /********************************************
173 osl_systemPathIsHiddenFileOrDirectoryEntry
174 Returns sal_True if the last part of
175 given system path is not '.' or '..'
176 alone and starts with a '.'
178 @param pustrPath [in] a system path,
181 @returns sal_True if the last part of
182 the given system path starts
183 with '.' or sal_False the last
184 part is '.' or '..' alone or
185 doesn't start with a dot
187 *********************************************/
189 sal_Bool SAL_CALL
osl_systemPathIsHiddenFileOrDirectoryEntry(
190 const rtl_uString
* pustrPath
);
193 /************************************************
194 osl_systemPathIsLocalOrParentDirectoryEntry
195 Returns sal_True if the last part of the given
196 system path is the local directory entry '.'
197 or the parent directory entry '..'
199 @param pustrPath [in] a system path,
202 @returns sal_True if the last part of the
203 given system path is '.' or '..'
206 ************************************************/
208 sal_Bool SAL_CALL
osl_systemPathIsLocalOrParentDirectoryEntry(
209 const rtl_uString
* pustrPath
);
212 /************************************************
214 Searches for a file name or path name in all
215 directories specified by a given path list.
216 Symbolic links in the resulting path will not be
217 resolved, it's up to the caller to do this.
219 @param pustrFilePath [in] a file name or
220 directory name to search for, the name must
221 be provided as system path not as a file URL
223 @param pustrSearchPathList [in] a ':'
224 separated list of paths in which to search for
225 the file or directory name
227 @ppustrPathFound [out] on success receives the
228 complete path of the file or directory found
231 @returns sal_True if the specified file or
232 directory was found else sal_False
233 ***********************************************/
235 sal_Bool SAL_CALL
osl_searchPath(
236 const rtl_uString
* pustrFilePath
,
237 const rtl_uString
* pustrSearchPathList
,
238 rtl_uString
** ppustrPathFound
);
246 #endif /* #ifndef _OSL_PATH_HELPER_H_ */