1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef _OSL_FILE_PATH_HELPER_H_
21 #define _OSL_FILE_PATH_HELPER_H_
23 #include <sal/types.h>
24 #include <rtl/ustring.h>
31 /*******************************************
32 osl_systemPathRemoveSeparator
33 Removes the last separator from the
34 given system path if any and if the path
35 is not the root path '/'
37 @param ppustrPath [inout] a system path
38 if the path is not the root path
39 and the last character is a
40 path separator it will be cut off
41 ppustrPath must not be NULL and
42 must point to a valid rtl_uString
46 ******************************************/
48 void SAL_CALL
osl_systemPathRemoveSeparator(
49 /*inout*/ rtl_uString
* pustrPath
);
51 /*******************************************
52 osl_systemPathEnsureSeparator
53 Adds a trailing path separator to the
54 given system path if not already there
55 and if the path is not the root path '/'
57 @param pustrPath [inout] a system path
58 if the path is not the root path
59 '/' and has no trailing separator
60 a separator will be added
61 ppustrPath must not be NULL and
62 must point to a valid rtl_uString
66 ******************************************/
68 void SAL_CALL
osl_systemPathEnsureSeparator(
69 rtl_uString
** ppustrPath
);
71 /*******************************************
72 osl_systemPathIsRelativePath
73 Returns true if the given path is a
74 relative path and so starts not with '/'
76 @param pustrPath [in] a system path
77 pustrPath must not be NULL
79 @returns sal_True if the given path
80 doesn't start with a separator
81 else sal_False will be returned
83 ******************************************/
85 sal_Bool SAL_CALL
osl_systemPathIsRelativePath(
86 const rtl_uString
* pustrPath
);
88 /******************************************
89 osl_systemPathMakeAbsolutePath
90 Append a relative path to a base path
92 @param pustrBasePath [in] a system
93 path that will be considered as
95 pustrBasePath must not be NULL
97 @param pustrRelPath [in] a system path
98 that will be considered as
100 pustrBasePath must not be NULL
102 @param ppustrAbsolutePath [out] the
103 resulting path which is a
104 concatination of the base and
106 if base path is empty the
107 resulting absolute path is the
109 if relative path is empty the
110 resulting absolute path is the
112 if base and relative path are
113 empty the resulting absolute
115 ppustrAbsolutePath must not be
116 NULL and *ppustrAbsolutePath
117 must be 0 or point to a valid
120 *****************************************/
122 void SAL_CALL
osl_systemPathMakeAbsolutePath(
123 const rtl_uString
* pustrBasePath
,
124 const rtl_uString
* pustrRelPath
,
125 rtl_uString
** ppustrAbsolutePath
);
127 /*****************************************
128 osl_systemPathGetFileOrLastDirectoryPart
129 Returns the file or the directory part
132 @param pustrPath [in] a system path,
135 @param ppustrFileOrDirPart [out] on
136 return receives the last part
137 of the given directory or the
139 if pustrPath is the root path
140 '/' an empty string will be
142 if pustrPath has a trailing
143 '/' the last part before the
144 '/' will be returned else
145 the part after the last '/'
150 ****************************************/
152 void SAL_CALL
osl_systemPathGetFileNameOrLastDirectoryPart(
153 const rtl_uString
* pustrPath
,
154 rtl_uString
** ppustrFileNameOrLastDirPart
);
156 /********************************************
157 osl_systemPathIsHiddenFileOrDirectoryEntry
158 Returns sal_True if the last part of
159 given system path is not '.' or '..'
160 alone and starts with a '.'
162 @param pustrPath [in] a system path,
165 @returns sal_True if the last part of
166 the given system path starts
167 with '.' or sal_False the last
168 part is '.' or '..' alone or
169 doesn't start with a dot
171 *********************************************/
173 sal_Bool SAL_CALL
osl_systemPathIsHiddenFileOrDirectoryEntry(
174 const rtl_uString
* pustrPath
);
176 /************************************************
177 osl_systemPathIsLocalOrParentDirectoryEntry
178 Returns sal_True if the last part of the given
179 system path is the local directory entry '.'
180 or the parent directory entry '..'
182 @param pustrPath [in] a system path,
185 @returns sal_True if the last part of the
186 given system path is '.' or '..'
189 ************************************************/
191 sal_Bool SAL_CALL
osl_systemPathIsLocalOrParentDirectoryEntry(
192 const rtl_uString
* pustrPath
);
194 /************************************************
196 Searches for a file name or path name in all
197 directories specified by a given path list.
198 Symbolic links in the resulting path will not be
199 resolved, it's up to the caller to do this.
201 @param pustrFilePath [in] a file name or
202 directory name to search for, the name must
203 be provided as system path not as a file URL
205 @param pustrSearchPathList [in] a ':'
206 separated list of paths in which to search for
207 the file or directory name
209 @param ppustrPathFound [out] on success receives the
210 complete path of the file or directory found
213 @returns sal_True if the specified file or
214 directory was found else sal_False
215 ***********************************************/
217 sal_Bool SAL_CALL
osl_searchPath(
218 const rtl_uString
* pustrFilePath
,
219 const rtl_uString
* pustrSearchPathList
,
220 rtl_uString
** ppustrPathFound
);
226 #endif /* #ifndef _OSL_PATH_HELPER_H_ */
228 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */