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_HXX_
30 #define _OSL_FILE_PATH_HELPER_HXX_
33 #include "file_path_helper.h"
35 #include <rtl/ustring.hxx>
41 /*******************************************
42 systemPathRemoveSeparator
43 Removes the last separator from the
44 given system path if any and if the path
45 is not the root path '/'
47 @param ppustrPath [inout] a system path
48 if the path is not the root path
49 and the last character is a
50 path separator it will be cut off
51 ppustrPath must not be NULL and
52 must point to a valid rtl_uString
56 ******************************************/
58 inline void systemPathRemoveSeparator(/*inout*/ rtl::OUString
& Path
)
60 osl_systemPathRemoveSeparator(Path
.pData
);
63 /*******************************************
64 systemPathEnsureSeparator
65 Adds a trailing path separator to the
66 given system path if not already there
67 and if the path is not the root path '/'
69 @param pustrPath [inout] a system path
70 if the path is not the root path
71 '/' and has no trailing separator
72 a separator will be added
73 ppustrPath must not be NULL and
74 must point to a valid rtl_uString
78 ******************************************/
80 inline void systemPathEnsureSeparator(/*inout*/ rtl::OUString
& Path
)
82 osl_systemPathEnsureSeparator(&Path
.pData
);
85 /*******************************************
86 systemPathIsRelativePath
87 Returns true if the given path is a
88 relative path and so starts not with '/'
90 @param pustrPath [in] a system path
91 pustrPath must not be NULL
93 @returns sal_True if the given path
94 doesn't start with a separator
95 else sal_False will be returned
97 ******************************************/
99 inline bool systemPathIsRelativePath(const rtl::OUString
& Path
)
101 return osl_systemPathIsRelativePath(Path
.pData
);
104 /******************************************
105 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 inline void systemPathMakeAbsolutePath(
139 const rtl::OUString
& BasePath
,
140 const rtl::OUString
& RelPath
,
141 rtl::OUString
& AbsolutePath
)
143 osl_systemPathMakeAbsolutePath(
144 BasePath
.pData
, RelPath
.pData
, &AbsolutePath
.pData
);
147 /*****************************************
148 systemPathGetFileOrLastDirectoryPart
149 Returns the file or the directory part
152 @param pustrPath [in] a system path,
155 @param ppustrFileOrDirPart [out] on
156 return receives the last part
157 of the given directory or the
159 if pustrPath is the root path
160 '/' an empty string will be
162 if pustrPath has a trailing
163 '/' the last part before the
164 '/' will be returned else
165 the part after the last '/'
170 ****************************************/
172 inline void systemPathGetFileNameOrLastDirectoryPart(
173 const rtl::OUString
& Path
,
174 rtl::OUString
& FileNameOrLastDirPart
)
176 osl_systemPathGetFileNameOrLastDirectoryPart(
177 Path
.pData
, &FileNameOrLastDirPart
.pData
);
181 /********************************************
182 systemPathIsHiddenFileOrDirectoryEntry
183 Returns sal_True if the last part of
184 given system path is not '.' or '..'
185 alone and starts with a '.'
187 @param pustrPath [in] a system path,
190 @returns sal_True if the last part of
191 the given system path starts
192 with '.' or sal_False the last
193 part is '.' or '..' alone or
194 doesn't start with a dot
196 *********************************************/
198 inline bool systemPathIsHiddenFileOrDirectoryEntry(
199 const rtl::OUString
& Path
)
201 return osl_systemPathIsHiddenFileOrDirectoryEntry(Path
.pData
);
205 /************************************************
206 systemPathIsLocalOrParentDirectoryEntry
207 Returns sal_True if the last part of the given
208 system path is the local directory entry '.'
209 or the parent directory entry '..'
211 @param pustrPath [in] a system path,
214 @returns sal_True if the last part of the
215 given system path is '.' or '..'
218 ************************************************/
220 inline bool systemPathIsLocalOrParentDirectoryEntry(
221 const rtl::OUString
& Path
)
223 return osl_systemPathIsLocalOrParentDirectoryEntry(Path
.pData
);
226 /************************************************
228 ***********************************************/
230 inline bool searchPath(
231 const rtl::OUString
& ustrFilePath
,
232 const rtl::OUString
& ustrSearchPathList
,
233 rtl::OUString
& ustrPathFound
)
235 return osl_searchPath(
237 ustrSearchPathList
.pData
,
238 &ustrPathFound
.pData
);
245 #endif /* #ifndef _OSL_PATH_HELPER_HXX_ */
248 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */