1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: file_path_helper.h,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _OSL_FILE_PATH_HELPER_H_
32 #define _OSL_FILE_PATH_HELPER_H_
36 #include <sal/types.h>
39 #ifndef _RTL_USTRING_H_
40 #include <rtl/ustring.h>
50 /*******************************************
51 osl_systemPathRemoveSeparator
52 Removes the last separator from the
53 given system path if any and if the path
54 is not the root path '/'
56 @param ppustrPath [inout] a system path
57 if the path is not the root path
58 and the last character is a
59 path separator it will be cut off
60 ppustrPath must not be NULL and
61 must point to a valid rtl_uString
65 ******************************************/
67 void SAL_CALL
osl_systemPathRemoveSeparator(
68 /*inout*/ rtl_uString
* pustrPath
);
70 /*******************************************
71 osl_systemPathEnsureSeparator
72 Adds a trailing path separator to the
73 given system path if not already there
74 and if the path is not the root path '/'
76 @param pustrPath [inout] a system path
77 if the path is not the root path
78 '/' and has no trailing separator
79 a separator will be added
80 ppustrPath must not be NULL and
81 must point to a valid rtl_uString
85 ******************************************/
87 void SAL_CALL
osl_systemPathEnsureSeparator(
88 /*inout*/ rtl_uString
** ppustrPath
);
90 /*******************************************
91 osl_systemPathIsRelativePath
92 Returns true if the given path is a
93 relative path and so starts not with '/'
95 @param pustrPath [in] a system path
96 pustrPath must not be NULL
98 @returns sal_True if the given path
99 doesn't start with a separator
100 else sal_False will be returned
102 ******************************************/
104 sal_Bool SAL_CALL
osl_systemPathIsRelativePath(
105 const rtl_uString
* pustrPath
);
107 /******************************************
108 osl_systemPathMakeAbsolutePath
109 Append a relative path to a base path
111 @param pustrBasePath [in] a system
112 path that will be considered as
114 pustrBasePath must not be NULL
116 @param pustrRelPath [in] a system path
117 that will be considered as
119 pustrBasePath must not be NULL
121 @param ppustrAbsolutePath [out] the
122 resulting path which is a
123 concatination of the base and
125 if base path is empty the
126 resulting absolute path is the
128 if relative path is empty the
129 resulting absolute path is the
131 if base and relative path are
132 empty the resulting absolute
134 ppustrAbsolutePath must not be
135 NULL and *ppustrAbsolutePath
136 must be 0 or point to a valid
139 *****************************************/
141 void SAL_CALL
osl_systemPathMakeAbsolutePath(
142 const rtl_uString
* pustrBasePath
,
143 const rtl_uString
* pustrRelPath
,
144 rtl_uString
** ppustrAbsolutePath
);
146 /*****************************************
147 osl_systemPathGetFileOrLastDirectoryPart
148 Returns the file or the directory part
151 @param pustrPath [in] a system path,
154 @param ppustrFileOrDirPart [out] on
155 return receives the last part
156 of the given directory or the
158 if pustrPath is the root path
159 '/' an empty string will be
161 if pustrPath has a trailing
162 '/' the last part before the
163 '/' will be returned else
164 the part after the last '/'
169 ****************************************/
170 void SAL_CALL
osl_systemPathGetFileNameOrLastDirectoryPart(
171 const rtl_uString
* pustrPath
,
172 rtl_uString
** ppustrFileNameOrLastDirPart
);
175 /********************************************
176 osl_systemPathIsHiddenFileOrDirectoryEntry
177 Returns sal_True if the last part of
178 given system path is not '.' or '..'
179 alone and starts with a '.'
181 @param pustrPath [in] a system path,
184 @returns sal_True if the last part of
185 the given system path starts
186 with '.' or sal_False the last
187 part is '.' or '..' alone or
188 doesn't start with a dot
190 *********************************************/
192 sal_Bool SAL_CALL
osl_systemPathIsHiddenFileOrDirectoryEntry(
193 const rtl_uString
* pustrPath
);
196 /************************************************
197 osl_systemPathIsLocalOrParentDirectoryEntry
198 Returns sal_True if the last part of the given
199 system path is the local directory entry '.'
200 or the parent directory entry '..'
202 @param pustrPath [in] a system path,
205 @returns sal_True if the last part of the
206 given system path is '.' or '..'
209 ************************************************/
211 sal_Bool SAL_CALL
osl_systemPathIsLocalOrParentDirectoryEntry(
212 const rtl_uString
* pustrPath
);
215 /************************************************
217 Searches for a file name or path name in all
218 directories specified by a given path list.
219 Symbolic links in the resulting path will not be
220 resolved, it's up to the caller to do this.
222 @param pustrFilePath [in] a file name or
223 directory name to search for, the name must
224 be provided as system path not as a file URL
226 @param pustrSearchPathList [in] a ':'
227 separated list of paths in which to search for
228 the file or directory name
230 @ppustrPathFound [out] on success receives the
231 complete path of the file or directory found
234 @returns sal_True if the specified file or
235 directory was found else sal_False
236 ***********************************************/
238 sal_Bool SAL_CALL
osl_searchPath(
239 const rtl_uString
* pustrFilePath
,
240 const rtl_uString
* pustrSearchPathList
,
241 rtl_uString
** ppustrPathFound
);
249 #endif /* #ifndef _OSL_PATH_HELPER_H_ */