xref: /AOO41X/main/sal/osl/os2/file_url.h (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
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  /***************************************************
29*cdf0e10cSrcweir   * Internal header file, declares all functions
30*cdf0e10cSrcweir   * that are not part of the offical API and are
31*cdf0e10cSrcweir   * not defined in the osl header files
32*cdf0e10cSrcweir   **************************************************/
33*cdf0e10cSrcweir 
34*cdf0e10cSrcweir  #ifndef _FILE_URL_H_
35*cdf0e10cSrcweir  #define _FILE_URL_H_
36*cdf0e10cSrcweir 
37*cdf0e10cSrcweir  #ifndef _FILE_H_
38*cdf0e10cSrcweir  #include <osl/file.h>
39*cdf0e10cSrcweir  #endif
40*cdf0e10cSrcweir 
41*cdf0e10cSrcweir 
42*cdf0e10cSrcweir /***************************************************
43*cdf0e10cSrcweir  * constants
44*cdf0e10cSrcweir  **************************************************/
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir #define _tcslen(a)		wcslen((const wchar_t *) a)
47*cdf0e10cSrcweir #define _tcsspn(a,b)	wcsspn((const wchar_t *) a, (const wchar_t *) b)
48*cdf0e10cSrcweir #define _istalpha(a)	iswalpha((wint_t) a)
49*cdf0e10cSrcweir 
50*cdf0e10cSrcweir const sal_Unicode UNICHAR_SLASH = ((sal_Unicode)'/');
51*cdf0e10cSrcweir const sal_Unicode UNICHAR_COLON = ((sal_Unicode)':');
52*cdf0e10cSrcweir const sal_Unicode UNICHAR_DOT   = ((sal_Unicode)'.');
53*cdf0e10cSrcweir 
54*cdf0e10cSrcweir #define ELEMENTS_OF_ARRAY(arr) (sizeof(arr)/(sizeof((arr)[0])))
55*cdf0e10cSrcweir 
56*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0
57*cdf0e10cSrcweir #define OSL_ENSURE_FILE( cond, msg, file ) ( (cond) ?  (void)0 : _osl_warnFile( msg, file ) )
58*cdf0e10cSrcweir #else
59*cdf0e10cSrcweir #define OSL_ENSURE_FILE( cond, msg, file ) ((void)0)
60*cdf0e10cSrcweir #endif
61*cdf0e10cSrcweir 
62*cdf0e10cSrcweir typedef sal_Unicode            				TCHAR;
63*cdf0e10cSrcweir typedef sal_Unicode           				*LPTSTR;
64*cdf0e10cSrcweir typedef const sal_Unicode     				*LPCTSTR;
65*cdf0e10cSrcweir typedef wchar_t           				*LPWSTR;
66*cdf0e10cSrcweir typedef const wchar_t     				*LPCWSTR;
67*cdf0e10cSrcweir typedef sal_Unicode							DWORD;
68*cdf0e10cSrcweir #define WINAPI
69*cdf0e10cSrcweir 
70*cdf0e10cSrcweir #define	CHARSET_SEPARATOR					L"\\/"
71*cdf0e10cSrcweir #define WSTR_SYSTEM_ROOT_PATH				L"\\\\.\\"
72*cdf0e10cSrcweir 
73*cdf0e10cSrcweir 
74*cdf0e10cSrcweir /******************************************************************************
75*cdf0e10cSrcweir  *
76*cdf0e10cSrcweir  *                  Data Type Definition
77*cdf0e10cSrcweir  *
78*cdf0e10cSrcweir  ******************************************************************************/
79*cdf0e10cSrcweir 
80*cdf0e10cSrcweir #define PATHTYPE_ERROR						0
81*cdf0e10cSrcweir #define PATHTYPE_RELATIVE					1
82*cdf0e10cSrcweir #define PATHTYPE_ABSOLUTE_UNC				2
83*cdf0e10cSrcweir #define PATHTYPE_ABSOLUTE_LOCAL				3
84*cdf0e10cSrcweir #define PATHTYPE_MASK_TYPE					0xFF
85*cdf0e10cSrcweir #define PATHTYPE_IS_VOLUME					0x0100
86*cdf0e10cSrcweir #define PATHTYPE_IS_SERVER					0x0200
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir #define VALIDATEPATH_NORMAL					0x0000
89*cdf0e10cSrcweir #define VALIDATEPATH_ALLOW_WILDCARDS		0x0001
90*cdf0e10cSrcweir #define VALIDATEPATH_ALLOW_ELLIPSE			0x0002
91*cdf0e10cSrcweir #define VALIDATEPATH_ALLOW_RELATIVE			0x0004
92*cdf0e10cSrcweir #define VALIDATEPATH_ALLOW_UNC				0x0008
93*cdf0e10cSrcweir 
94*cdf0e10cSrcweir typedef struct {
95*cdf0e10cSrcweir 	UINT			uType;
96*cdf0e10cSrcweir     rtl_uString* 	ustrDrive;
97*cdf0e10cSrcweir     rtl_uString* 	ustrFilePath;	/* holds native directory path */
98*cdf0e10cSrcweir 	int				d_attr;			/* OS/2 file attributes */
99*cdf0e10cSrcweir 	int				nRefCount;
100*cdf0e10cSrcweir }DirectoryItem_Impl;
101*cdf0e10cSrcweir 
102*cdf0e10cSrcweir #define	DIRECTORYTYPE_LOCALROOT	    0
103*cdf0e10cSrcweir #define	DIRECTORYTYPE_NETROOT		1
104*cdf0e10cSrcweir #define	DIRECTORYTYPE_NETRESORCE	2
105*cdf0e10cSrcweir #define	DIRECTORYTYPE_FILESYSTEM	3
106*cdf0e10cSrcweir 
107*cdf0e10cSrcweir #define DIRECTORYITEM_DRIVE		0
108*cdf0e10cSrcweir #define DIRECTORYITEM_FILE		1
109*cdf0e10cSrcweir #define DIRECTORYITEM_SERVER	2
110*cdf0e10cSrcweir 
111*cdf0e10cSrcweir typedef struct
112*cdf0e10cSrcweir {
113*cdf0e10cSrcweir 	UINT		 uType;
114*cdf0e10cSrcweir     rtl_uString* ustrPath;           /* holds native directory path */
115*cdf0e10cSrcweir     DIR*         pDirStruct;
116*cdf0e10cSrcweir 	ULONG		 ulDriveMap;
117*cdf0e10cSrcweir 	ULONG		 ulNextDrive;
118*cdf0e10cSrcweir 	ULONG		 ulNextDriveMask;
119*cdf0e10cSrcweir } DirectoryImpl;
120*cdf0e10cSrcweir 
121*cdf0e10cSrcweir /* Different types of paths */
122*cdf0e10cSrcweir typedef enum _PATHTYPE
123*cdf0e10cSrcweir {
124*cdf0e10cSrcweir 	PATHTYPE_SYNTAXERROR = 0,
125*cdf0e10cSrcweir 	PATHTYPE_NETROOT,
126*cdf0e10cSrcweir 	PATHTYPE_NETSERVER,
127*cdf0e10cSrcweir 	PATHTYPE_VOLUME,
128*cdf0e10cSrcweir 	PATHTYPE_FILE
129*cdf0e10cSrcweir } PATHTYPE;
130*cdf0e10cSrcweir 
131*cdf0e10cSrcweir DWORD WINAPI IsValidFilePath(LPCTSTR, LPCTSTR*, DWORD);
132*cdf0e10cSrcweir 
133*cdf0e10cSrcweir typedef struct
134*cdf0e10cSrcweir {
135*cdf0e10cSrcweir     rtl_uString* ustrFilePath;      /* holds native file path */
136*cdf0e10cSrcweir     int fd;
137*cdf0e10cSrcweir     sal_Bool bLocked;
138*cdf0e10cSrcweir } oslFileHandleImpl;
139*cdf0e10cSrcweir 
140*cdf0e10cSrcweir 
141*cdf0e10cSrcweir typedef struct _oslVolumeDeviceHandleImpl
142*cdf0e10cSrcweir {
143*cdf0e10cSrcweir     sal_Char pszMountPoint[PATH_MAX];
144*cdf0e10cSrcweir     sal_Char pszFilePath[PATH_MAX];
145*cdf0e10cSrcweir     sal_Char pszDevice[PATH_MAX];
146*cdf0e10cSrcweir     sal_Char ident[4];
147*cdf0e10cSrcweir     sal_uInt32   RefCount;
148*cdf0e10cSrcweir } oslVolumeDeviceHandleImpl;
149*cdf0e10cSrcweir 
150*cdf0e10cSrcweir /* OS error to errno values mapping table */
151*cdf0e10cSrcweir struct errentry {
152*cdf0e10cSrcweir 	unsigned long oscode;	/* OS return value */
153*cdf0e10cSrcweir 	int errnocode;			/* System V error code */
154*cdf0e10cSrcweir };
155*cdf0e10cSrcweir 
156*cdf0e10cSrcweir #ifdef __cplusplus
157*cdf0e10cSrcweir extern "C"
158*cdf0e10cSrcweir {
159*cdf0e10cSrcweir #endif
160*cdf0e10cSrcweir 
161*cdf0e10cSrcweir /**************************************************
162*cdf0e10cSrcweir * _osl_getSystemPathFromFileURL
163*cdf0e10cSrcweir *************************************************/
164*cdf0e10cSrcweir 
165*cdf0e10cSrcweir #define FURL_ALLOW_RELATIVE sal_True
166*cdf0e10cSrcweir #define FURL_DENY_RELATIVE  sal_False
167*cdf0e10cSrcweir 
168*cdf0e10cSrcweir oslFileError osl_getSystemPathFromFileURL_Ex(rtl_uString *ustrFileURL, rtl_uString **pustrSystemPath, sal_Bool bAllowRelative);
169*cdf0e10cSrcweir 
170*cdf0e10cSrcweir /**************************************************
171*cdf0e10cSrcweir * FileURLToPath
172*cdf0e10cSrcweir *************************************************/
173*cdf0e10cSrcweir 
174*cdf0e10cSrcweir oslFileError FileURLToPath(char * buffer, size_t bufLen, rtl_uString* ustrFileURL);
175*cdf0e10cSrcweir 
176*cdf0e10cSrcweir 
177*cdf0e10cSrcweir #ifdef __cplusplus
178*cdf0e10cSrcweir }
179*cdf0e10cSrcweir #endif
180*cdf0e10cSrcweir 
181*cdf0e10cSrcweir 
182*cdf0e10cSrcweir #endif /* #define _FILE_URL_H_ */
183*cdf0e10cSrcweir 
184