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