1*514f4c20SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*514f4c20SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*514f4c20SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*514f4c20SAndrew Rist * distributed with this work for additional information 6*514f4c20SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*514f4c20SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*514f4c20SAndrew Rist * "License"); you may not use this file except in compliance 9*514f4c20SAndrew Rist * with the License. You may obtain a copy of the License at 10*514f4c20SAndrew Rist * 11*514f4c20SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*514f4c20SAndrew Rist * 13*514f4c20SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*514f4c20SAndrew Rist * software distributed under the License is distributed on an 15*514f4c20SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*514f4c20SAndrew Rist * KIND, either express or implied. See the License for the 17*514f4c20SAndrew Rist * specific language governing permissions and limitations 18*514f4c20SAndrew Rist * under the License. 19*514f4c20SAndrew Rist * 20*514f4c20SAndrew Rist *************************************************************/ 21*514f4c20SAndrew Rist 22*514f4c20SAndrew 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> 98cdf0e10cSrcweir # include <sys/statfs.h> 99cdf0e10cSrcweir # include <sys/statvfs.h> 100cdf0e10cSrcweir # include <sys/types.h> 101cdf0e10cSrcweir # define TEST_PLATFORM "" 102cdf0e10cSrcweir # define TEST_PLATFORM_ROOT "/" 103cdf0e10cSrcweir # define TEST_PLATFORM_TEMP "tmp" 104cdf0e10cSrcweir # define PATH_LIST_DELIMITER ":" 105cdf0e10cSrcweir # define PATH_SEPERATOR "/" 106cdf0e10cSrcweir #endif 107cdf0e10cSrcweir #if (defined WNT ) // Windows 108cdf0e10cSrcweir #include <tools/prewin.h> 109cdf0e10cSrcweir // # include <windows.h> 110cdf0e10cSrcweir # include <tchar.h> 111cdf0e10cSrcweir # include <io.h> 112cdf0e10cSrcweir # include <stdio.h> 113cdf0e10cSrcweir # include <stdlib.h> 114cdf0e10cSrcweir #include <tools/postwin.h> 115cdf0e10cSrcweir # define PATH_MAX MAX_PATH 116cdf0e10cSrcweir # define TEST_PLATFORM "c:/" 117cdf0e10cSrcweir # define TEST_PLATFORM_ROOT "c:/" 118cdf0e10cSrcweir # define TEST_PLATFORM_TEMP "temp" 119cdf0e10cSrcweir # define PATH_LIST_DELIMITER ";" 120cdf0e10cSrcweir # define PATH_SEPERATOR "/" 121cdf0e10cSrcweir #endif 122cdf0e10cSrcweir 123cdf0e10cSrcweir 124cdf0e10cSrcweir //------------------------------------------------------------------------ 125cdf0e10cSrcweir // macro definition for the ASCII array/OUString declarations, 126cdf0e10cSrcweir // we use p### for the ASCII array, 127cdf0e10cSrcweir // a### for the OUString, 128cdf0e10cSrcweir // n###Len for its length 129cdf0e10cSrcweir //------------------------------------------------------------------------ 130cdf0e10cSrcweir 131cdf0e10cSrcweir #define OSLTEST_DECLARE( str_name, str_value ) \ 132cdf0e10cSrcweir ::rtl::OUString a##str_name = rtl::OUString::createFromAscii( ( str_value ) ) 133cdf0e10cSrcweir 134cdf0e10cSrcweir #define OSLTEST_DECLARE_UTF8(str_name, str_value ) \ 135cdf0e10cSrcweir ::rtl::OUString a##str_name = ::rtl::Uri::decode( ::rtl::OUString::createFromAscii( ( str_value ) ), rtl_UriDecodeToIuri, RTL_TEXTENCODING_UTF8) 136cdf0e10cSrcweir 137cdf0e10cSrcweir //------------------------------------------------------------------------ 138cdf0e10cSrcweir // OS independent file definition 139cdf0e10cSrcweir //------------------------------------------------------------------------ 140cdf0e10cSrcweir OSLTEST_DECLARE( NullURL, "" ); 141cdf0e10cSrcweir OSLTEST_DECLARE( SlashURL, PATH_SEPERATOR ); 142cdf0e10cSrcweir OSLTEST_DECLARE( PreURL, FILE_PREFIX ); 143cdf0e10cSrcweir OSLTEST_DECLARE( RootURL, FILE_PREFIX TEST_PLATFORM ); 144cdf0e10cSrcweir 145cdf0e10cSrcweir OSLTEST_DECLARE( TempDirectoryURL, FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP ); 146cdf0e10cSrcweir OSLTEST_DECLARE( TempDirectorySys, TEST_PLATFORM_ROOT TEST_PLATFORM_TEMP ); 147cdf0e10cSrcweir OSLTEST_DECLARE( UserDirectoryURL, FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP "" ); 148cdf0e10cSrcweir OSLTEST_DECLARE( UserDirectorySys, TEST_PLATFORM_ROOT TEST_PLATFORM_TEMP "" ); 149cdf0e10cSrcweir 150cdf0e10cSrcweir //------------------------------------------------------------------------ 151cdf0e10cSrcweir // common used URL:temp, canonical, root, relative, link,etc 152cdf0e10cSrcweir //------------------------------------------------------------------------ 153cdf0e10cSrcweir OSLTEST_DECLARE( CanURL1, FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP "/canonical.name" ); 154cdf0e10cSrcweir OSLTEST_DECLARE( CanURL2, "ca@#;+.,$///78no\0ni..name" ); 155cdf0e10cSrcweir OSLTEST_DECLARE( CanURL3, "ca@#;+.,$//tmp/678nonical//name" ); 156cdf0e10cSrcweir OSLTEST_DECLARE( CanURL4, "canonical.name" ); 157cdf0e10cSrcweir OSLTEST_DECLARE( TmpName1, "tmpdir" ); 158cdf0e10cSrcweir OSLTEST_DECLARE( TmpName2, "tmpname" ); 159cdf0e10cSrcweir OSLTEST_DECLARE( TmpName3, FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP "/tmpdir" ); 160cdf0e10cSrcweir OSLTEST_DECLARE( TmpName4, FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP "/tmpdir/tmpname" ); 161cdf0e10cSrcweir OSLTEST_DECLARE( TmpName5, FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP "/tmpdir/../tmpdir/./tmpname" ); 162cdf0e10cSrcweir OSLTEST_DECLARE( TmpName6, FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP "/tmpname" ); 163cdf0e10cSrcweir OSLTEST_DECLARE( TmpName7, FILE_PREFIX TEST_PLATFORM "tmpname" ); 164cdf0e10cSrcweir OSLTEST_DECLARE( TmpName8, FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP "/tmpname/tmpdir" ); 165cdf0e10cSrcweir OSLTEST_DECLARE( TmpName9, FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP "/tmpdir/../tmpdir/./" ); 166cdf0e10cSrcweir OSLTEST_DECLARE_UTF8( TmpName10, FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP "/%E6%9C%AA%E5%91%BD%E5%90%8Dzhgb18030" ); 167cdf0e10cSrcweir 168cdf0e10cSrcweir OSLTEST_DECLARE( RelURL1, "relative/file1" ); 169cdf0e10cSrcweir OSLTEST_DECLARE( RelURL2, "relative/./file2" ); 170cdf0e10cSrcweir OSLTEST_DECLARE( RelURL3, "relative/../file3" ); 171cdf0e10cSrcweir OSLTEST_DECLARE( RelURL4, "././relative/../file4" ); 172cdf0e10cSrcweir OSLTEST_DECLARE( RelURL5, TEST_PLATFORM_TEMP "/./../" TEST_PLATFORM_TEMP ); 173cdf0e10cSrcweir OSLTEST_DECLARE( LnkURL1, FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP "/link.file" ); 174cdf0e10cSrcweir OSLTEST_DECLARE( HidURL1, ".hiddenfile" ); 175cdf0e10cSrcweir 176cdf0e10cSrcweir //------------------------------------------------------------------------ 177cdf0e10cSrcweir // common used System Path:temp, root,etc 178cdf0e10cSrcweir //------------------------------------------------------------------------ 179cdf0e10cSrcweir OSLTEST_DECLARE( RootSys, TEST_PLATFORM_ROOT ); 180cdf0e10cSrcweir OSLTEST_DECLARE( SysPath1, TEST_PLATFORM_ROOT TEST_PLATFORM_TEMP "/system.path" ); 181cdf0e10cSrcweir OSLTEST_DECLARE( SysPath2, TEST_PLATFORM_ROOT TEST_PLATFORM_TEMP "/system/path" ); 182cdf0e10cSrcweir OSLTEST_DECLARE( SysPath3, TEST_PLATFORM_ROOT TEST_PLATFORM_TEMP "/tmpdir" ); 183cdf0e10cSrcweir OSLTEST_DECLARE( SysPath4, TEST_PLATFORM_ROOT TEST_PLATFORM_TEMP "/tmpname" ); 184cdf0e10cSrcweir OSLTEST_DECLARE_UTF8( SysPath5, TEST_PLATFORM_ROOT TEST_PLATFORM_TEMP "/%E6%9C%AA%E5%91%BD%E5%90%8Dzhgb18030" ); 185cdf0e10cSrcweir OSLTEST_DECLARE( FifoSys, TEST_PLATFORM_ROOT TEST_PLATFORM_TEMP "/tmpdir/fifo" ); 186cdf0e10cSrcweir 187cdf0e10cSrcweir //------------------------------------------------------------------------ 188cdf0e10cSrcweir // FileType URL, we pick some canonical file in corresponding system for test: 189cdf0e10cSrcweir // socket, link, etc. 190cdf0e10cSrcweir // Note that this may be changed in the different platform, so be careful to use. 191cdf0e10cSrcweir //------------------------------------------------------------------------ 192cdf0e10cSrcweir #if ( defined UNX ) || ( defined OS2 ) // Unix 193cdf0e10cSrcweir OSLTEST_DECLARE( TypeURL1, FILE_PREFIX "dev/ccv"); //socket Solaris/Linux 194cdf0e10cSrcweir OSLTEST_DECLARE( TypeURL2, FILE_PREFIX "devices/pseudo/tcp@0:tcp"); //special Solaris/Linux 195cdf0e10cSrcweir OSLTEST_DECLARE( TypeURL3, FILE_PREFIX "lib" ); //link Solaris 196cdf0e10cSrcweir #else // Windows 197cdf0e10cSrcweir OSLTEST_DECLARE( TypeURL1, FILE_PREFIX "" ); 198cdf0e10cSrcweir OSLTEST_DECLARE( TypeURL2, FILE_PREFIX "" ); 199cdf0e10cSrcweir OSLTEST_DECLARE( TypeURL3, FILE_PREFIX "" ); 200cdf0e10cSrcweir #endif 201cdf0e10cSrcweir 202cdf0e10cSrcweir //------------------------------------------------------------------------ 203cdf0e10cSrcweir // Volume device URL, we pick some canonical volume device for test: 204cdf0e10cSrcweir // UNIX file system, Floppy Disk, Proc file system, Temp file system, Compact Disk. 205cdf0e10cSrcweir //------------------------------------------------------------------------ 206cdf0e10cSrcweir #if ( defined UNX ) || ( defined OS2 ) // Unix 207cdf0e10cSrcweir OSLTEST_DECLARE( VolURL1, FILE_PREFIX ""); //ufs Solaris/Linux 208cdf0e10cSrcweir #ifdef SOLARIS 209cdf0e10cSrcweir OSLTEST_DECLARE( VolURL2, FILE_PREFIX "dev/fd" ); //fd Solaris 210cdf0e10cSrcweir #else 211cdf0e10cSrcweir OSLTEST_DECLARE( VolURL2, FILE_PREFIX "dev/floppy/0u1440" ); //fd0 Linux 212cdf0e10cSrcweir #endif 213cdf0e10cSrcweir OSLTEST_DECLARE( VolURL3, FILE_PREFIX "proc" ); //proc Solaris/Linux 214cdf0e10cSrcweir OSLTEST_DECLARE( VolURL4, FILE_PREFIX "staroffice" ); //nfs Solaris/Linux 215cdf0e10cSrcweir OSLTEST_DECLARE( VolURL5, FILE_PREFIX "tmp" ); //tmpfs Solaris 216cdf0e10cSrcweir OSLTEST_DECLARE( VolURL6, FILE_PREFIX "cdrom" ); //cd Solaris 217cdf0e10cSrcweir #else // Windows 218cdf0e10cSrcweir OSLTEST_DECLARE( VolURL1, FILE_PREFIX "c:/" ); 219cdf0e10cSrcweir OSLTEST_DECLARE( VolURL2, FILE_PREFIX "a:/" ); 220cdf0e10cSrcweir OSLTEST_DECLARE( VolURL3, FILE_PREFIX "" ); 221cdf0e10cSrcweir OSLTEST_DECLARE( VolURL4, FILE_PREFIX "" ); 222cdf0e10cSrcweir OSLTEST_DECLARE( VolURL5, FILE_PREFIX "c:/temp" ); 223cdf0e10cSrcweir OSLTEST_DECLARE( VolURL6, FILE_PREFIX "e:/" ); 224cdf0e10cSrcweir #endif 225cdf0e10cSrcweir 226cdf0e10cSrcweir 227cdf0e10cSrcweir //------------------------------------------------------------------------ 228cdf0e10cSrcweir //------------------------------------------------------------------------ 229cdf0e10cSrcweir 230cdf0e10cSrcweir #ifdef __cplusplus 231cdf0e10cSrcweir } 232cdf0e10cSrcweir #endif 233cdf0e10cSrcweir 234cdf0e10cSrcweir //------------------------------------------------------------------------ 235cdf0e10cSrcweir //------------------------------------------------------------------------ 236cdf0e10cSrcweir 237cdf0e10cSrcweir 238cdf0e10cSrcweir #endif /* _OSL_FILE_CONST_H_ */ 239