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_HXX_
29 #define _OSL_FILE_PATH_HELPER_HXX_
32 #ifndef _OSL_FILE_PATH_HELPER_H_
33 #include "file_path_helper.h"
36 #include <rtl/ustring.hxx>
42 /*******************************************
43 systemPathRemoveSeparator
44 Removes the last separator from the
45 given system path if any and if the path
46 is not the root path '/'
48 @param ppustrPath [inout] a system path
49 if the path is not the root path
50 and the last character is a
51 path separator it will be cut off
52 ppustrPath must not be NULL and
53 must point to a valid rtl_uString
57 ******************************************/
59 inline void systemPathRemoveSeparator(/*inout*/ rtl::OUString
& Path
)
61 osl_systemPathRemoveSeparator(Path
.pData
);
64 /*******************************************
65 systemPathEnsureSeparator
66 Adds a trailing path separator to the
67 given system path if not already there
68 and if the path is not the root path '/'
70 @param pustrPath [inout] a system path
71 if the path is not the root path
72 '/' and has no trailing separator
73 a separator will be added
74 ppustrPath must not be NULL and
75 must point to a valid rtl_uString
79 ******************************************/
81 inline void systemPathEnsureSeparator(/*inout*/ rtl::OUString
& Path
)
83 osl_systemPathEnsureSeparator(&Path
.pData
);
86 /*******************************************
87 systemPathIsRelativePath
88 Returns true if the given path is a
89 relative path and so starts not with '/'
91 @param pustrPath [in] a system path
92 pustrPath must not be NULL
94 @returns sal_True if the given path
95 doesn't start with a separator
96 else sal_False will be returned
98 ******************************************/
100 inline bool systemPathIsRelativePath(const rtl::OUString
& Path
)
102 return osl_systemPathIsRelativePath(Path
.pData
);
105 /******************************************
106 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 inline void systemPathMakeAbsolutePath(
140 const rtl::OUString
& BasePath
,
141 const rtl::OUString
& RelPath
,
142 rtl::OUString
& AbsolutePath
)
144 osl_systemPathMakeAbsolutePath(
145 BasePath
.pData
, RelPath
.pData
, &AbsolutePath
.pData
);
148 /*****************************************
149 systemPathGetFileOrLastDirectoryPart
150 Returns the file or the directory part
153 @param pustrPath [in] a system path,
156 @param ppustrFileOrDirPart [out] on
157 return receives the last part
158 of the given directory or the
160 if pustrPath is the root path
161 '/' an empty string will be
163 if pustrPath has a trailing
164 '/' the last part before the
165 '/' will be returned else
166 the part after the last '/'
171 ****************************************/
173 inline void systemPathGetFileNameOrLastDirectoryPart(
174 const rtl::OUString
& Path
,
175 rtl::OUString
& FileNameOrLastDirPart
)
177 osl_systemPathGetFileNameOrLastDirectoryPart(
178 Path
.pData
, &FileNameOrLastDirPart
.pData
);
182 /********************************************
183 systemPathIsHiddenFileOrDirectoryEntry
184 Returns sal_True if the last part of
185 given system path is not '.' or '..'
186 alone and starts with a '.'
188 @param pustrPath [in] a system path,
191 @returns sal_True if the last part of
192 the given system path starts
193 with '.' or sal_False the last
194 part is '.' or '..' alone or
195 doesn't start with a dot
197 *********************************************/
199 inline bool systemPathIsHiddenFileOrDirectoryEntry(
200 const rtl::OUString
& Path
)
202 return osl_systemPathIsHiddenFileOrDirectoryEntry(Path
.pData
);
206 /************************************************
207 systemPathIsLocalOrParentDirectoryEntry
208 Returns sal_True if the last part of the given
209 system path is the local directory entry '.'
210 or the parent directory entry '..'
212 @param pustrPath [in] a system path,
215 @returns sal_True if the last part of the
216 given system path is '.' or '..'
219 ************************************************/
221 inline bool systemPathIsLocalOrParentDirectoryEntry(
222 const rtl::OUString
& Path
)
224 return osl_systemPathIsLocalOrParentDirectoryEntry(Path
.pData
);
227 /************************************************
229 ***********************************************/
231 inline bool searchPath(
232 const rtl::OUString
& ustrFilePath
,
233 const rtl::OUString
& ustrSearchPathList
,
234 rtl::OUString
& ustrPathFound
)
236 return osl_searchPath(
238 ustrSearchPathList
.pData
,
239 &ustrPathFound
.pData
);
246 #endif /* #ifndef _OSL_PATH_HELPER_HXX_ */