1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #ifndef _OSL_FILE_PATH_HELPER_H_
30 #define _OSL_FILE_PATH_HELPER_H_
34 #include <sal/types.h>
37 #ifndef _RTL_USTRING_H_
38 #include <rtl/ustring.h>
48 /*******************************************
49 osl_systemPathRemoveSeparator
50 Removes the last separator from the
51 given system path if any and if the path
52 is not the root path '/'
54 @param ppustrPath [inout] a system path
55 if the path is not the root path
56 and the last character is a
57 path separator it will be cut off
58 ppustrPath must not be NULL and
59 must point to a valid rtl_uString
63 ******************************************/
65 void SAL_CALL
osl_systemPathRemoveSeparator(
66 /*inout*/ rtl_uString
* pustrPath
);
68 /*******************************************
69 osl_systemPathEnsureSeparator
70 Adds a trailing path separator to the
71 given system path if not already there
72 and if the path is not the root path '/'
74 @param pustrPath [inout] a system path
75 if the path is not the root path
76 '/' and has no trailing separator
77 a separator will be added
78 ppustrPath must not be NULL and
79 must point to a valid rtl_uString
83 ******************************************/
85 void SAL_CALL
osl_systemPathEnsureSeparator(
86 /*inout*/ rtl_uString
** ppustrPath
);
88 /*******************************************
89 osl_systemPathIsRelativePath
90 Returns true if the given path is a
91 relative path and so starts not with '/'
93 @param pustrPath [in] a system path
94 pustrPath must not be NULL
96 @returns sal_True if the given path
97 doesn't start with a separator
98 else sal_False will be returned
100 ******************************************/
102 sal_Bool SAL_CALL
osl_systemPathIsRelativePath(
103 const rtl_uString
* pustrPath
);
105 /******************************************
106 osl_systemPathMakeAbsolutePath
107 Append a relative path to a base path
109 @param pustrBasePath [in] a system
110 path that will be considered as
112 pustrBasePath must not be NULL
114 @param pustrRelPath [in] a system path
115 that will be considered as
117 pustrBasePath must not be NULL
119 @param ppustrAbsolutePath [out] the
120 resulting path which is a
121 concatination of the base and
123 if base path is empty the
124 resulting absolute path is the
126 if relative path is empty the
127 resulting absolute path is the
129 if base and relative path are
130 empty the resulting absolute
132 ppustrAbsolutePath must not be
133 NULL and *ppustrAbsolutePath
134 must be 0 or point to a valid
137 *****************************************/
139 void SAL_CALL
osl_systemPathMakeAbsolutePath(
140 const rtl_uString
* pustrBasePath
,
141 const rtl_uString
* pustrRelPath
,
142 rtl_uString
** ppustrAbsolutePath
);
144 /*****************************************
145 osl_systemPathGetFileOrLastDirectoryPart
146 Returns the file or the directory part
149 @param pustrPath [in] a system path,
152 @param ppustrFileOrDirPart [out] on
153 return receives the last part
154 of the given directory or the
156 if pustrPath is the root path
157 '/' an empty string will be
159 if pustrPath has a trailing
160 '/' the last part before the
161 '/' will be returned else
162 the part after the last '/'
167 ****************************************/
168 void SAL_CALL
osl_systemPathGetFileNameOrLastDirectoryPart(
169 const rtl_uString
* pustrPath
,
170 rtl_uString
** ppustrFileNameOrLastDirPart
);
173 /********************************************
174 osl_systemPathIsHiddenFileOrDirectoryEntry
175 Returns sal_True if the last part of
176 given system path is not '.' or '..'
177 alone and starts with a '.'
179 @param pustrPath [in] a system path,
182 @returns sal_True if the last part of
183 the given system path starts
184 with '.' or sal_False the last
185 part is '.' or '..' alone or
186 doesn't start with a dot
188 *********************************************/
190 sal_Bool SAL_CALL
osl_systemPathIsHiddenFileOrDirectoryEntry(
191 const rtl_uString
* pustrPath
);
194 /************************************************
195 osl_systemPathIsLocalOrParentDirectoryEntry
196 Returns sal_True if the last part of the given
197 system path is the local directory entry '.'
198 or the parent directory entry '..'
200 @param pustrPath [in] a system path,
203 @returns sal_True if the last part of the
204 given system path is '.' or '..'
207 ************************************************/
209 sal_Bool SAL_CALL
osl_systemPathIsLocalOrParentDirectoryEntry(
210 const rtl_uString
* pustrPath
);
213 /************************************************
215 Searches for a file name or path name in all
216 directories specified by a given path list.
217 Symbolic links in the resulting path will not be
218 resolved, it's up to the caller to do this.
220 @param pustrFilePath [in] a file name or
221 directory name to search for, the name must
222 be provided as system path not as a file URL
224 @param pustrSearchPathList [in] a ':'
225 separated list of paths in which to search for
226 the file or directory name
228 @ppustrPathFound [out] on success receives the
229 complete path of the file or directory found
232 @returns sal_True if the specified file or
233 directory was found else sal_False
234 ***********************************************/
236 sal_Bool SAL_CALL
osl_searchPath(
237 const rtl_uString
* pustrFilePath
,
238 const rtl_uString
* pustrSearchPathList
,
239 rtl_uString
** ppustrPathFound
);
247 #endif /* #ifndef _OSL_PATH_HELPER_H_ */
250 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */