1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SAL_QA_OSL_FILE_OSL_FILE_CONST_H
21 #define INCLUDED_SAL_QA_OSL_FILE_OSL_FILE_CONST_H
26 #include <sal/types.h>
27 #include <rtl/textenc.h>
29 #include <rtl/ustring.hxx>
30 #include <rtl/uri.hxx>
37 // common used string resource
38 // these common used string will be used as assist resource in test
39 // they are mostly OS independent, some of the resource can be reused
40 // so, acommon test data repository will be better since it can be
41 // shared among all test code
43 const sal_Char pBuffer_Char
[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
44 const sal_Char pBuffer_Number
[] = "1234567890";
45 const sal_Char pBuffer_Blank
[] = "";
47 // OS dependent/independent definitions/includes
48 // we use FILE_PREFIX for URL prefix,
49 // TEST_PLATFORM for test platform initial,
50 // TEST_PLATFORM_ROOT for root dir in comrresponding platform,
51 // TEST_PLATFORM_TEMP for temp dir in comrresponding platform,
52 // PATH_LIST_DELIMITER for separator of path list in comrresponding platform,
53 // PATH_SEPARATOR for separator in URL or system path in comrresponding platform,
54 // PATH_MAX/MAX_PATH for max path length in comrresponding platform,
56 // OS independent const definition
58 # define FILE_PREFIX "file:///"
59 # define TEST_FILE_SIZE 1024
61 // OS dependent declaration and includes
63 #if ( defined UNX ) //Unix
69 # include <sys/stat.h>
70 # if !defined(MACOSX) && !defined(IOS) && !defined(__OpenBSD__) && !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined (DRAGONFLY)
71 # include <sys/statfs.h>
73 # include <sys/param.h>
74 # include <sys/mount.h>
76 # if !defined(ANDROID)
77 # include <sys/statvfs.h>
79 # include <sys/types.h>
80 # define TEST_PLATFORM ""
81 # define TEST_PLATFORM_ROOT "/"
82 # define TEST_PLATFORM_TEMP "tmp"
83 # define PATH_LIST_DELIMITER ":"
84 # define PATH_SEPARATOR "/"
87 #if (defined WNT ) // Windows
92 # define PATH_MAX MAX_PATH
93 # define TEST_PLATFORM "c:/"
94 # define TEST_PLATFORM_ROOT "c:/"
95 # define TEST_PLATFORM_TEMP "temp"
96 # define PATH_LIST_DELIMITER ";"
97 # define PATH_SEPARATOR "/"
100 // macro definition for the ASCII array/OUString declarations,
101 // we use p### for the ASCII array,
102 // a### for the OUString,
103 // n###Len for its length
105 #define OSLTEST_DECLARE( str_name, str_value ) \
106 ::rtl::OUString a##str_name( ( str_value ) )
108 #define OSLTEST_DECLARE_UTF8(str_name, str_value ) \
109 ::rtl::OUString a##str_name = ::rtl::Uri::decode( ::rtl::OUString( str_value ), rtl_UriDecodeToIuri, RTL_TEXTENCODING_UTF8)
111 // OS independent file definition
113 OSLTEST_DECLARE( NullURL
, "" );
114 OSLTEST_DECLARE( SlashURL
, PATH_SEPARATOR
);
115 OSLTEST_DECLARE( PreURL
, FILE_PREFIX
);
116 OSLTEST_DECLARE( RootURL
, FILE_PREFIX TEST_PLATFORM
);
118 OSLTEST_DECLARE( TempDirectoryURL
, FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP
);
119 OSLTEST_DECLARE( TempDirectorySys
, TEST_PLATFORM_ROOT TEST_PLATFORM_TEMP
);
120 OSLTEST_DECLARE( UserDirectoryURL
, FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP
"" );
121 OSLTEST_DECLARE( UserDirectorySys
, TEST_PLATFORM_ROOT TEST_PLATFORM_TEMP
"" );
123 // common used URL:temp, canonical, root, relative, link,etc
125 OSLTEST_DECLARE( CanURL1
, FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP
"/canonical.name" );
126 rtl::OUString
aCanURL2(
127 RTL_CONSTASCII_USTRINGPARAM("ca@#;+.,$///78no\0ni..name"));
128 OSLTEST_DECLARE( CanURL3
, "ca@#;+.,$//tmp/678nonical//name" );
129 OSLTEST_DECLARE( CanURL4
, "canonical.name" );
130 OSLTEST_DECLARE( TmpName1
, "tmpdir" );
131 OSLTEST_DECLARE( TmpName2
, "tmpname" );
132 OSLTEST_DECLARE( TmpName3
, FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP
"/tmpdir" );
133 OSLTEST_DECLARE( TmpName4
, FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP
"/tmpdir/tmpname" );
134 OSLTEST_DECLARE( TmpName5
, FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP
"/tmpdir/../tmpdir/./tmpname" );
135 OSLTEST_DECLARE( TmpName6
, FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP
"/tmpname" );
136 OSLTEST_DECLARE( TmpName7
, FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP
"/noaccess" );
137 OSLTEST_DECLARE( TmpName8
, FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP
"/tmpname/tmpdir" );
138 OSLTEST_DECLARE( TmpName9
, FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP
"/tmpdir/../tmpdir/./" );
139 OSLTEST_DECLARE_UTF8( TmpName10
, FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP
"/%E6%9C%AA%E5%91%BD%E5%90%8Dzhgb18030" );
141 OSLTEST_DECLARE( RelURL1
, "relative/file1" );
142 OSLTEST_DECLARE( RelURL2
, "relative/./file2" );
143 OSLTEST_DECLARE( RelURL3
, "relative/../file3" );
144 OSLTEST_DECLARE( RelURL4
, "././relative/../file4" );
145 OSLTEST_DECLARE( RelURL5
, TEST_PLATFORM_TEMP
"/./../" TEST_PLATFORM_TEMP
);
146 OSLTEST_DECLARE( LnkURL1
, FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP
"/link.file" );
147 OSLTEST_DECLARE( HidURL1
, ".hiddenfile" );
149 // common used System Path:temp, root,etc
151 OSLTEST_DECLARE( RootSys
, TEST_PLATFORM_ROOT
);
152 OSLTEST_DECLARE( SysPath1
, TEST_PLATFORM_ROOT TEST_PLATFORM_TEMP
"/system.path" );
153 OSLTEST_DECLARE( SysPath2
, TEST_PLATFORM_ROOT TEST_PLATFORM_TEMP
"/system/path" );
154 OSLTEST_DECLARE( SysPath3
, TEST_PLATFORM_ROOT TEST_PLATFORM_TEMP
"/tmpdir" );
155 OSLTEST_DECLARE( SysPath4
, TEST_PLATFORM_ROOT TEST_PLATFORM_TEMP
"/tmpname" );
156 OSLTEST_DECLARE_UTF8( SysPath5
, TEST_PLATFORM_ROOT TEST_PLATFORM_TEMP
"/%E6%9C%AA%E5%91%BD%E5%90%8Dzhgb18030" );
157 OSLTEST_DECLARE( SysPathLnk
, TEST_PLATFORM_ROOT TEST_PLATFORM_TEMP
"/link.file" );
158 OSLTEST_DECLARE( FifoSys
, TEST_PLATFORM_ROOT TEST_PLATFORM_TEMP
"/tmpdir/fifo" );
160 // FileType URL, we pick some canonical file in corresponding system for test:
161 // socket, link, etc.
162 // Note that this may be changed in the different platform, so be careful to use.
164 #if ( defined UNX ) // Unix
165 OSLTEST_DECLARE( TypeURL1
, FILE_PREFIX
"dev/ccv"); //socket Solaris/Linux
166 OSLTEST_DECLARE( TypeURL2
, FILE_PREFIX
"devices/pseudo/tcp@0:tcp"); //special Solaris/Linux
167 OSLTEST_DECLARE( TypeURL3
, FILE_PREFIX
"lib" ); //link Solaris
169 OSLTEST_DECLARE( TypeURL1
, FILE_PREFIX
"" );
170 OSLTEST_DECLARE( TypeURL2
, FILE_PREFIX
"" );
171 OSLTEST_DECLARE( TypeURL3
, FILE_PREFIX
"" );
174 // Volume device URL, we pick some canonical volume device for test:
175 // UNIX file system, Floppy Disk, Proc file system, Temp file system, Compact Disk.
177 #if ( defined UNX ) // Unix
178 OSLTEST_DECLARE( VolURL1
, FILE_PREFIX
""); //ufs Solaris/Linux
180 OSLTEST_DECLARE( VolURL2
, FILE_PREFIX
"dev/fd" ); //fd Solaris
182 OSLTEST_DECLARE( VolURL2
, FILE_PREFIX
"dev/floppy/0u1440" ); //fd0 Linux
184 OSLTEST_DECLARE( VolURL3
, FILE_PREFIX
"proc" ); //proc Solaris/Linux
185 OSLTEST_DECLARE( VolURL4
, FILE_PREFIX
"staroffice" ); //nfs Solaris/Linux
186 OSLTEST_DECLARE( VolURL5
, FILE_PREFIX
"tmp" ); //tmpfs Solaris
187 OSLTEST_DECLARE( VolURL6
, FILE_PREFIX
"cdrom" ); //cd Solaris
189 OSLTEST_DECLARE( VolURL1
, FILE_PREFIX
"c:/" );
190 OSLTEST_DECLARE( VolURL2
, FILE_PREFIX
"a:/" );
191 OSLTEST_DECLARE( VolURL3
, FILE_PREFIX
"" );
192 OSLTEST_DECLARE( VolURL4
, FILE_PREFIX
"" );
193 OSLTEST_DECLARE( VolURL5
, FILE_PREFIX
"c:/temp" );
194 OSLTEST_DECLARE( VolURL6
, FILE_PREFIX
"e:/" );
201 #endif // INCLUDED_SAL_QA_OSL_FILE_OSL_FILE_CONST_H
203 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */