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