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