xref: /aoo41x/main/sal/qa/osl/file/osl_File_Const.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 //------------------------------------------------------------------------
29*cdf0e10cSrcweir //------------------------------------------------------------------------
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #ifndef _OSL_FILE_CONST_H_
32*cdf0e10cSrcweir #define _OSL_FILE_CONST_H_
33*cdf0e10cSrcweir 
34*cdf0e10cSrcweir //------------------------------------------------------------------------
35*cdf0e10cSrcweir //------------------------------------------------------------------------
36*cdf0e10cSrcweir #include <stdlib.h>
37*cdf0e10cSrcweir #include <stdio.h>
38*cdf0e10cSrcweir #include <string.h>
39*cdf0e10cSrcweir #include <sal/types.h>
40*cdf0e10cSrcweir #include <rtl/textenc.h>
41*cdf0e10cSrcweir 
42*cdf0e10cSrcweir #include <rtl/ustring.hxx>
43*cdf0e10cSrcweir #include <rtl/uri.hxx>
44*cdf0e10cSrcweir 
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir 
47*cdf0e10cSrcweir //------------------------------------------------------------------------
48*cdf0e10cSrcweir //------------------------------------------------------------------------
49*cdf0e10cSrcweir 
50*cdf0e10cSrcweir 
51*cdf0e10cSrcweir #ifdef __cplusplus
52*cdf0e10cSrcweir extern "C"
53*cdf0e10cSrcweir {
54*cdf0e10cSrcweir #endif
55*cdf0e10cSrcweir 
56*cdf0e10cSrcweir 
57*cdf0e10cSrcweir 
58*cdf0e10cSrcweir //------------------------------------------------------------------------
59*cdf0e10cSrcweir // common used string resource
60*cdf0e10cSrcweir // these common used string will be used as assist resource in test
61*cdf0e10cSrcweir // they are mostly OS independent, some of the resource can be reused
62*cdf0e10cSrcweir // so, acommon test data repository will be better since it can be
63*cdf0e10cSrcweir // shared among all test code
64*cdf0e10cSrcweir //------------------------------------------------------------------------
65*cdf0e10cSrcweir 
66*cdf0e10cSrcweir const sal_Char pBuffer_Char[]   = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
67*cdf0e10cSrcweir const sal_Char pBuffer_Number[] = "1234567890";
68*cdf0e10cSrcweir const sal_Char pBuffer_Blank[]  = "";
69*cdf0e10cSrcweir 
70*cdf0e10cSrcweir #define TRUNC_LEN               10;
71*cdf0e10cSrcweir #define ENLARG_LEN              100;
72*cdf0e10cSrcweir 
73*cdf0e10cSrcweir 
74*cdf0e10cSrcweir 
75*cdf0e10cSrcweir //------------------------------------------------------------------------
76*cdf0e10cSrcweir // OS dependent/independent definitions/includes
77*cdf0e10cSrcweir // we use FILE_PREFIX for URL prefix,
78*cdf0e10cSrcweir //        TEST_PLATFORM for test platform initial,
79*cdf0e10cSrcweir //        TEST_PLATFORM_ROOT for root dir in comrresponding platform,
80*cdf0e10cSrcweir //        TEST_PLATFORM_TEMP for temp dir in comrresponding platform,
81*cdf0e10cSrcweir //        PATH_LIST_DELIMITER for seperator of path list in comrresponding platform,
82*cdf0e10cSrcweir //        PATH_SEPERATOR for seperator in URL or system path in comrresponding platform,
83*cdf0e10cSrcweir //        PATH_MAX/MAX_PATH for max path length in comrresponding platform,
84*cdf0e10cSrcweir //------------------------------------------------------------------------
85*cdf0e10cSrcweir 
86*cdf0e10cSrcweir //------------------------------------------------------------------------
87*cdf0e10cSrcweir // OS independent const definition
88*cdf0e10cSrcweir //------------------------------------------------------------------------
89*cdf0e10cSrcweir #	define FILE_PREFIX          "file:///"
90*cdf0e10cSrcweir #	define TEST_FILE_SIZE       1024
91*cdf0e10cSrcweir 
92*cdf0e10cSrcweir //------------------------------------------------------------------------
93*cdf0e10cSrcweir // OS dependent declaration and includes
94*cdf0e10cSrcweir //------------------------------------------------------------------------
95*cdf0e10cSrcweir #if ( defined UNX ) || ( defined OS2 )  //Unix
96*cdf0e10cSrcweir #	include <unistd.h>
97*cdf0e10cSrcweir #	include <limits.h>
98*cdf0e10cSrcweir #	include <math.h>
99*cdf0e10cSrcweir #	include <errno.h>
100*cdf0e10cSrcweir #	include <fcntl.h>
101*cdf0e10cSrcweir #	include <sys/stat.h>
102*cdf0e10cSrcweir #	include <sys/statfs.h>
103*cdf0e10cSrcweir #	include <sys/statvfs.h>
104*cdf0e10cSrcweir #	include <sys/types.h>
105*cdf0e10cSrcweir #	define TEST_PLATFORM        ""
106*cdf0e10cSrcweir #	define TEST_PLATFORM_ROOT   "/"
107*cdf0e10cSrcweir #	define TEST_PLATFORM_TEMP   "tmp"
108*cdf0e10cSrcweir #	define PATH_LIST_DELIMITER  ":"
109*cdf0e10cSrcweir #	define PATH_SEPERATOR       "/"
110*cdf0e10cSrcweir #endif
111*cdf0e10cSrcweir #if (defined WNT )                      // Windows
112*cdf0e10cSrcweir #include <tools/prewin.h>
113*cdf0e10cSrcweir // #	include <windows.h>
114*cdf0e10cSrcweir #   include <tchar.h>
115*cdf0e10cSrcweir #	include <io.h>
116*cdf0e10cSrcweir #	include <stdio.h>
117*cdf0e10cSrcweir #	include <stdlib.h>
118*cdf0e10cSrcweir #include <tools/postwin.h>
119*cdf0e10cSrcweir #	define PATH_MAX             MAX_PATH
120*cdf0e10cSrcweir #	define TEST_PLATFORM        "c:/"
121*cdf0e10cSrcweir #	define TEST_PLATFORM_ROOT   "c:/"
122*cdf0e10cSrcweir #	define TEST_PLATFORM_TEMP   "temp"
123*cdf0e10cSrcweir #	define PATH_LIST_DELIMITER  ";"
124*cdf0e10cSrcweir #	define PATH_SEPERATOR		"/"
125*cdf0e10cSrcweir #endif
126*cdf0e10cSrcweir 
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir //------------------------------------------------------------------------
129*cdf0e10cSrcweir // macro definition for the ASCII array/OUString declarations,
130*cdf0e10cSrcweir // we use p### for the ASCII array,
131*cdf0e10cSrcweir //        a### for the OUString,
132*cdf0e10cSrcweir //        n###Len for its length
133*cdf0e10cSrcweir //------------------------------------------------------------------------
134*cdf0e10cSrcweir 
135*cdf0e10cSrcweir #define OSLTEST_DECLARE( str_name, str_value ) \
136*cdf0e10cSrcweir 	::rtl::OUString a##str_name = rtl::OUString::createFromAscii( ( str_value ) )
137*cdf0e10cSrcweir 
138*cdf0e10cSrcweir #define OSLTEST_DECLARE_UTF8(str_name, str_value ) \
139*cdf0e10cSrcweir 	::rtl::OUString a##str_name = ::rtl::Uri::decode( ::rtl::OUString::createFromAscii( ( str_value ) ), rtl_UriDecodeToIuri, RTL_TEXTENCODING_UTF8)
140*cdf0e10cSrcweir 
141*cdf0e10cSrcweir //------------------------------------------------------------------------
142*cdf0e10cSrcweir // OS independent file definition
143*cdf0e10cSrcweir //------------------------------------------------------------------------
144*cdf0e10cSrcweir OSLTEST_DECLARE( NullURL,  "" );
145*cdf0e10cSrcweir OSLTEST_DECLARE( SlashURL, PATH_SEPERATOR );
146*cdf0e10cSrcweir OSLTEST_DECLARE( PreURL, FILE_PREFIX );
147*cdf0e10cSrcweir OSLTEST_DECLARE( RootURL,  FILE_PREFIX TEST_PLATFORM );
148*cdf0e10cSrcweir 
149*cdf0e10cSrcweir OSLTEST_DECLARE( TempDirectoryURL,  FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP );
150*cdf0e10cSrcweir OSLTEST_DECLARE( TempDirectorySys,  TEST_PLATFORM_ROOT TEST_PLATFORM_TEMP );
151*cdf0e10cSrcweir OSLTEST_DECLARE( UserDirectoryURL,  FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP "" );
152*cdf0e10cSrcweir OSLTEST_DECLARE( UserDirectorySys,  TEST_PLATFORM_ROOT TEST_PLATFORM_TEMP "" );
153*cdf0e10cSrcweir 
154*cdf0e10cSrcweir //------------------------------------------------------------------------
155*cdf0e10cSrcweir // common used URL:temp, canonical, root, relative, link,etc
156*cdf0e10cSrcweir //------------------------------------------------------------------------
157*cdf0e10cSrcweir OSLTEST_DECLARE( CanURL1,  FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP "/canonical.name" );
158*cdf0e10cSrcweir OSLTEST_DECLARE( CanURL2,  "ca@#;+.,$///78no\0ni..name" );
159*cdf0e10cSrcweir OSLTEST_DECLARE( CanURL3,  "ca@#;+.,$//tmp/678nonical//name" );
160*cdf0e10cSrcweir OSLTEST_DECLARE( CanURL4,  "canonical.name" );
161*cdf0e10cSrcweir OSLTEST_DECLARE( TmpName1, "tmpdir" );
162*cdf0e10cSrcweir OSLTEST_DECLARE( TmpName2, "tmpname" );
163*cdf0e10cSrcweir OSLTEST_DECLARE( TmpName3, FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP "/tmpdir" );
164*cdf0e10cSrcweir OSLTEST_DECLARE( TmpName4, FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP "/tmpdir/tmpname" );
165*cdf0e10cSrcweir OSLTEST_DECLARE( TmpName5, FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP "/tmpdir/../tmpdir/./tmpname" );
166*cdf0e10cSrcweir OSLTEST_DECLARE( TmpName6, FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP "/tmpname" );
167*cdf0e10cSrcweir OSLTEST_DECLARE( TmpName7, FILE_PREFIX TEST_PLATFORM "tmpname" );
168*cdf0e10cSrcweir OSLTEST_DECLARE( TmpName8, FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP "/tmpname/tmpdir" );
169*cdf0e10cSrcweir OSLTEST_DECLARE( TmpName9, FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP "/tmpdir/../tmpdir/./" );
170*cdf0e10cSrcweir OSLTEST_DECLARE_UTF8( TmpName10, FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP "/%E6%9C%AA%E5%91%BD%E5%90%8Dzhgb18030" );
171*cdf0e10cSrcweir 
172*cdf0e10cSrcweir OSLTEST_DECLARE( RelURL1,  "relative/file1" );
173*cdf0e10cSrcweir OSLTEST_DECLARE( RelURL2,  "relative/./file2" );
174*cdf0e10cSrcweir OSLTEST_DECLARE( RelURL3,  "relative/../file3" );
175*cdf0e10cSrcweir OSLTEST_DECLARE( RelURL4,  "././relative/../file4" );
176*cdf0e10cSrcweir OSLTEST_DECLARE( RelURL5,  TEST_PLATFORM_TEMP "/./../" TEST_PLATFORM_TEMP );
177*cdf0e10cSrcweir OSLTEST_DECLARE( LnkURL1,  FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP "/link.file" );
178*cdf0e10cSrcweir OSLTEST_DECLARE( HidURL1,  ".hiddenfile" );
179*cdf0e10cSrcweir 
180*cdf0e10cSrcweir //------------------------------------------------------------------------
181*cdf0e10cSrcweir // common used System Path:temp, root,etc
182*cdf0e10cSrcweir //------------------------------------------------------------------------
183*cdf0e10cSrcweir OSLTEST_DECLARE( RootSys,  TEST_PLATFORM_ROOT );
184*cdf0e10cSrcweir OSLTEST_DECLARE( SysPath1, TEST_PLATFORM_ROOT TEST_PLATFORM_TEMP "/system.path" );
185*cdf0e10cSrcweir OSLTEST_DECLARE( SysPath2, TEST_PLATFORM_ROOT TEST_PLATFORM_TEMP "/system/path" );
186*cdf0e10cSrcweir OSLTEST_DECLARE( SysPath3, TEST_PLATFORM_ROOT TEST_PLATFORM_TEMP "/tmpdir" );
187*cdf0e10cSrcweir OSLTEST_DECLARE( SysPath4, TEST_PLATFORM_ROOT TEST_PLATFORM_TEMP "/tmpname" );
188*cdf0e10cSrcweir OSLTEST_DECLARE_UTF8( SysPath5, TEST_PLATFORM_ROOT TEST_PLATFORM_TEMP "/%E6%9C%AA%E5%91%BD%E5%90%8Dzhgb18030" );
189*cdf0e10cSrcweir OSLTEST_DECLARE( FifoSys,  TEST_PLATFORM_ROOT TEST_PLATFORM_TEMP "/tmpdir/fifo" );
190*cdf0e10cSrcweir 
191*cdf0e10cSrcweir //------------------------------------------------------------------------
192*cdf0e10cSrcweir // FileType URL, we pick some canonical file in corresponding system for test:
193*cdf0e10cSrcweir // socket, link, etc.
194*cdf0e10cSrcweir // Note that this may be changed in the different platform, so be careful to use.
195*cdf0e10cSrcweir //------------------------------------------------------------------------
196*cdf0e10cSrcweir #if ( defined UNX ) || ( defined OS2 )                                 //          Unix
197*cdf0e10cSrcweir OSLTEST_DECLARE( TypeURL1,  FILE_PREFIX "dev/ccv");                    //socket    Solaris/Linux
198*cdf0e10cSrcweir OSLTEST_DECLARE( TypeURL2,  FILE_PREFIX "devices/pseudo/tcp@0:tcp");   //special   Solaris/Linux
199*cdf0e10cSrcweir OSLTEST_DECLARE( TypeURL3,  FILE_PREFIX "lib" );                       //link      Solaris
200*cdf0e10cSrcweir #else                                                                  //          Windows
201*cdf0e10cSrcweir OSLTEST_DECLARE( TypeURL1,  FILE_PREFIX "" );
202*cdf0e10cSrcweir OSLTEST_DECLARE( TypeURL2,  FILE_PREFIX "" );
203*cdf0e10cSrcweir OSLTEST_DECLARE( TypeURL3,  FILE_PREFIX "" );
204*cdf0e10cSrcweir #endif
205*cdf0e10cSrcweir 
206*cdf0e10cSrcweir //------------------------------------------------------------------------
207*cdf0e10cSrcweir // Volume device URL, we pick some canonical volume device for test:
208*cdf0e10cSrcweir // UNIX file system, Floppy Disk, Proc file system, Temp file system, Compact Disk.
209*cdf0e10cSrcweir //------------------------------------------------------------------------
210*cdf0e10cSrcweir #if ( defined UNX ) || ( defined OS2 )					//			Unix
211*cdf0e10cSrcweir OSLTEST_DECLARE( VolURL1,  FILE_PREFIX  "");			//ufs		Solaris/Linux
212*cdf0e10cSrcweir #ifdef SOLARIS
213*cdf0e10cSrcweir OSLTEST_DECLARE( VolURL2,  FILE_PREFIX  "dev/fd" );		//fd		Solaris
214*cdf0e10cSrcweir #else
215*cdf0e10cSrcweir OSLTEST_DECLARE( VolURL2,  FILE_PREFIX  "dev/floppy/0u1440" );	//fd0		Linux
216*cdf0e10cSrcweir #endif
217*cdf0e10cSrcweir OSLTEST_DECLARE( VolURL3,  FILE_PREFIX  "proc" );		//proc		Solaris/Linux
218*cdf0e10cSrcweir OSLTEST_DECLARE( VolURL4,  FILE_PREFIX  "staroffice" );	//nfs		Solaris/Linux
219*cdf0e10cSrcweir OSLTEST_DECLARE( VolURL5,  FILE_PREFIX  "tmp" );		//tmpfs		Solaris
220*cdf0e10cSrcweir OSLTEST_DECLARE( VolURL6,  FILE_PREFIX  "cdrom" );		//cd		Solaris
221*cdf0e10cSrcweir #else													//			Windows
222*cdf0e10cSrcweir OSLTEST_DECLARE( VolURL1,  FILE_PREFIX  "c:/" );
223*cdf0e10cSrcweir OSLTEST_DECLARE( VolURL2,  FILE_PREFIX  "a:/" );
224*cdf0e10cSrcweir OSLTEST_DECLARE( VolURL3,  FILE_PREFIX  "" );
225*cdf0e10cSrcweir OSLTEST_DECLARE( VolURL4,  FILE_PREFIX  "" );
226*cdf0e10cSrcweir OSLTEST_DECLARE( VolURL5,  FILE_PREFIX  "c:/temp" );
227*cdf0e10cSrcweir OSLTEST_DECLARE( VolURL6,  FILE_PREFIX  "e:/" );
228*cdf0e10cSrcweir #endif
229*cdf0e10cSrcweir 
230*cdf0e10cSrcweir 
231*cdf0e10cSrcweir //------------------------------------------------------------------------
232*cdf0e10cSrcweir //------------------------------------------------------------------------
233*cdf0e10cSrcweir 
234*cdf0e10cSrcweir #ifdef __cplusplus
235*cdf0e10cSrcweir }
236*cdf0e10cSrcweir #endif
237*cdf0e10cSrcweir 
238*cdf0e10cSrcweir //------------------------------------------------------------------------
239*cdf0e10cSrcweir //------------------------------------------------------------------------
240*cdf0e10cSrcweir 
241*cdf0e10cSrcweir 
242*cdf0e10cSrcweir #endif /* _OSL_FILE_CONST_H_ */
243