xref: /aoo41x/main/sal/osl/os2/file_path_helper.h (revision cdf0e10c)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir  #ifndef _OSL_FILE_PATH_HELPER_H_
29*cdf0e10cSrcweir  #define _OSL_FILE_PATH_HELPER_H_
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir 
32*cdf0e10cSrcweir  #ifndef _SAL_TYPES_H_
33*cdf0e10cSrcweir  #include <sal/types.h>
34*cdf0e10cSrcweir  #endif
35*cdf0e10cSrcweir 
36*cdf0e10cSrcweir  #ifndef _RTL_USTRING_H_
37*cdf0e10cSrcweir  #include <rtl/ustring.h>
38*cdf0e10cSrcweir  #endif
39*cdf0e10cSrcweir 
40*cdf0e10cSrcweir 
41*cdf0e10cSrcweir  #ifdef __cplusplus
42*cdf0e10cSrcweir  extern "C"
43*cdf0e10cSrcweir  {
44*cdf0e10cSrcweir  #endif
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir 
47*cdf0e10cSrcweir  /*******************************************
48*cdf0e10cSrcweir     osl_systemPathRemoveSeparator
49*cdf0e10cSrcweir     Removes the last separator from the
50*cdf0e10cSrcweir     given system path if any and if the path
51*cdf0e10cSrcweir     is not the root path '/'
52*cdf0e10cSrcweir 
53*cdf0e10cSrcweir     @param	ppustrPath [inout] a system path
54*cdf0e10cSrcweir 			if the path is not the root path
55*cdf0e10cSrcweir 			and the last character is a
56*cdf0e10cSrcweir 			path separator it will be cut off
57*cdf0e10cSrcweir    			ppustrPath must not be NULL and
58*cdf0e10cSrcweir 			must point to a valid rtl_uString
59*cdf0e10cSrcweir 
60*cdf0e10cSrcweir     @returns nothing
61*cdf0e10cSrcweir 
62*cdf0e10cSrcweir   ******************************************/
63*cdf0e10cSrcweir 
64*cdf0e10cSrcweir  void SAL_CALL osl_systemPathRemoveSeparator(
65*cdf0e10cSrcweir  	/*inout*/ rtl_uString* pustrPath);
66*cdf0e10cSrcweir 
67*cdf0e10cSrcweir  /*******************************************
68*cdf0e10cSrcweir     osl_systemPathEnsureSeparator
69*cdf0e10cSrcweir     Adds a trailing path separator to the
70*cdf0e10cSrcweir     given system path if not already there
71*cdf0e10cSrcweir     and if the path is not the root path '/'
72*cdf0e10cSrcweir 
73*cdf0e10cSrcweir   	@param 	pustrPath [inout] a system path
74*cdf0e10cSrcweir 			if the path is not the root path
75*cdf0e10cSrcweir 			'/' and has no trailing separator
76*cdf0e10cSrcweir 			a separator will be added
77*cdf0e10cSrcweir 			ppustrPath must not be NULL and
78*cdf0e10cSrcweir 			must point to a valid rtl_uString
79*cdf0e10cSrcweir 
80*cdf0e10cSrcweir 	@returns nothing
81*cdf0e10cSrcweir 
82*cdf0e10cSrcweir   ******************************************/
83*cdf0e10cSrcweir 
84*cdf0e10cSrcweir  void SAL_CALL osl_systemPathEnsureSeparator(
85*cdf0e10cSrcweir  	/*inout*/ rtl_uString** ppustrPath);
86*cdf0e10cSrcweir 
87*cdf0e10cSrcweir  /*******************************************
88*cdf0e10cSrcweir     osl_systemPathIsRelativePath
89*cdf0e10cSrcweir     Returns true if the given path is a
90*cdf0e10cSrcweir 	relative path and so starts not with '/'
91*cdf0e10cSrcweir 
92*cdf0e10cSrcweir 	@param 	pustrPath [in] a system path
93*cdf0e10cSrcweir 			pustrPath must not be NULL
94*cdf0e10cSrcweir 
95*cdf0e10cSrcweir 	@returns sal_True if the given path
96*cdf0e10cSrcweir 			 doesn't start with a separator
97*cdf0e10cSrcweir 			 else sal_False will be returned
98*cdf0e10cSrcweir 
99*cdf0e10cSrcweir   ******************************************/
100*cdf0e10cSrcweir 
101*cdf0e10cSrcweir  sal_Bool SAL_CALL osl_systemPathIsRelativePath(
102*cdf0e10cSrcweir  	const rtl_uString* pustrPath);
103*cdf0e10cSrcweir 
104*cdf0e10cSrcweir  /******************************************
105*cdf0e10cSrcweir     osl_systemPathIsAbsolutePath
106*cdf0e10cSrcweir     Returns true if the given path is an
107*cdf0e10cSrcweir     absolute path and so starts with a '/'
108*cdf0e10cSrcweir 
109*cdf0e10cSrcweir 	@param pustrPath [in] a system path
110*cdf0e10cSrcweir 		   pustrPath must not be NULL
111*cdf0e10cSrcweir 
112*cdf0e10cSrcweir 	@returns sal_True if the given path
113*cdf0e10cSrcweir 			 start's with a separator else
114*cdf0e10cSrcweir 			 sal_False will be returned
115*cdf0e10cSrcweir 
116*cdf0e10cSrcweir   *****************************************/
117*cdf0e10cSrcweir 
118*cdf0e10cSrcweir  sal_Bool SAL_CALL osl_systemPathIsAbsolutePath(
119*cdf0e10cSrcweir  	const rtl_uString* pustrPath);
120*cdf0e10cSrcweir 
121*cdf0e10cSrcweir  /******************************************
122*cdf0e10cSrcweir     osl_systemPathMakeAbsolutePath
123*cdf0e10cSrcweir     Append a relative path to a base path
124*cdf0e10cSrcweir 
125*cdf0e10cSrcweir 	@param	pustrBasePath [in] a system
126*cdf0e10cSrcweir 			path that will be considered as
127*cdf0e10cSrcweir 			base path
128*cdf0e10cSrcweir 			pustrBasePath must not be NULL
129*cdf0e10cSrcweir 
130*cdf0e10cSrcweir 	@param	pustrRelPath [in] a system path
131*cdf0e10cSrcweir 			that will be considered as
132*cdf0e10cSrcweir 			relative path
133*cdf0e10cSrcweir 			pustrBasePath must not be NULL
134*cdf0e10cSrcweir 
135*cdf0e10cSrcweir 	@param	ppustrAbsolutePath [out] the
136*cdf0e10cSrcweir 			resulting path which is a
137*cdf0e10cSrcweir 			concatination of the base and
138*cdf0e10cSrcweir 			the relative path
139*cdf0e10cSrcweir 			if base path is empty the
140*cdf0e10cSrcweir 			resulting absolute path is the
141*cdf0e10cSrcweir 			relative path
142*cdf0e10cSrcweir 			if relative path is empty the
143*cdf0e10cSrcweir 			resulting absolute path is the
144*cdf0e10cSrcweir 			base path
145*cdf0e10cSrcweir 			if base and relative path are
146*cdf0e10cSrcweir 			empty the resulting absolute
147*cdf0e10cSrcweir 			path is also empty
148*cdf0e10cSrcweir 			ppustrAbsolutePath must not be
149*cdf0e10cSrcweir 			NULL and *ppustrAbsolutePath
150*cdf0e10cSrcweir 			must be 0 or point to a valid
151*cdf0e10cSrcweir 			rtl_uString
152*cdf0e10cSrcweir 
153*cdf0e10cSrcweir   *****************************************/
154*cdf0e10cSrcweir 
155*cdf0e10cSrcweir  void SAL_CALL osl_systemPathMakeAbsolutePath(
156*cdf0e10cSrcweir  	const rtl_uString* pustrBasePath,
157*cdf0e10cSrcweir 	const rtl_uString* pustrRelPath,
158*cdf0e10cSrcweir 	rtl_uString** 	   ppustrAbsolutePath);
159*cdf0e10cSrcweir 
160*cdf0e10cSrcweir  /*****************************************
161*cdf0e10cSrcweir 	osl_systemPathGetParent
162*cdf0e10cSrcweir 	Replaces the last occurrance of a path
163*cdf0e10cSrcweir 	separator with '\0' and returns the
164*cdf0e10cSrcweir 	position where the '/' was replaced
165*cdf0e10cSrcweir 
166*cdf0e10cSrcweir 	@param	pustrPath [inout] a system
167*cdf0e10cSrcweir 			path, the last separator of
168*cdf0e10cSrcweir 			this path will be replaced by
169*cdf0e10cSrcweir 			a '\0'
170*cdf0e10cSrcweir 			if the path is the root path
171*cdf0e10cSrcweir 			'/' or the path is considered
172*cdf0e10cSrcweir 			as to have no parent, e.g.
173*cdf0e10cSrcweir 			'/NoParent' or 'NoParent' or
174*cdf0e10cSrcweir 			the path is empty no
175*cdf0e10cSrcweir 			replacement will be made
176*cdf0e10cSrcweir 			pustrPath must not be NULL
177*cdf0e10cSrcweir 
178*cdf0e10cSrcweir 	@returns the position of the last path
179*cdf0e10cSrcweir 			 separator that was replaced
180*cdf0e10cSrcweir 			 or 0 if no replacement took
181*cdf0e10cSrcweir 			 place
182*cdf0e10cSrcweir 
183*cdf0e10cSrcweir   ****************************************/
184*cdf0e10cSrcweir 
185*cdf0e10cSrcweir  sal_Int32 SAL_CALL osl_systemPathGetParent(
186*cdf0e10cSrcweir 	/*inout*/ rtl_uString* pustrPath);
187*cdf0e10cSrcweir 
188*cdf0e10cSrcweir  /*****************************************
189*cdf0e10cSrcweir  	osl_systemPathGetFileOrLastDirectoryPart
190*cdf0e10cSrcweir 	Returns the file or the directory part
191*cdf0e10cSrcweir 	of the given path
192*cdf0e10cSrcweir 
193*cdf0e10cSrcweir 	@param pustrPath [in] a system path,
194*cdf0e10cSrcweir 		   must not be NULL
195*cdf0e10cSrcweir 
196*cdf0e10cSrcweir 	@param ppustrFileOrDirPart [out] on
197*cdf0e10cSrcweir 		   return receives the last part
198*cdf0e10cSrcweir 		   of the given directory or the
199*cdf0e10cSrcweir 		   file name
200*cdf0e10cSrcweir 		   if pustrPath is the root path
201*cdf0e10cSrcweir 		   '/' an empty string will be
202*cdf0e10cSrcweir 		   returned
203*cdf0e10cSrcweir 		   if pustrPath has a trailing
204*cdf0e10cSrcweir 		   '/' the last part before the
205*cdf0e10cSrcweir 		   '/' will be returned else
206*cdf0e10cSrcweir 		   the part after the last '/'
207*cdf0e10cSrcweir 		   will be returned
208*cdf0e10cSrcweir 
209*cdf0e10cSrcweir 	@returns nothing
210*cdf0e10cSrcweir 
211*cdf0e10cSrcweir   ****************************************/
212*cdf0e10cSrcweir  void SAL_CALL osl_systemPathGetFileNameOrLastDirectoryPart(
213*cdf0e10cSrcweir  	const rtl_uString* 	pustrPath,
214*cdf0e10cSrcweir 	rtl_uString** 		ppustrFileNameOrLastDirPart);
215*cdf0e10cSrcweir 
216*cdf0e10cSrcweir 
217*cdf0e10cSrcweir  /********************************************
218*cdf0e10cSrcweir  	osl_systemPathIsHiddenFileOrDirectoryEntry
219*cdf0e10cSrcweir 	Returns sal_True if the last part of
220*cdf0e10cSrcweir 	given system path is not '.' or '..'
221*cdf0e10cSrcweir 	alone and starts with a '.'
222*cdf0e10cSrcweir 
223*cdf0e10cSrcweir 	@param pustrPath [in] a system path,
224*cdf0e10cSrcweir 		   must not be NULL
225*cdf0e10cSrcweir 
226*cdf0e10cSrcweir 	@returns sal_True if the last part of
227*cdf0e10cSrcweir 			 the given system path starts
228*cdf0e10cSrcweir 			 with '.' or sal_False the last
229*cdf0e10cSrcweir 			 part is '.' or	'..' alone or
230*cdf0e10cSrcweir 			 doesn't start with a dot
231*cdf0e10cSrcweir 
232*cdf0e10cSrcweir  *********************************************/
233*cdf0e10cSrcweir 
234*cdf0e10cSrcweir  sal_Bool SAL_CALL osl_systemPathIsHiddenFileOrDirectoryEntry(
235*cdf0e10cSrcweir  	const rtl_uString* pustrPath);
236*cdf0e10cSrcweir 
237*cdf0e10cSrcweir 
238*cdf0e10cSrcweir  /************************************************
239*cdf0e10cSrcweir  	osl_systemPathIsLocalOrParentDirectoryEntry
240*cdf0e10cSrcweir 	Returns sal_True if the last part of the given
241*cdf0e10cSrcweir 	system path is the local directory entry '.'
242*cdf0e10cSrcweir 	or the parent directory entry '..'
243*cdf0e10cSrcweir 
244*cdf0e10cSrcweir 	@param pustrPath [in] a system path,
245*cdf0e10cSrcweir 		   must not be NULL
246*cdf0e10cSrcweir 
247*cdf0e10cSrcweir 	@returns sal_True if the last part of the
248*cdf0e10cSrcweir 			 given system path is '.' or '..'
249*cdf0e10cSrcweir 			 else sal_False
250*cdf0e10cSrcweir 
251*cdf0e10cSrcweir  ************************************************/
252*cdf0e10cSrcweir 
253*cdf0e10cSrcweir  sal_Bool SAL_CALL osl_systemPathIsLocalOrParentDirectoryEntry(
254*cdf0e10cSrcweir  	const rtl_uString* pustrPath);
255*cdf0e10cSrcweir 
256*cdf0e10cSrcweir 
257*cdf0e10cSrcweir  /************************************************
258*cdf0e10cSrcweir   	osl_searchPath
259*cdf0e10cSrcweir 	Searches for a file name or path name in all
260*cdf0e10cSrcweir 	directories specified by a given path list.
261*cdf0e10cSrcweir 	Symbolic links in the resulting path will not be
262*cdf0e10cSrcweir 	resolved, it's up to the caller to do this.
263*cdf0e10cSrcweir 
264*cdf0e10cSrcweir 	@param pustrFilePath [in] a file name or
265*cdf0e10cSrcweir 	directory name to search for, the name must
266*cdf0e10cSrcweir 	be provided as system path not as a file URL
267*cdf0e10cSrcweir 
268*cdf0e10cSrcweir 	@param pustrSearchPathList [in] a ':'
269*cdf0e10cSrcweir 	separated list of paths in which to search for
270*cdf0e10cSrcweir 	the file or directory name
271*cdf0e10cSrcweir 
272*cdf0e10cSrcweir 	@ppustrPathFound [out] on success receives the
273*cdf0e10cSrcweir 	complete path of the file or directory found
274*cdf0e10cSrcweir 	as a system path
275*cdf0e10cSrcweir 
276*cdf0e10cSrcweir 	@returns sal_True if the specified file or
277*cdf0e10cSrcweir 	directory was found else sal_False
278*cdf0e10cSrcweir   ***********************************************/
279*cdf0e10cSrcweir 
280*cdf0e10cSrcweir  sal_Bool SAL_CALL osl_searchPath(
281*cdf0e10cSrcweir  	const rtl_uString* pustrFilePath,
282*cdf0e10cSrcweir 	const rtl_uString* pustrSearchPathList,
283*cdf0e10cSrcweir 	rtl_uString**      ppustrPathFound);
284*cdf0e10cSrcweir 
285*cdf0e10cSrcweir 
286*cdf0e10cSrcweir  #ifdef __cplusplus
287*cdf0e10cSrcweir  }
288*cdf0e10cSrcweir  #endif
289*cdf0e10cSrcweir 
290*cdf0e10cSrcweir 
291*cdf0e10cSrcweir  #endif /* #ifndef _OSL_PATH_HELPER_H_ */
292*cdf0e10cSrcweir 
293