xref: /aoo41x/main/sal/workben/testfile.cxx (revision cdf0e10c)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_sal.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #define UNICODE
32*cdf0e10cSrcweir 
33*cdf0e10cSrcweir 
34*cdf0e10cSrcweir #include <osl/file.hxx>
35*cdf0e10cSrcweir #include <osl/process.h>
36*cdf0e10cSrcweir #include <osl/time.h>
37*cdf0e10cSrcweir #include <rtl/alloc.h>
38*cdf0e10cSrcweir #include <rtl/ustring.hxx>
39*cdf0e10cSrcweir #include <stdio.h>
40*cdf0e10cSrcweir #include <string.h>
41*cdf0e10cSrcweir #include <time.h>
42*cdf0e10cSrcweir 
43*cdf0e10cSrcweir 
44*cdf0e10cSrcweir #ifdef UNX
45*cdf0e10cSrcweir #include <wchar.h>
46*cdf0e10cSrcweir #endif
47*cdf0e10cSrcweir 
48*cdf0e10cSrcweir #ifdef WNT
49*cdf0e10cSrcweir #include <windows.h>
50*cdf0e10cSrcweir #endif
51*cdf0e10cSrcweir 
52*cdf0e10cSrcweir using namespace	osl;
53*cdf0e10cSrcweir using namespace	rtl;
54*cdf0e10cSrcweir 
55*cdf0e10cSrcweir #define MAXIMPATH	256
56*cdf0e10cSrcweir 
57*cdf0e10cSrcweir rtl::OUString	root;
58*cdf0e10cSrcweir 
59*cdf0e10cSrcweir rtl::OUString	dir1;
60*cdf0e10cSrcweir rtl::OUString	dir2;
61*cdf0e10cSrcweir rtl::OUString	dir_on_server;
62*cdf0e10cSrcweir rtl::OUString	dir_not_exist;
63*cdf0e10cSrcweir rtl::OUString	dir_not_exist_on_server;
64*cdf0e10cSrcweir rtl::OUString	dir_wrong_semantic;
65*cdf0e10cSrcweir 
66*cdf0e10cSrcweir rtl::OUString	file1;
67*cdf0e10cSrcweir rtl::OUString	file2;
68*cdf0e10cSrcweir rtl::OUString	file3;
69*cdf0e10cSrcweir rtl::OUString	file_on_server;
70*cdf0e10cSrcweir rtl::OUString	file_not_exist;
71*cdf0e10cSrcweir 
72*cdf0e10cSrcweir 
73*cdf0e10cSrcweir 
74*cdf0e10cSrcweir void print_error(::rtl::OString& str, FileBase::RC rc);
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir void PressKey()
77*cdf0e10cSrcweir {
78*cdf0e10cSrcweir 	printf("\nPress Return !\n");
79*cdf0e10cSrcweir 	int i=getchar();
80*cdf0e10cSrcweir }
81*cdf0e10cSrcweir 
82*cdf0e10cSrcweir void printFileName(::rtl::OUString& str)
83*cdf0e10cSrcweir {
84*cdf0e10cSrcweir 	rtl::OString		aString;
85*cdf0e10cSrcweir 
86*cdf0e10cSrcweir 	aString = rtl::OUStringToOString( str, RTL_TEXTENCODING_ASCII_US );
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir 	printf( "%s", aString.getStr() );
89*cdf0e10cSrcweir 
90*cdf0e10cSrcweir 	return;
91*cdf0e10cSrcweir }
92*cdf0e10cSrcweir 
93*cdf0e10cSrcweir //--------------------------------------------------
94*cdf0e10cSrcweir // Initialization
95*cdf0e10cSrcweir //--------------------------------------------------
96*cdf0e10cSrcweir 
97*cdf0e10cSrcweir sal_Bool testLineBreak( sal_Char *pCount , sal_uInt64 nLen , sal_uInt32 *cLineBreak )
98*cdf0e10cSrcweir {
99*cdf0e10cSrcweir 	sal_Bool fSuccess=sal_False;
100*cdf0e10cSrcweir 	*cLineBreak=0;
101*cdf0e10cSrcweir 
102*cdf0e10cSrcweir 	if (nLen==0)
103*cdf0e10cSrcweir 		return fSuccess;
104*cdf0e10cSrcweir 
105*cdf0e10cSrcweir 	if ( *pCount==13 )
106*cdf0e10cSrcweir 	{
107*cdf0e10cSrcweir 		if (nLen>=1 && *(pCount+1)==10)
108*cdf0e10cSrcweir 			*cLineBreak=2;
109*cdf0e10cSrcweir 		else
110*cdf0e10cSrcweir 			*cLineBreak=1;
111*cdf0e10cSrcweir 
112*cdf0e10cSrcweir 		if (nLen>=2 && *(pCount+2)==10)
113*cdf0e10cSrcweir 			(*cLineBreak)++;
114*cdf0e10cSrcweir 
115*cdf0e10cSrcweir 		fSuccess=sal_True;
116*cdf0e10cSrcweir 	}
117*cdf0e10cSrcweir 	else if ( *pCount==10 )
118*cdf0e10cSrcweir 	{
119*cdf0e10cSrcweir 		*cLineBreak=1;
120*cdf0e10cSrcweir 		fSuccess=sal_True;
121*cdf0e10cSrcweir 	}
122*cdf0e10cSrcweir 
123*cdf0e10cSrcweir 	return fSuccess;
124*cdf0e10cSrcweir }
125*cdf0e10cSrcweir 
126*cdf0e10cSrcweir // Initialization
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir sal_Bool Initialize( void )
129*cdf0e10cSrcweir {
130*cdf0e10cSrcweir 	DirectoryItem	aItem;
131*cdf0e10cSrcweir 	FileStatus		aStatus( FileStatusMask_All );
132*cdf0e10cSrcweir 	rtl_uString		*strExeFileURL=NULL;
133*cdf0e10cSrcweir 	oslProcessError	ProcessError;
134*cdf0e10cSrcweir 
135*cdf0e10cSrcweir 	rtl::OUString	iniFileURL;
136*cdf0e10cSrcweir 	File			*pFile;
137*cdf0e10cSrcweir 	sal_Unicode		*pExeFileCount;
138*cdf0e10cSrcweir 
139*cdf0e10cSrcweir 	FileBase::RC	rc;
140*cdf0e10cSrcweir 
141*cdf0e10cSrcweir 	sal_uInt64		uBytesRequested;
142*cdf0e10cSrcweir 	sal_uInt64		uBytesRead;
143*cdf0e10cSrcweir     sal_Char		*pBuffer;
144*cdf0e10cSrcweir 	sal_Char		*pBegin;
145*cdf0e10cSrcweir 	sal_Char		*pCount;
146*cdf0e10cSrcweir 
147*cdf0e10cSrcweir 	rtl::OUString	dir[12];
148*cdf0e10cSrcweir 
149*cdf0e10cSrcweir 	// Open to the ini-file
150*cdf0e10cSrcweir 
151*cdf0e10cSrcweir 	ProcessError=osl_getExecutableFile(&strExeFileURL);
152*cdf0e10cSrcweir 
153*cdf0e10cSrcweir 	if ( ProcessError == osl_Process_E_None)
154*cdf0e10cSrcweir 	{
155*cdf0e10cSrcweir 		pExeFileCount=rtl_uString_getStr(strExeFileURL)+rtl_uString_getLength(strExeFileURL);
156*cdf0e10cSrcweir 
157*cdf0e10cSrcweir 		// Search for the last slash in the Path
158*cdf0e10cSrcweir 		while (*pExeFileCount!=L'/' && pExeFileCount>rtl_uString_getStr(strExeFileURL))
159*cdf0e10cSrcweir 			pExeFileCount--;
160*cdf0e10cSrcweir 
161*cdf0e10cSrcweir 		// iniFileURL = strExeFileURL without the filename of the exe-File
162*cdf0e10cSrcweir 		iniFileURL=rtl::OUString( rtl_uString_getStr(strExeFileURL) ,(int) (pExeFileCount-rtl_uString_getStr(strExeFileURL)) );
163*cdf0e10cSrcweir 
164*cdf0e10cSrcweir 		// add "/testfile.ini" to iniFileURL
165*cdf0e10cSrcweir 		iniFileURL+=rtl::OUString::createFromAscii("/testfile.ini");
166*cdf0e10cSrcweir 
167*cdf0e10cSrcweir 		// Open the ini-File
168*cdf0e10cSrcweir 		pFile=new File( iniFileURL );
169*cdf0e10cSrcweir 		rc=pFile->open( OpenFlag_Read | OpenFlag_Write );
170*cdf0e10cSrcweir 		if ( rc!=FileBase::E_None )
171*cdf0e10cSrcweir 		{
172*cdf0e10cSrcweir 			rtl_uString_release(strExeFileURL);
173*cdf0e10cSrcweir 			return sal_False;
174*cdf0e10cSrcweir 		}
175*cdf0e10cSrcweir 	}
176*cdf0e10cSrcweir 	else
177*cdf0e10cSrcweir 	{
178*cdf0e10cSrcweir 		rtl_uString_release(strExeFileURL);
179*cdf0e10cSrcweir 		return sal_False;
180*cdf0e10cSrcweir 	}
181*cdf0e10cSrcweir 
182*cdf0e10cSrcweir 	// Get filesize of the ini-File
183*cdf0e10cSrcweir 
184*cdf0e10cSrcweir 	rc=DirectoryItem::get( iniFileURL, aItem );
185*cdf0e10cSrcweir 	if ( rc!=FileBase::E_None )
186*cdf0e10cSrcweir 		return sal_False;
187*cdf0e10cSrcweir 
188*cdf0e10cSrcweir 	rc=aItem.getFileStatus( aStatus );
189*cdf0e10cSrcweir 	if ( rc!=FileBase::E_None )
190*cdf0e10cSrcweir 		return sal_False;
191*cdf0e10cSrcweir 
192*cdf0e10cSrcweir 	uBytesRequested=aStatus.getFileSize();
193*cdf0e10cSrcweir 
194*cdf0e10cSrcweir 	// read ini-File
195*cdf0e10cSrcweir 	rc=pFile->setPos( Pos_Absolut, 0 );
196*cdf0e10cSrcweir 	pBuffer=(sal_Char*) rtl_allocateMemory( (sal_uInt32) (uBytesRequested+1)*sizeof(sal_Char) );
197*cdf0e10cSrcweir 	rtl_zeroMemory( pBuffer, (sal_uInt32)(uBytesRequested+1)*sizeof(sal_Char) );
198*cdf0e10cSrcweir 
199*cdf0e10cSrcweir 	rc=pFile->read( pBuffer , uBytesRequested , uBytesRead );
200*cdf0e10cSrcweir 	if ( rc!=FileBase::E_None )
201*cdf0e10cSrcweir 		return sal_False;
202*cdf0e10cSrcweir 
203*cdf0e10cSrcweir 
204*cdf0e10cSrcweir 	pBegin=pBuffer;
205*cdf0e10cSrcweir 	pCount=pBegin;
206*cdf0e10cSrcweir 
207*cdf0e10cSrcweir 	for ( int i=0 ; i<12 ; i++ )
208*cdf0e10cSrcweir 	{
209*cdf0e10cSrcweir 		sal_uInt32		cLineBrake=0;
210*cdf0e10cSrcweir 		while ( (pCount-pBuffer < uBytesRead) && *pCount!='=')
211*cdf0e10cSrcweir 			pCount++;
212*cdf0e10cSrcweir 
213*cdf0e10cSrcweir 		pCount++;
214*cdf0e10cSrcweir 		pBegin=pCount;
215*cdf0e10cSrcweir 
216*cdf0e10cSrcweir 		while ( (pCount-pBuffer < uBytesRead) && !testLineBreak(pCount,uBytesRead-(pCount-pBuffer), &cLineBrake))
217*cdf0e10cSrcweir 			pCount++;
218*cdf0e10cSrcweir 
219*cdf0e10cSrcweir 		dir[i]=rtl::OUString(pBegin, pCount-pBegin, RTL_TEXTENCODING_ASCII_US);
220*cdf0e10cSrcweir 
221*cdf0e10cSrcweir 		pCount+=cLineBrake;
222*cdf0e10cSrcweir 		pBegin=pCount;
223*cdf0e10cSrcweir 	}
224*cdf0e10cSrcweir 
225*cdf0e10cSrcweir 	root=rtl::OUString(dir[0]);
226*cdf0e10cSrcweir 	dir1=rtl::OUString(dir[1]);
227*cdf0e10cSrcweir 	dir2=rtl::OUString(dir[2]);
228*cdf0e10cSrcweir 	dir_on_server=rtl::OUString(dir[3]);
229*cdf0e10cSrcweir 	dir_not_exist=rtl::OUString(dir[4]);
230*cdf0e10cSrcweir 	dir_not_exist_on_server=rtl::OUString(dir[5]);
231*cdf0e10cSrcweir 	dir_wrong_semantic=rtl::OUString(dir[6]);
232*cdf0e10cSrcweir 
233*cdf0e10cSrcweir 	file1=rtl::OUString(dir[7]);
234*cdf0e10cSrcweir 	file2=rtl::OUString(dir[8]);
235*cdf0e10cSrcweir 	file3=rtl::OUString(dir[9]);
236*cdf0e10cSrcweir 	file_on_server=rtl::OUString(dir[10]);
237*cdf0e10cSrcweir 	file_not_exist=rtl::OUString(dir[11]);
238*cdf0e10cSrcweir 
239*cdf0e10cSrcweir 	// close the ini-file
240*cdf0e10cSrcweir 	rc=pFile->close();
241*cdf0e10cSrcweir 
242*cdf0e10cSrcweir 	rtl_freeMemory( pBuffer );
243*cdf0e10cSrcweir 
244*cdf0e10cSrcweir 
245*cdf0e10cSrcweir 	// Create directories
246*cdf0e10cSrcweir 	rc=Directory::create( dir1 );
247*cdf0e10cSrcweir 	if ( rc!=FileBase::E_None )
248*cdf0e10cSrcweir 		return sal_False;
249*cdf0e10cSrcweir 
250*cdf0e10cSrcweir 	rc=Directory::create( dir2 );
251*cdf0e10cSrcweir 	if ( rc!=FileBase::E_None )
252*cdf0e10cSrcweir 		return sal_False;
253*cdf0e10cSrcweir 
254*cdf0e10cSrcweir 	rc=Directory::create( dir_on_server );
255*cdf0e10cSrcweir 	if ( rc!=FileBase::E_None )
256*cdf0e10cSrcweir 		return sal_False;
257*cdf0e10cSrcweir 
258*cdf0e10cSrcweir 	pFile=new File( file1 );
259*cdf0e10cSrcweir 	rc=pFile->open( OpenFlag_Write | OpenFlag_Create );
260*cdf0e10cSrcweir 	if ( rc!=FileBase::E_None )
261*cdf0e10cSrcweir 		return sal_False;
262*cdf0e10cSrcweir 	rc=pFile->close();
263*cdf0e10cSrcweir 	delete pFile;
264*cdf0e10cSrcweir 
265*cdf0e10cSrcweir 	pFile=new File( file2 );
266*cdf0e10cSrcweir 	rc=pFile->open( OpenFlag_Write | OpenFlag_Create );
267*cdf0e10cSrcweir 	if ( rc!=FileBase::E_None )
268*cdf0e10cSrcweir 		return sal_False;
269*cdf0e10cSrcweir 	rc=pFile->close();
270*cdf0e10cSrcweir 	delete pFile;
271*cdf0e10cSrcweir 
272*cdf0e10cSrcweir 	pFile=new File( file_on_server );
273*cdf0e10cSrcweir 	rc=pFile->open( OpenFlag_Write | OpenFlag_Create );
274*cdf0e10cSrcweir 	if ( rc!=FileBase::E_None )
275*cdf0e10cSrcweir 		return sal_False;
276*cdf0e10cSrcweir 	rc=pFile->close();
277*cdf0e10cSrcweir 	delete pFile;
278*cdf0e10cSrcweir 
279*cdf0e10cSrcweir 	return sal_True;
280*cdf0e10cSrcweir }
281*cdf0e10cSrcweir 
282*cdf0e10cSrcweir //--------------------------------------------------
283*cdf0e10cSrcweir // Shutdown
284*cdf0e10cSrcweir //--------------------------------------------------
285*cdf0e10cSrcweir 
286*cdf0e10cSrcweir sal_Bool Shutdown( void )
287*cdf0e10cSrcweir {
288*cdf0e10cSrcweir 	sal_Bool		fSuccess=sal_True;
289*cdf0e10cSrcweir 	FileBase::RC	rc;
290*cdf0e10cSrcweir 	File			*pFile;
291*cdf0e10cSrcweir 
292*cdf0e10cSrcweir 	// remove created files
293*cdf0e10cSrcweir 
294*cdf0e10cSrcweir 	pFile=new File( file1 );
295*cdf0e10cSrcweir 	rc=pFile->remove( file1 );
296*cdf0e10cSrcweir 	if ( rc!=FileBase::E_None )
297*cdf0e10cSrcweir 		fSuccess=sal_False;
298*cdf0e10cSrcweir 	delete pFile;
299*cdf0e10cSrcweir 
300*cdf0e10cSrcweir 	pFile=new File( file2 );
301*cdf0e10cSrcweir 	rc=pFile->remove( file2 );
302*cdf0e10cSrcweir 	if ( rc!=FileBase::E_None )
303*cdf0e10cSrcweir 		fSuccess=sal_False;
304*cdf0e10cSrcweir 	delete pFile;
305*cdf0e10cSrcweir 
306*cdf0e10cSrcweir 	// remove created directories
307*cdf0e10cSrcweir 
308*cdf0e10cSrcweir 	rc=Directory::remove( dir1 );
309*cdf0e10cSrcweir 	if ( rc!=FileBase::E_None )
310*cdf0e10cSrcweir 		fSuccess=sal_False;
311*cdf0e10cSrcweir 
312*cdf0e10cSrcweir 	rc=Directory::remove( dir2 );
313*cdf0e10cSrcweir 	if ( rc!=FileBase::E_None )
314*cdf0e10cSrcweir 		fSuccess=sal_False;
315*cdf0e10cSrcweir 
316*cdf0e10cSrcweir 	// remove created file on the server
317*cdf0e10cSrcweir 
318*cdf0e10cSrcweir 	pFile=new File( file_on_server );
319*cdf0e10cSrcweir 	rc=pFile->remove( file_on_server );
320*cdf0e10cSrcweir 	if ( rc!=FileBase::E_None )
321*cdf0e10cSrcweir 		fSuccess=sal_False;
322*cdf0e10cSrcweir 	delete pFile;
323*cdf0e10cSrcweir 
324*cdf0e10cSrcweir 	// remove created directory on the server
325*cdf0e10cSrcweir 
326*cdf0e10cSrcweir 	rc=Directory::remove( dir_on_server );
327*cdf0e10cSrcweir 	if ( rc!=FileBase::E_None )
328*cdf0e10cSrcweir 		fSuccess=sal_False;
329*cdf0e10cSrcweir 
330*cdf0e10cSrcweir 	return fSuccess;
331*cdf0e10cSrcweir }
332*cdf0e10cSrcweir 
333*cdf0e10cSrcweir //--------------------------------------------------
334*cdf0e10cSrcweir // helper functions
335*cdf0e10cSrcweir //--------------------------------------------------
336*cdf0e10cSrcweir 
337*cdf0e10cSrcweir // Show FileType
338*cdf0e10cSrcweir void showFileType( FileStatus::Type aType )
339*cdf0e10cSrcweir {
340*cdf0e10cSrcweir 	if ( aType==FileStatus::Directory )
341*cdf0e10cSrcweir 		printf( "FileType: Directory \n" );
342*cdf0e10cSrcweir 	else if ( aType==FileStatus::Volume )
343*cdf0e10cSrcweir 		printf( "FileType: Volume \n" );
344*cdf0e10cSrcweir 	else if ( aType==FileStatus::Regular )
345*cdf0e10cSrcweir 		printf( "FileType: Regular \n" );
346*cdf0e10cSrcweir 	else if ( aType==FileStatus::Unknown )
347*cdf0e10cSrcweir 		printf( "FileType: Unknown \n" );
348*cdf0e10cSrcweir 
349*cdf0e10cSrcweir }
350*cdf0e10cSrcweir 
351*cdf0e10cSrcweir // Show Attributes
352*cdf0e10cSrcweir void showAttributes( sal_uInt64 uAttributes )
353*cdf0e10cSrcweir {
354*cdf0e10cSrcweir 	if ( uAttributes==0 )
355*cdf0e10cSrcweir 		printf( "No Attributes \n" );
356*cdf0e10cSrcweir 	if ( uAttributes & Attribute_ReadOnly )
357*cdf0e10cSrcweir 		printf( "Attribute: ReadOnly \n" );
358*cdf0e10cSrcweir 	if ( uAttributes & Attribute_Hidden )
359*cdf0e10cSrcweir 		printf( "Attribute: Hidden \n" );
360*cdf0e10cSrcweir 	if ( uAttributes & Attribute_Executable )
361*cdf0e10cSrcweir 		printf( "Attribute: Executable \n");
362*cdf0e10cSrcweir 	if ( uAttributes & Attribute_GrpWrite )
363*cdf0e10cSrcweir 		printf( "Attribute: GrpWrite \n");
364*cdf0e10cSrcweir 	if ( uAttributes & Attribute_GrpRead )
365*cdf0e10cSrcweir 		printf( "Attribute: GrpRead \n" );
366*cdf0e10cSrcweir 	if ( uAttributes & Attribute_GrpExe )
367*cdf0e10cSrcweir 		printf( "Attribute: GrpExe \n" );
368*cdf0e10cSrcweir 	if ( uAttributes & Attribute_OwnWrite )
369*cdf0e10cSrcweir 		printf( "Attribute: OwnWrite \n");
370*cdf0e10cSrcweir 	if ( uAttributes & Attribute_OwnRead )
371*cdf0e10cSrcweir 		printf( "Attribute: OwnRead \n" );
372*cdf0e10cSrcweir 	if ( uAttributes & Attribute_OwnExe )
373*cdf0e10cSrcweir 		printf( "Attribute: OwnExe \n" );
374*cdf0e10cSrcweir 	if ( uAttributes & Attribute_OthWrite )
375*cdf0e10cSrcweir 		printf( "Attribute: OthWrite \n" );
376*cdf0e10cSrcweir 	if ( uAttributes & Attribute_OthRead )
377*cdf0e10cSrcweir 		printf( "Attribute: OthRead \n");
378*cdf0e10cSrcweir 	if ( uAttributes & Attribute_OthExe )
379*cdf0e10cSrcweir 		printf( "Attribute: OthExe \n" );
380*cdf0e10cSrcweir 
381*cdf0e10cSrcweir 	return;
382*cdf0e10cSrcweir }
383*cdf0e10cSrcweir 
384*cdf0e10cSrcweir // Show Time
385*cdf0e10cSrcweir void showTime( TimeValue aTime )
386*cdf0e10cSrcweir {
387*cdf0e10cSrcweir 	TimeValue	aLocalTimeVal, aSystemTimeVal , aSysTimeVal;
388*cdf0e10cSrcweir 	oslDateTime	aDateTime, aSystemTime;
389*cdf0e10cSrcweir 
390*cdf0e10cSrcweir 	if ( osl_getLocalTimeFromSystemTime( &aTime, &aLocalTimeVal ) )
391*cdf0e10cSrcweir 	{
392*cdf0e10cSrcweir 		if ( osl_getDateTimeFromTimeValue( &aLocalTimeVal, &aDateTime ) )
393*cdf0e10cSrcweir 		{
394*cdf0e10cSrcweir 			printf("\t%02i.%02i.%4i , %02i.%02i.%02i Uhr\n", aDateTime.Day, aDateTime.Month, aDateTime.Year, aDateTime.Hours, aDateTime.Minutes, aDateTime.Seconds);
395*cdf0e10cSrcweir 		}
396*cdf0e10cSrcweir 		else
397*cdf0e10cSrcweir 			printf("Error !\n");
398*cdf0e10cSrcweir 	}
399*cdf0e10cSrcweir 
400*cdf0e10cSrcweir 	if ( osl_getDateTimeFromTimeValue( &aTime, &aSystemTime ) )
401*cdf0e10cSrcweir 	{
402*cdf0e10cSrcweir 		printf("SystemTime: \t\t%02i.%02i.%4i , %02i.%02i.%02i Uhr\n", aSystemTime.Day, aSystemTime.Month, aSystemTime.Year, aSystemTime.Hours, aSystemTime.Minutes, aSystemTime.Seconds);
403*cdf0e10cSrcweir 	}
404*cdf0e10cSrcweir 	else
405*cdf0e10cSrcweir 		printf("Error !\n");
406*cdf0e10cSrcweir 
407*cdf0e10cSrcweir 	//Verify
408*cdf0e10cSrcweir 
409*cdf0e10cSrcweir 	if ( osl_getTimeValueFromDateTime( &aSystemTime, &aSystemTimeVal ) )
410*cdf0e10cSrcweir 	{
411*cdf0e10cSrcweir 		if ( ( aSystemTimeVal.Seconds == aTime.Seconds ) && ( aSystemTimeVal.Nanosec == aTime.Nanosec ))
412*cdf0e10cSrcweir 			printf ("Verify : TimeValue : ok! \n");
413*cdf0e10cSrcweir 		else
414*cdf0e10cSrcweir 		{
415*cdf0e10cSrcweir 			printf ("Verify : TimeValue : Error! \n");
416*cdf0e10cSrcweir 			printf ("aTime : %u \n", aTime.Seconds);
417*cdf0e10cSrcweir 			printf ("aSystemTimeVal : %u \n", aSystemTimeVal.Seconds);
418*cdf0e10cSrcweir 		}
419*cdf0e10cSrcweir 	}
420*cdf0e10cSrcweir 	else
421*cdf0e10cSrcweir 		printf ("Verify : TimeValue : Error! \n");
422*cdf0e10cSrcweir 
423*cdf0e10cSrcweir 
424*cdf0e10cSrcweir 	if ( osl_getSystemTimeFromLocalTime( &aLocalTimeVal , &aSysTimeVal ) )
425*cdf0e10cSrcweir 	{
426*cdf0e10cSrcweir 		if ( ( aSysTimeVal.Seconds == aTime.Seconds ) && ( aSysTimeVal.Nanosec == aTime.Nanosec ))
427*cdf0e10cSrcweir 			printf ("Verify : SystemTime : ok! \n");
428*cdf0e10cSrcweir 		else
429*cdf0e10cSrcweir 		{
430*cdf0e10cSrcweir 			printf ("Verify : SystemTime : Error! \n");
431*cdf0e10cSrcweir 			printf ("aTime : %u\n", aTime.Seconds);
432*cdf0e10cSrcweir 			printf ("aSystemTimeVal : %u\n", aSysTimeVal.Seconds);
433*cdf0e10cSrcweir 		}
434*cdf0e10cSrcweir 	}
435*cdf0e10cSrcweir 	else
436*cdf0e10cSrcweir 		printf ("Verify : SystemTime : Error! \n");
437*cdf0e10cSrcweir 
438*cdf0e10cSrcweir 	return;
439*cdf0e10cSrcweir }
440*cdf0e10cSrcweir 
441*cdf0e10cSrcweir TimeValue getSystemTime()
442*cdf0e10cSrcweir {
443*cdf0e10cSrcweir 	TimeValue	aTime;
444*cdf0e10cSrcweir 	time_t ltime;
445*cdf0e10cSrcweir 
446*cdf0e10cSrcweir 	time( &ltime );
447*cdf0e10cSrcweir 
448*cdf0e10cSrcweir 	aTime.Seconds = ltime;
449*cdf0e10cSrcweir 	aTime.Nanosec = 0;
450*cdf0e10cSrcweir 
451*cdf0e10cSrcweir 	return aTime;
452*cdf0e10cSrcweir }
453*cdf0e10cSrcweir 
454*cdf0e10cSrcweir 
455*cdf0e10cSrcweir //--------------------------------------------------
456*cdf0e10cSrcweir // DirectoryOpenAndCloseTest
457*cdf0e10cSrcweir //--------------------------------------------------
458*cdf0e10cSrcweir 
459*cdf0e10cSrcweir void DirectoryOpenAndCloseTest( void )
460*cdf0e10cSrcweir {
461*cdf0e10cSrcweir 	FileBase::RC	rc;
462*cdf0e10cSrcweir 	int i=0;
463*cdf0e10cSrcweir 	Directory	*pDir;
464*cdf0e10cSrcweir 
465*cdf0e10cSrcweir 	printf( "--------------------------------------------\n");
466*cdf0e10cSrcweir 	printf( "Directory-Open-And-Close-Test\n");
467*cdf0e10cSrcweir 	printf( "--------------------------------------------\n\n");
468*cdf0e10cSrcweir 
469*cdf0e10cSrcweir 	//--------------------------------------------------
470*cdf0e10cSrcweir 	// open an existing directory
471*cdf0e10cSrcweir 	//--------------------------------------------------
472*cdf0e10cSrcweir 
473*cdf0e10cSrcweir 	pDir=new Directory( dir1 );
474*cdf0e10cSrcweir 	printf( "Open an existing directory: ");
475*cdf0e10cSrcweir 	printFileName( dir1 );
476*cdf0e10cSrcweir 	printf( "\n" );
477*cdf0e10cSrcweir 
478*cdf0e10cSrcweir 	rc= pDir->open();
479*cdf0e10cSrcweir 	print_error( rtl::OString( "Open Directory" ), rc );
480*cdf0e10cSrcweir 
481*cdf0e10cSrcweir 	if ( pDir->isOpen() )
482*cdf0e10cSrcweir 	{
483*cdf0e10cSrcweir 		print_error( rtl::OString( "Directory is Open" ), rc );
484*cdf0e10cSrcweir 	}
485*cdf0e10cSrcweir 
486*cdf0e10cSrcweir 	// Close Directory
487*cdf0e10cSrcweir 	rc=pDir->close();
488*cdf0e10cSrcweir 	print_error( rtl::OString( "Close Directory" ), rc );
489*cdf0e10cSrcweir 
490*cdf0e10cSrcweir 	delete pDir;
491*cdf0e10cSrcweir 	printf( "\n" );
492*cdf0e10cSrcweir 
493*cdf0e10cSrcweir 	//--------------------------------------------------
494*cdf0e10cSrcweir 	// open a not existing directory
495*cdf0e10cSrcweir 	//--------------------------------------------------
496*cdf0e10cSrcweir 
497*cdf0e10cSrcweir 	pDir=new Directory( dir_not_exist );
498*cdf0e10cSrcweir 
499*cdf0e10cSrcweir 	printf( "Open a not existing directory: ");
500*cdf0e10cSrcweir 	printFileName( dir_not_exist );
501*cdf0e10cSrcweir 	printf( "\n" );
502*cdf0e10cSrcweir 
503*cdf0e10cSrcweir 	rc= pDir->open();
504*cdf0e10cSrcweir 
505*cdf0e10cSrcweir 	print_error( rtl::OString( "Open Directory" ), rc );
506*cdf0e10cSrcweir 
507*cdf0e10cSrcweir 	delete pDir;
508*cdf0e10cSrcweir 
509*cdf0e10cSrcweir 	printf( "\n" );
510*cdf0e10cSrcweir 
511*cdf0e10cSrcweir 	//--------------------------------------------------
512*cdf0e10cSrcweir 	// open a directory with a wrong semantic
513*cdf0e10cSrcweir 	//--------------------------------------------------
514*cdf0e10cSrcweir 	pDir=new Directory( dir_wrong_semantic );
515*cdf0e10cSrcweir 
516*cdf0e10cSrcweir 	printf( "Open a directory with a wrong semantic: ");
517*cdf0e10cSrcweir 	printFileName( dir_wrong_semantic );
518*cdf0e10cSrcweir 	printf( "\n" );
519*cdf0e10cSrcweir 
520*cdf0e10cSrcweir 	rc= pDir->open();
521*cdf0e10cSrcweir 	print_error( rtl::OString( "Open Directory" ), rc );
522*cdf0e10cSrcweir 
523*cdf0e10cSrcweir 	delete pDir;
524*cdf0e10cSrcweir 
525*cdf0e10cSrcweir 	printf( "\n" );
526*cdf0e10cSrcweir 
527*cdf0e10cSrcweir 	//--------------------------------------------------
528*cdf0e10cSrcweir 	// open an existing directory on a server
529*cdf0e10cSrcweir 	//--------------------------------------------------
530*cdf0e10cSrcweir 
531*cdf0e10cSrcweir 	pDir=new Directory( dir_on_server );
532*cdf0e10cSrcweir 
533*cdf0e10cSrcweir 	printf( "Open an existing directory on a server: ");
534*cdf0e10cSrcweir 	printFileName( dir_on_server );
535*cdf0e10cSrcweir 	printf( "\n" );
536*cdf0e10cSrcweir 
537*cdf0e10cSrcweir 	rc= pDir->open();
538*cdf0e10cSrcweir 	print_error( rtl::OString( "Open Directory" ), rc );
539*cdf0e10cSrcweir 
540*cdf0e10cSrcweir 	// Close Directory
541*cdf0e10cSrcweir 	rc=pDir->close();
542*cdf0e10cSrcweir 	print_error( rtl::OString( "Close Directory" ), rc );
543*cdf0e10cSrcweir 
544*cdf0e10cSrcweir 	delete pDir;
545*cdf0e10cSrcweir 	printf( "\n" );
546*cdf0e10cSrcweir 
547*cdf0e10cSrcweir 	//--------------------------------------------------
548*cdf0e10cSrcweir 	// open a not existing directory on a server
549*cdf0e10cSrcweir 	//--------------------------------------------------
550*cdf0e10cSrcweir 
551*cdf0e10cSrcweir 	pDir=new Directory( dir_not_exist_on_server );
552*cdf0e10cSrcweir 
553*cdf0e10cSrcweir 	printf( "Open a not existing directory on a server: ");
554*cdf0e10cSrcweir 	printFileName( dir_not_exist_on_server );
555*cdf0e10cSrcweir 	printf( "\n" );
556*cdf0e10cSrcweir 
557*cdf0e10cSrcweir 	rc= pDir->open();
558*cdf0e10cSrcweir 	print_error( rtl::OString( "Open Directory" ), rc );
559*cdf0e10cSrcweir 
560*cdf0e10cSrcweir 	delete pDir;
561*cdf0e10cSrcweir 	printf( "\n" );
562*cdf0e10cSrcweir 
563*cdf0e10cSrcweir 	//--------------------------------------------------
564*cdf0e10cSrcweir 	// Close a not existing directory
565*cdf0e10cSrcweir 	//--------------------------------------------------
566*cdf0e10cSrcweir 
567*cdf0e10cSrcweir 	pDir=new Directory( dir_not_exist );
568*cdf0e10cSrcweir 	printf( "Close a not existing directory: ");
569*cdf0e10cSrcweir 	printFileName( dir_not_exist );
570*cdf0e10cSrcweir 	printf( "\n" );
571*cdf0e10cSrcweir 
572*cdf0e10cSrcweir 	rc=pDir->close();
573*cdf0e10cSrcweir 	print_error( rtl::OString( "Close Directory" ), rc );
574*cdf0e10cSrcweir 
575*cdf0e10cSrcweir 	PressKey();
576*cdf0e10cSrcweir 	return;
577*cdf0e10cSrcweir 
578*cdf0e10cSrcweir }
579*cdf0e10cSrcweir 
580*cdf0e10cSrcweir //--------------------------------------------------
581*cdf0e10cSrcweir // DirectoryCreateAndRemoveTest
582*cdf0e10cSrcweir //--------------------------------------------------
583*cdf0e10cSrcweir 
584*cdf0e10cSrcweir void DirectoryCreateAndRemoveTest( void )
585*cdf0e10cSrcweir {
586*cdf0e10cSrcweir 	FileBase::RC	rc,rc1;
587*cdf0e10cSrcweir 	int i=0;
588*cdf0e10cSrcweir 	Directory	*pDir;
589*cdf0e10cSrcweir 
590*cdf0e10cSrcweir 	printf( "--------------------------------------------\n" );
591*cdf0e10cSrcweir 	printf( "Directory-Create-And-Remove-Test\n" );
592*cdf0e10cSrcweir 	printf( "--------------------------------------------\n\n" );
593*cdf0e10cSrcweir 
594*cdf0e10cSrcweir 	//--------------------------------------------------
595*cdf0e10cSrcweir 	// Create directory
596*cdf0e10cSrcweir 	//--------------------------------------------------
597*cdf0e10cSrcweir 	printf( "Create a not existing directory: ");
598*cdf0e10cSrcweir 	printFileName( dir_not_exist );
599*cdf0e10cSrcweir 	printf( "\n" );
600*cdf0e10cSrcweir 
601*cdf0e10cSrcweir 	rc=Directory::create( dir_not_exist) ;
602*cdf0e10cSrcweir 	print_error( rtl::OString( "Create Directory" ), rc );
603*cdf0e10cSrcweir 
604*cdf0e10cSrcweir 	// Verify
605*cdf0e10cSrcweir 	pDir=new Directory( dir_not_exist );
606*cdf0e10cSrcweir 
607*cdf0e10cSrcweir 	rc= pDir->open();
608*cdf0e10cSrcweir 	print_error( rtl::OString( "Verify" ), rc );
609*cdf0e10cSrcweir 	pDir->close();
610*cdf0e10cSrcweir 	delete pDir;
611*cdf0e10cSrcweir 
612*cdf0e10cSrcweir 	printf( "\n" );
613*cdf0e10cSrcweir 
614*cdf0e10cSrcweir 	//--------------------------------------------------
615*cdf0e10cSrcweir 	// Create a directory on a server
616*cdf0e10cSrcweir 	//--------------------------------------------------
617*cdf0e10cSrcweir 
618*cdf0e10cSrcweir 	printf( "Create a not existing directory on a server: ");
619*cdf0e10cSrcweir 	printFileName( dir_not_exist_on_server );
620*cdf0e10cSrcweir 	printf( "\n" );
621*cdf0e10cSrcweir 
622*cdf0e10cSrcweir 	rc=Directory::create( dir_not_exist_on_server );
623*cdf0e10cSrcweir 	print_error( rtl::OString( "Create Directory" ), rc );
624*cdf0e10cSrcweir 
625*cdf0e10cSrcweir 	// Verify
626*cdf0e10cSrcweir 	pDir=new Directory( dir_not_exist_on_server );
627*cdf0e10cSrcweir 	rc= pDir->open();
628*cdf0e10cSrcweir 	print_error( rtl::OString( "Verify" ), rc );
629*cdf0e10cSrcweir 	pDir->close();
630*cdf0e10cSrcweir 	delete pDir;
631*cdf0e10cSrcweir 
632*cdf0e10cSrcweir 	printf( "\n" );
633*cdf0e10cSrcweir 
634*cdf0e10cSrcweir 	//--------------------------------------------------
635*cdf0e10cSrcweir 	// Remove Directories
636*cdf0e10cSrcweir 	//--------------------------------------------------
637*cdf0e10cSrcweir 
638*cdf0e10cSrcweir 	printf( "Remove the created directories: \n" );
639*cdf0e10cSrcweir 
640*cdf0e10cSrcweir 	rc=Directory::remove( dir_not_exist );
641*cdf0e10cSrcweir 
642*cdf0e10cSrcweir 	rc1=Directory::remove( dir_not_exist_on_server );
643*cdf0e10cSrcweir 
644*cdf0e10cSrcweir 	if ( rc==FileBase::E_None && rc1==FileBase::E_None )
645*cdf0e10cSrcweir 		print_error( rtl::OString( "Remove Directories" ), FileBase::E_None );
646*cdf0e10cSrcweir 	else if ( rc!=FileBase::E_None )
647*cdf0e10cSrcweir 		print_error( rtl::OString( "Remove local Directory" ),rc );
648*cdf0e10cSrcweir 	else
649*cdf0e10cSrcweir 		print_error( rtl::OString( "Remove Directory on a server" ),rc1 );
650*cdf0e10cSrcweir 
651*cdf0e10cSrcweir 	printf( "\n" );
652*cdf0e10cSrcweir 
653*cdf0e10cSrcweir 	//--------------------------------------------------
654*cdf0e10cSrcweir 	// Remove a not existing directory
655*cdf0e10cSrcweir 	//--------------------------------------------------
656*cdf0e10cSrcweir 
657*cdf0e10cSrcweir 	printf( "Remove a not existing directory: ");
658*cdf0e10cSrcweir 	printFileName( dir_not_exist );
659*cdf0e10cSrcweir 	printf( "\n" );
660*cdf0e10cSrcweir 
661*cdf0e10cSrcweir 	rc=Directory::remove( dir_not_exist );
662*cdf0e10cSrcweir 	print_error( rtl::OString( "Remove" ),rc );
663*cdf0e10cSrcweir 
664*cdf0e10cSrcweir 	PressKey();
665*cdf0e10cSrcweir 	return;
666*cdf0e10cSrcweir }
667*cdf0e10cSrcweir 
668*cdf0e10cSrcweir //--------------------------------------------------
669*cdf0e10cSrcweir // FileOpenAndCloseTest
670*cdf0e10cSrcweir //--------------------------------------------------
671*cdf0e10cSrcweir 
672*cdf0e10cSrcweir static void FileOpenAndCloseTest( void )
673*cdf0e10cSrcweir {
674*cdf0e10cSrcweir 	FileBase::RC	rc;
675*cdf0e10cSrcweir 	int i=0;
676*cdf0e10cSrcweir 
677*cdf0e10cSrcweir 	printf( "--------------------------------------------\n" );
678*cdf0e10cSrcweir 	printf( "File-Open-And-Close-Test\n" );
679*cdf0e10cSrcweir 	printf( "--------------------------------------------\n\n" );
680*cdf0e10cSrcweir 
681*cdf0e10cSrcweir 	File	*pFile;
682*cdf0e10cSrcweir 
683*cdf0e10cSrcweir 	pFile=new File( file1 );
684*cdf0e10cSrcweir 
685*cdf0e10cSrcweir 	printf( "Open an existing file: ");
686*cdf0e10cSrcweir 	printFileName( file1 );
687*cdf0e10cSrcweir 	printf( "\n" );
688*cdf0e10cSrcweir 
689*cdf0e10cSrcweir 	//--------------------------------------------------
690*cdf0e10cSrcweir 	// open an existing file (Read)
691*cdf0e10cSrcweir 	//--------------------------------------------------
692*cdf0e10cSrcweir 
693*cdf0e10cSrcweir 	rc=pFile->open( OpenFlag_Read );
694*cdf0e10cSrcweir 	print_error( rtl::OString( "Open File (Read)" ), rc );
695*cdf0e10cSrcweir 
696*cdf0e10cSrcweir 	//--------------------------------------------------
697*cdf0e10cSrcweir 	// close the file
698*cdf0e10cSrcweir 	//--------------------------------------------------
699*cdf0e10cSrcweir 
700*cdf0e10cSrcweir 	rc=pFile->close();
701*cdf0e10cSrcweir 	print_error( rtl::OString( "Close File" ), rc );
702*cdf0e10cSrcweir 
703*cdf0e10cSrcweir 	printf( "\n" );
704*cdf0e10cSrcweir 
705*cdf0e10cSrcweir 	//--------------------------------------------------
706*cdf0e10cSrcweir 	// open an existing file (Write)
707*cdf0e10cSrcweir 	//--------------------------------------------------
708*cdf0e10cSrcweir 
709*cdf0e10cSrcweir 	rc=pFile->open( OpenFlag_Write );
710*cdf0e10cSrcweir 	print_error( rtl::OString( "Open File (Write)" ), rc );
711*cdf0e10cSrcweir 
712*cdf0e10cSrcweir 	//--------------------------------------------------
713*cdf0e10cSrcweir 	// close the file
714*cdf0e10cSrcweir 	//--------------------------------------------------
715*cdf0e10cSrcweir 
716*cdf0e10cSrcweir  	rc=pFile->close();
717*cdf0e10cSrcweir 	print_error( rtl::OString( "Close File" ), rc );
718*cdf0e10cSrcweir 
719*cdf0e10cSrcweir 	printf( "\n" );
720*cdf0e10cSrcweir 
721*cdf0e10cSrcweir 	//--------------------------------------------------
722*cdf0e10cSrcweir 	// close the file a second time
723*cdf0e10cSrcweir 	//--------------------------------------------------
724*cdf0e10cSrcweir 
725*cdf0e10cSrcweir  	rc=pFile->close();
726*cdf0e10cSrcweir 	print_error( rtl::OString( "Close the file a second time" ), rc );
727*cdf0e10cSrcweir 
728*cdf0e10cSrcweir 	delete pFile;
729*cdf0e10cSrcweir 	PressKey();
730*cdf0e10cSrcweir }
731*cdf0e10cSrcweir 
732*cdf0e10cSrcweir //--------------------------------------------------
733*cdf0e10cSrcweir // FileCreateAndRemoveTest
734*cdf0e10cSrcweir //--------------------------------------------------
735*cdf0e10cSrcweir 
736*cdf0e10cSrcweir void FileCreateAndRemoveTest()
737*cdf0e10cSrcweir {
738*cdf0e10cSrcweir 	FileBase::RC	rc;
739*cdf0e10cSrcweir 	File	*pFile;
740*cdf0e10cSrcweir 
741*cdf0e10cSrcweir 	printf( "--------------------------------------------\n" );
742*cdf0e10cSrcweir 	printf( "File-Create-And-Remove-Test\n" );
743*cdf0e10cSrcweir 	printf( "--------------------------------------------\n\n" );
744*cdf0e10cSrcweir 
745*cdf0e10cSrcweir 	pFile=new File( file_not_exist );
746*cdf0e10cSrcweir 
747*cdf0e10cSrcweir 	printf( "Create File: ");
748*cdf0e10cSrcweir 	printFileName( file_not_exist );
749*cdf0e10cSrcweir 	printf( "\n" );
750*cdf0e10cSrcweir 
751*cdf0e10cSrcweir 	//----------------------------------------------------
752*cdf0e10cSrcweir 	// open (create) a not existing file (Read and write)
753*cdf0e10cSrcweir 	//----------------------------------------------------
754*cdf0e10cSrcweir 
755*cdf0e10cSrcweir 	rc = pFile->open( OpenFlag_Read | OpenFlag_Write | osl_File_OpenFlag_Create );
756*cdf0e10cSrcweir 
757*cdf0e10cSrcweir 	print_error( rtl::OString( "Create and Open File (Read & Write)" ), rc );
758*cdf0e10cSrcweir 
759*cdf0e10cSrcweir 	//----------------------------------------------------
760*cdf0e10cSrcweir 	// close the file
761*cdf0e10cSrcweir 	//----------------------------------------------------
762*cdf0e10cSrcweir 
763*cdf0e10cSrcweir 	rc=pFile->close();
764*cdf0e10cSrcweir 	print_error( rtl::OString( "Close File" ), rc );
765*cdf0e10cSrcweir 
766*cdf0e10cSrcweir 	//----------------------------------------------------
767*cdf0e10cSrcweir 	// remove the file
768*cdf0e10cSrcweir 	//----------------------------------------------------
769*cdf0e10cSrcweir 
770*cdf0e10cSrcweir 	rc=pFile->remove( file_not_exist );
771*cdf0e10cSrcweir 	print_error( rtl::OString(" Remove File" ), rc );
772*cdf0e10cSrcweir 
773*cdf0e10cSrcweir 	printf( "\n" );
774*cdf0e10cSrcweir 
775*cdf0e10cSrcweir 	//----------------------------------------------------
776*cdf0e10cSrcweir 	// remove the same file a second time
777*cdf0e10cSrcweir 	//----------------------------------------------------
778*cdf0e10cSrcweir 	rc=pFile->remove( file_not_exist );
779*cdf0e10cSrcweir 	print_error( rtl::OString( "Remove a not existing File" ), rc );
780*cdf0e10cSrcweir 
781*cdf0e10cSrcweir 	//----------------------------------------------------
782*cdf0e10cSrcweir 	// remove an open file
783*cdf0e10cSrcweir 	//----------------------------------------------------
784*cdf0e10cSrcweir 
785*cdf0e10cSrcweir 	pFile->open( OpenFlag_Read | OpenFlag_Write | osl_File_OpenFlag_Create );
786*cdf0e10cSrcweir 
787*cdf0e10cSrcweir 	rc=pFile->remove( file_not_exist );
788*cdf0e10cSrcweir 	print_error( rtl::OString( "Remove an open File" ), rc );
789*cdf0e10cSrcweir 
790*cdf0e10cSrcweir 	pFile->close();
791*cdf0e10cSrcweir 	pFile->remove( file_not_exist );
792*cdf0e10cSrcweir 
793*cdf0e10cSrcweir 	PressKey();
794*cdf0e10cSrcweir 
795*cdf0e10cSrcweir 	return;
796*cdf0e10cSrcweir }
797*cdf0e10cSrcweir 
798*cdf0e10cSrcweir //--------------------------------------------------
799*cdf0e10cSrcweir // FileWriteAndReadTest
800*cdf0e10cSrcweir //--------------------------------------------------
801*cdf0e10cSrcweir 
802*cdf0e10cSrcweir void FileWriteAndReadTest( void )
803*cdf0e10cSrcweir {
804*cdf0e10cSrcweir 	FileBase::RC	rc;
805*cdf0e10cSrcweir 
806*cdf0e10cSrcweir 	sal_uInt64 uWritten;
807*cdf0e10cSrcweir 	sal_uInt64 uRead;
808*cdf0e10cSrcweir 	sal_Char	*pWriteBuffer="Hier kommt der Osterhase !";
809*cdf0e10cSrcweir 	sal_uInt64	nLen=strlen( pWriteBuffer );
810*cdf0e10cSrcweir 	sal_Char *pReadBuffer;
811*cdf0e10cSrcweir 
812*cdf0e10cSrcweir 	printf( "--------------------------------------------\n" );
813*cdf0e10cSrcweir 	printf( "File-Write-And-Read-Test\n" );
814*cdf0e10cSrcweir 	printf( "--------------------------------------------\n\n" );
815*cdf0e10cSrcweir 
816*cdf0e10cSrcweir 	File	*pFile;
817*cdf0e10cSrcweir 
818*cdf0e10cSrcweir 	pFile=new File( file_not_exist );
819*cdf0e10cSrcweir 
820*cdf0e10cSrcweir 	printf( "Create File: ");
821*cdf0e10cSrcweir 	printFileName( file_not_exist );
822*cdf0e10cSrcweir 	printf("\n");
823*cdf0e10cSrcweir 
824*cdf0e10cSrcweir 	//----------------------------------------------------
825*cdf0e10cSrcweir 	// open (create) a not existing file (Read and write)
826*cdf0e10cSrcweir 	//----------------------------------------------------
827*cdf0e10cSrcweir 
828*cdf0e10cSrcweir 	rc = pFile->open( OpenFlag_Read | OpenFlag_Write | osl_File_OpenFlag_Create );
829*cdf0e10cSrcweir 
830*cdf0e10cSrcweir 	print_error( rtl::OString( "Create and Open File (Read & Write)" ), rc );
831*cdf0e10cSrcweir 
832*cdf0e10cSrcweir 	printf( "\n" );
833*cdf0e10cSrcweir 
834*cdf0e10cSrcweir 	//----------------------------------------------------
835*cdf0e10cSrcweir 	// write a string to the file
836*cdf0e10cSrcweir 	//----------------------------------------------------
837*cdf0e10cSrcweir 	rc=pFile->write( pWriteBuffer , nLen , uWritten );
838*cdf0e10cSrcweir 	print_error( rtl::OString( "Write File" ), rc );
839*cdf0e10cSrcweir 
840*cdf0e10cSrcweir 	if(uWritten==nLen)
841*cdf0e10cSrcweir 		printf( "Verify: OK! \n" );
842*cdf0e10cSrcweir 	else
843*cdf0e10cSrcweir 		printf( "Verify: Error\n" );
844*cdf0e10cSrcweir 
845*cdf0e10cSrcweir 	printf( "\n" );
846*cdf0e10cSrcweir 
847*cdf0e10cSrcweir 	//----------------------------------------------------
848*cdf0e10cSrcweir 	// move the filepointer to the beginning
849*cdf0e10cSrcweir 	//----------------------------------------------------
850*cdf0e10cSrcweir 
851*cdf0e10cSrcweir 	rc=pFile->setPos( Pos_Absolut , 0 );
852*cdf0e10cSrcweir 	print_error( rtl::OString( "Set FilePointer to the beginning of the file" ), rc );
853*cdf0e10cSrcweir 
854*cdf0e10cSrcweir 	printf( "\n" );
855*cdf0e10cSrcweir 
856*cdf0e10cSrcweir 	//----------------------------------------------------
857*cdf0e10cSrcweir 	// read the string
858*cdf0e10cSrcweir 	//----------------------------------------------------
859*cdf0e10cSrcweir 
860*cdf0e10cSrcweir 	pReadBuffer=(sal_Char*) rtl_allocateMemory( (sal_uInt32)(nLen+1)*sizeof(sal_Char) );
861*cdf0e10cSrcweir 	rtl_zeroMemory( pReadBuffer, (sal_uInt32)(nLen+1)*sizeof(sal_Char) );
862*cdf0e10cSrcweir 	rc=pFile->read( pReadBuffer , nLen,uRead );
863*cdf0e10cSrcweir 	print_error( rtl::OString( "Read File" ), rc );
864*cdf0e10cSrcweir 
865*cdf0e10cSrcweir 	if (strcmp(pWriteBuffer, pReadBuffer)==0)
866*cdf0e10cSrcweir 	{
867*cdf0e10cSrcweir 		printf( "Verify: OK !\n" );
868*cdf0e10cSrcweir 		printf( "Text: %s\n",pReadBuffer );
869*cdf0e10cSrcweir 	}
870*cdf0e10cSrcweir 	else
871*cdf0e10cSrcweir 		printf( "Verify: Error\n" );
872*cdf0e10cSrcweir 
873*cdf0e10cSrcweir 	rtl_freeMemory( pReadBuffer );
874*cdf0e10cSrcweir 
875*cdf0e10cSrcweir 	printf( "\n" );
876*cdf0e10cSrcweir 
877*cdf0e10cSrcweir 	// close the file
878*cdf0e10cSrcweir 	rc=pFile->close();
879*cdf0e10cSrcweir 	print_error( rtl::OString( "Close File" ), rc );
880*cdf0e10cSrcweir 
881*cdf0e10cSrcweir 	// remove the file
882*cdf0e10cSrcweir 	rc=pFile->remove( file_not_exist );
883*cdf0e10cSrcweir 	print_error( rtl::OString( "Remove File" ), rc );
884*cdf0e10cSrcweir 
885*cdf0e10cSrcweir 	PressKey();
886*cdf0e10cSrcweir 
887*cdf0e10cSrcweir 	return;
888*cdf0e10cSrcweir 
889*cdf0e10cSrcweir }
890*cdf0e10cSrcweir 
891*cdf0e10cSrcweir //--------------------------------------------------
892*cdf0e10cSrcweir // FileCopyMoveTest
893*cdf0e10cSrcweir //--------------------------------------------------
894*cdf0e10cSrcweir 
895*cdf0e10cSrcweir void FileCopyAndMoveTest( void )
896*cdf0e10cSrcweir {
897*cdf0e10cSrcweir 	FileBase::RC	rc;
898*cdf0e10cSrcweir 
899*cdf0e10cSrcweir 	printf( "--------------------------------------------\n" );
900*cdf0e10cSrcweir 	printf( "File-Copy-Move-Test\n" );
901*cdf0e10cSrcweir 	printf( "--------------------------------------------\n\n" );
902*cdf0e10cSrcweir 
903*cdf0e10cSrcweir 
904*cdf0e10cSrcweir 	File	*pFile;
905*cdf0e10cSrcweir 	rtl::OUString	destPath(dir2);
906*cdf0e10cSrcweir 
907*cdf0e10cSrcweir 	//--------------------------------------------------
908*cdf0e10cSrcweir 	// FileCopyTest
909*cdf0e10cSrcweir 	//--------------------------------------------------
910*cdf0e10cSrcweir 
911*cdf0e10cSrcweir 	destPath+=rtl::OUString::createFromAscii("/");
912*cdf0e10cSrcweir 	destPath+=file3;
913*cdf0e10cSrcweir 
914*cdf0e10cSrcweir 	printf( "Copy the file ");
915*cdf0e10cSrcweir 	printFileName( file1 );
916*cdf0e10cSrcweir 	printf( " to ");
917*cdf0e10cSrcweir 	printFileName( destPath );
918*cdf0e10cSrcweir 	printf( "\n" );
919*cdf0e10cSrcweir 
920*cdf0e10cSrcweir 
921*cdf0e10cSrcweir 	rc=File::copy( file1 , destPath );
922*cdf0e10cSrcweir 	print_error( rtl::OString( "FileCopy" ), rc );
923*cdf0e10cSrcweir 
924*cdf0e10cSrcweir 	pFile=new File( destPath );
925*cdf0e10cSrcweir 
926*cdf0e10cSrcweir 	rc=pFile->open( OpenFlag_Read );
927*cdf0e10cSrcweir 	if ( rc == FileBase::E_None)
928*cdf0e10cSrcweir 	{
929*cdf0e10cSrcweir 		printf( "Verify: OK!\n" );
930*cdf0e10cSrcweir 		pFile->close();
931*cdf0e10cSrcweir 		File::remove( destPath );
932*cdf0e10cSrcweir 	}
933*cdf0e10cSrcweir 	else
934*cdf0e10cSrcweir 		printf( "Verify: Error!\n" );
935*cdf0e10cSrcweir 
936*cdf0e10cSrcweir 	delete pFile;
937*cdf0e10cSrcweir 
938*cdf0e10cSrcweir 	printf( "\n" );
939*cdf0e10cSrcweir 
940*cdf0e10cSrcweir 	//--------------------------------------------------
941*cdf0e10cSrcweir 	// Copy a file to a not existing directory
942*cdf0e10cSrcweir 	//--------------------------------------------------
943*cdf0e10cSrcweir 
944*cdf0e10cSrcweir 	destPath=rtl::OUString( dir_not_exist );
945*cdf0e10cSrcweir 	destPath+=rtl::OUString::createFromAscii("/");
946*cdf0e10cSrcweir 	destPath+=file3;
947*cdf0e10cSrcweir 
948*cdf0e10cSrcweir 	printf( "Copy a file to a not existing directory \n");
949*cdf0e10cSrcweir 	printf( "Copy the file  %s to %s\n", file1.getStr(), destPath.getStr() );
950*cdf0e10cSrcweir 
951*cdf0e10cSrcweir 	rc=File::copy( file1, destPath );
952*cdf0e10cSrcweir 	print_error( rtl::OString( "FileCopy" ), rc );
953*cdf0e10cSrcweir 
954*cdf0e10cSrcweir 	printf( "\n" );
955*cdf0e10cSrcweir 
956*cdf0e10cSrcweir 	//--------------------------------------------------
957*cdf0e10cSrcweir 	// Copy a directory
958*cdf0e10cSrcweir 	//--------------------------------------------------
959*cdf0e10cSrcweir 
960*cdf0e10cSrcweir 	printf( "Copy the directory: ");
961*cdf0e10cSrcweir 	printFileName( dir1 );
962*cdf0e10cSrcweir 	printf( " to ");
963*cdf0e10cSrcweir 	printFileName( dir2 );
964*cdf0e10cSrcweir 	printf( "\n" );
965*cdf0e10cSrcweir 
966*cdf0e10cSrcweir 	rc=File::copy( dir1 , dir2 );
967*cdf0e10cSrcweir 	print_error( rtl::OString( "FileCopy" ), rc );
968*cdf0e10cSrcweir 
969*cdf0e10cSrcweir 	printf( "\n" );
970*cdf0e10cSrcweir 
971*cdf0e10cSrcweir 	//--------------------------------------------------
972*cdf0e10cSrcweir 	// FileMoveTest
973*cdf0e10cSrcweir 	//--------------------------------------------------
974*cdf0e10cSrcweir 
975*cdf0e10cSrcweir 	destPath=rtl::OUString( dir2 );
976*cdf0e10cSrcweir 	destPath+=rtl::OUString::createFromAscii("/");
977*cdf0e10cSrcweir 	destPath+=file3;
978*cdf0e10cSrcweir 
979*cdf0e10cSrcweir 	printf( "Move the file ");
980*cdf0e10cSrcweir 	printFileName( file1 );
981*cdf0e10cSrcweir 	printf( " to ");
982*cdf0e10cSrcweir 	printFileName( destPath );
983*cdf0e10cSrcweir 	printf( "\n" );
984*cdf0e10cSrcweir 
985*cdf0e10cSrcweir 	rc=File::move( file1, destPath );
986*cdf0e10cSrcweir 	print_error( rtl::OString( "FileMove" ), rc );
987*cdf0e10cSrcweir 
988*cdf0e10cSrcweir 	pFile=new File( destPath );
989*cdf0e10cSrcweir 
990*cdf0e10cSrcweir 	rc=pFile->open( OpenFlag_Read );
991*cdf0e10cSrcweir 	if ( rc==FileBase::E_None )
992*cdf0e10cSrcweir 	{
993*cdf0e10cSrcweir 		pFile->close();
994*cdf0e10cSrcweir 
995*cdf0e10cSrcweir 		delete pFile;
996*cdf0e10cSrcweir 		pFile=new File( file1 );
997*cdf0e10cSrcweir 
998*cdf0e10cSrcweir 		rc=pFile->open( OpenFlag_Read );
999*cdf0e10cSrcweir 
1000*cdf0e10cSrcweir 		if ( rc!=FileBase::E_None )
1001*cdf0e10cSrcweir 		{
1002*cdf0e10cSrcweir 			printf( "Verify: OK!\n" );
1003*cdf0e10cSrcweir 			File::move( destPath, file1 );
1004*cdf0e10cSrcweir 		}
1005*cdf0e10cSrcweir 		else
1006*cdf0e10cSrcweir 		{
1007*cdf0e10cSrcweir 			printf( "Verify: Error!\n" );
1008*cdf0e10cSrcweir 			pFile->close();
1009*cdf0e10cSrcweir 			File::remove( destPath );
1010*cdf0e10cSrcweir 		}
1011*cdf0e10cSrcweir 	}
1012*cdf0e10cSrcweir 	else
1013*cdf0e10cSrcweir 		printf( "Verify: Error!\n" );
1014*cdf0e10cSrcweir 
1015*cdf0e10cSrcweir 	delete pFile;
1016*cdf0e10cSrcweir 
1017*cdf0e10cSrcweir 	printf( "\n" );
1018*cdf0e10cSrcweir 
1019*cdf0e10cSrcweir 
1020*cdf0e10cSrcweir 	//--------------------------------------------------
1021*cdf0e10cSrcweir 	// Move a file to a not existing directory
1022*cdf0e10cSrcweir 	//--------------------------------------------------
1023*cdf0e10cSrcweir 
1024*cdf0e10cSrcweir 	destPath=rtl::OUString( dir_not_exist );
1025*cdf0e10cSrcweir 	destPath+=rtl::OUString::createFromAscii("/");
1026*cdf0e10cSrcweir 	destPath+=file3;
1027*cdf0e10cSrcweir 
1028*cdf0e10cSrcweir 	printf( "Move a file to a not existing directory: \n");
1029*cdf0e10cSrcweir 	printf( "Move the file ");
1030*cdf0e10cSrcweir 	printFileName( file1 );
1031*cdf0e10cSrcweir 	printf( " to ");
1032*cdf0e10cSrcweir 	printFileName( destPath );
1033*cdf0e10cSrcweir 	printf( "\n" );
1034*cdf0e10cSrcweir 
1035*cdf0e10cSrcweir 	rc=File::move( file1 , destPath );
1036*cdf0e10cSrcweir 	print_error( rtl::OString( "FileMove" ), rc );
1037*cdf0e10cSrcweir 
1038*cdf0e10cSrcweir 	printf( "\n" );
1039*cdf0e10cSrcweir 
1040*cdf0e10cSrcweir 	//--------------------------------------------------
1041*cdf0e10cSrcweir 	// Move a directory
1042*cdf0e10cSrcweir 	//--------------------------------------------------
1043*cdf0e10cSrcweir 
1044*cdf0e10cSrcweir 	printf( "Move a directory: \n");
1045*cdf0e10cSrcweir 
1046*cdf0e10cSrcweir 	printf( "Move the directory ");
1047*cdf0e10cSrcweir 	printFileName( dir1 );
1048*cdf0e10cSrcweir 	printf( " to ");
1049*cdf0e10cSrcweir 	printFileName( dir_not_exist );
1050*cdf0e10cSrcweir 	printf( "\n" );
1051*cdf0e10cSrcweir 
1052*cdf0e10cSrcweir 
1053*cdf0e10cSrcweir 	rc=File::move( dir1 , dir_not_exist);
1054*cdf0e10cSrcweir 	print_error( rtl::OString( "FileMove" ), rc );
1055*cdf0e10cSrcweir 
1056*cdf0e10cSrcweir 	if ( rc == FileBase::E_None )
1057*cdf0e10cSrcweir 		File::move( dir_not_exist , dir1);
1058*cdf0e10cSrcweir 
1059*cdf0e10cSrcweir 	printf( "\n" );
1060*cdf0e10cSrcweir 
1061*cdf0e10cSrcweir 
1062*cdf0e10cSrcweir 	PressKey();
1063*cdf0e10cSrcweir 	return;
1064*cdf0e10cSrcweir }
1065*cdf0e10cSrcweir 
1066*cdf0e10cSrcweir //----------------------------------------------------
1067*cdf0e10cSrcweir // FileSizeTest
1068*cdf0e10cSrcweir //----------------------------------------------------
1069*cdf0e10cSrcweir 
1070*cdf0e10cSrcweir void FileSizeTest( void )
1071*cdf0e10cSrcweir {
1072*cdf0e10cSrcweir 	FileBase::RC	rc;
1073*cdf0e10cSrcweir 	sal_uInt64		filesize;
1074*cdf0e10cSrcweir 	DirectoryItem	aItem;
1075*cdf0e10cSrcweir 
1076*cdf0e10cSrcweir 	printf( "--------------------------------------------\n" );
1077*cdf0e10cSrcweir 	printf( "File-Size-Test\n" );
1078*cdf0e10cSrcweir 	printf( "--------------------------------------------\n\n" );
1079*cdf0e10cSrcweir 
1080*cdf0e10cSrcweir 
1081*cdf0e10cSrcweir 	File	aFile( file_not_exist );
1082*cdf0e10cSrcweir 
1083*cdf0e10cSrcweir 	printf( "Create File: ");
1084*cdf0e10cSrcweir 	printFileName( file_not_exist );
1085*cdf0e10cSrcweir 	printf( "\n\n");
1086*cdf0e10cSrcweir 
1087*cdf0e10cSrcweir 	rc = aFile.open( OpenFlag_Read | OpenFlag_Write | osl_File_OpenFlag_Create );
1088*cdf0e10cSrcweir 	print_error( rtl::OString( "Create and Open File (Read & Write)" ), rc );
1089*cdf0e10cSrcweir 	printf( "\n" );
1090*cdf0e10cSrcweir 
1091*cdf0e10cSrcweir 	if ( rc == FileBase::E_None )
1092*cdf0e10cSrcweir 	{
1093*cdf0e10cSrcweir 		//----------------------------------------------------
1094*cdf0e10cSrcweir 		// Set Filesize to 5000
1095*cdf0e10cSrcweir 		//----------------------------------------------------
1096*cdf0e10cSrcweir 
1097*cdf0e10cSrcweir 		printf( "Set FileSize to 5000\n" );
1098*cdf0e10cSrcweir 		rc=aFile.setSize( 5000 );
1099*cdf0e10cSrcweir 		print_error( rtl::OString( "Set FileSize" ), rc );
1100*cdf0e10cSrcweir 
1101*cdf0e10cSrcweir 		printf( "\n" );
1102*cdf0e10cSrcweir 		printf( "Verify:\n" );
1103*cdf0e10cSrcweir 
1104*cdf0e10cSrcweir 		//----------------------------------------------------
1105*cdf0e10cSrcweir 		// Check whether Filesize is set to 5000
1106*cdf0e10cSrcweir 		//----------------------------------------------------
1107*cdf0e10cSrcweir 
1108*cdf0e10cSrcweir 		rc=DirectoryItem::get( file_not_exist, aItem );
1109*cdf0e10cSrcweir 		print_error( rtl::OString( "Get DirectoryItem" ), rc );
1110*cdf0e10cSrcweir 
1111*cdf0e10cSrcweir 		if ( rc == FileBase::E_None )
1112*cdf0e10cSrcweir 		{
1113*cdf0e10cSrcweir 			FileStatus rStatus( FileStatusMask_FileSize  );
1114*cdf0e10cSrcweir 			rc=aItem.getFileStatus( rStatus );
1115*cdf0e10cSrcweir 			print_error( rtl::OString( "Get FileStatus" ), rc );
1116*cdf0e10cSrcweir 
1117*cdf0e10cSrcweir 			if ( rc == FileBase::E_None )
1118*cdf0e10cSrcweir 			{
1119*cdf0e10cSrcweir 				filesize=rStatus.getFileSize();
1120*cdf0e10cSrcweir 
1121*cdf0e10cSrcweir 				if ( filesize == 5000 )
1122*cdf0e10cSrcweir 					printf( "\nOK : FileSize: %i\n", filesize );
1123*cdf0e10cSrcweir 				else
1124*cdf0e10cSrcweir 					printf( "\nError : FileSize: %i\n", filesize );
1125*cdf0e10cSrcweir 			}
1126*cdf0e10cSrcweir 		}
1127*cdf0e10cSrcweir 
1128*cdf0e10cSrcweir 		printf( "\n" );
1129*cdf0e10cSrcweir 
1130*cdf0e10cSrcweir 		//----------------------------------------------------
1131*cdf0e10cSrcweir 		// Set Filesize to -1
1132*cdf0e10cSrcweir 		//----------------------------------------------------
1133*cdf0e10cSrcweir 
1134*cdf0e10cSrcweir 		printf( "Set FileSize to -1\n" );
1135*cdf0e10cSrcweir 		rc=aFile.setSize( -1 );
1136*cdf0e10cSrcweir 		print_error( rtl::OString( "Set FileSize" ), rc );
1137*cdf0e10cSrcweir 
1138*cdf0e10cSrcweir 		printf( "\n" );
1139*cdf0e10cSrcweir 
1140*cdf0e10cSrcweir 		// close the file
1141*cdf0e10cSrcweir 		rc=aFile.close();
1142*cdf0e10cSrcweir 		print_error( rtl::OString( "Close File" ), rc );
1143*cdf0e10cSrcweir 
1144*cdf0e10cSrcweir 		// remove the file
1145*cdf0e10cSrcweir 		rc=File::remove( file_not_exist );
1146*cdf0e10cSrcweir 		print_error( rtl::OString( "Remove File" ), rc );
1147*cdf0e10cSrcweir 	}
1148*cdf0e10cSrcweir 
1149*cdf0e10cSrcweir 	PressKey();
1150*cdf0e10cSrcweir 
1151*cdf0e10cSrcweir 	return;
1152*cdf0e10cSrcweir }
1153*cdf0e10cSrcweir 
1154*cdf0e10cSrcweir 
1155*cdf0e10cSrcweir //----------------------------------------------------
1156*cdf0e10cSrcweir // FilePointerTest
1157*cdf0e10cSrcweir //----------------------------------------------------
1158*cdf0e10cSrcweir 
1159*cdf0e10cSrcweir void FilePointerTest( void )
1160*cdf0e10cSrcweir {
1161*cdf0e10cSrcweir 	FileBase::RC	rc;
1162*cdf0e10cSrcweir 	sal_uInt64 filepointer;
1163*cdf0e10cSrcweir 
1164*cdf0e10cSrcweir 	printf( "--------------------------------------------\n" );
1165*cdf0e10cSrcweir 	printf( "File-Pointer-Test\n" );
1166*cdf0e10cSrcweir 	printf( "--------------------------------------------\n\n" );
1167*cdf0e10cSrcweir 
1168*cdf0e10cSrcweir 
1169*cdf0e10cSrcweir 	File	rFile( file_not_exist );
1170*cdf0e10cSrcweir 
1171*cdf0e10cSrcweir 	printf( "Create File: ");
1172*cdf0e10cSrcweir 	printFileName( file_not_exist );
1173*cdf0e10cSrcweir 	printf( "\n\n");
1174*cdf0e10cSrcweir 
1175*cdf0e10cSrcweir 	rc = rFile.open( OpenFlag_Read | OpenFlag_Write | osl_File_OpenFlag_Create );
1176*cdf0e10cSrcweir 	print_error( rtl::OString( "Create and Open File (Read & Write) "), rc );
1177*cdf0e10cSrcweir 	printf( "\n" );
1178*cdf0e10cSrcweir 
1179*cdf0e10cSrcweir 	if ( rc==FileBase::E_None )
1180*cdf0e10cSrcweir 	{
1181*cdf0e10cSrcweir 
1182*cdf0e10cSrcweir 		//----------------------------------------------------
1183*cdf0e10cSrcweir 		// get the position of the filepointer
1184*cdf0e10cSrcweir 		//----------------------------------------------------
1185*cdf0e10cSrcweir 
1186*cdf0e10cSrcweir 		rc =rFile.getPos( filepointer );
1187*cdf0e10cSrcweir 		print_error( rtl::OString( "GetPos" ), rc );
1188*cdf0e10cSrcweir 		printf( "Position of the FilePointer: %i\n", filepointer );
1189*cdf0e10cSrcweir 
1190*cdf0e10cSrcweir 		printf( "\n" );
1191*cdf0e10cSrcweir 
1192*cdf0e10cSrcweir 		//----------------------------------------------------
1193*cdf0e10cSrcweir 		// set the filepointer at the end of a file
1194*cdf0e10cSrcweir 		//----------------------------------------------------
1195*cdf0e10cSrcweir 
1196*cdf0e10cSrcweir 		printf( "Set FileSize to 5000\n" );
1197*cdf0e10cSrcweir 		rFile.setSize( 5000 );
1198*cdf0e10cSrcweir 
1199*cdf0e10cSrcweir 		printf( "Set the FilePointer at the end of the file (5000)\n" );
1200*cdf0e10cSrcweir 		rc=rFile.setPos( Pos_End,0 );
1201*cdf0e10cSrcweir 		print_error( rtl::OString( "SetPos" ), rc );
1202*cdf0e10cSrcweir 
1203*cdf0e10cSrcweir 		rc=rFile.getPos( filepointer );
1204*cdf0e10cSrcweir 
1205*cdf0e10cSrcweir 		if ( filepointer==5000 )
1206*cdf0e10cSrcweir 		{
1207*cdf0e10cSrcweir 			print_error( rtl::OString( "GetPos" ), rc );
1208*cdf0e10cSrcweir 			printf( "\nVerify: OK !\n" );
1209*cdf0e10cSrcweir 			printf( "Filepointer-Position: %llu\n",filepointer );
1210*cdf0e10cSrcweir 		}
1211*cdf0e10cSrcweir 		else
1212*cdf0e10cSrcweir 		{
1213*cdf0e10cSrcweir 			print_error( rtl::OString( "GetPos" ), rc );
1214*cdf0e10cSrcweir 			printf( "\nFilePointer-Test: Error\n" );
1215*cdf0e10cSrcweir 			printf( "Filepointer-Position: %i != 5000 \n",filepointer );
1216*cdf0e10cSrcweir 		}
1217*cdf0e10cSrcweir 
1218*cdf0e10cSrcweir 		printf( "\n" );
1219*cdf0e10cSrcweir 
1220*cdf0e10cSrcweir 		// close the file
1221*cdf0e10cSrcweir 		rc=rFile.close();
1222*cdf0e10cSrcweir 		print_error( rtl::OString( "Close File" ), rc );
1223*cdf0e10cSrcweir 
1224*cdf0e10cSrcweir 		// remove the file
1225*cdf0e10cSrcweir 		rc=File::remove( file_not_exist );
1226*cdf0e10cSrcweir 		print_error( rtl::OString( "Remove File" ), rc );
1227*cdf0e10cSrcweir 	}
1228*cdf0e10cSrcweir 
1229*cdf0e10cSrcweir 	PressKey();
1230*cdf0e10cSrcweir 
1231*cdf0e10cSrcweir 	return;
1232*cdf0e10cSrcweir }
1233*cdf0e10cSrcweir 
1234*cdf0e10cSrcweir //--------------------------------------------------
1235*cdf0e10cSrcweir // FileAttributesTest
1236*cdf0e10cSrcweir //--------------------------------------------------
1237*cdf0e10cSrcweir 
1238*cdf0e10cSrcweir void verifyFileAttributes( void )
1239*cdf0e10cSrcweir {
1240*cdf0e10cSrcweir 	FileBase::RC	rc;
1241*cdf0e10cSrcweir 	DirectoryItem	aItem;
1242*cdf0e10cSrcweir 	FileStatus rStatus( FileStatusMask_Attributes  );
1243*cdf0e10cSrcweir 
1244*cdf0e10cSrcweir 	printf( "\nVerify:\n" );
1245*cdf0e10cSrcweir 
1246*cdf0e10cSrcweir 	rc=DirectoryItem::get( file1, aItem );
1247*cdf0e10cSrcweir 
1248*cdf0e10cSrcweir 	if ( rc==FileBase::E_None )
1249*cdf0e10cSrcweir 	{
1250*cdf0e10cSrcweir 		rc=aItem.getFileStatus( rStatus );
1251*cdf0e10cSrcweir 
1252*cdf0e10cSrcweir 		if ( rc==FileBase::E_None )
1253*cdf0e10cSrcweir 		{
1254*cdf0e10cSrcweir 			sal_uInt64 uAttributes=rStatus.getAttributes();
1255*cdf0e10cSrcweir 			showAttributes(uAttributes);
1256*cdf0e10cSrcweir 			printf( "\n" );
1257*cdf0e10cSrcweir 		}
1258*cdf0e10cSrcweir 		else
1259*cdf0e10cSrcweir 			print_error( rtl::OString( "Get FileStatus" ), rc );
1260*cdf0e10cSrcweir 	}
1261*cdf0e10cSrcweir 	else
1262*cdf0e10cSrcweir 		print_error( rtl::OString( "Get DirectoryItem" ), rc );
1263*cdf0e10cSrcweir 
1264*cdf0e10cSrcweir 	return;
1265*cdf0e10cSrcweir }
1266*cdf0e10cSrcweir 
1267*cdf0e10cSrcweir #ifdef UNX
1268*cdf0e10cSrcweir void FileAttributesTest( void )
1269*cdf0e10cSrcweir {
1270*cdf0e10cSrcweir 	FileBase::RC	rc;
1271*cdf0e10cSrcweir 
1272*cdf0e10cSrcweir 	printf( "--------------------------------------------\n" );
1273*cdf0e10cSrcweir 	printf( "File-Attributes-Test\n" );
1274*cdf0e10cSrcweir 	printf( "--------------------------------------------\n\n" );
1275*cdf0e10cSrcweir 
1276*cdf0e10cSrcweir 	printf( "File: ");
1277*cdf0e10cSrcweir 	printFileName( file1 );
1278*cdf0e10cSrcweir 	printf( "\n\n" );
1279*cdf0e10cSrcweir 
1280*cdf0e10cSrcweir 
1281*cdf0e10cSrcweir 	rc=File::setAttributes( file1, Attribute_GrpWrite );
1282*cdf0e10cSrcweir 	print_error( rtl::OString( "Set Attribute: GrpWrite" ), rc );
1283*cdf0e10cSrcweir 
1284*cdf0e10cSrcweir 	verifyFileAttributes();
1285*cdf0e10cSrcweir 
1286*cdf0e10cSrcweir 	rc=File::setAttributes( file1, 0 );
1287*cdf0e10cSrcweir 	if ( rc!=FileBase::E_None )
1288*cdf0e10cSrcweir 		print_error( rtl::OString( "Reset Attributes" ), rc );
1289*cdf0e10cSrcweir 
1290*cdf0e10cSrcweir 	rc=File::setAttributes( file1, Attribute_GrpRead );
1291*cdf0e10cSrcweir 	print_error( rtl::OString( "Set Attribute: GrpRead" ), rc );
1292*cdf0e10cSrcweir 
1293*cdf0e10cSrcweir 	verifyFileAttributes();
1294*cdf0e10cSrcweir 
1295*cdf0e10cSrcweir 	rc=File::setAttributes( file1, 0 );
1296*cdf0e10cSrcweir 	if ( rc!=FileBase::E_None )
1297*cdf0e10cSrcweir 		print_error( rtl::OString( "Reset Attributes" ), rc );
1298*cdf0e10cSrcweir 
1299*cdf0e10cSrcweir 	rc=File::setAttributes( file1, Attribute_GrpExe );
1300*cdf0e10cSrcweir 	print_error( rtl::OString( "Set Attribute: GrpExe" ), rc );
1301*cdf0e10cSrcweir 
1302*cdf0e10cSrcweir 	verifyFileAttributes();
1303*cdf0e10cSrcweir 
1304*cdf0e10cSrcweir 	rc=File::setAttributes( file1, 0 );
1305*cdf0e10cSrcweir 	if ( rc!=FileBase::E_None )
1306*cdf0e10cSrcweir 		print_error( rtl::OString( "Reset Attributes" ), rc );
1307*cdf0e10cSrcweir 
1308*cdf0e10cSrcweir 	rc=File::setAttributes( file1, Attribute_OwnWrite );
1309*cdf0e10cSrcweir 	print_error( rtl::OString( "Set Attribute: OwnWrite" ), rc );
1310*cdf0e10cSrcweir 
1311*cdf0e10cSrcweir 	verifyFileAttributes();
1312*cdf0e10cSrcweir 
1313*cdf0e10cSrcweir 	rc=File::setAttributes( file1, 0 );
1314*cdf0e10cSrcweir 	if ( rc!=FileBase::E_None )
1315*cdf0e10cSrcweir 		print_error( rtl::OString( "Reset Attributes" ), rc );
1316*cdf0e10cSrcweir 
1317*cdf0e10cSrcweir 	rc=File::setAttributes( file1, Attribute_OwnRead );
1318*cdf0e10cSrcweir 	print_error( rtl::OString( "Set Attribute: OwnRead" ), rc );
1319*cdf0e10cSrcweir 
1320*cdf0e10cSrcweir 	verifyFileAttributes();
1321*cdf0e10cSrcweir 
1322*cdf0e10cSrcweir 	rc=File::setAttributes( file1, 0 );
1323*cdf0e10cSrcweir 	if ( rc!=FileBase::E_None )
1324*cdf0e10cSrcweir 		print_error( rtl::OString( "Reset Attributes" ), rc );
1325*cdf0e10cSrcweir 
1326*cdf0e10cSrcweir 	rc=File::setAttributes( file1, Attribute_OwnExe );
1327*cdf0e10cSrcweir 	print_error( rtl::OString( "Set Attribute: OwnExe" ), rc );
1328*cdf0e10cSrcweir 
1329*cdf0e10cSrcweir 	verifyFileAttributes();
1330*cdf0e10cSrcweir 
1331*cdf0e10cSrcweir 	rc=File::setAttributes( file1, 0 );
1332*cdf0e10cSrcweir 	if ( rc!=FileBase::E_None )
1333*cdf0e10cSrcweir 		print_error( rtl::OString( "Reset Attributes" ), rc );
1334*cdf0e10cSrcweir 
1335*cdf0e10cSrcweir 	rc=File::setAttributes( file1, Attribute_OthWrite );
1336*cdf0e10cSrcweir 	print_error( rtl::OString( "Set Attribute: OthWrite" ), rc );
1337*cdf0e10cSrcweir 
1338*cdf0e10cSrcweir 	verifyFileAttributes();
1339*cdf0e10cSrcweir 
1340*cdf0e10cSrcweir 	rc=File::setAttributes( file1, 0 );
1341*cdf0e10cSrcweir 	if ( rc!=FileBase::E_None )
1342*cdf0e10cSrcweir 		print_error( rtl::OString( "Reset Attributes" ), rc );
1343*cdf0e10cSrcweir 
1344*cdf0e10cSrcweir 	rc=File::setAttributes( file1, Attribute_OthRead );
1345*cdf0e10cSrcweir 	print_error( rtl::OString( "Set Attribute: OthRead" ), rc );
1346*cdf0e10cSrcweir 
1347*cdf0e10cSrcweir 	verifyFileAttributes();
1348*cdf0e10cSrcweir 
1349*cdf0e10cSrcweir 	rc=File::setAttributes( file1, 0 );
1350*cdf0e10cSrcweir 	if ( rc!=FileBase::E_None )
1351*cdf0e10cSrcweir 		print_error( rtl::OString( "Reset Attributes" ), rc );
1352*cdf0e10cSrcweir 
1353*cdf0e10cSrcweir 	rc=File::setAttributes( file1, Attribute_OthExe );
1354*cdf0e10cSrcweir 	print_error( rtl::OString( "Set Attribute: OthExe" ), rc );
1355*cdf0e10cSrcweir 
1356*cdf0e10cSrcweir 	verifyFileAttributes();
1357*cdf0e10cSrcweir 
1358*cdf0e10cSrcweir 	rc=File::setAttributes( file1, 0 );
1359*cdf0e10cSrcweir 	if ( rc!=FileBase::E_None )
1360*cdf0e10cSrcweir 		print_error( rtl::OString( "Reset Attributes" ), rc );
1361*cdf0e10cSrcweir 
1362*cdf0e10cSrcweir 
1363*cdf0e10cSrcweir 	rc=File::setAttributes( file1, Attribute_GrpWrite | Attribute_GrpRead | Attribute_GrpExe | Attribute_OwnWrite | Attribute_OwnRead | Attribute_OwnExe | Attribute_OthWrite | Attribute_OthRead | Attribute_OthExe );
1364*cdf0e10cSrcweir 	print_error( rtl::OString( "Set all Attributes" ), rc );
1365*cdf0e10cSrcweir 
1366*cdf0e10cSrcweir 	verifyFileAttributes();
1367*cdf0e10cSrcweir 
1368*cdf0e10cSrcweir 	PressKey();
1369*cdf0e10cSrcweir 
1370*cdf0e10cSrcweir 	return;
1371*cdf0e10cSrcweir }
1372*cdf0e10cSrcweir #endif
1373*cdf0e10cSrcweir 
1374*cdf0e10cSrcweir #ifdef WNT
1375*cdf0e10cSrcweir void FileAttributesTest( void )
1376*cdf0e10cSrcweir {
1377*cdf0e10cSrcweir 	FileBase::RC	rc;
1378*cdf0e10cSrcweir 
1379*cdf0e10cSrcweir 	printf( "--------------------------------------------\n" );
1380*cdf0e10cSrcweir 	printf( "File-Attributes-Test\n" );
1381*cdf0e10cSrcweir 	printf( "--------------------------------------------\n\n" );
1382*cdf0e10cSrcweir 
1383*cdf0e10cSrcweir 	printf( "File: ");
1384*cdf0e10cSrcweir 	printFileName( file1 );
1385*cdf0e10cSrcweir 	printf( "\n\n" );
1386*cdf0e10cSrcweir 
1387*cdf0e10cSrcweir 
1388*cdf0e10cSrcweir 	rc=File::setAttributes( file1, Attribute_ReadOnly );
1389*cdf0e10cSrcweir 	print_error( rtl::OString( "Set Attribute: ReadOnly" ), rc );
1390*cdf0e10cSrcweir 
1391*cdf0e10cSrcweir 	verifyFileAttributes();
1392*cdf0e10cSrcweir 
1393*cdf0e10cSrcweir 	rc=File::setAttributes( file1, 0 );
1394*cdf0e10cSrcweir 	print_error( rtl::OString( "Reset Attributes" ), rc );
1395*cdf0e10cSrcweir 
1396*cdf0e10cSrcweir 	verifyFileAttributes();
1397*cdf0e10cSrcweir 
1398*cdf0e10cSrcweir 	rc=File::setAttributes( file1, Attribute_Hidden );
1399*cdf0e10cSrcweir 	print_error( rtl::OString( "Set Attribute: Hidden" ), rc );
1400*cdf0e10cSrcweir 
1401*cdf0e10cSrcweir 	verifyFileAttributes();
1402*cdf0e10cSrcweir 
1403*cdf0e10cSrcweir 	rc=File::setAttributes( file1, 0 );
1404*cdf0e10cSrcweir 	print_error( rtl::OString( "Reset Attributes" ), rc );
1405*cdf0e10cSrcweir 
1406*cdf0e10cSrcweir 	verifyFileAttributes();
1407*cdf0e10cSrcweir 
1408*cdf0e10cSrcweir 	rc=File::setAttributes( file1, Attribute_Hidden | Attribute_ReadOnly );
1409*cdf0e10cSrcweir 	print_error( rtl::OString( "Set Attribute: Hidden & ReadOnly" ), rc );
1410*cdf0e10cSrcweir 
1411*cdf0e10cSrcweir 	verifyFileAttributes();
1412*cdf0e10cSrcweir 
1413*cdf0e10cSrcweir 	rc=File::setAttributes( file1, 0 );
1414*cdf0e10cSrcweir 	print_error( rtl::OString( "Reset Attributes") , rc );
1415*cdf0e10cSrcweir 
1416*cdf0e10cSrcweir 	verifyFileAttributes();
1417*cdf0e10cSrcweir 
1418*cdf0e10cSrcweir 	PressKey();
1419*cdf0e10cSrcweir 
1420*cdf0e10cSrcweir 	return;
1421*cdf0e10cSrcweir }
1422*cdf0e10cSrcweir #endif
1423*cdf0e10cSrcweir 
1424*cdf0e10cSrcweir //--------------------------------------------------
1425*cdf0e10cSrcweir // FileTimeTest
1426*cdf0e10cSrcweir //--------------------------------------------------
1427*cdf0e10cSrcweir 
1428*cdf0e10cSrcweir void FileTimeTest( void )
1429*cdf0e10cSrcweir {
1430*cdf0e10cSrcweir 	FileBase::RC	rc;
1431*cdf0e10cSrcweir 
1432*cdf0e10cSrcweir 	DirectoryItem	aItem;
1433*cdf0e10cSrcweir 
1434*cdf0e10cSrcweir 	struct tm sSysCreationTime = { 0, 20, 12, 4, 9, 100 };
1435*cdf0e10cSrcweir 	struct tm sSysAccessTime = { 0, 40, 1, 6, 5, 98 };
1436*cdf0e10cSrcweir 	struct tm sSysModifyTime = { 0, 1, 24, 13, 11, 95 };
1437*cdf0e10cSrcweir 
1438*cdf0e10cSrcweir 	time_t aSysCreationTime =  mktime( &sSysCreationTime );
1439*cdf0e10cSrcweir 	time_t aSysAccessTime =  mktime( &sSysAccessTime );
1440*cdf0e10cSrcweir 	time_t aSysModifyTime =  mktime( &sSysModifyTime );
1441*cdf0e10cSrcweir 
1442*cdf0e10cSrcweir 	TimeValue		aCreationTime	= { aSysCreationTime, 0};
1443*cdf0e10cSrcweir 	TimeValue		aAccessTime		= { aSysAccessTime, 0};
1444*cdf0e10cSrcweir 	TimeValue		aModifyTime		= { aSysModifyTime, 0};
1445*cdf0e10cSrcweir 
1446*cdf0e10cSrcweir 	TimeValue		aCreationTimeRead;
1447*cdf0e10cSrcweir 	TimeValue		aAccessTimeRead;
1448*cdf0e10cSrcweir 	TimeValue		aModifyTimeRead;
1449*cdf0e10cSrcweir 
1450*cdf0e10cSrcweir 
1451*cdf0e10cSrcweir 	printf( "--------------------------------------------\n" );
1452*cdf0e10cSrcweir 	printf( "File-Time-Test\n" );
1453*cdf0e10cSrcweir 	printf( "--------------------------------------------\n\n" );
1454*cdf0e10cSrcweir 
1455*cdf0e10cSrcweir 	printf( "File: ");
1456*cdf0e10cSrcweir 	printFileName( file1 );
1457*cdf0e10cSrcweir 	printf( "\n\n" );
1458*cdf0e10cSrcweir 
1459*cdf0e10cSrcweir 	printf( "CreationTime \t : ");
1460*cdf0e10cSrcweir 	showTime( aCreationTime );
1461*cdf0e10cSrcweir 
1462*cdf0e10cSrcweir 	printf( "\nAccessTime \t : ");
1463*cdf0e10cSrcweir 	showTime( aAccessTime );
1464*cdf0e10cSrcweir 
1465*cdf0e10cSrcweir 	printf( "\nModifyTime \t : ");
1466*cdf0e10cSrcweir 	showTime( aModifyTime );
1467*cdf0e10cSrcweir 
1468*cdf0e10cSrcweir 	//--------------------------------------------------
1469*cdf0e10cSrcweir 	// setTime
1470*cdf0e10cSrcweir 	//--------------------------------------------------
1471*cdf0e10cSrcweir 
1472*cdf0e10cSrcweir 	printf( "\n" );
1473*cdf0e10cSrcweir 	rc=File::setTime( file1 , aCreationTime , aAccessTime , aModifyTime );
1474*cdf0e10cSrcweir 	print_error( rtl::OString( "SetTime" ), rc );
1475*cdf0e10cSrcweir 
1476*cdf0e10cSrcweir 	//--------------------------------------------------
1477*cdf0e10cSrcweir 	// Verify
1478*cdf0e10cSrcweir 	//--------------------------------------------------
1479*cdf0e10cSrcweir 
1480*cdf0e10cSrcweir 	FileStatus rStatus( FileStatusMask_CreationTime | FileStatusMask_AccessTime | FileStatusMask_ModifyTime);
1481*cdf0e10cSrcweir 
1482*cdf0e10cSrcweir 	printf( "\nVerify:\n" );
1483*cdf0e10cSrcweir 
1484*cdf0e10cSrcweir 	rc=DirectoryItem::get( file1, aItem );
1485*cdf0e10cSrcweir 	print_error( rtl::OString( "Get DirectoryItem" ), rc );
1486*cdf0e10cSrcweir 
1487*cdf0e10cSrcweir 	if ( rc==FileBase::E_None )
1488*cdf0e10cSrcweir 	{
1489*cdf0e10cSrcweir 		rc=aItem.getFileStatus( rStatus );
1490*cdf0e10cSrcweir 		print_error( rtl::OString( "Get FileStatus" ), rc );
1491*cdf0e10cSrcweir 		printf( "\n" );
1492*cdf0e10cSrcweir 
1493*cdf0e10cSrcweir 		if ( rc==FileBase::E_None )
1494*cdf0e10cSrcweir 		{
1495*cdf0e10cSrcweir 			//--------------------------------------------------
1496*cdf0e10cSrcweir 			// GetCreationTime
1497*cdf0e10cSrcweir 			//--------------------------------------------------
1498*cdf0e10cSrcweir 
1499*cdf0e10cSrcweir 			aCreationTimeRead=rStatus.getCreationTime();
1500*cdf0e10cSrcweir #ifdef WNT
1501*cdf0e10cSrcweir 			if ( aCreationTime.Seconds == aCreationTimeRead.Seconds && aCreationTime.Nanosec == aCreationTimeRead.Nanosec )
1502*cdf0e10cSrcweir 				printf( "GetCreationTime: ok : " );
1503*cdf0e10cSrcweir 			else
1504*cdf0e10cSrcweir 				printf( "GetCreationTime: Error : " );
1505*cdf0e10cSrcweir 
1506*cdf0e10cSrcweir 			showTime( aCreationTimeRead );
1507*cdf0e10cSrcweir 			printf( "\n" );
1508*cdf0e10cSrcweir #endif
1509*cdf0e10cSrcweir 			//--------------------------------------------------
1510*cdf0e10cSrcweir 			// GetAccessTime
1511*cdf0e10cSrcweir 			//--------------------------------------------------
1512*cdf0e10cSrcweir 
1513*cdf0e10cSrcweir 			aAccessTimeRead=rStatus.getAccessTime();
1514*cdf0e10cSrcweir 
1515*cdf0e10cSrcweir 			if ( aAccessTime.Seconds == aAccessTimeRead.Seconds && aAccessTime.Nanosec == aAccessTimeRead.Nanosec )
1516*cdf0e10cSrcweir 				printf( "GetAccessTime: ok : " );
1517*cdf0e10cSrcweir 			else
1518*cdf0e10cSrcweir 				printf( "GetAccessTime: Error : " );
1519*cdf0e10cSrcweir 
1520*cdf0e10cSrcweir 			showTime( aAccessTimeRead );
1521*cdf0e10cSrcweir 			printf( "\n" );
1522*cdf0e10cSrcweir 
1523*cdf0e10cSrcweir 			//--------------------------------------------------
1524*cdf0e10cSrcweir 			// GetModifyTime
1525*cdf0e10cSrcweir 			//--------------------------------------------------
1526*cdf0e10cSrcweir 
1527*cdf0e10cSrcweir 			aModifyTimeRead=rStatus.getModifyTime();
1528*cdf0e10cSrcweir 
1529*cdf0e10cSrcweir 			if ( aModifyTime.Seconds == aModifyTimeRead.Seconds && aModifyTime.Nanosec == aModifyTimeRead.Nanosec )
1530*cdf0e10cSrcweir 				printf( "GetModifyTime: ok : " );
1531*cdf0e10cSrcweir 			else
1532*cdf0e10cSrcweir 				printf( "GetModifyTime: Error : " );
1533*cdf0e10cSrcweir 
1534*cdf0e10cSrcweir 			showTime( aModifyTimeRead );
1535*cdf0e10cSrcweir 			printf( "\n" );
1536*cdf0e10cSrcweir 		}
1537*cdf0e10cSrcweir 	}
1538*cdf0e10cSrcweir 
1539*cdf0e10cSrcweir 	PressKey();
1540*cdf0e10cSrcweir 	return;
1541*cdf0e10cSrcweir }
1542*cdf0e10cSrcweir 
1543*cdf0e10cSrcweir 
1544*cdf0e10cSrcweir //--------------------------------------------------
1545*cdf0e10cSrcweir // DirectoryItemTest
1546*cdf0e10cSrcweir //--------------------------------------------------
1547*cdf0e10cSrcweir 
1548*cdf0e10cSrcweir void DirectoryItemTest( void )
1549*cdf0e10cSrcweir {
1550*cdf0e10cSrcweir 	FileBase::RC	rc;
1551*cdf0e10cSrcweir 	Directory		*pDir;
1552*cdf0e10cSrcweir 	DirectoryItem	aItem;
1553*cdf0e10cSrcweir 	FileStatus		*pStatus;
1554*cdf0e10cSrcweir 	File			*pFile;
1555*cdf0e10cSrcweir 
1556*cdf0e10cSrcweir 	printf( "--------------------------------------------\n" );
1557*cdf0e10cSrcweir 	printf( "Directory-Item-Test\n" );
1558*cdf0e10cSrcweir 	printf( "--------------------------------------------\n\n" );
1559*cdf0e10cSrcweir 
1560*cdf0e10cSrcweir 	//--------------------------------------------------
1561*cdf0e10cSrcweir 	// get DirectoryItem from an existing directory
1562*cdf0e10cSrcweir 	//--------------------------------------------------
1563*cdf0e10cSrcweir 
1564*cdf0e10cSrcweir 	printf( "Get DirectoryItem from an existing Directory: ");
1565*cdf0e10cSrcweir 	printFileName( dir1 );
1566*cdf0e10cSrcweir 	printf( "\n");
1567*cdf0e10cSrcweir 
1568*cdf0e10cSrcweir 	rc=DirectoryItem::get( dir1 , aItem );
1569*cdf0e10cSrcweir 	print_error( rtl::OString( "GetDirectoryItem" ), rc );
1570*cdf0e10cSrcweir 
1571*cdf0e10cSrcweir 	pStatus=new FileStatus( FileStatusMask_All );
1572*cdf0e10cSrcweir 	rc=aItem.getFileStatus( *pStatus );
1573*cdf0e10cSrcweir 
1574*cdf0e10cSrcweir 	if ( rc==FileBase::E_None )
1575*cdf0e10cSrcweir 	{
1576*cdf0e10cSrcweir 		printf( "GetFileStatus: FileURL: ");
1577*cdf0e10cSrcweir 		printFileName(pStatus->getFileURL() );
1578*cdf0e10cSrcweir 		printf( "\n" );
1579*cdf0e10cSrcweir 	}
1580*cdf0e10cSrcweir 
1581*cdf0e10cSrcweir 	delete pStatus;
1582*cdf0e10cSrcweir 
1583*cdf0e10cSrcweir 	printf( "\n" );
1584*cdf0e10cSrcweir 
1585*cdf0e10cSrcweir 	//--------------------------------------------------
1586*cdf0e10cSrcweir 	// get DirectoryItem from a not existing directory
1587*cdf0e10cSrcweir 	//--------------------------------------------------
1588*cdf0e10cSrcweir 
1589*cdf0e10cSrcweir 	printf( "Get DirectoryItem from a not existing Directory: ");
1590*cdf0e10cSrcweir 	printFileName( dir_not_exist );
1591*cdf0e10cSrcweir 	printf( "\n" );
1592*cdf0e10cSrcweir 
1593*cdf0e10cSrcweir 	rc=DirectoryItem::get( dir_not_exist , aItem );
1594*cdf0e10cSrcweir 	print_error( rtl::OString( "Get DirectoryItem" ), rc );
1595*cdf0e10cSrcweir 
1596*cdf0e10cSrcweir 	printf( "\n" );
1597*cdf0e10cSrcweir 
1598*cdf0e10cSrcweir 	//--------------------------------------------------
1599*cdf0e10cSrcweir 	// get DirectoryItem from an existing file
1600*cdf0e10cSrcweir 	//--------------------------------------------------
1601*cdf0e10cSrcweir 
1602*cdf0e10cSrcweir 	printf( "Get DirectoryItem from an existing File: ");
1603*cdf0e10cSrcweir 	printFileName( file1 );
1604*cdf0e10cSrcweir 	printf( "\n" );
1605*cdf0e10cSrcweir 
1606*cdf0e10cSrcweir 	rc=DirectoryItem::get( file1 , aItem );
1607*cdf0e10cSrcweir 	print_error( rtl::OString( "GetDirectoryItem" ), rc );
1608*cdf0e10cSrcweir 
1609*cdf0e10cSrcweir 	pStatus=new FileStatus( FileStatusMask_All );
1610*cdf0e10cSrcweir 	rc=aItem.getFileStatus( *pStatus );
1611*cdf0e10cSrcweir 
1612*cdf0e10cSrcweir 	if ( rc==FileBase::E_None )
1613*cdf0e10cSrcweir 	{
1614*cdf0e10cSrcweir 		printf( "GetFileStatus: FileURL: ");
1615*cdf0e10cSrcweir 		printFileName( pStatus->getFileURL() );
1616*cdf0e10cSrcweir 		printf( "\n" );
1617*cdf0e10cSrcweir 	}
1618*cdf0e10cSrcweir 
1619*cdf0e10cSrcweir 	delete pStatus;
1620*cdf0e10cSrcweir 
1621*cdf0e10cSrcweir 	printf( "\n" );
1622*cdf0e10cSrcweir 
1623*cdf0e10cSrcweir 	//--------------------------------------------------
1624*cdf0e10cSrcweir 	// get DirectoryItem from a not existing file
1625*cdf0e10cSrcweir 	//--------------------------------------------------
1626*cdf0e10cSrcweir 
1627*cdf0e10cSrcweir 	printf( "Get DirectoryItem from a not existing File: ");
1628*cdf0e10cSrcweir 	printFileName( file_not_exist );
1629*cdf0e10cSrcweir 	printf( "\n" );
1630*cdf0e10cSrcweir 
1631*cdf0e10cSrcweir 	rc=DirectoryItem::get( file_not_exist , aItem );
1632*cdf0e10cSrcweir 	print_error( rtl::OString( "Get DirectoryItem" ), rc );
1633*cdf0e10cSrcweir 
1634*cdf0e10cSrcweir 	printf( "\n" );
1635*cdf0e10cSrcweir 
1636*cdf0e10cSrcweir 	//----------------------------------------------------------
1637*cdf0e10cSrcweir 	// get DirectoryItem from a directory with a wrong semantic
1638*cdf0e10cSrcweir 	//----------------------------------------------------------
1639*cdf0e10cSrcweir 
1640*cdf0e10cSrcweir 	printf( "Get DirectoryItem from a Directory with a wrong semantic: ");
1641*cdf0e10cSrcweir 	printFileName( dir_not_exist );
1642*cdf0e10cSrcweir 	printf( "\n" );
1643*cdf0e10cSrcweir 
1644*cdf0e10cSrcweir 	rc=DirectoryItem::get( dir_wrong_semantic, aItem );
1645*cdf0e10cSrcweir 	print_error( rtl::OString( "Get DirectoryItem" ),rc );
1646*cdf0e10cSrcweir 
1647*cdf0e10cSrcweir 	printf( "\n" );
1648*cdf0e10cSrcweir 
1649*cdf0e10cSrcweir 	//---------------------------------------------------
1650*cdf0e10cSrcweir 	// get DirectoryItem from a file-handle
1651*cdf0e10cSrcweir 	//--------------------------------------------------
1652*cdf0e10cSrcweir 
1653*cdf0e10cSrcweir 	pFile=new File( file1 );
1654*cdf0e10cSrcweir 
1655*cdf0e10cSrcweir 	rc=pFile->open( OpenFlag_Read );
1656*cdf0e10cSrcweir 	if ( rc==FileBase::E_None )
1657*cdf0e10cSrcweir 	{
1658*cdf0e10cSrcweir 		printf( "Get DirectoryItem from a File-Handle: ");
1659*cdf0e10cSrcweir 		printFileName( file1 );
1660*cdf0e10cSrcweir 		printf( "\n" );
1661*cdf0e10cSrcweir 
1662*cdf0e10cSrcweir 		rc=DirectoryItem::get( *pFile , aItem );
1663*cdf0e10cSrcweir 		print_error( rtl::OString( "GetDirectoryItem" ), rc );
1664*cdf0e10cSrcweir 
1665*cdf0e10cSrcweir 		pStatus=new FileStatus( FileStatusMask_All );
1666*cdf0e10cSrcweir 		rc=aItem.getFileStatus( *pStatus );
1667*cdf0e10cSrcweir 
1668*cdf0e10cSrcweir 		if ( rc==FileBase::E_None )
1669*cdf0e10cSrcweir 		{
1670*cdf0e10cSrcweir 			printf( "GetFileStatus: FileURL:  ");
1671*cdf0e10cSrcweir 			printFileName( pStatus->getFileURL() );
1672*cdf0e10cSrcweir 			printf( "\n");
1673*cdf0e10cSrcweir 		}
1674*cdf0e10cSrcweir 
1675*cdf0e10cSrcweir 		delete pStatus;
1676*cdf0e10cSrcweir 
1677*cdf0e10cSrcweir 		pFile->close();
1678*cdf0e10cSrcweir 	}
1679*cdf0e10cSrcweir 
1680*cdf0e10cSrcweir 	delete pFile;
1681*cdf0e10cSrcweir 
1682*cdf0e10cSrcweir 	printf( "\n" );
1683*cdf0e10cSrcweir 
1684*cdf0e10cSrcweir 	//---------------------------------------------------
1685*cdf0e10cSrcweir 	// get DirectoryItem from an empty file-handle
1686*cdf0e10cSrcweir 	//--------------------------------------------------
1687*cdf0e10cSrcweir 
1688*cdf0e10cSrcweir 	pFile=new File( file1 );
1689*cdf0e10cSrcweir 
1690*cdf0e10cSrcweir 	printf( "Get DirectoryItem from an empty File-Handle\n" );
1691*cdf0e10cSrcweir 	rc=DirectoryItem::get( *pFile , aItem );
1692*cdf0e10cSrcweir 	print_error( rtl::OString( "GetDirectoryItem" ), rc );
1693*cdf0e10cSrcweir 
1694*cdf0e10cSrcweir 	delete pFile;
1695*cdf0e10cSrcweir 
1696*cdf0e10cSrcweir 	printf( "\n" );
1697*cdf0e10cSrcweir 
1698*cdf0e10cSrcweir 	//--------------------------------------------------
1699*cdf0e10cSrcweir 	// GetNextItem from a directory
1700*cdf0e10cSrcweir 	//--------------------------------------------------
1701*cdf0e10cSrcweir 
1702*cdf0e10cSrcweir 	pDir=new Directory( dir1 );
1703*cdf0e10cSrcweir 	printf( "Get next DirectoryItem from a directory: ");
1704*cdf0e10cSrcweir 	printFileName( dir1);
1705*cdf0e10cSrcweir 	printf( "\n" );
1706*cdf0e10cSrcweir 
1707*cdf0e10cSrcweir 	rc= pDir->open();
1708*cdf0e10cSrcweir 	print_error( rtl::OString( "Open Directory" ), rc );
1709*cdf0e10cSrcweir 
1710*cdf0e10cSrcweir 	printf( "\n" );
1711*cdf0e10cSrcweir 
1712*cdf0e10cSrcweir 	if ( pDir->isOpen() )
1713*cdf0e10cSrcweir 	{
1714*cdf0e10cSrcweir 		//--------------------------------------------------
1715*cdf0e10cSrcweir 		// get all files from the directory
1716*cdf0e10cSrcweir 		//--------------------------------------------------
1717*cdf0e10cSrcweir 
1718*cdf0e10cSrcweir 		rtl::OUString	str;
1719*cdf0e10cSrcweir 		rtl::OUString	str1[2];
1720*cdf0e10cSrcweir 
1721*cdf0e10cSrcweir 		aItem=DirectoryItem();
1722*cdf0e10cSrcweir 		rc=pDir->getNextItem( aItem );
1723*cdf0e10cSrcweir 		print_error( rtl::OString( "GetNextItem" ),rc );
1724*cdf0e10cSrcweir 
1725*cdf0e10cSrcweir 		while( rc==FileBase::E_None )
1726*cdf0e10cSrcweir 		{
1727*cdf0e10cSrcweir 
1728*cdf0e10cSrcweir 			FileStatus rStatus( FileStatusMask_All );
1729*cdf0e10cSrcweir 			aItem.getFileStatus( rStatus );
1730*cdf0e10cSrcweir 
1731*cdf0e10cSrcweir 			str=rStatus.getFileName();
1732*cdf0e10cSrcweir 			printf( "Filename: ");
1733*cdf0e10cSrcweir 			printFileName( str );
1734*cdf0e10cSrcweir 			printf( "\n");
1735*cdf0e10cSrcweir 
1736*cdf0e10cSrcweir 			aItem=DirectoryItem();
1737*cdf0e10cSrcweir 			rc=pDir->getNextItem( aItem );
1738*cdf0e10cSrcweir 			print_error( rtl::OString( "GetNextItem" ),rc );
1739*cdf0e10cSrcweir 		}
1740*cdf0e10cSrcweir 
1741*cdf0e10cSrcweir 		printf( "\n" );
1742*cdf0e10cSrcweir 
1743*cdf0e10cSrcweir 		//--------------------------------------------------
1744*cdf0e10cSrcweir 		// Reset-Test
1745*cdf0e10cSrcweir 		//--------------------------------------------------
1746*cdf0e10cSrcweir 
1747*cdf0e10cSrcweir 		for (int i=0; i<2; i++)
1748*cdf0e10cSrcweir 		{
1749*cdf0e10cSrcweir 			aItem=DirectoryItem();
1750*cdf0e10cSrcweir 			rc=pDir->reset();
1751*cdf0e10cSrcweir 			rc=pDir->getNextItem( aItem );
1752*cdf0e10cSrcweir 
1753*cdf0e10cSrcweir 			FileStatus rStatus( FileStatusMask_All );
1754*cdf0e10cSrcweir 			aItem.getFileStatus( rStatus );
1755*cdf0e10cSrcweir 
1756*cdf0e10cSrcweir 			str1[i]=rStatus.getFileName();
1757*cdf0e10cSrcweir 		}
1758*cdf0e10cSrcweir 
1759*cdf0e10cSrcweir 
1760*cdf0e10cSrcweir 		if ( str1[0].compareTo(str1[1]) == 0 )
1761*cdf0e10cSrcweir 			print_error( rtl::OString( "Reset" ),FileBase::E_None );
1762*cdf0e10cSrcweir 		else
1763*cdf0e10cSrcweir 			print_error( rtl::OString( "Reset" ),FileBase::E_invalidError );
1764*cdf0e10cSrcweir 
1765*cdf0e10cSrcweir 		printf( "\n" );
1766*cdf0e10cSrcweir 
1767*cdf0e10cSrcweir 		// Close Directory
1768*cdf0e10cSrcweir 		rc=pDir->close();
1769*cdf0e10cSrcweir 		print_error( rtl::OString( "Close Directory" ), rc );
1770*cdf0e10cSrcweir 	}
1771*cdf0e10cSrcweir 
1772*cdf0e10cSrcweir 	printf( "\n");
1773*cdf0e10cSrcweir 
1774*cdf0e10cSrcweir 	//--------------------------------------------------
1775*cdf0e10cSrcweir 	// GetNextItem from a closed directory
1776*cdf0e10cSrcweir 	//--------------------------------------------------
1777*cdf0e10cSrcweir 
1778*cdf0e10cSrcweir 	printf( "Get next DirectoryItem from a closed directory: ");
1779*cdf0e10cSrcweir 	printFileName( dir1 );
1780*cdf0e10cSrcweir 	printf( "\n" );
1781*cdf0e10cSrcweir 
1782*cdf0e10cSrcweir 	aItem=DirectoryItem();
1783*cdf0e10cSrcweir 	rc=pDir->getNextItem( aItem );
1784*cdf0e10cSrcweir 	print_error( rtl::OString( "GetNextItem" ),rc );
1785*cdf0e10cSrcweir 
1786*cdf0e10cSrcweir 	delete pDir;
1787*cdf0e10cSrcweir 
1788*cdf0e10cSrcweir 	PressKey();
1789*cdf0e10cSrcweir 	return;
1790*cdf0e10cSrcweir }
1791*cdf0e10cSrcweir 
1792*cdf0e10cSrcweir //--------------------------------------------------
1793*cdf0e10cSrcweir // FileStatusTest (for different types)
1794*cdf0e10cSrcweir //--------------------------------------------------
1795*cdf0e10cSrcweir 
1796*cdf0e10cSrcweir void FileStatusTest( FileStatus *pStatus )
1797*cdf0e10cSrcweir {
1798*cdf0e10cSrcweir 	//--------------------------------------------------
1799*cdf0e10cSrcweir 	// GetFileType of the directory
1800*cdf0e10cSrcweir 	//--------------------------------------------------
1801*cdf0e10cSrcweir 
1802*cdf0e10cSrcweir 	FileStatus::Type	aType;
1803*cdf0e10cSrcweir 
1804*cdf0e10cSrcweir 	printf( "\ngetFileType:\n" );
1805*cdf0e10cSrcweir 	aType=pStatus->getFileType();
1806*cdf0e10cSrcweir 	showFileType( aType );
1807*cdf0e10cSrcweir 
1808*cdf0e10cSrcweir 	//--------------------------------------------------
1809*cdf0e10cSrcweir 	// GetAttributes
1810*cdf0e10cSrcweir 	//--------------------------------------------------
1811*cdf0e10cSrcweir 
1812*cdf0e10cSrcweir 	sal_uInt64			uAttributes;
1813*cdf0e10cSrcweir 
1814*cdf0e10cSrcweir 	printf( "\ngetAttributes:\n" );
1815*cdf0e10cSrcweir 	uAttributes=pStatus->getAttributes();
1816*cdf0e10cSrcweir 	showAttributes( uAttributes );
1817*cdf0e10cSrcweir 
1818*cdf0e10cSrcweir 	//--------------------------------------------------
1819*cdf0e10cSrcweir 	// GetCreationTime
1820*cdf0e10cSrcweir 	//--------------------------------------------------
1821*cdf0e10cSrcweir 
1822*cdf0e10cSrcweir 	TimeValue	aCreationTime;
1823*cdf0e10cSrcweir 
1824*cdf0e10cSrcweir 	printf( "\ngetCreationTime:\n" );
1825*cdf0e10cSrcweir 	aCreationTime=pStatus->getCreationTime();
1826*cdf0e10cSrcweir 
1827*cdf0e10cSrcweir 	printf( "CreationTime: " );
1828*cdf0e10cSrcweir 	showTime( aCreationTime );
1829*cdf0e10cSrcweir 
1830*cdf0e10cSrcweir 	//--------------------------------------------------
1831*cdf0e10cSrcweir 	// GetAccessTime
1832*cdf0e10cSrcweir 	//--------------------------------------------------
1833*cdf0e10cSrcweir 
1834*cdf0e10cSrcweir 	TimeValue	aAccessTime;
1835*cdf0e10cSrcweir 
1836*cdf0e10cSrcweir 	printf( "\ngetAccessTime:\n" );
1837*cdf0e10cSrcweir 	aAccessTime=pStatus->getAccessTime();
1838*cdf0e10cSrcweir 
1839*cdf0e10cSrcweir 	printf( "AccessTime: " );
1840*cdf0e10cSrcweir 	showTime( aAccessTime );
1841*cdf0e10cSrcweir 
1842*cdf0e10cSrcweir 	//--------------------------------------------------
1843*cdf0e10cSrcweir 	// GetModifyTime
1844*cdf0e10cSrcweir 	//--------------------------------------------------
1845*cdf0e10cSrcweir 
1846*cdf0e10cSrcweir 	TimeValue	aModifyTime;
1847*cdf0e10cSrcweir 
1848*cdf0e10cSrcweir 	printf( "\ngetModifyTime:\n" );
1849*cdf0e10cSrcweir 	aModifyTime=pStatus->getModifyTime();
1850*cdf0e10cSrcweir 
1851*cdf0e10cSrcweir 	printf( "ModifyTime: " );
1852*cdf0e10cSrcweir 	showTime( aModifyTime );
1853*cdf0e10cSrcweir 
1854*cdf0e10cSrcweir 	//--------------------------------------------------
1855*cdf0e10cSrcweir 	// GetFileSize
1856*cdf0e10cSrcweir 	//--------------------------------------------------
1857*cdf0e10cSrcweir 
1858*cdf0e10cSrcweir 	sal_uInt64			FileSize;
1859*cdf0e10cSrcweir 
1860*cdf0e10cSrcweir 	printf( "\ngetFileSize:\n" );
1861*cdf0e10cSrcweir 
1862*cdf0e10cSrcweir 	FileSize=pStatus->getFileSize();
1863*cdf0e10cSrcweir 	printf( "FileSize: %i\n", FileSize);
1864*cdf0e10cSrcweir 
1865*cdf0e10cSrcweir 	//--------------------------------------------------
1866*cdf0e10cSrcweir 	// GetFileName
1867*cdf0e10cSrcweir 	//--------------------------------------------------
1868*cdf0e10cSrcweir 
1869*cdf0e10cSrcweir 	rtl::OUString			FileName;
1870*cdf0e10cSrcweir 
1871*cdf0e10cSrcweir 	printf( "\ngetFileName:\n" );
1872*cdf0e10cSrcweir 
1873*cdf0e10cSrcweir 	FileName=pStatus->getFileName();
1874*cdf0e10cSrcweir 	printf( "FileName: ");
1875*cdf0e10cSrcweir 	printFileName( FileName );
1876*cdf0e10cSrcweir 	printf( "\n" );
1877*cdf0e10cSrcweir 
1878*cdf0e10cSrcweir 	//--------------------------------------------------
1879*cdf0e10cSrcweir 	// GetFileURL
1880*cdf0e10cSrcweir 	//--------------------------------------------------
1881*cdf0e10cSrcweir 
1882*cdf0e10cSrcweir 	rtl::OUString			FileURL;
1883*cdf0e10cSrcweir 
1884*cdf0e10cSrcweir 	printf( "\ngetFileURL:\n" );
1885*cdf0e10cSrcweir 
1886*cdf0e10cSrcweir 	FileURL=pStatus->getFileURL();
1887*cdf0e10cSrcweir 	printf( "FileURL: ");
1888*cdf0e10cSrcweir 	printFileName( FileURL );
1889*cdf0e10cSrcweir 	printf( "\n" );
1890*cdf0e10cSrcweir 
1891*cdf0e10cSrcweir 	//--------------------------------------------------
1892*cdf0e10cSrcweir 	// GetLinkTargetURL
1893*cdf0e10cSrcweir 	//--------------------------------------------------
1894*cdf0e10cSrcweir 
1895*cdf0e10cSrcweir 	rtl::OUString			LinkTargetURL;
1896*cdf0e10cSrcweir 
1897*cdf0e10cSrcweir 	printf( "\ngetLinkTargetURL:\n");
1898*cdf0e10cSrcweir 
1899*cdf0e10cSrcweir 	LinkTargetURL=pStatus->getLinkTargetURL();
1900*cdf0e10cSrcweir 	printf( "LinkTargetURL: ");
1901*cdf0e10cSrcweir 	printFileName( LinkTargetURL );
1902*cdf0e10cSrcweir 	printf( "\n" );
1903*cdf0e10cSrcweir 
1904*cdf0e10cSrcweir 	return;
1905*cdf0e10cSrcweir }
1906*cdf0e10cSrcweir 
1907*cdf0e10cSrcweir //--------------------------------------------------
1908*cdf0e10cSrcweir // DirectoryFileStatusTest
1909*cdf0e10cSrcweir //--------------------------------------------------
1910*cdf0e10cSrcweir 
1911*cdf0e10cSrcweir void DirectoryFileStatusTest( void )
1912*cdf0e10cSrcweir {
1913*cdf0e10cSrcweir 	FileBase::RC	rc;
1914*cdf0e10cSrcweir 	DirectoryItem	aItem;
1915*cdf0e10cSrcweir 	FileStatus		*pStatus;
1916*cdf0e10cSrcweir 
1917*cdf0e10cSrcweir 	printf( "--------------------------------------------\n" );
1918*cdf0e10cSrcweir 	printf( "Directory-FileStatus-Test\n" );
1919*cdf0e10cSrcweir 	printf( "--------------------------------------------\n\n" );
1920*cdf0e10cSrcweir 
1921*cdf0e10cSrcweir 	printf( "FileStatus of the directory: ");
1922*cdf0e10cSrcweir 	printFileName( dir1 );
1923*cdf0e10cSrcweir 	printf( "\n" );
1924*cdf0e10cSrcweir 
1925*cdf0e10cSrcweir 	aItem=DirectoryItem();
1926*cdf0e10cSrcweir 
1927*cdf0e10cSrcweir 	rc=DirectoryItem::get( dir1, aItem );
1928*cdf0e10cSrcweir 	print_error( rtl::OString( "Get DirectoryItem" ), rc );
1929*cdf0e10cSrcweir 
1930*cdf0e10cSrcweir 	if ( rc==FileBase::E_None )
1931*cdf0e10cSrcweir 	{
1932*cdf0e10cSrcweir 		pStatus=new FileStatus( FileStatusMask_All );
1933*cdf0e10cSrcweir 		rc=aItem.getFileStatus( *pStatus );
1934*cdf0e10cSrcweir 
1935*cdf0e10cSrcweir 		FileStatusTest( pStatus );
1936*cdf0e10cSrcweir 
1937*cdf0e10cSrcweir 		delete pStatus;
1938*cdf0e10cSrcweir 	}
1939*cdf0e10cSrcweir 
1940*cdf0e10cSrcweir 	printf( "\n" );
1941*cdf0e10cSrcweir 
1942*cdf0e10cSrcweir 	PressKey();
1943*cdf0e10cSrcweir 	return;
1944*cdf0e10cSrcweir }
1945*cdf0e10cSrcweir 
1946*cdf0e10cSrcweir //--------------------------------------------------
1947*cdf0e10cSrcweir // FileFileStatusTest
1948*cdf0e10cSrcweir //--------------------------------------------------
1949*cdf0e10cSrcweir 
1950*cdf0e10cSrcweir void FileFileStatusTest( void )
1951*cdf0e10cSrcweir {
1952*cdf0e10cSrcweir 	FileBase::RC	rc;
1953*cdf0e10cSrcweir 	DirectoryItem	aItem;
1954*cdf0e10cSrcweir 	FileStatus		*pStatus;
1955*cdf0e10cSrcweir 
1956*cdf0e10cSrcweir 	printf( "--------------------------------------------\n" );
1957*cdf0e10cSrcweir 	printf( "File-FileStatus-Test\n" );
1958*cdf0e10cSrcweir 	printf( "--------------------------------------------\n\n" );
1959*cdf0e10cSrcweir 
1960*cdf0e10cSrcweir 	printf( "FileStatus of the file: ");
1961*cdf0e10cSrcweir 	printFileName( file1 );
1962*cdf0e10cSrcweir 	printf( "\n" );
1963*cdf0e10cSrcweir 
1964*cdf0e10cSrcweir 	aItem=DirectoryItem();
1965*cdf0e10cSrcweir 
1966*cdf0e10cSrcweir 	rc=DirectoryItem::get( file1 , aItem );
1967*cdf0e10cSrcweir 	print_error( rtl::OString( "Get DirectoryItem" ), rc );
1968*cdf0e10cSrcweir 
1969*cdf0e10cSrcweir 	if ( rc==FileBase::E_None )
1970*cdf0e10cSrcweir 	{
1971*cdf0e10cSrcweir 		pStatus=new FileStatus( FileStatusMask_All );
1972*cdf0e10cSrcweir 		rc=aItem.getFileStatus( *pStatus );
1973*cdf0e10cSrcweir 
1974*cdf0e10cSrcweir 		FileStatusTest( pStatus );
1975*cdf0e10cSrcweir 
1976*cdf0e10cSrcweir 		delete pStatus;
1977*cdf0e10cSrcweir 	}
1978*cdf0e10cSrcweir 
1979*cdf0e10cSrcweir 	printf( "\n" );
1980*cdf0e10cSrcweir 
1981*cdf0e10cSrcweir 	PressKey();
1982*cdf0e10cSrcweir 	return;
1983*cdf0e10cSrcweir }
1984*cdf0e10cSrcweir 
1985*cdf0e10cSrcweir //--------------------------------------------------
1986*cdf0e10cSrcweir // VolumeFileStatusTest
1987*cdf0e10cSrcweir //--------------------------------------------------
1988*cdf0e10cSrcweir 
1989*cdf0e10cSrcweir void VolumeFileStatusTest( void )
1990*cdf0e10cSrcweir {
1991*cdf0e10cSrcweir 	FileBase::RC	rc;
1992*cdf0e10cSrcweir 	DirectoryItem	aItem;
1993*cdf0e10cSrcweir 	FileStatus		*pStatus;
1994*cdf0e10cSrcweir 
1995*cdf0e10cSrcweir 	printf( "--------------------------------------------\n" );
1996*cdf0e10cSrcweir 	printf( "Volume-FileStatus-Test\n" );
1997*cdf0e10cSrcweir 	printf( "--------------------------------------------\n\n" );
1998*cdf0e10cSrcweir 
1999*cdf0e10cSrcweir 	printf( "FileStatus of the Volume: ");
2000*cdf0e10cSrcweir 	printFileName( root );
2001*cdf0e10cSrcweir 	printf( "\n" );
2002*cdf0e10cSrcweir 
2003*cdf0e10cSrcweir 	aItem=DirectoryItem();
2004*cdf0e10cSrcweir 
2005*cdf0e10cSrcweir 	rc=DirectoryItem::get( root , aItem );
2006*cdf0e10cSrcweir 	print_error( rtl::OString( "Get DirectoryItem" ), rc );
2007*cdf0e10cSrcweir 
2008*cdf0e10cSrcweir 	if ( rc==FileBase::E_None )
2009*cdf0e10cSrcweir 	{
2010*cdf0e10cSrcweir 		pStatus=new FileStatus( FileStatusMask_All) ;
2011*cdf0e10cSrcweir 		rc=aItem.getFileStatus( *pStatus );
2012*cdf0e10cSrcweir 
2013*cdf0e10cSrcweir 		FileStatusTest( pStatus );
2014*cdf0e10cSrcweir 
2015*cdf0e10cSrcweir 		delete pStatus;
2016*cdf0e10cSrcweir 	}
2017*cdf0e10cSrcweir 
2018*cdf0e10cSrcweir 	printf( "\n" );
2019*cdf0e10cSrcweir 
2020*cdf0e10cSrcweir 	PressKey();
2021*cdf0e10cSrcweir 	return;
2022*cdf0e10cSrcweir }
2023*cdf0e10cSrcweir 
2024*cdf0e10cSrcweir 
2025*cdf0e10cSrcweir //--------------------------------------------------
2026*cdf0e10cSrcweir // VolumeInfoTest
2027*cdf0e10cSrcweir //--------------------------------------------------
2028*cdf0e10cSrcweir 
2029*cdf0e10cSrcweir void VolumeInfoTest( void )
2030*cdf0e10cSrcweir {
2031*cdf0e10cSrcweir 	FileBase::RC	rc;
2032*cdf0e10cSrcweir 
2033*cdf0e10cSrcweir 	printf( "--------------------------------------------\n" );
2034*cdf0e10cSrcweir 	printf( "Volume-Info-Test\n" );
2035*cdf0e10cSrcweir 	printf( "--------------------------------------------\n\n" );
2036*cdf0e10cSrcweir 
2037*cdf0e10cSrcweir 	printf( "VolumeInfo of the volume ");
2038*cdf0e10cSrcweir 	printFileName( root );
2039*cdf0e10cSrcweir 
2040*cdf0e10cSrcweir 	printf( "\n" );
2041*cdf0e10cSrcweir 
2042*cdf0e10cSrcweir 	VolumeInfo rInfo( VolumeInfoMask_FreeSpace );
2043*cdf0e10cSrcweir 	rc=Directory::getVolumeInfo( root , rInfo );
2044*cdf0e10cSrcweir 	print_error( rtl::OString( "GetVolumeInfo" ),rc );
2045*cdf0e10cSrcweir 
2046*cdf0e10cSrcweir 	printf( "\n" );
2047*cdf0e10cSrcweir 
2048*cdf0e10cSrcweir 	//--------------------------------------------------
2049*cdf0e10cSrcweir 	// getRemoteFlag
2050*cdf0e10cSrcweir 	//--------------------------------------------------
2051*cdf0e10cSrcweir 
2052*cdf0e10cSrcweir 	if ( rInfo.getRemoteFlag() )
2053*cdf0e10cSrcweir 		printf( "RemoteFlag: Yes\n" );
2054*cdf0e10cSrcweir 	else
2055*cdf0e10cSrcweir 		printf( "RemoteFlag: No\n" );
2056*cdf0e10cSrcweir 
2057*cdf0e10cSrcweir 	//--------------------------------------------------
2058*cdf0e10cSrcweir 	// getRemoveableFlag
2059*cdf0e10cSrcweir 	//--------------------------------------------------
2060*cdf0e10cSrcweir 
2061*cdf0e10cSrcweir 	if ( rInfo.getRemoveableFlag() )
2062*cdf0e10cSrcweir 		printf( "RemoveableFlag: Yes\n" );
2063*cdf0e10cSrcweir 	else
2064*cdf0e10cSrcweir 		printf( "RemoveableFlag: No\n" );
2065*cdf0e10cSrcweir 
2066*cdf0e10cSrcweir 	//--------------------------------------------------
2067*cdf0e10cSrcweir 	// getTotalSpace
2068*cdf0e10cSrcweir 	//--------------------------------------------------
2069*cdf0e10cSrcweir 
2070*cdf0e10cSrcweir 	sal_uInt64	TotalSpace;
2071*cdf0e10cSrcweir 	TotalSpace=rInfo.getTotalSpace();
2072*cdf0e10cSrcweir 	printf( "Total Space: %i\n",TotalSpace );
2073*cdf0e10cSrcweir 
2074*cdf0e10cSrcweir 	//--------------------------------------------------
2075*cdf0e10cSrcweir 	// getFreeSpace
2076*cdf0e10cSrcweir 	//--------------------------------------------------
2077*cdf0e10cSrcweir 
2078*cdf0e10cSrcweir 	sal_uInt64	FreeSpace;
2079*cdf0e10cSrcweir 	FreeSpace=rInfo.getFreeSpace();
2080*cdf0e10cSrcweir 	printf( "Free Space: %i\n",FreeSpace );
2081*cdf0e10cSrcweir 
2082*cdf0e10cSrcweir 	//--------------------------------------------------
2083*cdf0e10cSrcweir 	// getUsedSpace
2084*cdf0e10cSrcweir 	//--------------------------------------------------
2085*cdf0e10cSrcweir 
2086*cdf0e10cSrcweir 	sal_uInt64	UsedSpace;
2087*cdf0e10cSrcweir 	UsedSpace=rInfo.getUsedSpace();
2088*cdf0e10cSrcweir 	printf( "Used Space: %i\n",UsedSpace );
2089*cdf0e10cSrcweir 
2090*cdf0e10cSrcweir 	//--------------------------------------------------
2091*cdf0e10cSrcweir 	// getMaxNameLength
2092*cdf0e10cSrcweir 	//--------------------------------------------------
2093*cdf0e10cSrcweir 
2094*cdf0e10cSrcweir 	sal_uInt32	MaxNameLength;
2095*cdf0e10cSrcweir 	MaxNameLength=rInfo.getMaxNameLength();
2096*cdf0e10cSrcweir 	printf( "MaxNameLength: %i\n",MaxNameLength );
2097*cdf0e10cSrcweir 
2098*cdf0e10cSrcweir 	//--------------------------------------------------
2099*cdf0e10cSrcweir 	// getMaxPathLength
2100*cdf0e10cSrcweir 	//--------------------------------------------------
2101*cdf0e10cSrcweir 
2102*cdf0e10cSrcweir 	sal_uInt32	MaxPathLength;
2103*cdf0e10cSrcweir 	MaxPathLength=rInfo.getMaxPathLength();
2104*cdf0e10cSrcweir 	printf( "MaxPathLength: %i\n",MaxPathLength );
2105*cdf0e10cSrcweir 
2106*cdf0e10cSrcweir 	//--------------------------------------------------
2107*cdf0e10cSrcweir 	// getFileSystemName
2108*cdf0e10cSrcweir 	//--------------------------------------------------
2109*cdf0e10cSrcweir 
2110*cdf0e10cSrcweir 	rtl::OUString	FileSystemName;
2111*cdf0e10cSrcweir 	FileSystemName=rInfo.getFileSystemName();
2112*cdf0e10cSrcweir 	printf( "File-System-Name: ");
2113*cdf0e10cSrcweir 	printFileName( FileSystemName );
2114*cdf0e10cSrcweir 	printf( "\n" );
2115*cdf0e10cSrcweir 
2116*cdf0e10cSrcweir 	PressKey();
2117*cdf0e10cSrcweir 	return;
2118*cdf0e10cSrcweir }
2119*cdf0e10cSrcweir 
2120*cdf0e10cSrcweir //--------------------------------------------------
2121*cdf0e10cSrcweir // FileBaseTest
2122*cdf0e10cSrcweir //--------------------------------------------------
2123*cdf0e10cSrcweir 
2124*cdf0e10cSrcweir void ConvertPathTest(rtl::OUString& strPath)
2125*cdf0e10cSrcweir {
2126*cdf0e10cSrcweir 	FileBase::RC	rc;
2127*cdf0e10cSrcweir 
2128*cdf0e10cSrcweir 	rtl::OUString		strNormPath;
2129*cdf0e10cSrcweir 	rtl::OUString		strFileURL;
2130*cdf0e10cSrcweir 	rtl::OUString		strNormPathFromFileURL;
2131*cdf0e10cSrcweir 	rtl::OUString		strSystemPath;
2132*cdf0e10cSrcweir 
2133*cdf0e10cSrcweir 	//--------------------------------------------------
2134*cdf0e10cSrcweir 	// normalizePath
2135*cdf0e10cSrcweir 	//--------------------------------------------------
2136*cdf0e10cSrcweir 
2137*cdf0e10cSrcweir 	rc=FileBase::getFileURLFromSystemPath( strPath, strNormPath );
2138*cdf0e10cSrcweir 
2139*cdf0e10cSrcweir 	if ( rc == FileBase::E_None )
2140*cdf0e10cSrcweir 	{
2141*cdf0e10cSrcweir 		printf( "Normalized Path: \t\t");
2142*cdf0e10cSrcweir 		printFileName( strNormPath );
2143*cdf0e10cSrcweir 		printf( "\n" );
2144*cdf0e10cSrcweir 	}
2145*cdf0e10cSrcweir 	else
2146*cdf0e10cSrcweir 		printf( "normalizePath: Error \n" );
2147*cdf0e10cSrcweir 
2148*cdf0e10cSrcweir 	//--------------------------------------------------
2149*cdf0e10cSrcweir 	// getFileURLFromSystemPath
2150*cdf0e10cSrcweir 	//--------------------------------------------------
2151*cdf0e10cSrcweir 
2152*cdf0e10cSrcweir 	if ( strNormPath.getLength() != 0 )
2153*cdf0e10cSrcweir 	{
2154*cdf0e10cSrcweir 		rc=FileBase::getFileURLFromSystemPath( strNormPath, strFileURL );
2155*cdf0e10cSrcweir 
2156*cdf0e10cSrcweir 		if ( rc == FileBase::E_None )
2157*cdf0e10cSrcweir 		{
2158*cdf0e10cSrcweir 			printf( "File-URL: \t\t\t");
2159*cdf0e10cSrcweir 			printFileName( strFileURL );
2160*cdf0e10cSrcweir 			printf( "\n" );
2161*cdf0e10cSrcweir 		}
2162*cdf0e10cSrcweir 		else
2163*cdf0e10cSrcweir 			printf( "getFileURLFromSystemPath: Error \n" );
2164*cdf0e10cSrcweir 	}
2165*cdf0e10cSrcweir 	else
2166*cdf0e10cSrcweir 		printf( "getFileURLFromSystemPath: not tested \n" );
2167*cdf0e10cSrcweir 
2168*cdf0e10cSrcweir 	//--------------------------------------------------
2169*cdf0e10cSrcweir 	// getNormalizedPathFromFileURL
2170*cdf0e10cSrcweir 	//--------------------------------------------------
2171*cdf0e10cSrcweir 
2172*cdf0e10cSrcweir 	if ( strFileURL.getLength() != 0 )
2173*cdf0e10cSrcweir 	{
2174*cdf0e10cSrcweir 		rc=FileBase::getSystemPathFromFileURL( strFileURL, strNormPathFromFileURL );
2175*cdf0e10cSrcweir 
2176*cdf0e10cSrcweir 		if ( rc == FileBase::E_None )
2177*cdf0e10cSrcweir 		{
2178*cdf0e10cSrcweir 			printf( "Normalized Path from File-URL: \t");
2179*cdf0e10cSrcweir 			printFileName( strNormPathFromFileURL );
2180*cdf0e10cSrcweir 			printf( "\n" );
2181*cdf0e10cSrcweir 		}
2182*cdf0e10cSrcweir 		else
2183*cdf0e10cSrcweir 			printf( "getNormalizedPathFromFileURL: Error \n" );
2184*cdf0e10cSrcweir 	}
2185*cdf0e10cSrcweir 	else
2186*cdf0e10cSrcweir 		printf( "getNormalizedPathFromFileURL: not tested \n" );
2187*cdf0e10cSrcweir 
2188*cdf0e10cSrcweir 
2189*cdf0e10cSrcweir 	//--------------------------------------------------
2190*cdf0e10cSrcweir 	// getSystemPathFromFileURL
2191*cdf0e10cSrcweir 	//--------------------------------------------------
2192*cdf0e10cSrcweir 
2193*cdf0e10cSrcweir 	if ( strNormPath.getLength() != 0 )
2194*cdf0e10cSrcweir 	{
2195*cdf0e10cSrcweir 		rc=FileBase::getSystemPathFromFileURL( strNormPath, strSystemPath );
2196*cdf0e10cSrcweir 
2197*cdf0e10cSrcweir 		if ( rc == FileBase::E_None )
2198*cdf0e10cSrcweir 		{
2199*cdf0e10cSrcweir 			printf( "System-Path: \t\t\t");
2200*cdf0e10cSrcweir 			printFileName( strSystemPath );
2201*cdf0e10cSrcweir 			printf( "\n");
2202*cdf0e10cSrcweir 		}
2203*cdf0e10cSrcweir 		else
2204*cdf0e10cSrcweir 			printf( "getSystemPathFromFileURL: Error \n" );
2205*cdf0e10cSrcweir 	}
2206*cdf0e10cSrcweir 	else
2207*cdf0e10cSrcweir 		printf( "getSystemPathFromFileURL: not tested \n" );
2208*cdf0e10cSrcweir 
2209*cdf0e10cSrcweir 	//--------------------------------------------------
2210*cdf0e10cSrcweir 	// Verify
2211*cdf0e10cSrcweir 	//--------------------------------------------------
2212*cdf0e10cSrcweir 
2213*cdf0e10cSrcweir 	if ( strNormPathFromFileURL == strNormPath )
2214*cdf0e10cSrcweir 		printf( "\nVerify: OK ! ( Normalized-Path == Normalized-Path-From-File-URL )\n" );
2215*cdf0e10cSrcweir 	else
2216*cdf0e10cSrcweir 		printf( "\nVerify: Error ! ( Normalized-Path != Normalized-Path-From-File-URL )\n" );
2217*cdf0e10cSrcweir 
2218*cdf0e10cSrcweir 	return;
2219*cdf0e10cSrcweir }
2220*cdf0e10cSrcweir 
2221*cdf0e10cSrcweir void FileBaseTest()
2222*cdf0e10cSrcweir {
2223*cdf0e10cSrcweir 	printf( "--------------------------------------------\n" );
2224*cdf0e10cSrcweir 	printf( "FileBase-Test\n" );
2225*cdf0e10cSrcweir 	printf( "--------------------------------------------\n\n" );
2226*cdf0e10cSrcweir 
2227*cdf0e10cSrcweir 	//--------------------------------------------------
2228*cdf0e10cSrcweir 	// ConvertPath-Test (Local File)
2229*cdf0e10cSrcweir 	//--------------------------------------------------
2230*cdf0e10cSrcweir 
2231*cdf0e10cSrcweir 	printf( "- Local File: ");
2232*cdf0e10cSrcweir 	printFileName( file1 );
2233*cdf0e10cSrcweir 	printf( "\n\n" );
2234*cdf0e10cSrcweir 
2235*cdf0e10cSrcweir 	ConvertPathTest(file1);
2236*cdf0e10cSrcweir 
2237*cdf0e10cSrcweir 	//--------------------------------------------------
2238*cdf0e10cSrcweir 	// ConvertPath-Test (File on a server)
2239*cdf0e10cSrcweir 	//--------------------------------------------------
2240*cdf0e10cSrcweir 
2241*cdf0e10cSrcweir 	printf( "\n- File on server: ");
2242*cdf0e10cSrcweir 	printFileName( file_on_server );
2243*cdf0e10cSrcweir 	printf( "\n\n" );
2244*cdf0e10cSrcweir 	ConvertPathTest(file_on_server);
2245*cdf0e10cSrcweir 
2246*cdf0e10cSrcweir 	PressKey();
2247*cdf0e10cSrcweir 
2248*cdf0e10cSrcweir 	return;
2249*cdf0e10cSrcweir }
2250*cdf0e10cSrcweir 
2251*cdf0e10cSrcweir 
2252*cdf0e10cSrcweir //--------------------------------------------------
2253*cdf0e10cSrcweir // AbsolutePathTest
2254*cdf0e10cSrcweir //--------------------------------------------------
2255*cdf0e10cSrcweir void DoAbsolutePathTest(rtl::OUString strDirBase, rtl::OUString	strRelative)
2256*cdf0e10cSrcweir {
2257*cdf0e10cSrcweir 	FileBase::RC	rc;
2258*cdf0e10cSrcweir 
2259*cdf0e10cSrcweir 	rtl::OUString		strAbsolute;
2260*cdf0e10cSrcweir 
2261*cdf0e10cSrcweir 	printf( "Base-Directory: \t");
2262*cdf0e10cSrcweir 	printFileName( strDirBase );
2263*cdf0e10cSrcweir 	printf( "\n" );
2264*cdf0e10cSrcweir 	printf( "Relative-Path: \t\t");
2265*cdf0e10cSrcweir 	printFileName ( strRelative );
2266*cdf0e10cSrcweir 	printf( "\n" );
2267*cdf0e10cSrcweir 
2268*cdf0e10cSrcweir 	rc=FileBase::getAbsoluteFileURL( strDirBase, strRelative, strAbsolute );
2269*cdf0e10cSrcweir 
2270*cdf0e10cSrcweir 	if ( rc == FileBase::E_None )
2271*cdf0e10cSrcweir 	{
2272*cdf0e10cSrcweir 		printf( "Absolute-Path: \t\t");
2273*cdf0e10cSrcweir 		printFileName ( strAbsolute );
2274*cdf0e10cSrcweir 		printf( "\n" );
2275*cdf0e10cSrcweir 	}
2276*cdf0e10cSrcweir 	else
2277*cdf0e10cSrcweir 		printf( "Absolute-Path: Error \n" );
2278*cdf0e10cSrcweir 
2279*cdf0e10cSrcweir 	printf( "\n" );
2280*cdf0e10cSrcweir 	return;
2281*cdf0e10cSrcweir }
2282*cdf0e10cSrcweir 
2283*cdf0e10cSrcweir void AbsolutePathTest(void)
2284*cdf0e10cSrcweir {
2285*cdf0e10cSrcweir 	printf( "--------------------------------------------\n" );
2286*cdf0e10cSrcweir 	printf( "AbsolutePath-Test\n" );
2287*cdf0e10cSrcweir 	printf( "--------------------------------------------\n\n" );
2288*cdf0e10cSrcweir 
2289*cdf0e10cSrcweir 	DoAbsolutePathTest(dir1, rtl::OUString::createFromAscii("."));
2290*cdf0e10cSrcweir 	DoAbsolutePathTest(dir1, rtl::OUString::createFromAscii(".."));
2291*cdf0e10cSrcweir 	DoAbsolutePathTest(dir1, rtl::OUString::createFromAscii("../.."));
2292*cdf0e10cSrcweir 	DoAbsolutePathTest(dir1, rtl::OUString::createFromAscii("../HUHU"));
2293*cdf0e10cSrcweir 
2294*cdf0e10cSrcweir 	DoAbsolutePathTest(dir_on_server, rtl::OUString::createFromAscii("."));
2295*cdf0e10cSrcweir 	DoAbsolutePathTest(dir_on_server, rtl::OUString::createFromAscii(".."));
2296*cdf0e10cSrcweir 	DoAbsolutePathTest(dir_on_server, rtl::OUString::createFromAscii("../.."));
2297*cdf0e10cSrcweir 	DoAbsolutePathTest(dir_on_server, rtl::OUString::createFromAscii("../HUHU"));
2298*cdf0e10cSrcweir 
2299*cdf0e10cSrcweir 	PressKey();
2300*cdf0e10cSrcweir 	return;
2301*cdf0e10cSrcweir }
2302*cdf0e10cSrcweir 
2303*cdf0e10cSrcweir 
2304*cdf0e10cSrcweir //--------------------------------------------------
2305*cdf0e10cSrcweir // searchPathTest
2306*cdf0e10cSrcweir //--------------------------------------------------
2307*cdf0e10cSrcweir 
2308*cdf0e10cSrcweir void SearchPathTest(void)
2309*cdf0e10cSrcweir {
2310*cdf0e10cSrcweir 	FileBase::RC	rc;
2311*cdf0e10cSrcweir 
2312*cdf0e10cSrcweir 	rtl::OUString		strNormPath(file1);
2313*cdf0e10cSrcweir 	rtl::OUString		strFileURL;
2314*cdf0e10cSrcweir 	rtl::OUString		strSystemPath;
2315*cdf0e10cSrcweir 	rtl::OUString		strResultPath;
2316*cdf0e10cSrcweir 
2317*cdf0e10cSrcweir 	printf( "--------------------------------------------\n" );
2318*cdf0e10cSrcweir 	printf( "SearchPath-Test\n" );
2319*cdf0e10cSrcweir 	printf( "--------------------------------------------\n\n" );
2320*cdf0e10cSrcweir 
2321*cdf0e10cSrcweir 
2322*cdf0e10cSrcweir 	rc=FileBase::getFileURLFromSystemPath( strNormPath, strFileURL );
2323*cdf0e10cSrcweir 	print_error( rtl::OString( "getFileURLFromSystemPath" ), rc );
2324*cdf0e10cSrcweir 	rc=FileBase::getSystemPathFromFileURL( strNormPath, strSystemPath );
2325*cdf0e10cSrcweir 	print_error( rtl::OString( "getSystemPathFromFileURL" ), rc );
2326*cdf0e10cSrcweir 
2327*cdf0e10cSrcweir 	//--------------------------------------------------
2328*cdf0e10cSrcweir 	// searchFileURL (with a normalized path)
2329*cdf0e10cSrcweir 	//--------------------------------------------------
2330*cdf0e10cSrcweir 
2331*cdf0e10cSrcweir 	if ( strNormPath.getLength() != 0 )
2332*cdf0e10cSrcweir 	{
2333*cdf0e10cSrcweir 		printf( "\nSearch-Normalized-Path (with a normalized path) : ");
2334*cdf0e10cSrcweir 		printFileName ( strNormPath );
2335*cdf0e10cSrcweir 		printf( "\n" );
2336*cdf0e10cSrcweir 
2337*cdf0e10cSrcweir 		rc=FileBase::searchFileURL( strNormPath , rtl::OUString() , strResultPath );
2338*cdf0e10cSrcweir 
2339*cdf0e10cSrcweir 		if ( rc == FileBase::E_None )
2340*cdf0e10cSrcweir 		{
2341*cdf0e10cSrcweir 			printf( "Result: \t\t\t");
2342*cdf0e10cSrcweir 			printFileName ( strResultPath );
2343*cdf0e10cSrcweir 			printf( "\n" );
2344*cdf0e10cSrcweir 		}
2345*cdf0e10cSrcweir 		else
2346*cdf0e10cSrcweir 			printf( "searchFileURL (with a normalized path): Error\n" );
2347*cdf0e10cSrcweir 	}
2348*cdf0e10cSrcweir 	else
2349*cdf0e10cSrcweir 		printf( "searchFileURL (with a normalized path): not tested\n" );
2350*cdf0e10cSrcweir 
2351*cdf0e10cSrcweir 	//--------------------------------------------------
2352*cdf0e10cSrcweir 	// searchFileURL (with a File-URL)
2353*cdf0e10cSrcweir 	//--------------------------------------------------
2354*cdf0e10cSrcweir 
2355*cdf0e10cSrcweir 	if ( strFileURL.getLength() != 0 )
2356*cdf0e10cSrcweir 	{
2357*cdf0e10cSrcweir 		printf( "\nSearch-Normalized-Path (with a FileURL) : ");
2358*cdf0e10cSrcweir 		printFileName( strFileURL );
2359*cdf0e10cSrcweir 		printf( "\n" );
2360*cdf0e10cSrcweir 
2361*cdf0e10cSrcweir 		rc=FileBase::searchFileURL( strFileURL , rtl::OUString() , strResultPath );
2362*cdf0e10cSrcweir 
2363*cdf0e10cSrcweir 		if ( rc == FileBase::E_None )
2364*cdf0e10cSrcweir 		{
2365*cdf0e10cSrcweir 			printf( "Result: \t\t\t");
2366*cdf0e10cSrcweir 			printFileName ( strResultPath );
2367*cdf0e10cSrcweir 			printf( "\n" );
2368*cdf0e10cSrcweir 		}
2369*cdf0e10cSrcweir 		else
2370*cdf0e10cSrcweir 			printf( "searchFileURL (with a FileURL path): Error\n" );
2371*cdf0e10cSrcweir 	}
2372*cdf0e10cSrcweir 	else
2373*cdf0e10cSrcweir 		printf( "searchFileURL (with a FileURL path): not tested\n" );
2374*cdf0e10cSrcweir 
2375*cdf0e10cSrcweir 	//--------------------------------------------------
2376*cdf0e10cSrcweir 	// searchFileURL (with a systempath)
2377*cdf0e10cSrcweir 	//--------------------------------------------------
2378*cdf0e10cSrcweir 
2379*cdf0e10cSrcweir 	if ( strSystemPath.getLength() != 0 )
2380*cdf0e10cSrcweir 	{
2381*cdf0e10cSrcweir 		printf( "\nSearch-Normalized-Path (with a SystemPath) : ");
2382*cdf0e10cSrcweir 		printFileName( strSystemPath );
2383*cdf0e10cSrcweir 		printf( "\n" );
2384*cdf0e10cSrcweir 
2385*cdf0e10cSrcweir 		rc=FileBase::searchFileURL( strSystemPath , rtl::OUString() , strResultPath );
2386*cdf0e10cSrcweir 
2387*cdf0e10cSrcweir 		if ( rc == FileBase::E_None )
2388*cdf0e10cSrcweir 		{
2389*cdf0e10cSrcweir 			printf( "Result: \t\t\t");
2390*cdf0e10cSrcweir 			printFileName( strResultPath );
2391*cdf0e10cSrcweir 			printf( "\n" );
2392*cdf0e10cSrcweir 		}
2393*cdf0e10cSrcweir 		else
2394*cdf0e10cSrcweir 			printf( "searchFileURL (with a systempath): Error\n" );
2395*cdf0e10cSrcweir 	}
2396*cdf0e10cSrcweir 	else
2397*cdf0e10cSrcweir 		printf( "searchFileURL (with a systempath): not tested\n" );
2398*cdf0e10cSrcweir 
2399*cdf0e10cSrcweir 	//--------------------------------------------------
2400*cdf0e10cSrcweir 	// searchFileURL (File and no searchpath)
2401*cdf0e10cSrcweir 	//--------------------------------------------------
2402*cdf0e10cSrcweir 
2403*cdf0e10cSrcweir 	printf( "\nsearchFileURL:  File (no searchpath) : ");
2404*cdf0e10cSrcweir 	printFileName( file3 );
2405*cdf0e10cSrcweir 	printf( "\n" );
2406*cdf0e10cSrcweir 
2407*cdf0e10cSrcweir 	rc=FileBase::searchFileURL( file3 , rtl::OUString::createFromAscii("") , strResultPath );
2408*cdf0e10cSrcweir 
2409*cdf0e10cSrcweir 	if ( rc == FileBase::E_None )
2410*cdf0e10cSrcweir 	{
2411*cdf0e10cSrcweir 		printf( "Result: \t\t\t");
2412*cdf0e10cSrcweir 		printFileName( strResultPath );
2413*cdf0e10cSrcweir 		printf( "\n" );
2414*cdf0e10cSrcweir 	}
2415*cdf0e10cSrcweir 	else
2416*cdf0e10cSrcweir 		printf( "searchFileURL:  File not found: OK ! \n" );
2417*cdf0e10cSrcweir 
2418*cdf0e10cSrcweir 	//--------------------------------------------------
2419*cdf0e10cSrcweir 	// searchFileURL (File and Path)
2420*cdf0e10cSrcweir 	//--------------------------------------------------
2421*cdf0e10cSrcweir 
2422*cdf0e10cSrcweir 	printf( "\nsearchFileURL:  File : ");
2423*cdf0e10cSrcweir 	printFileName( file3 );
2424*cdf0e10cSrcweir 	printf( "\tSearchPath ");
2425*cdf0e10cSrcweir 	printFileName( dir1 );
2426*cdf0e10cSrcweir 	printf( "\n");
2427*cdf0e10cSrcweir 
2428*cdf0e10cSrcweir 	rc=FileBase::searchFileURL( file3 , dir1 , strResultPath );
2429*cdf0e10cSrcweir 
2430*cdf0e10cSrcweir 	if ( rc == FileBase::E_None )
2431*cdf0e10cSrcweir 	{
2432*cdf0e10cSrcweir 		printf( "Result: \t\t\t");
2433*cdf0e10cSrcweir 		printFileName( strResultPath );
2434*cdf0e10cSrcweir 		printf( "\n");
2435*cdf0e10cSrcweir 	}
2436*cdf0e10cSrcweir 	else
2437*cdf0e10cSrcweir 		printf( "searchFileURL:  File not found: Error\n" );
2438*cdf0e10cSrcweir 
2439*cdf0e10cSrcweir 	//------------------------------------------------------------
2440*cdf0e10cSrcweir 	// searchFileURL (File and searchpath with two entries)
2441*cdf0e10cSrcweir 	//------------------------------------------------------------
2442*cdf0e10cSrcweir 
2443*cdf0e10cSrcweir 	rtl::OUString		strSearchPath( dir_not_exist );
2444*cdf0e10cSrcweir 	strSearchPath+=rtl::OUString::createFromAscii(";");
2445*cdf0e10cSrcweir 	strSearchPath+=dir_on_server;
2446*cdf0e10cSrcweir 
2447*cdf0e10cSrcweir 	printf( "\nsearchFileURL:  File : ");
2448*cdf0e10cSrcweir 	printFileName( file3 );
2449*cdf0e10cSrcweir 	printf( "SearchPath ");
2450*cdf0e10cSrcweir 	printFileName( strSearchPath );
2451*cdf0e10cSrcweir 	printf( "\n");
2452*cdf0e10cSrcweir 
2453*cdf0e10cSrcweir 	rc=FileBase::searchFileURL( file3 , strSearchPath , strResultPath );
2454*cdf0e10cSrcweir 
2455*cdf0e10cSrcweir 	if ( rc == FileBase::E_None )
2456*cdf0e10cSrcweir 	{
2457*cdf0e10cSrcweir 		printf( "Result: \t\t\t");
2458*cdf0e10cSrcweir 		printFileName( strResultPath );
2459*cdf0e10cSrcweir 		printf( "\n" );
2460*cdf0e10cSrcweir 	}
2461*cdf0e10cSrcweir 	else
2462*cdf0e10cSrcweir 		printf( "searchFileURL:  File not found: Error\n" );
2463*cdf0e10cSrcweir 
2464*cdf0e10cSrcweir 	//-------------------------------------------------------------------
2465*cdf0e10cSrcweir 	// searchFileURL (File and searchpath (with a wrong semantic))
2466*cdf0e10cSrcweir 	//-------------------------------------------------------------------
2467*cdf0e10cSrcweir 
2468*cdf0e10cSrcweir 	strSearchPath=rtl::OUString( dir_wrong_semantic );
2469*cdf0e10cSrcweir 
2470*cdf0e10cSrcweir 	printf( "\nsearchFileURL:  File : ");
2471*cdf0e10cSrcweir 	printFileName( file3 );
2472*cdf0e10cSrcweir 	printf( "SearchPath ");
2473*cdf0e10cSrcweir 	printFileName( strSearchPath );
2474*cdf0e10cSrcweir 	printf( "\n");
2475*cdf0e10cSrcweir 
2476*cdf0e10cSrcweir 	rc=FileBase::searchFileURL( file3 , strSearchPath , strResultPath );
2477*cdf0e10cSrcweir 
2478*cdf0e10cSrcweir 	if ( rc == FileBase::E_None )
2479*cdf0e10cSrcweir 		printf( "Error: Wrong Semantich but no error occurs !\n" );
2480*cdf0e10cSrcweir 	else
2481*cdf0e10cSrcweir 		printf( "searchFileURL:  File not found: OK !\n" );
2482*cdf0e10cSrcweir 
2483*cdf0e10cSrcweir 	return;
2484*cdf0e10cSrcweir }
2485*cdf0e10cSrcweir 
2486*cdf0e10cSrcweir //--------------------------------------------------
2487*cdf0e10cSrcweir // CanonicalNameTest
2488*cdf0e10cSrcweir //--------------------------------------------------
2489*cdf0e10cSrcweir 
2490*cdf0e10cSrcweir void getCanonicalNameTest(rtl::OUString strPath)
2491*cdf0e10cSrcweir {
2492*cdf0e10cSrcweir 	FileBase::RC	rc;
2493*cdf0e10cSrcweir 
2494*cdf0e10cSrcweir 	rtl::OUString	strValid;
2495*cdf0e10cSrcweir 
2496*cdf0e10cSrcweir 	printf( "Original-Name: \t\t");
2497*cdf0e10cSrcweir 	printFileName( strPath );
2498*cdf0e10cSrcweir 	printf( "\n" );
2499*cdf0e10cSrcweir 
2500*cdf0e10cSrcweir 	rc=FileBase::getCanonicalName( strPath, strValid );
2501*cdf0e10cSrcweir 
2502*cdf0e10cSrcweir 	if ( rc == FileBase::E_None)
2503*cdf0e10cSrcweir 	{
2504*cdf0e10cSrcweir 		printf( "Canonical-Name: \t");
2505*cdf0e10cSrcweir 		printFileName( strValid );
2506*cdf0e10cSrcweir 		printf( "\n");
2507*cdf0e10cSrcweir 
2508*cdf0e10cSrcweir 	}
2509*cdf0e10cSrcweir 	else
2510*cdf0e10cSrcweir 		printf( "Canonical-Name: Error \n" );
2511*cdf0e10cSrcweir 
2512*cdf0e10cSrcweir 	printf( "\n" );
2513*cdf0e10cSrcweir 	return;
2514*cdf0e10cSrcweir }
2515*cdf0e10cSrcweir 
2516*cdf0e10cSrcweir void CanonicalNameTest(void)
2517*cdf0e10cSrcweir {
2518*cdf0e10cSrcweir 	printf( "--------------------------------------------\n" );
2519*cdf0e10cSrcweir 	printf( "CanonicalName-Test\n" );
2520*cdf0e10cSrcweir 	printf( "--------------------------------------------\n\n" );
2521*cdf0e10cSrcweir 
2522*cdf0e10cSrcweir 	getCanonicalNameTest( dir1 );
2523*cdf0e10cSrcweir 	getCanonicalNameTest( dir_on_server );
2524*cdf0e10cSrcweir 	getCanonicalNameTest( file1 );
2525*cdf0e10cSrcweir 	getCanonicalNameTest( file_on_server );
2526*cdf0e10cSrcweir 
2527*cdf0e10cSrcweir 	PressKey();
2528*cdf0e10cSrcweir 	return;
2529*cdf0e10cSrcweir }
2530*cdf0e10cSrcweir 
2531*cdf0e10cSrcweir //--------------------------------------------------
2532*cdf0e10cSrcweir // print_error
2533*cdf0e10cSrcweir //--------------------------------------------------
2534*cdf0e10cSrcweir 
2535*cdf0e10cSrcweir void print_error( ::rtl::OString& str, FileBase::RC rc )
2536*cdf0e10cSrcweir {
2537*cdf0e10cSrcweir 
2538*cdf0e10cSrcweir 	printf( "%s : ",str.getStr() );
2539*cdf0e10cSrcweir 	switch(rc)
2540*cdf0e10cSrcweir 	{
2541*cdf0e10cSrcweir 	case FileBase::E_None:
2542*cdf0e10cSrcweir 		printf("OK !\n");
2543*cdf0e10cSrcweir 		break;
2544*cdf0e10cSrcweir 	case FileBase::E_PERM:
2545*cdf0e10cSrcweir 		printf("E_PERM\n");
2546*cdf0e10cSrcweir 		break;
2547*cdf0e10cSrcweir 	case FileBase::E_NOENT:
2548*cdf0e10cSrcweir 		printf("E_NOENT\n");
2549*cdf0e10cSrcweir 		break;
2550*cdf0e10cSrcweir 	case FileBase::E_SRCH:
2551*cdf0e10cSrcweir 		printf("E_SRCH\n");
2552*cdf0e10cSrcweir 		break;
2553*cdf0e10cSrcweir 	case FileBase::E_INTR:
2554*cdf0e10cSrcweir 		printf("E_INTR\n");
2555*cdf0e10cSrcweir 		break;
2556*cdf0e10cSrcweir 	case FileBase::E_IO:
2557*cdf0e10cSrcweir 		printf("E_IO\n");
2558*cdf0e10cSrcweir 		break;
2559*cdf0e10cSrcweir 	case FileBase::E_NXIO:
2560*cdf0e10cSrcweir 		printf("E_NXIO\n");
2561*cdf0e10cSrcweir 		break;
2562*cdf0e10cSrcweir 	case FileBase::E_2BIG:
2563*cdf0e10cSrcweir 		printf("E_2BIG\n");
2564*cdf0e10cSrcweir 		break;
2565*cdf0e10cSrcweir 	case FileBase::E_NOEXEC:
2566*cdf0e10cSrcweir 		printf("E_NOEXEC\n");
2567*cdf0e10cSrcweir 		break;
2568*cdf0e10cSrcweir 	case FileBase::E_BADF:
2569*cdf0e10cSrcweir 		printf("E_BADF\n");
2570*cdf0e10cSrcweir 		break;
2571*cdf0e10cSrcweir 	case FileBase::E_CHILD:
2572*cdf0e10cSrcweir 		printf("E_CHILD\n");
2573*cdf0e10cSrcweir 		break;
2574*cdf0e10cSrcweir 	case FileBase::E_AGAIN:
2575*cdf0e10cSrcweir 		printf("E_AGAIN\n");
2576*cdf0e10cSrcweir 		break;
2577*cdf0e10cSrcweir 	case FileBase::E_NOMEM:
2578*cdf0e10cSrcweir 		printf("E_NOMEM\n");
2579*cdf0e10cSrcweir 		break;
2580*cdf0e10cSrcweir 	case FileBase::E_ACCES:
2581*cdf0e10cSrcweir 		printf("E_ACCES\n");
2582*cdf0e10cSrcweir 		break;
2583*cdf0e10cSrcweir 	case FileBase::E_FAULT:
2584*cdf0e10cSrcweir 		printf("E_FAULT\n");
2585*cdf0e10cSrcweir 		break;
2586*cdf0e10cSrcweir 	case FileBase::E_BUSY:
2587*cdf0e10cSrcweir 		printf("E_BUSY\n");
2588*cdf0e10cSrcweir 		break;
2589*cdf0e10cSrcweir 	case FileBase::E_EXIST:
2590*cdf0e10cSrcweir 		printf("E_EXIST\n");
2591*cdf0e10cSrcweir 		break;
2592*cdf0e10cSrcweir 	case FileBase::E_XDEV:
2593*cdf0e10cSrcweir 		printf("E_XDEV\n");
2594*cdf0e10cSrcweir 		break;
2595*cdf0e10cSrcweir 	case FileBase::E_NODEV:
2596*cdf0e10cSrcweir 		printf("E_NODEV\n");
2597*cdf0e10cSrcweir 		break;
2598*cdf0e10cSrcweir 	case FileBase::E_NOTDIR:
2599*cdf0e10cSrcweir 		printf("E_NOTDIR\n");
2600*cdf0e10cSrcweir 		break;
2601*cdf0e10cSrcweir 	case FileBase::E_ISDIR:
2602*cdf0e10cSrcweir 		printf("E_ISDIR\n");
2603*cdf0e10cSrcweir 		break;
2604*cdf0e10cSrcweir 	case FileBase::E_INVAL:
2605*cdf0e10cSrcweir 		printf("E_INVAL\n");
2606*cdf0e10cSrcweir 		break;
2607*cdf0e10cSrcweir 	case FileBase::E_NFILE:
2608*cdf0e10cSrcweir 		printf("E_NFILE\n");
2609*cdf0e10cSrcweir 		break;
2610*cdf0e10cSrcweir 	case FileBase::E_MFILE:
2611*cdf0e10cSrcweir 		printf("E_MFILE\n");
2612*cdf0e10cSrcweir 		break;
2613*cdf0e10cSrcweir 	case FileBase::E_NOTTY:
2614*cdf0e10cSrcweir 		printf("E_NOTTY\n");
2615*cdf0e10cSrcweir 		break;
2616*cdf0e10cSrcweir 	case FileBase::E_FBIG:
2617*cdf0e10cSrcweir 		printf("E_FBIG\n");
2618*cdf0e10cSrcweir 		break;
2619*cdf0e10cSrcweir 	case FileBase::E_NOSPC:
2620*cdf0e10cSrcweir 		printf("E_NOSPC\n");
2621*cdf0e10cSrcweir 		break;
2622*cdf0e10cSrcweir 	case FileBase::E_SPIPE:
2623*cdf0e10cSrcweir 		printf("E_SPIPE\n");
2624*cdf0e10cSrcweir 		break;
2625*cdf0e10cSrcweir 	case FileBase::E_ROFS:
2626*cdf0e10cSrcweir 		printf("E_ROFS\n");
2627*cdf0e10cSrcweir 		break;
2628*cdf0e10cSrcweir 	case FileBase::E_MLINK:
2629*cdf0e10cSrcweir 		printf("E_MLINK\n");
2630*cdf0e10cSrcweir 		break;
2631*cdf0e10cSrcweir 	case FileBase::E_PIPE:
2632*cdf0e10cSrcweir 		printf("E_PIPE\n");
2633*cdf0e10cSrcweir 		break;
2634*cdf0e10cSrcweir 	case FileBase::E_DOM:
2635*cdf0e10cSrcweir 		printf("E_DOM\n");
2636*cdf0e10cSrcweir 		break;
2637*cdf0e10cSrcweir 	case FileBase::E_RANGE:
2638*cdf0e10cSrcweir 		printf("E_RANGE\n");
2639*cdf0e10cSrcweir 		break;
2640*cdf0e10cSrcweir 	case FileBase::E_DEADLK:
2641*cdf0e10cSrcweir 		printf("E_DEADLK\n");
2642*cdf0e10cSrcweir 		break;
2643*cdf0e10cSrcweir 	case FileBase::E_NAMETOOLONG:
2644*cdf0e10cSrcweir 		printf("E_NAMETOOLONG\n");
2645*cdf0e10cSrcweir 		break;
2646*cdf0e10cSrcweir 	case FileBase::E_NOLCK:
2647*cdf0e10cSrcweir 		printf("E_NOLCK\n");
2648*cdf0e10cSrcweir 		break;
2649*cdf0e10cSrcweir 	case FileBase::E_NOSYS:
2650*cdf0e10cSrcweir 		printf("E_NOSYS\n");
2651*cdf0e10cSrcweir 		break;
2652*cdf0e10cSrcweir 	case FileBase::E_NOTEMPTY:
2653*cdf0e10cSrcweir 		printf("E_NOTEMPTY\n");
2654*cdf0e10cSrcweir 		break;
2655*cdf0e10cSrcweir 	case FileBase::E_LOOP:
2656*cdf0e10cSrcweir 		printf("E_LOOP\n");
2657*cdf0e10cSrcweir 		break;
2658*cdf0e10cSrcweir 	case FileBase::E_ILSEQ:
2659*cdf0e10cSrcweir 		printf("E_ILSEQ\n");
2660*cdf0e10cSrcweir 		break;
2661*cdf0e10cSrcweir 	case FileBase::E_NOLINK:
2662*cdf0e10cSrcweir 		printf("E_NOLINK\n");
2663*cdf0e10cSrcweir 		break;
2664*cdf0e10cSrcweir 	case FileBase::E_MULTIHOP:
2665*cdf0e10cSrcweir 		printf("E_MULTIHOP\n");
2666*cdf0e10cSrcweir 		break;
2667*cdf0e10cSrcweir 	case FileBase::E_USERS:
2668*cdf0e10cSrcweir 		printf("E_USERS\n");
2669*cdf0e10cSrcweir 		break;
2670*cdf0e10cSrcweir 	case FileBase::E_OVERFLOW:
2671*cdf0e10cSrcweir 		printf("E_OVERFLOW\n");
2672*cdf0e10cSrcweir 		break;
2673*cdf0e10cSrcweir 	default:
2674*cdf0e10cSrcweir 		printf("E_Unknown\n");
2675*cdf0e10cSrcweir 		break;
2676*cdf0e10cSrcweir 	}
2677*cdf0e10cSrcweir 	return;
2678*cdf0e10cSrcweir }
2679*cdf0e10cSrcweir 
2680*cdf0e10cSrcweir //--------------------------------------------------
2681*cdf0e10cSrcweir // main
2682*cdf0e10cSrcweir //--------------------------------------------------
2683*cdf0e10cSrcweir #if defined WNT
2684*cdf0e10cSrcweir         #define MAIN _cdecl main
2685*cdf0e10cSrcweir #else
2686*cdf0e10cSrcweir         #define MAIN main
2687*cdf0e10cSrcweir #endif
2688*cdf0e10cSrcweir 
2689*cdf0e10cSrcweir int MAIN( int argc, char* argv[] )
2690*cdf0e10cSrcweir {
2691*cdf0e10cSrcweir 	sal_Bool fSuccess=sal_False;
2692*cdf0e10cSrcweir 
2693*cdf0e10cSrcweir 	//Initialization
2694*cdf0e10cSrcweir 	fSuccess=Initialize();
2695*cdf0e10cSrcweir 	if ( !fSuccess )
2696*cdf0e10cSrcweir 	{
2697*cdf0e10cSrcweir 		printf("Error during Initialization");
2698*cdf0e10cSrcweir 		return -1;
2699*cdf0e10cSrcweir 	}
2700*cdf0e10cSrcweir 
2701*cdf0e10cSrcweir 
2702*cdf0e10cSrcweir 	if (argc==1)
2703*cdf0e10cSrcweir 	{
2704*cdf0e10cSrcweir 		DirectoryOpenAndCloseTest();
2705*cdf0e10cSrcweir 		DirectoryCreateAndRemoveTest();
2706*cdf0e10cSrcweir 
2707*cdf0e10cSrcweir 		FileOpenAndCloseTest();
2708*cdf0e10cSrcweir 		FileCreateAndRemoveTest();
2709*cdf0e10cSrcweir 		FileWriteAndReadTest();
2710*cdf0e10cSrcweir 		FileCopyAndMoveTest();
2711*cdf0e10cSrcweir 		FileSizeTest();
2712*cdf0e10cSrcweir 		FilePointerTest();
2713*cdf0e10cSrcweir 		FileAttributesTest();
2714*cdf0e10cSrcweir 		FileTimeTest();
2715*cdf0e10cSrcweir 		DirectoryItemTest();
2716*cdf0e10cSrcweir 		DirectoryFileStatusTest();
2717*cdf0e10cSrcweir 		VolumeFileStatusTest();
2718*cdf0e10cSrcweir 		FileFileStatusTest();
2719*cdf0e10cSrcweir 		VolumeInfoTest();
2720*cdf0e10cSrcweir 		FileBaseTest();
2721*cdf0e10cSrcweir 		SearchPathTest();
2722*cdf0e10cSrcweir 		AbsolutePathTest();
2723*cdf0e10cSrcweir 		CanonicalNameTest();
2724*cdf0e10cSrcweir 	}
2725*cdf0e10cSrcweir 	// command line arguments ?
2726*cdf0e10cSrcweir 	else
2727*cdf0e10cSrcweir 	{
2728*cdf0e10cSrcweir 		int i=1;
2729*cdf0e10cSrcweir 
2730*cdf0e10cSrcweir 		while (i<argc)
2731*cdf0e10cSrcweir 		{
2732*cdf0e10cSrcweir 			if (strcmp(argv[i], "doc")==0)
2733*cdf0e10cSrcweir 				DirectoryOpenAndCloseTest();
2734*cdf0e10cSrcweir 			else if (strcmp(argv[i], "dcr")==0)
2735*cdf0e10cSrcweir 				DirectoryCreateAndRemoveTest();
2736*cdf0e10cSrcweir 			else if (strcmp(argv[i], "foc")==0)
2737*cdf0e10cSrcweir 				FileOpenAndCloseTest();
2738*cdf0e10cSrcweir 			else if (strcmp(argv[i], "fcr")==0)
2739*cdf0e10cSrcweir 				FileCreateAndRemoveTest();
2740*cdf0e10cSrcweir 			else if (strcmp(argv[i], "fwr")==0)
2741*cdf0e10cSrcweir 				FileWriteAndReadTest();
2742*cdf0e10cSrcweir 			else if (strcmp(argv[i], "fcm")==0)
2743*cdf0e10cSrcweir 				FileCopyAndMoveTest();
2744*cdf0e10cSrcweir 			else if (strcmp(argv[i], "fs")==0)
2745*cdf0e10cSrcweir 				FileSizeTest();
2746*cdf0e10cSrcweir 			else if (strcmp(argv[i], "fp")==0)
2747*cdf0e10cSrcweir 				FilePointerTest();
2748*cdf0e10cSrcweir 			else if (strcmp(argv[i], "fa")==0)
2749*cdf0e10cSrcweir 				FileAttributesTest();
2750*cdf0e10cSrcweir 			else if (strcmp(argv[i], "ft")==0)
2751*cdf0e10cSrcweir 				FileTimeTest();
2752*cdf0e10cSrcweir 			else if (strcmp(argv[i], "di")==0)
2753*cdf0e10cSrcweir 				DirectoryItemTest();
2754*cdf0e10cSrcweir 			else if (strcmp(argv[i], "dfs")==0)
2755*cdf0e10cSrcweir 				DirectoryFileStatusTest();
2756*cdf0e10cSrcweir 			else if (strcmp(argv[i], "vfs")==0)
2757*cdf0e10cSrcweir 				VolumeFileStatusTest();
2758*cdf0e10cSrcweir 			else if (strcmp(argv[i], "ffs")==0)
2759*cdf0e10cSrcweir 				FileFileStatusTest();
2760*cdf0e10cSrcweir 			else if (strcmp(argv[i], "vi")==0)
2761*cdf0e10cSrcweir 				VolumeInfoTest();
2762*cdf0e10cSrcweir 			else if (strcmp(argv[i], "fb")==0)
2763*cdf0e10cSrcweir 				FileBaseTest();
2764*cdf0e10cSrcweir 			else if (strcmp(argv[i], "sp")==0)
2765*cdf0e10cSrcweir 				SearchPathTest();
2766*cdf0e10cSrcweir 			else if (strcmp(argv[i], "ap")==0)
2767*cdf0e10cSrcweir 				AbsolutePathTest();
2768*cdf0e10cSrcweir 			else if (strcmp(argv[i], "cn")==0)
2769*cdf0e10cSrcweir 				CanonicalNameTest();
2770*cdf0e10cSrcweir 
2771*cdf0e10cSrcweir 			i++;
2772*cdf0e10cSrcweir 		}
2773*cdf0e10cSrcweir 	}
2774*cdf0e10cSrcweir 
2775*cdf0e10cSrcweir 	// Shutdown
2776*cdf0e10cSrcweir 	fSuccess=Shutdown();
2777*cdf0e10cSrcweir 	if ( !fSuccess )
2778*cdf0e10cSrcweir 	{
2779*cdf0e10cSrcweir 		printf("Error during Shutdown");
2780*cdf0e10cSrcweir 		return -1;
2781*cdf0e10cSrcweir 	}
2782*cdf0e10cSrcweir 
2783*cdf0e10cSrcweir 	return 0;
2784*cdf0e10cSrcweir }
2785*cdf0e10cSrcweir 
2786*cdf0e10cSrcweir 
2787