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