xref: /aoo42x/main/sal/qa/osl/file/osl_File.cxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_sal.hxx"
30 
31 //------------------------------------------------------------------------
32 // include files
33 //------------------------------------------------------------------------
34 #include <sal/types.h>
35 #include <rtl/ustring.hxx>
36 #include <rtl/ustrbuf.hxx>
37 
38 #include "osl/thread.h"
39 
40 #include "rtl/ustrbuf.hxx"
41 #include <osl/file.hxx>
42 #include <osl_File_Const.h>
43 
44 #include <testshl/simpleheader.hxx>
45 
46 // #ifdef WNT
47 // #   define UNICODE
48 // #	define WIN32_LEAN_AND_MEAN
49 // #	include <windows.h>
50 // #   include <tchar.h>
51 // #endif
52 
53 
54 using namespace osl;
55 using namespace rtl;
56 
57 //------------------------------------------------------------------------
58 // helper functions
59 //------------------------------------------------------------------------
60 
61 /** detailed wrong message.
62 */
63 inline ::rtl::OString errorToString( const ::osl::FileBase::RC _nError )
64 {
65 	::rtl::OString sResult;
66 	switch ( _nError ) {
67 		case ::osl::FileBase::E_None:
68 			sResult = "Success";
69 			break;
70 		case ::osl::FileBase::E_PERM:
71 			sResult = "Operation not permitted";
72 			break;
73 		case ::osl::FileBase::E_NOENT:
74 			sResult = "No such file or directory";
75 			break;
76 		case ::osl::FileBase::E_EXIST:
77 			sResult = "Already Exist";
78 			break;
79 		case ::osl::FileBase::E_ACCES:
80 			sResult = "Permission denied";
81 			break;
82 		case ::osl::FileBase::E_INVAL:
83 			sResult = "The format of the parameters was not valid";
84 			break;
85 		case ::osl::FileBase::E_NOTDIR:
86 			sResult = "Not a directory";
87 			break;
88 		case ::osl::FileBase::E_ISDIR:
89 			sResult = "Is a directory";
90 			break;
91 		case ::osl::FileBase::E_BADF:
92 			sResult = "Bad file";
93 			break;
94 		case ::osl::FileBase::E_NOTEMPTY:
95 			sResult = "The directory is not empty";
96 			break;
97 		default:
98 			sResult = "Unknown Error";
99 			break;
100 	}
101 	return sResult;
102 }
103 
104 rtl::OUString errorToStr( ::osl::FileBase::RC const& nError)
105 {
106     rtl::OUStringBuffer suBuf;
107     suBuf.append( rtl::OUString::createFromAscii("The returned error is: ") );
108     suBuf.append( rtl::OStringToOUString(errorToString(nError), RTL_TEXTENCODING_ASCII_US) );
109     suBuf.append( rtl::OUString::createFromAscii("!\n") );
110     return suBuf.makeStringAndClear();
111 }
112 
113 /** print a file type name.
114 */
115 inline void printFileType( const ::osl::FileStatus::Type nType )
116 {
117 	t_print( "#printFileType# " );
118 	switch ( nType ) {
119 		case ::osl::FileStatus::Directory:
120 			t_print( "This file is a: Directory.\n" );
121 			break;
122 		case ::osl::FileStatus::Volume:
123 			t_print( "This file is a: volume device.\n" );
124 			break;
125 		case ::osl::FileStatus::Regular:
126 			t_print( "This file is a: regular file.\n" );
127 			break;
128 		case ::osl::FileStatus::Fifo:
129 			t_print( "This file is a: fifo.\n" );
130 			break;
131 		case ::osl::FileStatus::Socket:
132 			t_print( "This file is a: socket.\n" );
133 			break;
134 		case ::osl::FileStatus::Link:
135 			t_print( "This file is a: link file.\n" );
136 			break;
137 		case ::osl::FileStatus::Special:
138 			t_print( "This file is a: special.\n" );
139 			break;
140 		case ::osl::FileStatus::Unknown:
141 			t_print( "The file type is unknown %d \n", nType );
142 			break;
143 	}
144 }
145 
146 /** print a file attributes.
147 */
148 inline void printFileAttributes( const sal_Int64 nAttributes )
149 {
150 	t_print( "#printFileAttributes# This file is a: (" );
151 	if ( ( nAttributes | Attribute_ReadOnly ) == nAttributes )
152 			t_print( " ReadOnly " );
153 	if ( ( nAttributes | Attribute_Hidden ) == nAttributes )
154 			t_print( " Hidden " );
155 	if ( ( nAttributes | Attribute_Executable ) == nAttributes )
156 			t_print( " Executable " );
157 	if ( ( nAttributes | Attribute_GrpWrite ) == nAttributes )
158 			t_print( " GrpWrite " );
159 	if ( ( nAttributes | Attribute_GrpRead ) == nAttributes )
160 			t_print( " GrpRead " );
161 	if ( ( nAttributes | Attribute_GrpExe ) == nAttributes )
162 			t_print( " GrpExe " );
163 	if ( ( nAttributes | Attribute_OwnWrite ) == nAttributes )
164 			t_print( " OwnWrite " );
165 	if ( ( nAttributes | Attribute_OwnRead ) == nAttributes )
166 			t_print( " OwnRead " );
167 	if ( ( nAttributes | Attribute_OwnExe ) == nAttributes )
168 			t_print( " OwnExe " );
169 	if ( ( nAttributes | Attribute_OthWrite ) == nAttributes )
170 			t_print( " OthWrite " );
171 	if ( ( nAttributes | Attribute_OthRead ) == nAttributes )
172 			t_print( " OthRead " );
173 	if ( ( nAttributes | Attribute_OthExe ) == nAttributes )
174 			t_print( " OthExe " );
175 	t_print( ") file!\n" );
176 }
177 
178 /** print a UNI_CODE file name.
179 */
180 inline void printFileName( const ::rtl::OUString & str )
181 {
182 	rtl::OString aString;
183 
184 	t_print( "#printFileName_u# " );
185 	aString = ::rtl::OUStringToOString( str, RTL_TEXTENCODING_ASCII_US );
186 	t_print( "%s\n", aString.getStr( ) );
187 }
188 
189 /** print a ASCII_CODE file name.
190 */
191 inline void printFileName( const sal_Char * str )
192 {
193 	t_print( "#printFileName_a# " );
194 	t_print( "%s\n", str );
195 }
196 
197 /** print an output wrong message.
198 */
199 inline void printError( const ::osl::FileBase::RC nError )
200 {
201 	t_print( "#printError# " );
202 	printFileName( errorToStr(nError) );
203 }
204 
205 /** print an signed Integer Number.
206 */
207 inline void printInt( sal_Int64 i )
208 {
209 	t_print( "#printInt_i64# " );
210 	t_print( "The Integer64 is %lld\n", i);
211 }
212 
213 /** print an unsigned Integer Number.
214 */
215 inline void printInt( sal_uInt64 i )
216 {
217 	t_print( "#printInt_u64# " );
218 	t_print( "The unsigned Integer64 is %llu\n", i);
219 }
220 
221 /** print Boolean value.
222 */
223 inline void printBool( sal_Bool bOk )
224 {
225 	t_print( "#printBool# " );
226 	( sal_True == bOk ) ? t_print( "YES!\n" ): t_print( "NO!\n" );
227 }
228 
229 /** print struct TimeValue in local time format.
230 */
231 inline void printTime( TimeValue *tv )
232 {
233 	oslDateTime *pDateTime = ( oslDateTime* )malloc( sizeof( oslDateTime ) ) ;
234  	CPPUNIT_ASSERT_MESSAGE( "Error in printTime() function,malloc ", pDateTime != NULL );
235 	TimeValue *pLocalTV = ( TimeValue* )malloc( sizeof( TimeValue ) );
236  	CPPUNIT_ASSERT_MESSAGE( "Error in printTime() function,malloc ", pLocalTV != NULL );
237 
238 	CPPUNIT_ASSERT_MESSAGE( "Error in printTime() function,osl_getLocalTimeFromSystemTime ",sal_True == osl_getLocalTimeFromSystemTime( tv, pLocalTV ) );
239 	CPPUNIT_ASSERT_MESSAGE( "Error in printTime() function,osl_gepDateTimeFromTimeValue ",sal_True == osl_getDateTimeFromTimeValue( pLocalTV, pDateTime ) );
240 
241 	t_print( "#printTime# " );
242  	t_print( " Time is: %d/%d/%d ", pDateTime->Month, pDateTime->Day, pDateTime->Year);
243 	switch ( pDateTime->DayOfWeek )
244 	{
245 		case 0: t_print("Sun. "); break;
246 		case 1: t_print("Mon. "); break;
247 		case 2: t_print("Tue. "); break;
248 		case 3: t_print("Thr. "); break;
249 		case 4: t_print("Wen. "); break;
250 		case 5: t_print("Fri. "); break;
251 		case 6: t_print("Sat. "); break;
252 	}
253 	t_print( " %d:%d:%d %d nsecs\n", pDateTime->Hours, pDateTime->Minutes, pDateTime->Seconds, pDateTime->NanoSeconds);
254 
255 	free( pDateTime );
256 	free( pLocalTV );
257 }
258 
259 /** compare two TimeValue, unit is "ms", since Windows time precision is better than UNX.
260 */
261 
262 #if ( defined UNX ) || ( defined OS2 )                 //precision of time in Windows is better than UNX
263 #	define delta 2000                    //time precision, 2000ms
264 #else
265 #	define delta 1800                    //time precision, 1.8s
266 #endif
267 
268 inline sal_Int64 t_abs64(sal_Int64 _nValue)
269 {
270     // std::abs() seems to have some ambiguity problems (so-texas)
271     // return abs(_nValue);
272     t_print("t_abs64(%ld)\n", _nValue);
273     // CPPUNIT_ASSERT(_nValue < 2147483647);
274 
275     if (_nValue < 0)
276     {
277         _nValue = -_nValue;
278     }
279     return _nValue;
280 }
281 
282 inline sal_Bool t_compareTime( TimeValue *m_aEndTime,  TimeValue *m_aStartTime, sal_Int32 nDelta)
283 {
284     // sal_uInt64 uTimeValue;
285     // sal_Int64 iTimeValue;
286     //
287     // iTimeValue = t_abs64(( tv1->Seconds - tv2->Seconds) * 1000000000 + tv1->Nanosec - tv2->Nanosec);
288     // uTimeValue = ( iTimeValue / 1000000 );
289 
290     sal_Int32 nDeltaSeconds = m_aEndTime->Seconds - m_aStartTime->Seconds;
291     sal_Int32 nDeltaNanoSec = sal_Int32(m_aEndTime->Nanosec) - sal_Int32(m_aStartTime->Nanosec);
292     if (nDeltaNanoSec < 0)
293     {
294         nDeltaNanoSec = 1000000000 + nDeltaNanoSec;
295         nDeltaSeconds--;
296     }
297 
298     sal_Int32 nDeltaMilliSec = (nDeltaSeconds * 1000) + (nDeltaNanoSec / 1000000);
299     return ( nDeltaMilliSec < nDelta );
300 }
301 
302 /** compare two OUString file name.
303 */
304 inline sal_Bool compareFileName( const ::rtl::OUString & ustr1, const ::rtl::OUString & ustr2 )
305 {
306 	sal_Bool bOk;
307 //on Windows, the seperatar is '\', so here change to '/', then compare
308 #if defined (WNT )
309 	::rtl::OUString ustr1new,ustr2new;
310 	sal_Unicode reverseSlash = (sal_Unicode)'\\';
311 
312 	if (ustr1.lastIndexOf(reverseSlash) != -1)
313 		ustr1new = ustr1.replace(reverseSlash,(sal_Unicode)'/');
314 	else
315 		ustr1new = ustr1;
316 	if (ustr2.lastIndexOf(reverseSlash) != -1)
317 		ustr2new = ustr2.replace(reverseSlash,(sal_Unicode)'/');
318 	else
319 		ustr2new = ustr2;
320 	bOk = ustr1new.equalsIgnoreAsciiCase( ustr2new )  ;
321 #else
322 	bOk = ustr1.equalsIgnoreAsciiCase( ustr2 );
323 #endif
324 	return bOk;
325 }
326 
327 /** compare a OUString and an ASCII file name.
328 */
329 inline sal_Bool compareFileName( const ::rtl::OUString & ustr, const sal_Char *astr )
330 {
331     (void)ustr;
332 	::rtl::OUString ustr1 = rtl::OUString::createFromAscii( astr );
333 	sal_Bool bOk = ustr1.equalsIgnoreAsciiCase( ustr1 );
334 
335 	return bOk;
336 }
337 
338 /** simple version to judge if a file name or directory name is a URL or a system path, just to see if it
339     is start with "file:///";.
340 */
341 inline sal_Bool isURL( const sal_Char *pathname )
342 {
343 	return ( 0 == strncmp( pathname, FILE_PREFIX, sizeof( FILE_PREFIX ) - 1 ) );
344 }
345 
346 /** simple version to judge if a file name or directory name is a URL or a system path, just to see if it
347     is start with "file:///";.
348 */
349 inline sal_Bool isURL( const ::rtl::OUString pathname )
350 {
351 	return ( ( pathname.indexOf( aPreURL ) == 0 ) ? sal_True : sal_False );
352 }
353 
354 /** concat two part to form a URL or system path, add PATH_SEPERATOR between them if necessary, add "file:///" to begining if necessary.
355 */
356 inline void concatURL( ::rtl::OUString & pathname1, const ::rtl::OUString & pathname2 )
357 {
358 	//check if pathname1 is full qualified URL;
359 	if ( !isURL( pathname1 ) )
360 	{
361 		::rtl::OUString     aPathName   = pathname1.copy( 0 );
362 		::osl::FileBase::getFileURLFromSystemPath( pathname1, aPathName ); //convert if not full qualified URL
363 		pathname1   = aPathName.copy( 0 );
364 	}
365 
366 	sal_Int32 index = 0;
367 	//check if '/' is in the end of pathname1 or at the begin of pathname2;
368 	if ( ( ( index = pathname1.lastIndexOf( aSlashURL ) ) != ( pathname1.getLength( ) - 1 ) ) &&
369 		 ( ( index = pathname2.indexOf( aSlashURL ) ) != 0 ) )
370 		pathname1 += aSlashURL;
371 	pathname1 += pathname2;
372 }
373 
374 /** create a temp test file using OUString name of full qualified URL or system path.
375 */
376 inline void createTestFile( const ::rtl::OUString filename )
377 {
378 	::rtl::OUString     aPathURL   = filename.copy( 0 );
379 	::osl::FileBase::RC	nError;
380 
381 	if ( !isURL( filename ) )
382 		::osl::FileBase::getFileURLFromSystemPath( filename, aPathURL ); //convert if not full qualified URL
383 
384 	//::std::auto_ptr<File> pFile( new File( aPathURL ) );
385 	File aFile(aPathURL);
386 	//nError = pFile->open( OpenFlag_Read | OpenFlag_Write | OpenFlag_Create );
387 	nError = aFile.open( OpenFlag_Read | OpenFlag_Write | OpenFlag_Create );
388 	//CPPUNIT_ASSERT_MESSAGE( "In createTestFile Function: creation ", ( ::osl::FileBase::E_None == nError ) || ( nError == ::osl::FileBase::E_EXIST ) );
389 	if ( ( ::osl::FileBase::E_None != nError ) && ( nError != ::osl::FileBase::E_EXIST ))
390 	{
391 		t_print("createTestFile failed!\n");
392 	}
393 	aFile.close();
394 
395 }
396 
397 /** create a temp test file using OUString name of full qualified URL or system path in a base directory.
398 */
399 inline void createTestFile( const ::rtl::OUString basename, const ::rtl::OUString filename )
400 {
401 	::rtl::OUString aBaseURL = basename.copy( 0 );
402 
403 	concatURL( aBaseURL, filename );
404 	createTestFile( aBaseURL );
405 }
406 
407 /** detete a temp test file using OUString name.
408 */
409 inline void deleteTestFile( const ::rtl::OUString filename )
410 {
411     // LLA: t_print("deleteTestFile\n");
412 	::rtl::OUString     aPathURL   = filename.copy( 0 );
413 	::osl::FileBase::RC	nError;
414 
415 	if ( !isURL( filename ) )
416 		::osl::FileBase::getFileURLFromSystemPath( filename, aPathURL ); //convert if not full qualified URL
417 
418 	nError = ::osl::File::setAttributes( aPathURL, Attribute_GrpWrite| Attribute_OwnWrite| Attribute_OthWrite ); // if readonly, make writtenable.
419 	CPPUNIT_ASSERT_MESSAGE( "In deleteTestFile Function: set writtenable ", ( ::osl::FileBase::E_None == nError ) || ( ::osl::FileBase::E_NOENT == nError ) );
420 
421 	nError = ::osl::File::remove( aPathURL );
422 	CPPUNIT_ASSERT_MESSAGE( "In deleteTestFile Function: remove ", ( ::osl::FileBase::E_None == nError ) || ( nError == ::osl::FileBase::E_NOENT ) );
423 }
424 
425 /** delete a temp test file using OUString name of full qualified URL or system path in a base directory.
426 */
427 inline void deleteTestFile( const ::rtl::OUString basename, const ::rtl::OUString filename )
428 {
429 	::rtl::OUString     aBaseURL   = basename.copy( 0 );
430 
431 	concatURL( aBaseURL, filename );
432 	deleteTestFile( aBaseURL );
433 }
434 
435 /** create a temp test directory using OUString name of full qualified URL or system path.
436 */
437 inline void createTestDirectory( const ::rtl::OUString dirname )
438 {
439 	::rtl::OUString     aPathURL   = dirname.copy( 0 );
440 	::osl::FileBase::RC	nError;
441 
442 	if ( !isURL( dirname ) )
443 		::osl::FileBase::getFileURLFromSystemPath( dirname, aPathURL ); //convert if not full qualified URL
444 	nError = ::osl::Directory::create( aPathURL );
445 	//CPPUNIT_ASSERT_MESSAGE( "In createTestDirectory Function: creation: ", ( ::osl::FileBase::E_None == nError ) || ( nError == ::osl::FileBase::E_EXIST ) );
446 	if ( ( ::osl::FileBase::E_None != nError ) && ( nError != ::osl::FileBase::E_EXIST ))
447 	  t_print("createTestDirectory failed!\n");
448 }
449 
450 /** create a temp test directory using OUString name of full qualified URL or system path in a base directory.
451 */
452 inline void createTestDirectory( const ::rtl::OUString basename, const ::rtl::OUString dirname )
453 {
454 	::rtl::OUString     aBaseURL   = basename.copy( 0 );
455 	::rtl::OString      aString;
456 
457 	concatURL( aBaseURL, dirname );
458 	createTestDirectory( aBaseURL );
459 }
460 
461 /** delete a temp test directory using OUString name of full qualified URL or system path.
462 */
463 inline void deleteTestDirectory( const ::rtl::OUString dirname )
464 {
465     // LLA: t_print("deleteTestDirectory\n");
466 	::rtl::OUString     aPathURL   = dirname.copy( 0 );
467 	::osl::FileBase::RC	nError;
468 	// LLA: printFileName(aPathURL);
469 	if ( !isURL( dirname ) )
470 		::osl::FileBase::getFileURLFromSystemPath( dirname, aPathURL ); //convert if not full qualified URL
471 
472 	::osl::Directory testDir( aPathURL );
473 	if ( testDir.isOpen( ) == sal_True )
474 	{
475         // LLA: t_print("#close Dir\n");
476         testDir.close( );  //close if still open.
477     	}
478 
479 	nError = ::osl::Directory::remove( aPathURL );
480     // LLA: printError(nError);
481     // LLA: if (( ::osl::FileBase::E_None == nError ))
482     // LLA: {
483     // LLA:     t_print("nError == E_None\n");
484     // LLA: }
485     // LLA: else if ( ( nError == ::osl::FileBase::E_NOENT ))
486     // LLA: {
487     // LLA:     t_print("nError == E_NOENT\n");
488     // LLA: }
489     // LLA: else
490     // LLA: {
491     // LLA:     // t_print("nError == %d\n", nError);
492     // LLA: }
493         rtl::OUString strError = rtl::OUString::createFromAscii( "In deleteTestDirectory function: remove Directory ");
494         strError += aPathURL;
495 	CPPUNIT_ASSERT_MESSAGE( strError, ( ::osl::FileBase::E_None == nError ) || ( nError == ::osl::FileBase::E_NOENT ) );
496     // LLA: if (! ( ::osl::FileBase::E_None == nError ) || ( nError == ::osl::FileBase::E_NOENT ))
497     // LLA: {
498     // LLA:     t_print("In deleteTestDirectory function: remove\n");
499     // LLA: }
500 }
501 
502 /** delete a temp test directory using OUString name of full qualified URL or system path in a base directory.
503 */
504 inline void deleteTestDirectory( const ::rtl::OUString basename, const ::rtl::OUString dirname )
505 {
506 	::rtl::OUString     aBaseURL   = basename.copy( 0 );
507 
508 	concatURL( aBaseURL, dirname );
509 	deleteTestDirectory( aBaseURL );
510 }
511 
512 
513 /** Check for the file and directory access right.
514 */
515 typedef enum {
516 	osl_Check_Mode_Exist,
517 	osl_Check_Mode_OpenAccess,
518 	osl_Check_Mode_ReadAccess,
519 	osl_Check_Mode_WriteAccess
520 } oslCheckMode;
521 
522 // not used here
523 inline sal_Bool checkFile( const ::rtl::OUString & str, oslCheckMode nCheckMode )
524 {
525 	::osl::FileBase::RC   nError1, nError2;
526 	::osl::File       testFile( str );
527 	sal_Bool		bCheckResult;
528 
529 	bCheckResult = sal_False;
530 	nError1 = testFile.open ( OpenFlag_Read );
531 	if ( ( ::osl::FileBase::E_NOENT != nError1 ) && ( ::osl::FileBase::E_ACCES != nError1 ) ){
532 
533 		switch ( nCheckMode ) {
534 			case osl_Check_Mode_Exist:
535 				/// check if the file is exist.
536 				if ( ::osl::FileBase::E_None == nError1 )
537 					bCheckResult = sal_True;
538 				break;
539 			case osl_Check_Mode_OpenAccess:
540 				/// check if the file is openable.
541 				if ( ::osl::FileBase::E_None == nError1 )
542 					bCheckResult = sal_True;
543 				break;
544 			case osl_Check_Mode_WriteAccess:
545 				/// check the file name and whether it can be write.
546 				/// write chars into the file.
547 				//testFile.close( );
548 				//testFile.open( OpenFlag_Write );
549 				sal_uInt64 nCount_write;
550 				nError2 = testFile.write( pBuffer_Char, 10, nCount_write );
551 				if ( ::osl::FileBase::E_None == nError2 )
552 					bCheckResult = sal_True;
553 				break;
554 
555 			default:
556 				bCheckResult = sal_False;
557 		}/// swith
558 
559 		nError2 = testFile.close( );
560 		CPPUNIT_ASSERT_MESSAGE( " in CheckFile() function, close file ", nError2 == FileBase::E_None );
561 
562 	}
563 
564 	return bCheckResult;
565 }
566 
567 //check if the file exist
568 inline sal_Bool ifFileExist( const ::rtl::OUString & str )
569 {
570 	sal_Bool		bCheckResult = sal_False;
571 
572 /*#ifdef WNT
573 	::rtl::OUString 	aUStr  = str.copy( 0 );
574 	if ( isURL( str ) )
575 		::osl::FileBase::getSystemPathFromFileURL( str, aUStr );
576 
577 	::rtl::OString aString = ::rtl::OUStringToOString( aUStr, RTL_TEXTENCODING_ASCII_US );
578 	const char *path = aString.getStr( );
579 	if (( _access( path, 0 ) ) != -1 )
580  		bCheckResult = sal_True;
581 #else*/
582 	::rtl::OString aString = ::rtl::OUStringToOString( str, RTL_TEXTENCODING_ASCII_US );
583 	// const char *path = aString.getStr( );
584 	::osl::File	testFile( str );
585 	bCheckResult = ( osl::FileBase::E_None == testFile.open( OpenFlag_Read ) );
586 	//if (bCheckResult)
587 	//t_print("%s exist!\n", path);
588 	//else
589 	//t_print("%s not exist!\n", path);
590 //#endif
591 	return bCheckResult;
592 
593 }
594 
595 //check if the file can be writen
596 inline sal_Bool ifFileCanWrite( const ::rtl::OUString & str )
597 {
598 	sal_Bool		bCheckResult = sal_False;
599 	//on Windows, the file has no write right, but can be written
600 #ifdef WNT
601 	::rtl::OUString 	aUStr  = str.copy( 0 );
602 	if ( isURL( str ) )
603 		::osl::FileBase::getSystemPathFromFileURL( str, aUStr );
604 
605 	::rtl::OString aString = ::rtl::OUStringToOString( aUStr, RTL_TEXTENCODING_ASCII_US );
606 	const char *path = aString.getStr( );
607 	if (( _access( path, 2 ) ) != -1 )
608  		bCheckResult = sal_True;
609  	//on UNX, just test if open success with OpenFlag_Write
610 #else
611 	::osl::File	testFile( str );
612 	bCheckResult = (osl::FileBase::E_None == testFile.open( OpenFlag_Write ));
613 #endif
614 	return bCheckResult;
615 }
616 
617 inline sal_Bool checkDirectory( const ::rtl::OUString & str, oslCheckMode nCheckMode )
618 {
619 	rtl::OUString 	aUString;
620 	DirectoryItem	rItem;
621 	FileBase::RC	rc;
622 	sal_Bool		bCheckResult= sal_False;
623 
624 	//::std::auto_ptr<Directory> pDir( new Directory( str ) );
625 	Directory aDir( str );
626 	rc = aDir.open( );
627 
628 	if ( ( ::osl::FileBase::E_NOENT != rc ) && ( ::osl::FileBase::E_ACCES != rc ) ){
629 
630 		switch ( nCheckMode ) {
631 			case osl_Check_Mode_Exist:
632 				if ( rc == ::osl::FileBase::E_None )
633 					bCheckResult = sal_True;
634 				break;
635 			case osl_Check_Mode_OpenAccess:
636 				if ( rc == ::osl::FileBase::E_None )
637 					bCheckResult = sal_True;
638 				break;
639 			case osl_Check_Mode_ReadAccess:
640 				//rc = pDir->getNextItem( rItem, 0 );
641 				rc = aDir.getNextItem( rItem, 0 );
642 				if ( ( rc == ::osl::FileBase::E_None ) || ( rc == ::osl::FileBase::E_NOENT ) )
643 					bCheckResult = sal_True;
644 				else
645 					bCheckResult = sal_False;
646 				break;
647 			case osl_Check_Mode_WriteAccess:
648 				( ( aUString += str ) += aSlashURL ) += aTmpName2;
649 				//if ( ( rc = pDir->create( aUString ) ) == ::osl::FileBase::E_None )
650 				if ( ( rc = Directory::create( aUString ) ) == ::osl::FileBase::E_None )
651 				{
652 					bCheckResult = sal_True;
653 					//rc = pDir->remove( aUString );
654 					rc = Directory::remove( aUString );
655 					CPPUNIT_ASSERT( rc == ::osl::FileBase::E_None );
656 				}
657 				else
658 					bCheckResult = sal_False;
659 				break;
660 
661 			default:
662 				bCheckResult = sal_False;
663 		}// switch
664 
665 		rc = aDir.close( );
666 		CPPUNIT_ASSERT( rc == FileBase::E_None );
667 
668 	}//if
669 
670 	return bCheckResult;
671 }
672 
673 /** construct error message
674 */
675 inline ::rtl::OUString outputError( const ::rtl::OUString & returnVal, const ::rtl::OUString & rightVal, const sal_Char * msg = "")
676 {
677 	::rtl::OUString aUString;
678 	if ( returnVal.equals( rightVal ) )
679 		return aUString;
680 	aUString += ::rtl::OUString::createFromAscii(msg);
681 	aUString += ::rtl::OUString::createFromAscii(": the returned value is '");
682 	aUString += returnVal;
683 	aUString += ::rtl::OUString::createFromAscii("', but the value should be '");
684 	aUString += rightVal;
685 	aUString += ::rtl::OUString::createFromAscii("'.");
686 	return aUString;
687 }
688 
689 /** Change file mode, two version in UNIX and Windows;.
690 */
691 #if ( defined UNX ) || ( defined OS2 )	       //chmod() method is differ in Windows
692 inline void changeFileMode( ::rtl::OUString & filepath, sal_Int32 mode )
693 {
694 	rtl::OString 	aString;
695 	rtl::OUString 	aUStr  = filepath.copy( 0 );
696 
697 	if ( isURL( filepath ) )
698 		::osl::FileBase::getSystemPathFromFileURL( filepath, aUStr );
699 	aString = ::rtl::OUStringToOString( aUStr, RTL_TEXTENCODING_ASCII_US );
700 	chmod( aString.getStr( ), mode );
701 }
702 #else                                          //Windows version
703 inline void changeFileMode( ::rtl::OUString & filepath, sal_Int32 mode )
704 {
705     (void)filepath;
706     (void)mode;
707 	t_print("this method is not implemented yet");
708 }
709 #endif
710 
711 inline ::rtl::OUString getCurrentPID( void );
712 
713 
714 
715 //------------------------------------------------------------------------
716 // Beginning of the test cases for FileBase class
717 //------------------------------------------------------------------------
718 namespace osl_FileBase
719 {
720 
721 #if 0  //~ this function has been deprecated
722 	//---------------------------------------------------------------------
723 	// testing the method
724 	// static inline RC getCanonicalName( const ::rtl::OUString& ustrRequestedURL, ::rtl::OUString& ustrValidURL )
725 	//
726 	// The illegal characters are ;+=[]',\"*\\<>/?:|.
727 	// because getCanonicalName method is not implemented yet and will be deprecated in the future, this test is not necessary.
728 	//---------------------------------------------------------------------
729 
730 	class getCanonicalName:public CppUnit::TestFixture
731 	{
732 
733 	    public:
734 		::osl::FileBase::RC	nError;
735 
736 		void getCanonicalName_001( )
737 		{
738 			::rtl::OUString aUStr_ValidURL;
739 			nError = ::osl::FileBase::getCanonicalName( aCanURL1, aUStr_ValidURL );
740 
741 			CPPUNIT_ASSERT_MESSAGE("test for getCanonicalName function: check valid and unused file name",
742 				 					( osl::FileBase::E_None == nError ) && aUStr_ValidURL.equalsIgnoreAsciiCase( aCanURL1 ) );
743 		}
744 
745 		void getCanonicalName_002( )
746 		{
747 			::rtl::OUString		aUStr_ValidURL;
748 
749 			createTestFile( aCanURL1 );
750 			nError = ::osl::FileBase::getCanonicalName( aCanURL1, aUStr_ValidURL );
751 			deleteTestFile( aCanURL1 );
752 
753 			CPPUNIT_ASSERT_MESSAGE( " test for getCanonicalName function: an existed file name, should different from the request, it did not passed(W32)(UNX)",
754 									( osl::FileBase::E_None == nError ) && aUStr_ValidURL.equalsIgnoreAsciiCase( aCanURL1 ) );
755 		}
756 
757 		void getCanonicalName_003( )
758 		{
759 			::rtl::OUString aUStr_ValidURL;
760 			nError = ::osl::FileBase::getCanonicalName ( aCanURL2,  aUStr_ValidURL );
761 
762 			CPPUNIT_ASSERT_MESSAGE( " test for getCanonicalName function: invalid file name, should different from the request,  it did not passed(W32)(UNX)",
763 				( osl::FileBase::E_None == nError ) && aUStr_ValidURL.equalsIgnoreAsciiCase( aCanURL2 ) );
764 		}
765 
766 		CPPUNIT_TEST_SUITE( getCanonicalName );
767 		CPPUNIT_TEST( getCanonicalName_001 );
768 		CPPUNIT_TEST( getCanonicalName_002 );
769 		CPPUNIT_TEST( getCanonicalName_003 );
770 		CPPUNIT_TEST_SUITE_END( );
771 	};// class getCanonicalName
772 #endif
773 
774 	//---------------------------------------------------------------------
775 	// testing the method
776 	// static inline RC getAbsoluteFileURL( const ::rtl::OUString& ustrBaseDirectoryURL,
777 	//										const ::rtl::OUString& ustrRelativeFileURL,
778 	//											  ::rtl::OUString& ustrAbsoluteFileURL )
779 	//---------------------------------------------------------------------
780 
781 	class getAbsoluteFileURL:public CppUnit::TestFixture
782 	{
783 		//::osl::FileBase		aFileBase;
784             ::rtl::OUString		aResultURL1, aResultURL2, aResultURL3, aResultURL4, aResultURL5, aResultURL6;
785             // ::osl::FileBase::RC	nError;
786 		sal_Bool		bOk;
787 
788 	    public:
789 
790 	    	void check_getAbsoluteFileURL( rtl::OUString const& _suBaseURL,  rtl::OString const& _sRelativeURL, ::osl::FileBase::RC _nAssumeError, rtl::OUString const& _suAssumeResultStr );
791 
792 	  void getAbsoluteFileURL_001_1();
793 	  void getAbsoluteFileURL_001_2();
794 	  void getAbsoluteFileURL_001_3();
795 	  void getAbsoluteFileURL_001_4();
796 	  void getAbsoluteFileURL_001_5();
797 	  void getAbsoluteFileURL_001_6();
798 	  void getAbsoluteFileURL_001_7();
799 	  void getAbsoluteFileURL_001_8();
800 	  void getAbsoluteFileURL_002();
801 	  void getAbsoluteFileURL_003();
802 	  void getAbsoluteFileURL_004();
803 
804 		CPPUNIT_TEST_SUITE( getAbsoluteFileURL );
805 		CPPUNIT_TEST( getAbsoluteFileURL_001_1 );
806 	  CPPUNIT_TEST( getAbsoluteFileURL_001_2 );
807 	  CPPUNIT_TEST( getAbsoluteFileURL_001_3 );
808 	  CPPUNIT_TEST( getAbsoluteFileURL_001_4 );
809 	  CPPUNIT_TEST( getAbsoluteFileURL_001_5 );
810 	  CPPUNIT_TEST( getAbsoluteFileURL_001_6 );
811 	  CPPUNIT_TEST( getAbsoluteFileURL_001_7 );
812 	  CPPUNIT_TEST( getAbsoluteFileURL_001_8 );
813 	  CPPUNIT_TEST( getAbsoluteFileURL_002 );
814 	  CPPUNIT_TEST( getAbsoluteFileURL_003 );
815 	  CPPUNIT_TEST( getAbsoluteFileURL_004 );
816 	  CPPUNIT_TEST_SUITE_END( );
817 
818 		}; //class getAbsoluteFileURL
819 
820 /* use coding format as same as getSystemPathFromFileURL
821 		// initialization
822 		void setUp( )
823 		{
824 			sal_Char pResultURL1[]  = "/relative/file1";
825 			sal_Char pResultURL2[]  = "/relative/file2";
826 			sal_Char pResultURL3[]  = "/file3";
827 			sal_Char pResultURL4[]  = "/file4";
828 			sal_Char pResultURL5[]  = "/canonical.name";
829 			sal_Char pResultURL6[]  = "/relative/";
830 			aResultURL1 = aUserDirectoryURL.concat( rtl::OUString::createFromAscii( pResultURL1 ) );
831 			aResultURL2 = aUserDirectoryURL.concat( rtl::OUString::createFromAscii( pResultURL2 ) );
832 			aResultURL3 = aUserDirectoryURL.concat( rtl::OUString::createFromAscii( pResultURL3 ) );
833 			aResultURL4 = aUserDirectoryURL.concat( rtl::OUString::createFromAscii( pResultURL4 ) );
834 			aResultURL5 = aUserDirectoryURL.concat( rtl::OUString::createFromAscii( pResultURL5 ) );
835 			aResultURL6 = aUserDirectoryURL.concat( rtl::OUString::createFromAscii( pResultURL6 ) );
836 		}
837 
838 		void tearDown( )
839 		{
840 		}
841 
842 		// test code
843 		void getAbsoluteFileURL_001( )
844 		{
845 			::rtl::OUString aUStr_AbsURL;
846 
847 			::osl::FileBase::RC nError11 = aFileBase.getAbsoluteFileURL( aUserDirectoryURL,  aRelURL1, aUStr_AbsURL );
848 			::rtl::OUString suError = ::rtl::OUString::createFromAscii("test for getAbsoluteFileURL(' ");
849 			suError += aUserDirectoryURL;
850 			suError += ::rtl::OUString::createFromAscii("', '");
851 			suError += aRelURL1;
852 			suError += ::rtl::OUString::createFromAscii("', '");
853 			suError += aUStr_AbsURL;
854 			suError += outputError( aUStr_AbsURL, aResultURL1, "' ),");
855 
856 			sal_Bool nError12 = aUStr_AbsURL.equals( aResultURL1 );
857 			::osl::FileBase::RC nError21 = aFileBase.getAbsoluteFileURL( aUserDirectoryURL,  aRelURL2, aUStr_AbsURL );
858 			sal_Bool nError22 = aUStr_AbsURL.equals( aResultURL2 );
859 			::osl::FileBase::RC nError31 = aFileBase.getAbsoluteFileURL( aUserDirectoryURL,  aRelURL3, aUStr_AbsURL );
860 			sal_Bool nError32 = aUStr_AbsURL.equals( aResultURL3 );
861 			::osl::FileBase::RC nError41 = aFileBase.getAbsoluteFileURL( aUserDirectoryURL,  aRelURL4, aUStr_AbsURL );
862 			sal_Bool nError42 = aUStr_AbsURL.equals( aResultURL4 );
863 			::osl::FileBase::RC nError61 = aFileBase.getAbsoluteFileURL( aUserDirectoryURL,  aRelURL6, aUStr_AbsURL );
864 			sal_Bool nError62 = aUStr_AbsURL.equals( aResultURL6 );
865 			printFileName( aUStr_AbsURL );
866 			printFileName( aResultURL6 );
867 
868 			CPPUNIT_ASSERT_MESSAGE("test for getAbsoluteFileURL function: valid file name with valid directory",
869 				 					( ::osl::FileBase::E_None == nError11 ) && ( sal_True == nError12 ) &&
870 				 					( ::osl::FileBase::E_None == nError21 ) && ( sal_True == nError22 ) &&
871 				 					( ::osl::FileBase::E_None == nError31 ) && ( sal_True == nError32 ) &&
872 				 					( ::osl::FileBase::E_None == nError41 ) && ( sal_True == nError42 ) &&
873 				 					( ::osl::FileBase::E_None == nError61 ) && ( sal_True == nError62 ) );
874 		}
875 
876 
877 #if ( defined UNX ) || ( defined OS2 )	//Link is not defined in Windows
878 		void getAbsoluteFileURL_002( )
879 		{
880 			::rtl::OUString aUStr_AbsURL, aUStr_LnkFileSys( aTempDirectorySys ), aUStr_SrcFileSys( aTempDirectorySys );
881 			( ( aUStr_LnkFileSys += aSlashURL ) += getCurrentPID( ) ) += ::rtl::OUString::createFromAscii("/link.file");
882 			( ( aUStr_SrcFileSys += aSlashURL ) += getCurrentPID( ) ) += ::rtl::OUString::createFromAscii("/canonical.name");
883 
884                 rtl::OString strLinkFileName, strSrcFileName;
885                 strLinkFileName = OUStringToOString( aUStr_LnkFileSys, RTL_TEXTENCODING_ASCII_US );
886                 strSrcFileName =  OUStringToOString( aUStr_SrcFileSys, RTL_TEXTENCODING_ASCII_US );
887 
888 			createTestFile( aCanURL1 );
889                 sal_Int32 fd = symlink( strSrcFileName.getStr(), strLinkFileName.getStr() );
890 			CPPUNIT_ASSERT( fd == 0 );
891 
892 			nError = aFileBase.getAbsoluteFileURL( aUserDirectoryURL, aLnkURL1, aUStr_AbsURL );
893 			bOk = aUStr_AbsURL.equals( aResultURL5 );
894 
895 			::rtl::OUString suError = ::rtl::OUString::createFromAscii("test for getAbsoluteFileURL(' ");
896 			suError += aUserDirectoryURL;
897 			suError += ::rtl::OUString::createFromAscii("', '");
898 			suError += aLnkURL1;
899 			suError += ::rtl::OUString::createFromAscii("', '");
900 			suError += aUStr_AbsURL;
901 			suError += outputError( aUStr_AbsURL, aResultURL5, "' ),");
902 			//printFileName(suError);
903 
904 			deleteTestFile( aCanURL1 );
905                 fd = remove( strLinkFileName.getStr() );
906 			CPPUNIT_ASSERT( fd == 0 );
907 
908 			CPPUNIT_ASSERT_MESSAGE("test for getAbsoluteFileURL function: URL contain link( Solaris version )",
909 				 					( ::osl::FileBase::E_None == nError ) && ( sal_True == bOk ) );
910 		}
911 #else		//Windows version
912 		void getAbsoluteFileURL_002( )
913 		{
914 			CPPUNIT_ASSERT_MESSAGE("test for getAbsoluteFileURL function: URL contain link( Windows version )",
915 					1 );
916 		}
917 #endif
918 
919 		void getAbsoluteFileURL_003( )
920 		{
921 // LLA: may be a wrong test, aTmpName1 not a real URL
922 #if 0
923             ::rtl::OUString aUStr_AbsURL;
924 
925 			nError = aFileBase.getAbsoluteFileURL( aTmpName1,  aRelURL1, aUStr_AbsURL );    //base dir invalid error
926 			::rtl::OUString suError = ::rtl::OUString::createFromAscii("test for getAbsoluteFileURL('");
927 			suError += aTmpName1;
928 			suError += ::rtl::OUString::createFromAscii("', '");
929 			suError += aRelURL1;
930 			suError += ::rtl::OUString::createFromAscii("', '");
931 			suError += aUStr_AbsURL;
932 			suError += ::rtl::OUString::createFromAscii("' ),Parameter is invalid. it ignore the invalid base in Windows, did not pass in (W32), the reason maybe caused by the similar bug with getSystemPathFromFileURL() ");
933 
934 			CPPUNIT_ASSERT_MESSAGE( suError, ( ::osl::FileBase::E_INVAL == nError ) );
935 #endif
936         }
937 
938 		//use ".." in relartive path, the BasePath must exist on the file system
939 		void getAbsoluteFileURL_004( )
940 		{
941 			//create two level directories under $Temp/PID/
942 			::rtl::OUString	aUStrUpBase = aUserDirectoryURL + ::rtl::OUString::createFromAscii("/test1");
943 			createTestDirectory( aUStrUpBase );
944 			::rtl::OUString	aUStrBase = aUserDirectoryURL + ::rtl::OUString::createFromAscii("/test1/dir1");
945 			createTestDirectory( aUStrBase );
946 
947 			::rtl::OUString	aUStrRelar = ::rtl::OUString::createFromAscii("../../mytestfile");
948 			::rtl::OUString	aUStr_AbsURL;
949 			::rtl::OUString aResultURL6 = aUserDirectoryURL + ::rtl::OUString::createFromAscii("/mytestfile");
950 
951 			nError = aFileBase.getAbsoluteFileURL( aUStrBase,  aUStrRelar, aUStr_AbsURL );
952 			bOk = aUStr_AbsURL.equals( aResultURL6 );
953 			::rtl::OUString suError = ::rtl::OUString::createFromAscii("test for getAbsoluteFileURL('");
954 			suError += aUStrBase;
955 			suError += ::rtl::OUString::createFromAscii("', '");
956 			suError += aUStrRelar;
957 			suError += ::rtl::OUString::createFromAscii("', '");
958 			suError += aUStr_AbsURL;
959 			suError += outputError( aUStr_AbsURL, aResultURL6, "' ), did not pass on Win32 ");
960 
961 			deleteTestDirectory( aUStrBase );
962 			deleteTestDirectory( aUStrUpBase );
963 
964 			CPPUNIT_ASSERT_MESSAGE( suError, ( ::osl::FileBase::E_None == nError ) && ( sal_True == bOk ) );
965 		}
966 
967 		CPPUNIT_TEST_SUITE( getAbsoluteFileURL );
968 		CPPUNIT_TEST( getAbsoluteFileURL_001 );
969 		CPPUNIT_TEST( getAbsoluteFileURL_002 );
970 		CPPUNIT_TEST( getAbsoluteFileURL_003 );
971 		CPPUNIT_TEST( getAbsoluteFileURL_004 );
972 		CPPUNIT_TEST_SUITE_END( );
973 	};// class getAbsoluteFileURL*/
974 
975 	void getAbsoluteFileURL::check_getAbsoluteFileURL( rtl::OUString const& _suBaseURL,  rtl::OString const& _sRelativeURL, ::osl::FileBase::RC _nAssumeError, rtl::OUString const& _suAssumeResultStr )
976 	{
977 		rtl::OUString suRelativeURL = rtl::OStringToOUString(_sRelativeURL, RTL_TEXTENCODING_UTF8);
978 		rtl::OString sBaseURL = rtl::OUStringToOString(_suBaseURL, RTL_TEXTENCODING_UTF8);
979 		rtl::OUString suResultURL;
980 		osl::FileBase::RC nError = FileBase::getAbsoluteFileURL( _suBaseURL,  suRelativeURL, suResultURL );
981 		rtl::OString sResultURL = rtl::OUStringToOString( suResultURL, RTL_TEXTENCODING_UTF8);
982 		rtl::OString sError = errorToString(nError);
983 		t_print("getAbsoluteFileURL('%s','%s') deliver absolute URL: '%s', error '%s'\n", sBaseURL.getStr(), _sRelativeURL.getStr(),sResultURL.getStr(), sError.getStr() );
984 		CPPUNIT_ASSERT_MESSAGE( "Assumption is wrong: error number is wrong", nError == _nAssumeError );
985 		if ( nError == ::osl::FileBase::E_None )
986 		{
987 			sal_Bool bStrAreEqual = _suAssumeResultStr.equals( suResultURL );
988             		CPPUNIT_ASSERT_MESSAGE( "Assumption is wrong: ResultURL is not equal to expected URL ", bStrAreEqual == sal_True );
989             	}
990 	}
991 
992   void getAbsoluteFileURL::getAbsoluteFileURL_001_1()
993   {
994     rtl::OUString suAssume = aUserDirectoryURL.concat( rtl::OUString::createFromAscii("/relative/file1") );
995     check_getAbsoluteFileURL( aUserDirectoryURL, "relative/file1",::osl::FileBase::E_None, suAssume );
996   }
997   void getAbsoluteFileURL::getAbsoluteFileURL_001_2()
998   {
999     rtl::OUString suAssume = aUserDirectoryURL.concat( rtl::OUString::createFromAscii("/relative/file2") );
1000     check_getAbsoluteFileURL( aUserDirectoryURL, "relative/./file2",::osl::FileBase::E_None, suAssume );
1001   }
1002   void getAbsoluteFileURL::getAbsoluteFileURL_001_3()
1003   {
1004     rtl::OUString suAssume = aUserDirectoryURL.concat( rtl::OUString::createFromAscii("/file3") );
1005     check_getAbsoluteFileURL( aUserDirectoryURL, "relative/../file3",::osl::FileBase::E_None, suAssume );
1006   }
1007   void getAbsoluteFileURL::getAbsoluteFileURL_001_4()
1008   {
1009     rtl::OUString suAssume = aUserDirectoryURL.concat( rtl::OUString::createFromAscii("/file4") );
1010     check_getAbsoluteFileURL( aUserDirectoryURL, "././relative/../file4",::osl::FileBase::E_None, suAssume );
1011   }
1012   void getAbsoluteFileURL::getAbsoluteFileURL_001_5()
1013   {
1014     rtl::OUString suAssume;
1015 #if ( defined UNX )
1016     suAssume = aUserDirectoryURL.concat( rtl::OUString::createFromAscii("/relative/") );
1017 #else
1018     suAssume = aUserDirectoryURL.concat( rtl::OUString::createFromAscii("/relative") );
1019 #endif
1020     check_getAbsoluteFileURL( aUserDirectoryURL, "././relative/.",::osl::FileBase::E_None, suAssume );
1021   }
1022   void getAbsoluteFileURL::getAbsoluteFileURL_001_6()
1023   {
1024     rtl::OUString suAssume = aUserDirectoryURL.concat( rtl::OUString::createFromAscii("/.relative") );
1025     check_getAbsoluteFileURL( aUserDirectoryURL, "./.relative",::osl::FileBase::E_None, suAssume );
1026   }
1027   void getAbsoluteFileURL::getAbsoluteFileURL_001_7()
1028   {
1029     rtl::OUString suAssume;
1030 #if (defined UNX )
1031     suAssume = aUserDirectoryURL.concat( rtl::OUString::createFromAscii("/.a/") );
1032 #else //windows
1033     suAssume = aUserDirectoryURL.concat( rtl::OUString::createFromAscii("/.a") );
1034 #endif
1035     check_getAbsoluteFileURL( aUserDirectoryURL, "./.a/mydir/..",::osl::FileBase::E_None, suAssume );
1036   }
1037   void getAbsoluteFileURL::getAbsoluteFileURL_001_8()
1038   {
1039     rtl::OUString suAssume = aUserDirectoryURL.concat( rtl::OUString::createFromAscii("/tmp/ok") );
1040 #if ( defined UNX ) || ( defined OS2 )
1041     check_getAbsoluteFileURL( aUserDirectoryURL, "tmp//ok",::osl::FileBase::E_None, suAssume );
1042 #else
1043     check_getAbsoluteFileURL( aUserDirectoryURL, "tmp//ok",::osl::FileBase::E_INVAL, suAssume );
1044 #endif
1045   }
1046   void getAbsoluteFileURL::getAbsoluteFileURL_002()
1047   {
1048 #if ( defined UNX ) || ( defined OS2 )		//Link is not defined in Windows
1049 		::rtl::OUString aUStr_AbsURL, aUStr_LnkFileSys( aTempDirectorySys ), aUStr_SrcFileSys( aTempDirectorySys );
1050 		( ( aUStr_LnkFileSys += aSlashURL ) += getCurrentPID( ) ) += ::rtl::OUString::createFromAscii("/link.file");
1051 		( ( aUStr_SrcFileSys += aSlashURL ) += getCurrentPID( ) ) += ::rtl::OUString::createFromAscii("/canonical.name");
1052 
1053                 rtl::OString strLinkFileName, strSrcFileName;
1054                 strLinkFileName = OUStringToOString( aUStr_LnkFileSys, RTL_TEXTENCODING_ASCII_US );
1055                 strSrcFileName =  OUStringToOString( aUStr_SrcFileSys, RTL_TEXTENCODING_ASCII_US );
1056 
1057 		createTestFile( aCanURL1 );
1058                 sal_Int32 fd = symlink( strSrcFileName.getStr(), strLinkFileName.getStr() );
1059 		CPPUNIT_ASSERT( fd == 0 );
1060 		rtl::OString sLnkURL = OUStringToOString( aLnkURL1, RTL_TEXTENCODING_ASCII_US );
1061     		rtl::OUString suAssume = aUserDirectoryURL.concat( rtl::OUString::createFromAscii("/canonical.name") );
1062 		check_getAbsoluteFileURL( aUserDirectoryURL, sLnkURL, ::osl::FileBase::E_None, suAssume );
1063 		deleteTestFile( aCanURL1 );
1064                 fd = remove( strLinkFileName.getStr() );
1065 		CPPUNIT_ASSERT( fd == 0 );
1066 #endif
1067   }
1068   //please see line# 930
1069   void getAbsoluteFileURL::getAbsoluteFileURL_003()
1070   {
1071   }
1072 	void getAbsoluteFileURL::getAbsoluteFileURL_004()
1073 	{
1074 		//create two level directories under $Temp/PID/
1075 		::rtl::OUString	aUStrUpBase = aUserDirectoryURL + ::rtl::OUString::createFromAscii("/test1");
1076 		createTestDirectory( aUStrUpBase );
1077 		::rtl::OUString	aUStrBase = aUserDirectoryURL + ::rtl::OUString::createFromAscii("/test1/dir1");
1078 		createTestDirectory( aUStrBase );
1079 
1080 		::rtl::OUString suAssume = aUserDirectoryURL.concat( ::rtl::OUString::createFromAscii("/mytestfile") );
1081 		check_getAbsoluteFileURL( aUStrBase, "../../mytestfile" , ::osl::FileBase::E_None, suAssume );
1082 		deleteTestDirectory( aUStrBase );
1083 		deleteTestDirectory( aUStrUpBase );
1084 	}
1085 	//---------------------------------------------------------------------
1086 	// testing two methods:
1087 	// static inline RC getSystemPathFromFileURL( const ::rtl::OUString& ustrFileURL,
1088 	//				  ::rtl::OUString& ustrSystemPath )
1089         // static RC getFileURLFromSystemPath( const ::rtl::OUString & ustrSystemPath,
1090         //                                ::rtl::OUString & ustrFileURL );
1091 	//---------------------------------------------------------------------
1092 	class SystemPath_FileURL:public CppUnit::TestFixture
1093 	{
1094 		//::osl::FileBase aFileBase;
1095 		// ::rtl::OUString aUStr;
1096 		// ::osl::FileBase::RC nError;
1097 
1098 	  //void check_getSystemPathFromFileURL(rtl::OString const& _sURL, ::osl::FileBase::RC _nAssumeError, rtl::OString const& _sAssumeResultStr);
1099 	  void check_SystemPath_FileURL(rtl::OString const& _sSource, ::osl::FileBase::RC _nAssumeError, rtl::OString const& _sAssumeResultStr, sal_Bool bDirection = sal_True );
1100 	  void checkWNTBehaviour_getSystemPathFromFileURL(rtl::OString const& _sURL, ::osl::FileBase::RC _nAssumeError, rtl::OString const& _sWNTAssumeResultString );
1101 	  void checkUNXBehaviour_getSystemPathFromFileURL(rtl::OString const& _sURL, ::osl::FileBase::RC _nAssumeError, rtl::OString const& _sUnixAssumeResultString );
1102 	  void checkWNTBehaviour_getFileURLFromSystemPath(rtl::OString const& _sSysPath, ::osl::FileBase::RC _nAssumeError, rtl::OString const& _sWNTAssumeResultString);
1103 	  void checkUNXBehaviour_getFileURLFromSystemPath(rtl::OString const& _sSysPath, ::osl::FileBase::RC _nAssumeError, rtl::OString const& _sUnixAssumeResultString);
1104 
1105     public:
1106 		// test code.
1107 		void getSystemPathFromFileURL_001_1( );
1108 		void getSystemPathFromFileURL_001_2( );
1109 		void getSystemPathFromFileURL_001_21( );
1110 		void getSystemPathFromFileURL_001_22( );
1111 		void getSystemPathFromFileURL_001_3( );
1112 		void getSystemPathFromFileURL_001_31( );
1113 		void getSystemPathFromFileURL_001_4( );
1114 		void getSystemPathFromFileURL_001_41( );
1115 		void getSystemPathFromFileURL_001_5( );
1116 		void getSystemPathFromFileURL_001_51( );
1117 		void getSystemPathFromFileURL_001_52( );
1118 		void getSystemPathFromFileURL_001_53( );
1119 		void getSystemPathFromFileURL_001_6( );
1120 		void getSystemPathFromFileURL_001_61( );
1121 		void getSystemPathFromFileURL_001_7( );
1122 		void getSystemPathFromFileURL_001_71( );
1123 		void getSystemPathFromFileURL_001_8( );
1124 	        void getSystemPathFromFileURL_001_81( );
1125 		void getSystemPathFromFileURL_001_9( );
1126 		void getSystemPathFromFileURL_001_91( );
1127 		void getSystemPathFromFileURL_001_92( );
1128 		void getSystemPathFromFileURL_004( );
1129 		void getSystemPathFromFileURL_005( );
1130 
1131 	  //test case fot getFileURLFromSystemPath
1132 	        void getFileURLFromSystemPath_001( );
1133 	        void getFileURLFromSystemPath_002( );
1134 	        void getFileURLFromSystemPath_003( );
1135 	        void getFileURLFromSystemPath_004( );
1136 		void getFileURLFromSystemPath_005( );
1137 
1138 		CPPUNIT_TEST_SUITE( SystemPath_FileURL );
1139 		CPPUNIT_TEST( getSystemPathFromFileURL_001_1 );
1140 		CPPUNIT_TEST( getSystemPathFromFileURL_001_2 );
1141 		CPPUNIT_TEST( getSystemPathFromFileURL_001_21 );
1142 		CPPUNIT_TEST( getSystemPathFromFileURL_001_22 );
1143 		CPPUNIT_TEST( getSystemPathFromFileURL_001_3 );
1144 		CPPUNIT_TEST( getSystemPathFromFileURL_001_31 );
1145 		CPPUNIT_TEST( getSystemPathFromFileURL_001_4 );
1146 		CPPUNIT_TEST( getSystemPathFromFileURL_001_41 );
1147 		CPPUNIT_TEST( getSystemPathFromFileURL_001_5 );
1148 		CPPUNIT_TEST( getSystemPathFromFileURL_001_51 );
1149 		CPPUNIT_TEST( getSystemPathFromFileURL_001_52 );
1150 		CPPUNIT_TEST( getSystemPathFromFileURL_001_53 );
1151 		CPPUNIT_TEST( getSystemPathFromFileURL_001_6 );
1152 		CPPUNIT_TEST( getSystemPathFromFileURL_001_61 );
1153 		CPPUNIT_TEST( getSystemPathFromFileURL_001_7 );
1154 		CPPUNIT_TEST( getSystemPathFromFileURL_001_71 );
1155 		CPPUNIT_TEST( getSystemPathFromFileURL_001_8 );
1156 	        CPPUNIT_TEST( getSystemPathFromFileURL_001_81 );
1157 		CPPUNIT_TEST( getSystemPathFromFileURL_001_9 );
1158 		CPPUNIT_TEST( getSystemPathFromFileURL_001_91 );
1159 		CPPUNIT_TEST( getSystemPathFromFileURL_001_92 );
1160 		CPPUNIT_TEST( getSystemPathFromFileURL_004 );
1161 		CPPUNIT_TEST( getSystemPathFromFileURL_005 );
1162 	        CPPUNIT_TEST( getFileURLFromSystemPath_001 );
1163 		CPPUNIT_TEST( getFileURLFromSystemPath_002 );
1164 		CPPUNIT_TEST( getFileURLFromSystemPath_003 );
1165 		CPPUNIT_TEST( getFileURLFromSystemPath_004 );
1166 		CPPUNIT_TEST( getFileURLFromSystemPath_005 );
1167 		CPPUNIT_TEST_SUITE_END( );
1168 	};// class SystemPath_FileURL
1169 
1170 
1171     // test code.
1172 
1173   /*    void getSystemPathFromFileURL::check_getSystemPathFromFileURL(rtl::OString const& _sURL, ::osl::FileBase::RC _nAssumeError, rtl::OString const& _sAssumeResultStr)
1174     {
1175         // PRE: URL as String
1176         rtl::OUString suURL;
1177         rtl::OUString suStr;
1178         suURL = rtl::OStringToOUString(_sURL, RTL_TEXTENCODING_UTF8);
1179         ::osl::FileBase::RC nError =  osl::FileBase::getSystemPathFromFileURL( suURL, suStr ); // start with /
1180 
1181         // if the given string is gt length 0,
1182         // we check also this string
1183         rtl::OString sStr = rtl::OUStringToOString(suStr, RTL_TEXTENCODING_UTF8);
1184         rtl::OString sError = errorToString(nError);
1185         t_print("getSystemPathFromFileURL('%s') deliver system path: '%s', error '%s'\n", _sURL.getStr(), sStr.getStr(), sError.getStr() );
1186 
1187         // rtl::OUString suStrEncode = rtl::Uri::encode(suStr, rtl_UriCharClassUnoParamValue, rtl_UriEncodeKeepEscapes, RTL_TEXTENCODING_UTF8);
1188         // sStr = rtl::OUStringToOString(suStr, RTL_TEXTENCODING_UTF8);
1189         // t_print("UTF8: %s\n", sStr.getStr() );
1190 
1191         if (_sAssumeResultStr.getLength() > 0)
1192         {
1193             sal_Bool bStrAreEqual = _sAssumeResultStr.equals(sStr);
1194             CPPUNIT_ASSERT_MESSAGE( "Assumption is wrong",
1195                                     nError == _nAssumeError && bStrAreEqual == sal_True );
1196         }
1197         else
1198         {
1199             CPPUNIT_ASSERT_MESSAGE( "Assumption is wrong", nError == _nAssumeError );
1200         }
1201 	}*/
1202 
1203     // if bDirection==sal_True, check getSystemPathFromFileURL
1204     // if bDirection==sal_False, check getFileURLFromSystemPath
1205     void SystemPath_FileURL::check_SystemPath_FileURL(rtl::OString const& _sSource, ::osl::FileBase::RC _nAssumeError, rtl::OString const& _sAssumeResultStr, sal_Bool bDirection)
1206     {
1207         // PRE: URL as String
1208         rtl::OUString suSource;
1209         rtl::OUString suStr;
1210         suSource = rtl::OStringToOUString(_sSource, RTL_TEXTENCODING_UTF8);
1211 	::osl::FileBase::RC nError;
1212 	if ( bDirection == sal_True )
1213 	  nError = osl::FileBase::getSystemPathFromFileURL( suSource, suStr );
1214 	else
1215 	  nError = osl::FileBase::getFileURLFromSystemPath( suSource, suStr );
1216 
1217         // if the given string is gt length 0,
1218         // we check also this string
1219         rtl::OString sStr = rtl::OUStringToOString(suStr, RTL_TEXTENCODING_UTF8);
1220         rtl::OString sError = errorToString(nError);
1221 	if ( bDirection == sal_True )
1222 	  t_print("getSystemPathFromFileURL('%s') deliver system path: '%s', error '%s'\n", _sSource.getStr(), sStr.getStr(), sError.getStr() );
1223 	else
1224 	  t_print("getFileURLFromSystemPath('%s') deliver File URL: '%s', error '%s'\n", _sSource.getStr(), sStr.getStr(), sError.getStr() );
1225 
1226         // rtl::OUString suStrEncode = rtl::Uri::encode(suStr, rtl_UriCharClassUnoParamValue, rtl_UriEncodeKeepEscapes, RTL_TEXTENCODING_UTF8);
1227         // sStr = rtl::OUStringToOString(suStr, RTL_TEXTENCODING_UTF8);
1228         // t_print("UTF8: %s\n", sStr.getStr() );
1229 
1230         if (_sAssumeResultStr.getLength() > 0)
1231         {
1232             sal_Bool bStrAreEqual = _sAssumeResultStr.equals(sStr);
1233             CPPUNIT_ASSERT_MESSAGE( "Assumption is wrong",
1234                                     nError == _nAssumeError && bStrAreEqual == sal_True );
1235         }
1236         else
1237         {
1238             CPPUNIT_ASSERT_MESSAGE( "Assumption is wrong", nError == _nAssumeError );
1239         }
1240     }
1241     void SystemPath_FileURL::checkWNTBehaviour_getSystemPathFromFileURL(rtl::OString const& _sURL, ::osl::FileBase::RC _nAssumeError, rtl::OString const& _sWNTAssumeResultString)
1242     {
1243 #if ( defined WNT )
1244         check_SystemPath_FileURL(_sURL, _nAssumeError, _sWNTAssumeResultString);
1245 #else
1246         (void)_sURL;
1247         (void)_nAssumeError;
1248         (void)_sWNTAssumeResultString;
1249 #endif
1250     }
1251 
1252     void SystemPath_FileURL::checkUNXBehaviour_getSystemPathFromFileURL(rtl::OString const& _sURL, ::osl::FileBase::RC _nAssumeError, rtl::OString const& _sUnixAssumeResultString)
1253     {
1254 #if ( defined UNX )
1255         check_SystemPath_FileURL(_sURL, _nAssumeError, _sUnixAssumeResultString);
1256 #else
1257         (void)_sURL;
1258         (void)_nAssumeError;
1259         (void)_sUnixAssumeResultString;
1260 #endif
1261     }
1262 
1263     void SystemPath_FileURL::checkWNTBehaviour_getFileURLFromSystemPath(rtl::OString const& _sSysPath, ::osl::FileBase::RC _nAssumeError, rtl::OString const& _sWNTAssumeResultString)
1264     {
1265 #if ( defined WNT )
1266         check_SystemPath_FileURL(_sSysPath, _nAssumeError, _sWNTAssumeResultString, sal_False );
1267 #else
1268         (void)_sSysPath;
1269         (void)_nAssumeError;
1270         (void)_sWNTAssumeResultString;
1271 #endif
1272     }
1273 
1274     void SystemPath_FileURL::checkUNXBehaviour_getFileURLFromSystemPath(rtl::OString const& _sSysPath, ::osl::FileBase::RC _nAssumeError, rtl::OString const& _sUnixAssumeResultString)
1275     {
1276 #if ( defined UNX )
1277         check_SystemPath_FileURL(_sSysPath, _nAssumeError, _sUnixAssumeResultString, sal_False );
1278 #else
1279         (void)_sSysPath;
1280         (void)_nAssumeError;
1281         (void)_sUnixAssumeResultString;
1282 #endif
1283     }
1284 
1285     /** LLA: Test for getSystemPathFromFileURL()
1286         this test is splitted into 2 different OS tests,
1287         the first function checkUNXBehaviour... runs only on Unix based Systems,
1288         the second only on windows based systems
1289         the first parameter are a file URL where we want to get the system path of,
1290         the second parameter is the assumed error of the osl_getSystemPathFromFileURL() function,
1291         the thrid parameter is the assumed result string, the string will only test, if it's length is greater 0
1292     */
1293 
1294     void SystemPath_FileURL::getSystemPathFromFileURL_001_1()
1295     {
1296         rtl::OString sURL("");
1297 		checkUNXBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_INVAL, "");
1298 		checkWNTBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_INVAL, "");
1299     }
1300 
1301     void SystemPath_FileURL::getSystemPathFromFileURL_001_2()
1302     {
1303         rtl::OString sURL("/");
1304 		checkUNXBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_INVAL, "");
1305 		checkWNTBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, "\\");
1306     }
1307     void SystemPath_FileURL::getSystemPathFromFileURL_001_21()
1308     {
1309       //        rtl::OString sURL("%2f");
1310       rtl::OString sURL("%2F");
1311 		checkUNXBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, "/"); // LLA: this is may be a BUG
1312 		checkWNTBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_INVAL, "");
1313     }
1314     void SystemPath_FileURL::getSystemPathFromFileURL_001_22()
1315     {
1316       rtl::OString sURL("file:///tmp%2Fmydir");
1317 		checkUNXBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_INVAL, "");
1318 		checkWNTBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_INVAL, "");
1319     }
1320     void SystemPath_FileURL::getSystemPathFromFileURL_001_3()
1321     {
1322         rtl::OString sURL("a");
1323 		checkUNXBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, "a");
1324 		checkWNTBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, "a");
1325     }
1326     void SystemPath_FileURL::getSystemPathFromFileURL_001_31()
1327     {
1328         rtl::OString sURL("tmpname");
1329 		checkUNXBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, "tmpname");
1330 		checkWNTBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, "tmpname");
1331     }
1332     void SystemPath_FileURL::getSystemPathFromFileURL_001_4()
1333     {
1334         rtl::OString sURL("file://");
1335 		checkUNXBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, "");
1336 		checkWNTBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_INVAL, "");
1337     }
1338     void SystemPath_FileURL::getSystemPathFromFileURL_001_41()
1339     {
1340         rtl::OString sURL("file://localhost/tmp");
1341 		checkUNXBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, "");
1342 		checkWNTBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_INVAL, "");
1343     }
1344     void SystemPath_FileURL::getSystemPathFromFileURL_001_5()
1345     {
1346         rtl::OString sURL("file:///tmp");
1347 		checkUNXBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, "/tmp");
1348 		checkWNTBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_INVAL, "");
1349     }
1350     void SystemPath_FileURL::getSystemPathFromFileURL_001_51()
1351     {
1352         rtl::OString sURL("file://c:/tmp");
1353 		checkUNXBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, "c:/tmp"); // LLA: this is may be a BUG
1354 		checkWNTBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_INVAL, "");
1355     }
1356     void SystemPath_FileURL::getSystemPathFromFileURL_001_52()
1357     {
1358         rtl::OString sURL("file:///c:/tmp");
1359 		checkUNXBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, "/c:/tmp");
1360 		checkWNTBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, "c:\\tmp");
1361     }
1362     void SystemPath_FileURL::getSystemPathFromFileURL_001_53()
1363     {
1364 // LLA: is this a legal file path?
1365         rtl::OString sURL("file:///c|/tmp");
1366 		checkUNXBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, "/c|/tmp");
1367 		checkWNTBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, "c:\\tmp");
1368     }
1369     void SystemPath_FileURL::getSystemPathFromFileURL_001_6()
1370     {
1371         rtl::OString sURL("file:///tmp/first");
1372 		checkUNXBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, "/tmp/first");
1373 		checkWNTBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_INVAL, "");
1374     }
1375     void SystemPath_FileURL::getSystemPathFromFileURL_001_61()
1376     {
1377         rtl::OString sURL("file:///c:/tmp/first");
1378 		checkUNXBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, "/c:/tmp/first");
1379 		checkWNTBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, "c:\\tmp\\first");
1380     }
1381     void SystemPath_FileURL::getSystemPathFromFileURL_001_7()
1382     {
1383         rtl::OString sURL("file:///tmp/../second");
1384 		checkUNXBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, "/tmp/../second"); // LLA: may be a BUG
1385 		checkWNTBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_INVAL, "");
1386     }
1387     void SystemPath_FileURL::getSystemPathFromFileURL_001_71()
1388     {
1389         rtl::OString sURL("file:///c:/tmp/../second");
1390 		checkUNXBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, "/c:/tmp/../second");
1391 		checkWNTBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, "c:\\tmp\\..\\second");
1392     }
1393     void SystemPath_FileURL::getSystemPathFromFileURL_001_8()
1394     {
1395         rtl::OString sURL("../tmp");
1396 		checkUNXBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, "../tmp");
1397 		checkWNTBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, "..\\tmp");
1398     }
1399     void SystemPath_FileURL::getSystemPathFromFileURL_001_81()
1400     {
1401         rtl::OString sURL("file://~/tmp");
1402 	char* home_path;
1403 	home_path = getenv("HOME");
1404 	rtl::OString expResult(home_path);
1405 	expResult += "/tmp";
1406 	checkUNXBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, expResult );
1407 	//	checkWNTBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, "\\tmp");
1408     }
1409     void SystemPath_FileURL::getSystemPathFromFileURL_001_9()
1410     {
1411         rtl::OString sURL("file:///tmp/first%20second");
1412 		checkUNXBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, "/tmp/first second");
1413 		checkWNTBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_INVAL, "");
1414     }
1415     void SystemPath_FileURL::getSystemPathFromFileURL_001_91()
1416     {
1417         rtl::OString sURL("file:///c:/tmp/first%20second");
1418 		checkUNXBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, "/c:/tmp/first second");
1419 		checkWNTBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, "c:\\tmp\\first second");
1420     }
1421 
1422     void SystemPath_FileURL::getSystemPathFromFileURL_001_92()
1423     {
1424         rtl::OString sURL("ca@#;+.,$///78no%01ni..name");
1425 		checkUNXBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, "");
1426 		checkWNTBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_INVAL, "");
1427     }
1428 
1429 #if 0
1430     void SystemPath_FileURL::getSystemPathFromFileURL_003( )
1431 		{
1432 // LLA: ???
1433 //!! seams to be, that the directories do not pass together
1434             ::rtl::OUString aUStr;
1435 			::rtl::OUString aRelativeURL = ::rtl::OUString::createFromAscii("../../relartive/file3");
1436 			::rtl::OUString aResultURL ( aSysPath4 );
1437             ::osl::FileBase::RC nError = osl::FileBase::getSystemPathFromFileURL( aRelativeURL, aUStr );
1438 
1439 			sal_Bool bOk = compareFileName( aUStr, aResultURL );
1440 
1441 			::rtl::OUString suError = ::rtl::OUString::createFromAscii("test for getSystemPathFromFileURL(");
1442 			suError += aRelativeURL;
1443 			suError += ::rtl::OUString::createFromAscii(") function:use a relative file URL, did not pass in(W32), it did not specified in method declaration of relative path issue, ");
1444 			suError += outputError(aUStr, aResultURL);
1445 			CPPUNIT_ASSERT_MESSAGE( suError, ( osl::FileBase::E_None == nError ) && ( sal_True == bOk ) );
1446 		}
1447 #endif
1448 
1449 		//normal legal case
1450     void SystemPath_FileURL::getSystemPathFromFileURL_004( )
1451 		{
1452         ::rtl::OUString aUStr;
1453         ::rtl::OUString aNormalURL( aTmpName6 );
1454         ::rtl::OUString aResultURL ( aSysPath4 );
1455         ::osl::FileBase::RC nError = osl::FileBase::getSystemPathFromFileURL( aNormalURL, aUStr );
1456 
1457 			sal_Bool bOk = compareFileName( aUStr, aResultURL );
1458 
1459 			::rtl::OUString suError = ::rtl::OUString::createFromAscii("test for getSystemPathFromFileURL(' ");
1460 			suError += aNormalURL;
1461 			suError += ::rtl::OUString::createFromAscii(" ') function:use an absolute file URL, ");
1462 			suError += outputError(aUStr, aResultURL);
1463 
1464 			CPPUNIT_ASSERT_MESSAGE( suError, ( osl::FileBase::E_None == nError ) && ( sal_True == bOk ) );
1465 
1466 		}
1467 
1468 		//CJK charactors case
1469     void SystemPath_FileURL::getSystemPathFromFileURL_005( )
1470 		{
1471             ::rtl::OUString aUStr;
1472             createTestDirectory( aTmpName10 );
1473             ::rtl::OUString aNormalURL( aTmpName10 );
1474             ::rtl::OUString aResultURL ( aSysPath5 );
1475 
1476             ::osl::FileBase::RC nError = osl::FileBase::getSystemPathFromFileURL( aNormalURL, aUStr );
1477 
1478 			sal_Bool bOk = compareFileName( aUStr, aResultURL );
1479 
1480 			::rtl::OUString suError = ::rtl::OUString::createFromAscii("test for getSystemPathFromFileURL(' ");
1481 			suError += aNormalURL;
1482 			suError += ::rtl::OUString::createFromAscii(" ') function:use a CJK coded absolute URL, ");
1483 			suError += outputError(aUStr, aResultURL);
1484 			deleteTestDirectory( aTmpName10 );
1485 
1486 			CPPUNIT_ASSERT_MESSAGE( suError, ( osl::FileBase::E_None == nError ) && ( sal_True == bOk ) );
1487 		}
1488      void SystemPath_FileURL::getFileURLFromSystemPath_001()
1489      {
1490         rtl::OString sSysPath("~/tmp");
1491 	char* home_path;
1492 	home_path = getenv("HOME");
1493 	rtl::OString expResult(home_path);
1494 	expResult = "file://"+ expResult + "/tmp";
1495 		checkUNXBehaviour_getFileURLFromSystemPath(sSysPath, osl::FileBase::E_None, expResult );
1496 		checkWNTBehaviour_getFileURLFromSystemPath(sSysPath, osl::FileBase::E_None, "~/tmp");
1497      }
1498      void SystemPath_FileURL::getFileURLFromSystemPath_002()
1499      {
1500         rtl::OString sSysPath("c:/tmp");
1501 		checkUNXBehaviour_getFileURLFromSystemPath(sSysPath, osl::FileBase::E_None, "c:/tmp");
1502 		checkWNTBehaviour_getFileURLFromSystemPath(sSysPath, osl::FileBase::E_None, "file:///c:/tmp");
1503      }
1504      void SystemPath_FileURL::getFileURLFromSystemPath_003()
1505      {
1506         rtl::OString sSysPath("file:///temp");
1507 		checkUNXBehaviour_getFileURLFromSystemPath(sSysPath, osl::FileBase::E_INVAL, "");
1508 		checkWNTBehaviour_getFileURLFromSystemPath(sSysPath, osl::FileBase::E_INVAL, "");
1509      }
1510     void SystemPath_FileURL::getFileURLFromSystemPath_004()
1511      {
1512         rtl::OString sSysPath("//tmp//first start");
1513 		checkUNXBehaviour_getFileURLFromSystemPath(sSysPath, osl::FileBase::E_None, "file:///tmp/first%20start");
1514 		checkWNTBehaviour_getFileURLFromSystemPath(sSysPath, osl::FileBase::E_INVAL, "");
1515      }
1516      void SystemPath_FileURL::getFileURLFromSystemPath_005()
1517      {
1518         rtl::OString sSysPath("");
1519 		checkUNXBehaviour_getFileURLFromSystemPath(sSysPath, osl::FileBase::E_INVAL, "");
1520 		checkWNTBehaviour_getFileURLFromSystemPath(sSysPath, osl::FileBase::E_INVAL, "");
1521      }
1522      	// start with "~user", not impletment
1523 	//      void SystemPath_FileURL::getFileURLFromSystemPath_006()
1524 
1525 
1526 
1527 
1528 	//---------------------------------------------------------------------
1529 	// testing the method
1530 	// static inline RC searchFileURL(  const ::rtl::OUString& ustrFileName,
1531 	// 									const ::rtl::OUString& ustrSearchPath,
1532 	//									::rtl::OUString& ustrFileURL )
1533 	//---------------------------------------------------------------------
1534 	class searchFileURL:public CppUnit::TestFixture
1535 	{
1536 		//::osl::FileBase aFileBase;
1537 		::rtl::OUString aUStr;
1538 		::osl::FileBase::RC nError1, nError2, nError3,nError4;
1539 
1540 	    public:
1541 
1542 		// test code.
1543 		void searchFileURL_001( )
1544 		{
1545 			/* search file is passed by system filename */
1546 			nError1 = ::osl::FileBase::searchFileURL( aTmpName1, aUserDirectorySys, aUStr );
1547 			/* search file is passed by full qualified file URL */
1548 			nError2 = ::osl::FileBase::searchFileURL( aCanURL1, aUserDirectorySys, aUStr );
1549 			/* search file is passed by relative file path */
1550 			nError3 = ::osl::FileBase::searchFileURL( aRelURL4, aUserDirectorySys, aUStr );
1551 
1552 			CPPUNIT_ASSERT_MESSAGE( "test for searchFileURL function: system filename/URL filename/relative path, system directory, searched files that is not exist, but it reply invalid error, did not pass in (W32) ",
1553 				 					( osl::FileBase::E_NOENT == nError1 ) &&
1554 				 					( osl::FileBase::E_NOENT == nError2 ) &&
1555 									( osl::FileBase::E_NOENT == nError3 ));
1556 		}
1557 
1558  		void searchFileURL_002( )
1559 		{
1560 			/* search file is passed by system filename */
1561 			nError1 = ::osl::FileBase::searchFileURL( aTempDirectorySys, aRootSys, aUStr );
1562 			sal_Bool bOk1 = compareFileName( aUStr, aTempDirectoryURL );
1563 			/* search file is passed by full qualified file URL */
1564 			nError2 = ::osl::FileBase::searchFileURL( aTempDirectoryURL, aRootSys, aUStr );
1565 			sal_Bool bOk2 = compareFileName( aUStr, aTempDirectoryURL );
1566 			/* search file is passed by relative file path */
1567 			nError3 = ::osl::FileBase::searchFileURL( aRelURL5, aRootSys, aUStr );
1568 			sal_Bool bOk3 = compareFileName( aUStr, aTempDirectoryURL );
1569 			/* search file is passed by an exist file */
1570 			createTestFile( aCanURL1 );
1571 			nError4 = ::osl::FileBase::searchFileURL( aCanURL4, aUserDirectorySys, aUStr );
1572 			sal_Bool bOk4 = compareFileName( aUStr, aCanURL1 );
1573 			deleteTestFile( aCanURL1 );
1574 
1575 			CPPUNIT_ASSERT_MESSAGE( "test for searchFileURL function: system filename/URL filename/relative path, system directory, searched file already exist.",
1576 									( osl::FileBase::E_None == nError1 ) &&
1577 									( osl::FileBase::E_None == nError2 ) &&
1578 									( osl::FileBase::E_None == nError3 ) &&
1579 									( osl::FileBase::E_None == nError4 ) &&
1580 									( sal_True == bOk1 ) &&
1581 									( sal_True == bOk2 ) &&
1582 									( sal_True == bOk3 ) &&
1583 									( sal_True == bOk4 ) );
1584 		}
1585 
1586 
1587 		void searchFileURL_003( )
1588 		{
1589 			OSLTEST_DECLARE( SystemPathList,  TEST_PLATFORM_ROOT":"TEST_PLATFORM_ROOT TEST_PLATFORM_TEMP":"TEST_PLATFORM_ROOT"system/path" );
1590 			nError1 = ::osl::FileBase::searchFileURL( aUserDirectoryURL, aSystemPathList, aUStr );
1591 			sal_Bool bOk = compareFileName( aUStr, aUserDirectoryURL );
1592 			CPPUNIT_ASSERT_MESSAGE( "test for searchFileURL function: search directory is a list of system paths",
1593 									( osl::FileBase::E_None == nError1 ) &&
1594 									( sal_True == bOk ) );
1595 		}
1596 
1597 		void searchFileURL_004( )
1598 		{
1599 			OSLTEST_DECLARE( SystemPathList,  TEST_PLATFORM_ROOT PATH_LIST_DELIMITER TEST_PLATFORM_ROOT TEST_PLATFORM_TEMP PATH_LIST_DELIMITER TEST_PLATFORM_ROOT "system/path/../name" );
1600 			nError1 = ::osl::FileBase::searchFileURL( aUserDirectoryURL, aSystemPathList, aUStr );
1601 			sal_Bool bOk = compareFileName( aUStr, aUserDirectoryURL );
1602 			CPPUNIT_ASSERT_MESSAGE( "test for searchFileURL function: search directory is a list of system paths",
1603 									( osl::FileBase::E_None == nError1 ) &&
1604 									( sal_True == bOk ) );
1605 		}
1606 
1607 		void searchFileURL_005( )
1608 		{
1609 			nError1 = ::osl::FileBase::searchFileURL( aUserDirectoryURL, aNullURL, aUStr );
1610 			sal_Bool bOk = compareFileName( aUStr, aUserDirectoryURL );
1611 			CPPUNIT_ASSERT_MESSAGE( "test for searchFileURL function: search directory is NULL",
1612 									( osl::FileBase::E_None == nError1 ) &&
1613 									( sal_True == bOk ) );
1614 		}
1615 
1616 		CPPUNIT_TEST_SUITE( searchFileURL );
1617 		CPPUNIT_TEST( searchFileURL_001 );
1618 		CPPUNIT_TEST( searchFileURL_002 );
1619 		CPPUNIT_TEST( searchFileURL_003 );
1620 		CPPUNIT_TEST( searchFileURL_004 );
1621 		CPPUNIT_TEST( searchFileURL_005 );
1622 		CPPUNIT_TEST_SUITE_END( );
1623 	};// class searchFileURL
1624 
1625 
1626 	//---------------------------------------------------------------------
1627 	// testing the method
1628 	// static inline RC getTempDirURL( ::rtl::OUString& ustrTempDirURL )
1629 	//---------------------------------------------------------------------
1630 	class getTempDirURL:public CppUnit::TestFixture
1631 	{
1632 		//::osl::FileBase aFileBase;
1633 		::rtl::OUString aUStr;
1634 		::osl::FileBase::RC nError;
1635 
1636 	    public:
1637 		// initialization
1638 		void setUp( )
1639 		{
1640 			 nError = FileBase::getTempDirURL( aUStr );
1641 		}
1642 
1643 		void tearDown( )
1644 		{
1645 		}
1646 
1647 		// test code.
1648 		void getTempDirURL_001( )
1649 		{
1650 
1651 			CPPUNIT_ASSERT_MESSAGE( "test for getTempDirURL function: excution",
1652 				 					( osl::FileBase::E_None == nError ) );
1653 		}
1654 
1655 		void getTempDirURL_002( )
1656 		{
1657 			CPPUNIT_ASSERT_MESSAGE( "test for getTempDirURL function: test for open and write access rights",
1658 									checkDirectory( aUStr, osl_Check_Mode_OpenAccess ) &&
1659 									checkDirectory( aUStr, osl_Check_Mode_ReadAccess ) &&
1660 									checkDirectory( aUStr,osl_Check_Mode_WriteAccess ) );
1661 		}
1662 
1663 		CPPUNIT_TEST_SUITE( getTempDirURL );
1664 		CPPUNIT_TEST( getTempDirURL_001 );
1665 		CPPUNIT_TEST( getTempDirURL_002 );
1666 		CPPUNIT_TEST_SUITE_END( );
1667 	};// class getTempDirURL
1668 
1669 
1670 	//---------------------------------------------------------------------
1671 	// 	testing the method
1672 	// 	static inline RC createTempFile( ::rtl::OUString* pustrDirectoryURL,
1673 	//									 oslFileHandle* pHandle,
1674 	//									 ::rtl::OUString* pustrTempFileURL)
1675 	//---------------------------------------------------------------------
1676 	class createTempFile:public CppUnit::TestFixture
1677 	{
1678 		//::osl::FileBase aFileBase;
1679 		::osl::FileBase::RC nError1, nError2;
1680 		sal_Bool bOK;
1681 
1682 		oslFileHandle	*pHandle;
1683 		::rtl::OUString	*pUStr_DirURL;
1684 		::rtl::OUString	*pUStr_FileURL;
1685 
1686 	    public:
1687 
1688 		// initialization
1689 		void setUp( )
1690 		{
1691 			pHandle = new oslFileHandle();
1692 			pUStr_DirURL = new ::rtl::OUString( aUserDirectoryURL );
1693 			pUStr_FileURL = new ::rtl::OUString();
1694 			//*pUStr_DirURL = aUserDirectoryURL;                /// create temp file in /tmp/PID or c:\temp\PID.*/
1695 		}
1696 
1697 		void tearDown( )
1698 		{
1699 			delete pUStr_DirURL;
1700 			delete pUStr_FileURL;
1701 			delete pHandle;
1702 		}
1703 
1704 		// test code.
1705 		void createTempFile_001( )
1706 		{
1707 			nError1 = FileBase::createTempFile( pUStr_DirURL, pHandle, pUStr_FileURL );
1708 			::osl::File testFile( *pUStr_FileURL );
1709 			//printFileName(*pUStr_FileURL);
1710 			nError2 = testFile.open( OpenFlag_Create );
1711 			if ( osl::FileBase::E_EXIST == nError2 )  {
1712 				osl_closeFile( *pHandle );
1713 				deleteTestFile( *pUStr_FileURL );
1714 			}
1715 
1716 			CPPUNIT_ASSERT_MESSAGE( "test for createTempFile function: create temp file and test the existence",
1717 				 					( osl::FileBase::E_None == nError1 ) && ( pHandle != NULL ) &&   ( osl::FileBase::E_EXIST== nError2 )   );
1718 		}
1719 
1720 		void createTempFile_002( )
1721 		{
1722 			bOK = sal_False;
1723 			nError1 = FileBase::createTempFile( pUStr_DirURL, pHandle, pUStr_FileURL );
1724 			::osl::File testFile( *pUStr_FileURL );
1725 			nError2 = testFile.open( OpenFlag_Create );
1726 
1727 			CPPUNIT_ASSERT_MESSAGE( "createTempFile function: create a temp file, but it does not exist",
1728 				( osl::FileBase::E_None == nError1 ) && ( pHandle != NULL ) &&
1729 				( osl::FileBase::E_EXIST == nError2 ) );
1730 
1731 			//check file if have the write permission
1732 			if ( osl::FileBase::E_EXIST == nError2 )  {
1733 				bOK = ifFileCanWrite( *pUStr_FileURL );
1734 				osl_closeFile( *pHandle );
1735 				deleteTestFile( *pUStr_FileURL );
1736 			}
1737 
1738 			CPPUNIT_ASSERT_MESSAGE( "test for open and write access rights, in (W32), it did not have write access right, but it should be writtenable.",
1739 									 ( sal_True == bOK ) );
1740 		}
1741 
1742 		void createTempFile_003( )
1743 		{
1744 			nError1 = FileBase::createTempFile( pUStr_DirURL, pHandle, 0 );
1745 			//the temp file will be removed when return from createTempFile
1746 			bOK = ( pHandle != NULL && pHandle != 0);
1747 			if ( sal_True == bOK )
1748 				osl_closeFile( *pHandle );
1749 
1750 			CPPUNIT_ASSERT_MESSAGE( "test for createTempFile function: set pUStrFileURL to 0 to let it remove the file after call.",
1751 								( ::osl::FileBase::E_None == nError1 ) &&( sal_True == bOK ) );
1752 		}
1753 		void createTempFile_004( )
1754 		{
1755 			nError1 = FileBase::createTempFile( pUStr_DirURL, 0, pUStr_FileURL );
1756 			bOK = ( pUStr_FileURL != 0);
1757 			::osl::File testFile( *pUStr_FileURL );
1758 			nError2 = testFile.open( OpenFlag_Create );
1759 			deleteTestFile( *pUStr_FileURL );
1760 			CPPUNIT_ASSERT_MESSAGE( "createTempFile function: create a temp file, but it does not exist",
1761 				( osl::FileBase::E_None == nError1 ) && ( osl::FileBase::E_EXIST == nError2 ) &&( sal_True == bOK ) );
1762 
1763 		}
1764 
1765 		CPPUNIT_TEST_SUITE( createTempFile );
1766 		CPPUNIT_TEST( createTempFile_001 );
1767 		CPPUNIT_TEST( createTempFile_002 );
1768 		CPPUNIT_TEST( createTempFile_003 );
1769 		CPPUNIT_TEST( createTempFile_004 );
1770 		CPPUNIT_TEST_SUITE_END( );
1771 	};// class createTempFile
1772 
1773 	// -----------------------------------------------------------------------------
1774 #if 0     //~ this function has been deprecated.
1775 	CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_FileBase::getCanonicalName, "osl_FileBase" );
1776 #endif
1777 	CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_FileBase::getAbsoluteFileURL, "osl_FileBase" );
1778 	CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_FileBase::SystemPath_FileURL, "osl_FileBase" );
1779   //        CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_FileBase::getFileURLFromSystemPath, "osl_FileBase" );
1780 	CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_FileBase::searchFileURL, "osl_FileBase" );
1781 	CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_FileBase::getTempDirURL, "osl_FileBase" );
1782 	CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_FileBase::createTempFile, "osl_FileBase" );
1783 }// namespace osl_FileBase
1784 
1785 
1786 //------------------------------------------------------------------------
1787 // Beginning of the test cases for VolumeDevice class
1788 //------------------------------------------------------------------------
1789 
1790 #if 0  //~ this Class has been deprecated
1791 namespace osl_VolumeDevice
1792 {
1793 
1794 	//---------------------------------------------------------------------
1795 	// 	testing the method
1796 	// 	VolumeDevice() : _aHandle( NULL )
1797 	//---------------------------------------------------------------------
1798     class  ctors : public CppUnit::TestFixture
1799 	{
1800 		::osl::VolumeDevice aVolumeDevice;
1801 		::rtl::OUString aUStr;
1802 		::osl::FileBase::RC nError1, nError2;
1803 
1804 	    public:
1805 		// initialization
1806 		void setUp( )
1807 		{
1808 		}
1809 
1810 		void tearDown( )
1811 		{
1812 		}
1813 
1814 		// test code.
1815 		void ctors_001( )
1816 		{
1817 			::osl::VolumeDevice aVolumeDevice1;
1818 
1819 			CPPUNIT_ASSERT_MESSAGE( "test for ctors function: Constructor for VolumeDevice with no args.",
1820 				 					( osl::FileBase::E_None !=  aVolumeDevice1.automount( ) ) &&
1821 									( osl::FileBase::E_None !=  aVolumeDevice1.unmount( ) )   &&
1822 									( aNullURL.equals( aVolumeDevice1.getMountPath( ) ) ) );
1823 		}
1824 
1825  		void ctors_002( )
1826 		{
1827 			::osl::VolumeInfo   aVolumeInfo( VolumeInfoMask_Attributes );
1828 			nError1 = ::osl::Directory::getVolumeInfo( aRootURL, aVolumeInfo );
1829 			CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 );
1830 
1831 			::osl::VolumeDevice aVolumeDevice1( aVolumeInfo.getDeviceHandle( ) );
1832 			sal_Bool bOk = compareFileName( aNullURL, aVolumeDevice1.getMountPath( ) );
1833 			CPPUNIT_ASSERT_MESSAGE( "test for ctors function: Copy constructor for VolumeDevice, the copied VolumeDevice should have a mount path file:///, but it returned an empty OUString, it also may be the error from getDeviceHandle(), it did not pass in (UNX), (W32).",
1834 									sal_False == bOk );
1835 		}
1836 
1837  		void ctors_003( )
1838 		{
1839 			::osl::VolumeInfo   aVolumeInfo( VolumeInfoMask_Attributes );
1840 			nError1 = ::osl::Directory::getVolumeInfo( aRootURL, aVolumeInfo );
1841 			CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 );
1842 
1843 			::osl::VolumeDevice aVolumeDevice1 = aVolumeInfo.getDeviceHandle( );
1844 			sal_Bool bOk = compareFileName( aNullURL, aVolumeDevice1.getMountPath( ) );
1845 			CPPUNIT_ASSERT_MESSAGE( "test for ctors function: Assigned operator for VolumeDevice, the assigned VolumeDevice should have a mount path file:///, but it returned an empty OUString, it also may be the error from getDeviceHandle(),it did not pass in (UNX), (W32).",
1846 									sal_False == bOk );
1847 		}
1848 
1849 		CPPUNIT_TEST_SUITE( ctors );
1850 		CPPUNIT_TEST( ctors_001 );
1851 		CPPUNIT_TEST( ctors_002 );
1852 		CPPUNIT_TEST( ctors_003 );
1853 		CPPUNIT_TEST_SUITE_END( );
1854 	};// class ctors
1855 
1856 
1857 	//---------------------------------------------------------------------
1858 	// 	testing the method
1859 	// 	inline RC automount()
1860 	//---------------------------------------------------------------------
1861     class  automount : public CppUnit::TestFixture
1862 	{
1863 		::osl::VolumeDevice aVolumeDevice;
1864 		::rtl::OUString aUStr;
1865 		::osl::FileBase::RC nError1, nError2;
1866 
1867 	    public:
1868 		// initialization
1869 		void setUp( )
1870 		{
1871 		}
1872 
1873 		void tearDown( )
1874 		{
1875 
1876 		}
1877 
1878 		// test code.
1879 		void automount_001( )
1880 		{
1881 			::osl::VolumeDevice aVolumeDevice1;
1882 			nError1 = aVolumeDevice1.automount( );
1883 
1884 			CPPUNIT_ASSERT_MESSAGE( "test for automount function: invalid parameter.",
1885 				 					( osl::FileBase::E_INVAL == nError1 ) );
1886 		}
1887 
1888   		void automount_002( )
1889 		{
1890 			::osl::VolumeInfo   aVolumeInfo( VolumeInfoMask_Attributes );
1891 			nError1 = ::osl::Directory::getVolumeInfo( aVolURL2, aVolumeInfo );
1892 			CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 );
1893 
1894 			::osl::VolumeDevice aVolumeDevice1( aVolumeInfo.getDeviceHandle( ) );
1895       		nError1 = aVolumeDevice1.unmount( );
1896       		nError1 = aVolumeDevice1.automount( );
1897 			CPPUNIT_ASSERT_MESSAGE( "test for automount function: this test is not implemented yet, it did not pass in (UNX), (W32).",
1898 									( osl::FileBase::E_None == nError1 ) );
1899 		}
1900 
1901 		CPPUNIT_TEST_SUITE( automount );
1902 		CPPUNIT_TEST( automount_001 );
1903 		CPPUNIT_TEST( automount_002 );
1904 		CPPUNIT_TEST_SUITE_END( );
1905 	};// class automount
1906 
1907 
1908 	// -----------------------------------------------------------------------------
1909 	CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_VolumeDevice::ctors, "osl_VolumeDevice" );
1910 	CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_VolumeDevice::automount, "osl_VolumeDevice" );
1911 }// namespace osl_VolumeDevice
1912 #endif
1913 
1914 
1915 //------------------------------------------------------------------------
1916 // Beginning of the test cases for VolumeInfo class
1917 //------------------------------------------------------------------------
1918 namespace osl_VolumeInfo
1919 {
1920 
1921 	//---------------------------------------------------------------------
1922 	// 	testing the method
1923 	// 	VolumeInfo( sal_uInt32 nMask ): _nMask( nMask )
1924 	//---------------------------------------------------------------------
1925     class  ctors : public CppUnit::TestFixture
1926 	{
1927 		::rtl::OUString aUStr;
1928 		::osl::FileBase::RC nError1, nError2;
1929 
1930  		::osl::VolumeDevice aVolumeDevice1;
1931 
1932 	    public:
1933 		// initialization
1934 		void setUp( )
1935 		{
1936 		}
1937 
1938 		void tearDown( )
1939 		{
1940 		}
1941 
1942 		// test code.
1943 		void ctors_001( )
1944 		{
1945 			::osl::VolumeInfo   aVolumeInfo( 0 );
1946 			nError1 = ::osl::Directory::getVolumeInfo( aRootURL, aVolumeInfo );
1947 			CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 );
1948 			sal_uInt64 uiTotalSpace = aVolumeInfo.getTotalSpace( );
1949 			sal_uInt32 uiMaxPathLength = aVolumeInfo.getMaxPathLength( );
1950 			aUStr = aVolumeInfo.getFileSystemName( );
1951 
1952 			CPPUNIT_ASSERT_MESSAGE( "test for ctors function: mask is empty",
1953 				 					( 0 == uiTotalSpace ) &&
1954 									( 0 == uiMaxPathLength ) &&
1955 									sal_True == compareFileName( aUStr, aNullURL ) );
1956 		}
1957 
1958 #if ( defined UNX ) || ( defined OS2 )
1959 		void ctors_002( )
1960 		{
1961 			::osl::VolumeInfo   aVolumeInfo( VolumeInfoMask_TotalSpace |
1962 											 VolumeInfoMask_UsedSpace |
1963 											 VolumeInfoMask_FileSystemName );
1964 			nError1 = ::osl::Directory::getVolumeInfo( aVolURL4, aVolumeInfo );
1965 			CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 );
1966 			//CPPUNIT_ASSERT( aVolumeInfo.isValid( mask ) );
1967 			sal_uInt64 uiTotalSpace = aVolumeInfo.getTotalSpace( );
1968 			sal_uInt64 uiUsedSpace = aVolumeInfo.getUsedSpace( );
1969 			aUStr = aVolumeInfo.getFileSystemName( );
1970 
1971 			CPPUNIT_ASSERT_MESSAGE( "test for ctors function: mask is specified as certain valid fields, and get the masked fields",
1972 				 					( 0 != uiTotalSpace ) &&
1973 									( 0 != uiUsedSpace ) &&
1974 									sal_True == compareFileName( aUStr, "nfs" ) );
1975 		}
1976 #else           /// Windows version,here we can not determine whichvolume in Windows is serve as an nfs volume.
1977 		void ctors_002( )
1978 		{
1979 			CPPUNIT_ASSERT_MESSAGE( "test for ctors function: mask is specified as certain valid fields, and get the masked fields( Windows version )",
1980 				 					1 == 1 );
1981 		}
1982 #endif
1983 
1984 		void ctors_003( )
1985 		{
1986 
1987  			sal_Int32 mask1 = VolumeInfoMask_FreeSpace;
1988 			::osl::VolumeInfo aVolumeInfo1( mask1 );
1989 			nError1 = ::osl::Directory::getVolumeInfo( aRootURL, aVolumeInfo1 );
1990 			CPPUNIT_ASSERT( sal_True == aVolumeInfo1.isValid( mask1 ) );
1991 			CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 );
1992 
1993 			sal_uInt64 uiTotalSpace1 = aVolumeInfo1.getTotalSpace( );
1994 			aUStr = aVolumeInfo1.getFileSystemName( );
1995 
1996  			sal_Int32 mask2 = VolumeInfoMask_TotalSpace;
1997 			::osl::VolumeInfo aVolumeInfo2( mask2 );
1998 			nError2 = ::osl::Directory::getVolumeInfo( aRootURL, aVolumeInfo2 );
1999 			CPPUNIT_ASSERT( sal_True == aVolumeInfo2.isValid( mask2 ) );
2000 			CPPUNIT_ASSERT( osl::FileBase::E_None == nError2 );
2001 
2002 			sal_uInt64 uiTotalSpace2 = aVolumeInfo2.getTotalSpace( );
2003 
2004 			CPPUNIT_ASSERT_MESSAGE( "test for ctors function: mask is specified as certain valid fields, but get unmasked fields, use mask to FreeSpace, but I can get TotalSpace, did not pass in (UNX)(W32)",
2005 				 					( 0 == uiTotalSpace1 ) && ( 0 != uiTotalSpace2 ) &&
2006 									sal_True == compareFileName( aUStr, aNullURL ) );
2007 		}
2008 
2009 		CPPUNIT_TEST_SUITE( ctors );
2010 		CPPUNIT_TEST( ctors_001 );
2011 		CPPUNIT_TEST( ctors_002 );
2012 		CPPUNIT_TEST( ctors_003 );
2013 		CPPUNIT_TEST_SUITE_END( );
2014 	};// class ctors
2015 
2016 
2017  	//---------------------------------------------------------------------
2018 	// 	testing the method
2019 	// 	inline sal_Bool isValid( sal_uInt32 nMask ) const
2020 	//---------------------------------------------------------------------
2021     class  isValid : public CppUnit::TestFixture
2022 	{
2023 		::osl::VolumeDevice aVolumeDevice;
2024 		::rtl::OUString aUStr;
2025 		::osl::FileBase::RC nError1, nError2;
2026 
2027 	    public:
2028 		// initialization
2029 		void setUp( )
2030 		{
2031 		}
2032 
2033 		void tearDown( )
2034 		{
2035 
2036 		}
2037 
2038 		// test code.
2039 		void isValid_001( )
2040 		{
2041 			sal_Int32 mask = 0;
2042 			::osl::VolumeInfo aVolumeInfo( mask );
2043 			nError1 = ::osl::Directory::getVolumeInfo( aVolURL4, aVolumeInfo );
2044 			CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 );
2045 
2046 			CPPUNIT_ASSERT_MESSAGE( "test for isValid function: no fields specified.",
2047 				 					 sal_True == aVolumeInfo.isValid( mask ) );
2048 		}
2049 
2050 #if ( defined UNX ) || ( defined OS2 )
2051   		void isValid_002( )
2052 		{
2053 			sal_Int32 mask = VolumeInfoMask_Attributes | VolumeInfoMask_TotalSpace | osl_VolumeInfo_Mask_UsedSpace |
2054 							 osl_VolumeInfo_Mask_FreeSpace | osl_VolumeInfo_Mask_MaxNameLength |
2055 							 osl_VolumeInfo_Mask_MaxPathLength | osl_VolumeInfo_Mask_FileSystemName;
2056 			::osl::VolumeInfo aVolumeInfo( mask );
2057 			nError1 = ::osl::Directory::getVolumeInfo( aVolURL4, aVolumeInfo );
2058 			CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 );
2059 
2060 			CPPUNIT_ASSERT_MESSAGE( "test for isValid function: all valid fields specified for a nfs volume.",
2061 				 					sal_True == aVolumeInfo.isValid( mask ) );
2062 		}
2063 #else           /// Windows version,here we can not determine whichvolume in Windows is serve as an nfs volume.
2064 		void isValid_002( )
2065 		{
2066 			CPPUNIT_ASSERT_MESSAGE( "test for isValid function: all valid fields specified for a nfs volume.( Windows version )",
2067 				 					1 == 1 );
2068 		}
2069 #endif
2070 
2071  		void isValid_003( )
2072 		{
2073  			::osl::VolumeDevice aVolumeDevice1;
2074 			sal_Int32 mask = VolumeInfoMask_Attributes;
2075 			::osl::VolumeInfo   aVolumeInfo( mask );
2076 			nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo );
2077 			CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 );
2078 			sal_Bool bOk1 = aVolumeInfo.isValid( mask );
2079 
2080 			nError1 = ::osl::Directory::getVolumeInfo( aVolURL2, aVolumeInfo );
2081 			CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 );
2082 			sal_Bool bOk2 = aVolumeInfo.isValid( mask );
2083 
2084 			CPPUNIT_ASSERT_MESSAGE( "test for isValid function: VolumeInfoMask_Attributes, it should be valid for some volume such as /, floppy, cdrom, etc. but it did not pass",
2085 				 					( sal_True == bOk1 ) && ( sal_True == bOk2 ) );
2086 		}
2087 
2088 		CPPUNIT_TEST_SUITE( isValid );
2089 		CPPUNIT_TEST( isValid_001 );
2090 		CPPUNIT_TEST( isValid_002 );
2091 		CPPUNIT_TEST( isValid_003 );
2092 		CPPUNIT_TEST_SUITE_END( );
2093 	};// class isValid
2094 
2095  	//---------------------------------------------------------------------
2096 	// 	testing the method
2097 	// 	inline sal_Bool getRemoteFlag() const
2098 	//---------------------------------------------------------------------
2099     class  getRemoteFlag : public CppUnit::TestFixture
2100 	{
2101 		::osl::VolumeDevice aVolumeDevice;
2102 		::rtl::OUString aUStr;
2103 		::osl::FileBase::RC nError1, nError2;
2104 
2105 	    public:
2106 		// test code.
2107 		void getRemoteFlag_001( )
2108 		{
2109 			sal_Int32 mask = VolumeInfoMask_Attributes;
2110 			::osl::VolumeInfo aVolumeInfo( mask );
2111 			nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo );
2112 			CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 );
2113 			sal_Bool bOk = aVolumeInfo.getRemoteFlag( );
2114 
2115 			CPPUNIT_ASSERT_MESSAGE( "test for getRemoteFlag function: get a volume device which is not remote.",
2116 				 					( sal_False == bOk ) );
2117 		}
2118 
2119  #if ( defined UNX ) || ( defined OS2 )	//remote Volume is different in Solaris and Windows
2120 		void getRemoteFlag_002( )
2121 		{
2122 			sal_Int32 mask = VolumeInfoMask_Attributes;
2123 			::osl::VolumeInfo aVolumeInfo( mask );
2124 			nError1 = ::osl::Directory::getVolumeInfo( aVolURL4, aVolumeInfo );
2125 			CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 );
2126 			sal_Bool bOk = aVolumeInfo.getRemoteFlag( );
2127 
2128 			CPPUNIT_ASSERT_MESSAGE( "test for getRemoteFlag function: get a volume device which is remote( Solaris version ).",
2129 				 					( sal_True == bOk ) );
2130 		}
2131 #else                                    //Windows version
2132 		void getRemoteFlag_002( )
2133 		{
2134 			CPPUNIT_ASSERT_MESSAGE( "test for getRemoteFlag function: get a volume device which is remote( Windows version )",
2135 				 					1 == 1 );
2136 		}
2137 #endif
2138 
2139 		CPPUNIT_TEST_SUITE( getRemoteFlag );
2140 		CPPUNIT_TEST( getRemoteFlag_001 );
2141 		CPPUNIT_TEST( getRemoteFlag_002 );
2142 		CPPUNIT_TEST_SUITE_END( );
2143 	};// class getRemoteFlag
2144 
2145 	//---------------------------------------------------------------------
2146 	// 	testing the method
2147 	// 	inline sal_Bool getRemoveableFlag() const
2148 	//---------------------------------------------------------------------
2149     class  getRemoveableFlag : public CppUnit::TestFixture
2150 	{
2151 		::osl::FileBase::RC nError1, nError2;
2152 
2153 	    public:
2154 		// test code.
2155 		void getRemoveableFlag_001( )
2156 		{
2157 			sal_Int32 mask = VolumeInfoMask_Attributes;
2158 			::osl::VolumeInfo aVolumeInfo( mask );
2159 			nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo );
2160 			CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 );
2161 			sal_Bool bOk = aVolumeInfo.getRemoveableFlag( );
2162 
2163 			CPPUNIT_ASSERT_MESSAGE( "test for getRemoveableFlag function: get a volume device which is not removable.",
2164 				 					sal_False == bOk );
2165 		}
2166 
2167 		void getRemoveableFlag_002( )
2168 		{
2169 			sal_Int32 mask = VolumeInfoMask_Attributes;
2170 			::osl::VolumeInfo aVolumeInfo( mask );
2171 			nError1 = ::osl::Directory::getVolumeInfo( aVolURL2, aVolumeInfo );
2172 			CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 );
2173 			sal_Bool bOk = aVolumeInfo.getRemoveableFlag( );
2174 
2175 			CPPUNIT_ASSERT_MESSAGE( "test for getRemoveableFlag function: get a volume device which is removable, not sure, here we use floppy disk, but it did not pass.",
2176 				 					sal_True == bOk );
2177 		}
2178 		CPPUNIT_TEST_SUITE( getRemoveableFlag );
2179 		CPPUNIT_TEST( getRemoveableFlag_001 );
2180 		CPPUNIT_TEST( getRemoveableFlag_002 );
2181 		CPPUNIT_TEST_SUITE_END( );
2182 	};// class getRemoveableFlag
2183 
2184 
2185 	//---------------------------------------------------------------------
2186 	// 	testing the method
2187 	// 	inline sal_Bool getCompactDiscFlag() const
2188 	//---------------------------------------------------------------------
2189     class  getCompactDiscFlag : public CppUnit::TestFixture
2190 	{
2191 		::osl::FileBase::RC nError1;
2192 
2193 	    public:
2194 		// test code.
2195 		void getCompactDiscFlag_001( )
2196 		{
2197 			sal_Int32 mask = VolumeInfoMask_Attributes;
2198 			::osl::VolumeInfo aVolumeInfo( mask );
2199 			nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo );
2200 			CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 );
2201 			sal_Bool bOk = aVolumeInfo.getCompactDiscFlag( );
2202 
2203 			CPPUNIT_ASSERT_MESSAGE( "test for getCompactDiscFlag function: get a volume device which is not a cdrom.",
2204 				 					 ( sal_False == bOk ) );
2205 		}
2206 
2207 		void getCompactDiscFlag_002( )
2208 		{
2209  			sal_Int32 mask = VolumeInfoMask_Attributes;
2210 			::osl::VolumeInfo aVolumeInfo( mask );
2211 			nError1 = ::osl::Directory::getVolumeInfo( aVolURL6, aVolumeInfo );
2212 			CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 );
2213 			sal_Bool bOk = aVolumeInfo.getCompactDiscFlag( );
2214 
2215 			CPPUNIT_ASSERT_MESSAGE( "test for getCompactDiscFlag function: get a cdrom volume device flag, it did not pass.",
2216 				 					 ( sal_True == bOk ) );
2217 		}
2218 		CPPUNIT_TEST_SUITE( getCompactDiscFlag );
2219 		CPPUNIT_TEST( getCompactDiscFlag_001 );
2220 		CPPUNIT_TEST( getCompactDiscFlag_002 );
2221 		CPPUNIT_TEST_SUITE_END( );
2222 	};// class getCompactDiscFlag
2223 
2224 
2225 	//---------------------------------------------------------------------
2226 	// 	testing the method
2227 	// 	inline sal_Bool getFloppyDiskFlag() const
2228 	//---------------------------------------------------------------------
2229     class  getFloppyDiskFlag : public CppUnit::TestFixture
2230 	{
2231 		::osl::FileBase::RC nError1;
2232 
2233 	    public:
2234 		// test code.
2235 		void getFloppyDiskFlag_001( )
2236 		{
2237 			sal_Int32 mask = VolumeInfoMask_Attributes;
2238 			::osl::VolumeInfo aVolumeInfo( mask );
2239 			nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo );
2240 			CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 );
2241 			sal_Bool bOk = aVolumeInfo.getFloppyDiskFlag( );
2242 
2243 			CPPUNIT_ASSERT_MESSAGE( "test for getFloppyDiskFlag function: get a volume device which is not a floppy disk.",
2244 				 					 ( sal_False == bOk ) );
2245 		}
2246 
2247 		void getFloppyDiskFlag_002( )
2248 		{
2249  			sal_Int32 mask = VolumeInfoMask_Attributes;
2250 			::osl::VolumeInfo aVolumeInfo( mask );
2251 			nError1 = ::osl::Directory::getVolumeInfo( aVolURL2, aVolumeInfo );
2252 			CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 );
2253 			sal_Bool bOk = aVolumeInfo.getFloppyDiskFlag( );
2254 
2255 			CPPUNIT_ASSERT_MESSAGE( "test for getFloppyDiskFlag function: get a floppy volume device flag, it did not pass.",
2256 				 					 ( sal_True == bOk ) );
2257 		}
2258 		CPPUNIT_TEST_SUITE( getFloppyDiskFlag );
2259 		CPPUNIT_TEST( getFloppyDiskFlag_001 );
2260 		CPPUNIT_TEST( getFloppyDiskFlag_002 );
2261 		CPPUNIT_TEST_SUITE_END( );
2262 	};// class getFloppyDiskFlag
2263 
2264 
2265 	//---------------------------------------------------------------------
2266 	// 	testing the method
2267 	// 	inline sal_Bool getFixedDiskFlag() const
2268 	//---------------------------------------------------------------------
2269     class  getFixedDiskFlag : public CppUnit::TestFixture
2270 	{
2271 		::osl::FileBase::RC nError1;
2272 
2273 	    public:
2274 		// test code.
2275 		void getFixedDiskFlag_001( )
2276 		{
2277 			sal_Int32 mask = VolumeInfoMask_Attributes;
2278 			::osl::VolumeInfo aVolumeInfo( mask );
2279 			nError1 = ::osl::Directory::getVolumeInfo( aVolURL2, aVolumeInfo );
2280 			CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 );
2281 			sal_Bool bOk = aVolumeInfo.getFixedDiskFlag( );
2282 
2283 			CPPUNIT_ASSERT_MESSAGE( "test for getFixedDiskFlag function: get a volume device which is not a fixed disk.",
2284 				 					( sal_False == bOk ) );
2285 		}
2286 
2287 		void getFixedDiskFlag_002( )
2288 		{
2289  			sal_Int32 mask = VolumeInfoMask_Attributes;
2290 			::osl::VolumeInfo aVolumeInfo( mask );
2291 			nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo );
2292 			CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 );
2293 			sal_Bool bOk = aVolumeInfo.getFixedDiskFlag( );
2294 
2295 			CPPUNIT_ASSERT_MESSAGE( "test for getFixedDiskFlag function: get a fixed disk volume device flag, it did not pass.",
2296 				 					( sal_True == bOk ) );
2297 		}
2298 		CPPUNIT_TEST_SUITE( getFixedDiskFlag );
2299 		CPPUNIT_TEST( getFixedDiskFlag_001 );
2300 		CPPUNIT_TEST( getFixedDiskFlag_002 );
2301 		CPPUNIT_TEST_SUITE_END( );
2302 	};// class getFixedDiskFlag
2303 
2304 	//---------------------------------------------------------------------
2305 	// 	testing the method
2306 	// 	inline sal_Bool getRAMDiskFlag() const
2307 	//---------------------------------------------------------------------
2308     class  getRAMDiskFlag : public CppUnit::TestFixture
2309 	{
2310 		::osl::FileBase::RC nError1;
2311 
2312 	    public:
2313 		// test code.
2314 		void getRAMDiskFlag_001( )
2315 		{
2316 			sal_Int32 mask = VolumeInfoMask_Attributes;
2317 			::osl::VolumeInfo aVolumeInfo( mask );
2318 			nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo );
2319 			CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 );
2320 			sal_Bool bOk = aVolumeInfo.getRAMDiskFlag( );
2321 
2322 			CPPUNIT_ASSERT_MESSAGE( "test for getRAMDiskFlag function: get a volume device which is not a RAM disk.",
2323 				 					( sal_False == bOk ) );
2324 		}
2325 
2326 		void getRAMDiskFlag_002( )
2327 		{
2328  			sal_Int32 mask = VolumeInfoMask_Attributes;
2329 			::osl::VolumeInfo aVolumeInfo( mask );
2330 			nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo );
2331 			CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 );
2332 			sal_Bool bOk = aVolumeInfo.getRAMDiskFlag( );
2333 
2334 			CPPUNIT_ASSERT_MESSAGE( "test for getRAMDiskFlag function: FIX ME, don't know how to get a RAM disk flag, perhaps Windows 98 boot disk can create a RAM disk, it did not pass in (UNX)(W32).",
2335 				 					( sal_True == bOk ) );
2336 		}
2337 		CPPUNIT_TEST_SUITE( getRAMDiskFlag );
2338 		CPPUNIT_TEST( getRAMDiskFlag_001 );
2339 		CPPUNIT_TEST( getRAMDiskFlag_002 );
2340 		CPPUNIT_TEST_SUITE_END( );
2341 	};// class getRAMDiskFlag
2342 
2343 
2344 	//---------------------------------------------------------------------
2345 	// 	testing the method
2346 	// 	inline sal_uInt64 getTotalSpace() const
2347 	//---------------------------------------------------------------------
2348     class  getTotalSpace : public CppUnit::TestFixture
2349 	{
2350 		::osl::FileBase::RC nError1;
2351 
2352 	    public:
2353 		// test code.
2354 		void getTotalSpace_001( )
2355 		{
2356 			sal_Int32 mask = VolumeInfoMask_TotalSpace;
2357 			::osl::VolumeInfo aVolumeInfo( mask );
2358 			nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo );
2359 			CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 );
2360 			CPPUNIT_ASSERT( sal_True == aVolumeInfo.isValid( mask ) );
2361 			sal_uInt64 uiTotalSpace = aVolumeInfo.getTotalSpace( );
2362 
2363 			CPPUNIT_ASSERT_MESSAGE( "test for getTotalSpace function: get total space of Fixed disk volume mounted on /, it should not be 0",
2364 				 					0 != uiTotalSpace );
2365 		}
2366 
2367  #if defined( UNX )
2368 		void getTotalSpace_002( )
2369 		{
2370  			sal_Int32 mask = VolumeInfoMask_TotalSpace;
2371 			::osl::VolumeInfo aVolumeInfo( mask );
2372 			nError1 = ::osl::Directory::getVolumeInfo( aVolURL3, aVolumeInfo );
2373 			CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 );
2374 			CPPUNIT_ASSERT( sal_True == aVolumeInfo.isValid( mask ) );
2375 			sal_uInt64 uiTotalSpace = aVolumeInfo.getTotalSpace( );
2376 
2377 			CPPUNIT_ASSERT_MESSAGE( "test for getTotalSpace function: get total space of /proc, it should be 0",
2378 				 					0 == uiTotalSpace );
2379 		}
2380 #else           /// Windows version, in Windows, there is no /proc directory
2381 		void getTotalSpace_002( )
2382 		{
2383 			CPPUNIT_ASSERT_MESSAGE( "test for getTotalSpace function:not applicable for /proc( Windows version )",
2384 				 					1 == 1 );
2385 		}
2386 #endif
2387 
2388 
2389 
2390 #if defined(SOLARIS)
2391  		void getTotalSpace_003( )
2392 		{
2393  			struct statvfs aStatFS;
2394 			static const sal_Char  name[] = "/";
2395 
2396 			memset (&aStatFS, 0, sizeof(aStatFS));
2397 			statvfs( name, &aStatFS);
2398 			sal_uInt64 TotalSpace = aStatFS.f_frsize * aStatFS.f_blocks ;
2399 
2400  			sal_Int32 mask = VolumeInfoMask_TotalSpace;
2401 			::osl::VolumeInfo aVolumeInfo( mask );
2402 			nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo );
2403 			CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 );
2404 			CPPUNIT_ASSERT( sal_True == aVolumeInfo.isValid( mask ) );
2405 			sal_uInt64 uiTotalSpace = aVolumeInfo.getTotalSpace( );
2406 
2407  			CPPUNIT_ASSERT_MESSAGE( "test for getTotalSpace function: get total space by hand, then compare with getTotalSpace, it did not pass",
2408 				 					uiTotalSpace == TotalSpace );
2409 		}
2410 #else           /// Windows version
2411 		void getTotalSpace_003( )
2412 		{
2413 			CPPUNIT_ASSERT_MESSAGE( "test for getTotalSpace function:not implemented yet( Windows version )",
2414 				 					1 == 1 );
2415 		}
2416 #endif
2417 
2418 		CPPUNIT_TEST_SUITE( getTotalSpace );
2419 		CPPUNIT_TEST( getTotalSpace_001 );
2420 		CPPUNIT_TEST( getTotalSpace_002 );
2421 		CPPUNIT_TEST( getTotalSpace_003 );
2422 		CPPUNIT_TEST_SUITE_END( );
2423 	};// class getTotalSpace
2424 
2425 	//---------------------------------------------------------------------
2426 	// 	testing the method
2427 	// 	inline sal_uInt64 getFreeSpace() const
2428 	//---------------------------------------------------------------------
2429     class  getFreeSpace : public CppUnit::TestFixture
2430 	{
2431 		::osl::FileBase::RC nError1;
2432 
2433 	    public:
2434 		// test code.
2435 		void getFreeSpace_001( )
2436 		{
2437 			sal_Int32 mask = VolumeInfoMask_FreeSpace;
2438 			::osl::VolumeInfo aVolumeInfo( mask );
2439 			nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo );
2440 			CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 );
2441 			CPPUNIT_ASSERT( sal_True == aVolumeInfo.isValid( mask ) );
2442 			sal_uInt64 uiFreeSpace = aVolumeInfo.getFreeSpace( );
2443 
2444 			CPPUNIT_ASSERT_MESSAGE( "test for getFreeSpace function: get free space of Fixed disk volume mounted on /, it should not be 0, suggestion: returned value, -1 is better, since some times the free space may be 0",
2445 				 					0 != uiFreeSpace );
2446 		}
2447 
2448 #if defined( UNX )
2449   		void getFreeSpace_002( )
2450 		{
2451  			sal_Int32 mask = VolumeInfoMask_FreeSpace;
2452 			::osl::VolumeInfo aVolumeInfo( mask );
2453 			nError1 = ::osl::Directory::getVolumeInfo( aVolURL3, aVolumeInfo );
2454 			CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 );
2455 			CPPUNIT_ASSERT( sal_True == aVolumeInfo.isValid( mask ) );
2456 			sal_uInt64 uiFreeSpace = aVolumeInfo.getFreeSpace( );
2457 
2458 			CPPUNIT_ASSERT_MESSAGE( "test for getFreeSpace function: get free space of /proc, it should be 0",
2459 				 					0 == uiFreeSpace );
2460 		}
2461 #else           /// Windows version, in Windows, there is no /proc directory
2462 		void getFreeSpace_002( )
2463 		{
2464 			CPPUNIT_ASSERT_MESSAGE( "test for getFreeSpace function: not applicable for /proc( Windows version )",
2465 				 					1 == 1 );
2466 		}
2467 #endif
2468 
2469 
2470 #if defined(SOLARIS)
2471  		void getFreeSpace_003( )
2472 		{
2473  			struct statvfs aStatFS;
2474 			static const sal_Char  name[] = "/";
2475 
2476 			memset (&aStatFS, 0, sizeof(aStatFS));
2477 			statvfs( name, &aStatFS);
2478 			sal_uInt64 FreeSpace = aStatFS.f_bfree * aStatFS.f_frsize  ;
2479 
2480  			sal_Int32 mask = VolumeInfoMask_FreeSpace;
2481 			::osl::VolumeInfo aVolumeInfo( mask );
2482 			nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo );
2483 			CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 );
2484 			CPPUNIT_ASSERT( sal_True == aVolumeInfo.isValid( mask ) );
2485 			sal_uInt64 uiFreeSpace = aVolumeInfo.getFreeSpace( );
2486 
2487  			CPPUNIT_ASSERT_MESSAGE( "test for getFreeSpace function: get free space by hand, then compare with getFreeSpace, it did not pass",
2488 				 					uiFreeSpace == FreeSpace );
2489 		}
2490 #else                                    //Windows version
2491 		void getFreeSpace_003( )
2492 		{
2493 			CPPUNIT_ASSERT_MESSAGE( "test for getFreeSpace function: not implemented yet( Windows version )",
2494 				 					1 == 1 );
2495 		}
2496 #endif
2497 
2498 
2499 		CPPUNIT_TEST_SUITE( getFreeSpace );
2500 		CPPUNIT_TEST( getFreeSpace_001 );
2501  		CPPUNIT_TEST( getFreeSpace_002 );
2502 		CPPUNIT_TEST( getFreeSpace_003 );
2503 		CPPUNIT_TEST_SUITE_END( );
2504 	};// class getFreeSpace
2505 
2506 	//---------------------------------------------------------------------
2507 	// 	testing the method
2508 	// 	inline sal_uInt64 getUsedSpace() const
2509 	//---------------------------------------------------------------------
2510     class  getUsedSpace : public CppUnit::TestFixture
2511 	{
2512 		::osl::FileBase::RC nError1;
2513 
2514 	    public:
2515 		// test code.
2516 		void getUsedSpace_001( )
2517 		{
2518 			sal_Int32 mask = VolumeInfoMask_UsedSpace;
2519 			::osl::VolumeInfo aVolumeInfo( mask );
2520 			nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo );
2521 			CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 );
2522 			CPPUNIT_ASSERT( sal_True == aVolumeInfo.isValid( mask ) );
2523 			sal_uInt64 uiUsedSpace = aVolumeInfo.getUsedSpace( );
2524 
2525 			CPPUNIT_ASSERT_MESSAGE( "test for getUsedSpace function: get used space of Fixed disk volume mounted on /, it should not be 0, suggestion: returned value, -1 is better, since some times the used space may be 0",
2526 				 					0 != uiUsedSpace );
2527 		}
2528 
2529 #if defined( UNX )
2530    		void getUsedSpace_002( )
2531 		{
2532  			sal_Int32 mask = VolumeInfoMask_UsedSpace;
2533 			::osl::VolumeInfo aVolumeInfo( mask );
2534 			nError1 = ::osl::Directory::getVolumeInfo( aVolURL3, aVolumeInfo );
2535 			CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 );
2536 			CPPUNIT_ASSERT( sal_True == aVolumeInfo.isValid( mask ) );
2537 			sal_uInt64 uiUsedSpace = aVolumeInfo.getUsedSpace( );
2538 
2539 			CPPUNIT_ASSERT_MESSAGE( "test for getUsedSpace function: get used space of /proc, it should be 0",
2540 				 					0 == uiUsedSpace );
2541 		}
2542 #else                                    /// Windows version, in Windows, there is no /proc directory
2543 		void getUsedSpace_002( )
2544 		{
2545 			CPPUNIT_ASSERT_MESSAGE( "test for getUsedSpace function: not applicable for /proc( Windows version )",
2546 				 					1 == 1 );
2547 		}
2548 #endif
2549 
2550 
2551 #if defined(SOLARIS)
2552  		void getUsedSpace_003( )
2553 		{
2554  			struct statvfs aStatFS;
2555 			static const sal_Char  name[] = "/";
2556 
2557 			memset (&aStatFS, 0, sizeof(aStatFS));
2558 			statvfs( name, &aStatFS);
2559 			sal_uInt64 UsedSpace = ( aStatFS.f_blocks - aStatFS.f_bavail ) * aStatFS.f_frsize;
2560 
2561 
2562  			sal_Int32 mask = VolumeInfoMask_UsedSpace;
2563 			::osl::VolumeInfo aVolumeInfo( mask );
2564 			nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo );
2565 			CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 );
2566 			CPPUNIT_ASSERT( sal_True == aVolumeInfo.isValid( mask ) );
2567 			sal_uInt64 uiUsedSpace = aVolumeInfo.getUsedSpace( );
2568 
2569  			CPPUNIT_ASSERT_MESSAGE( "test for getUsedSpace function: get used space by hand, then compare with getUsedSpace, it did not pass",
2570 				 					uiUsedSpace == UsedSpace );
2571 		}
2572 #else                                    //Windows version
2573 		void getUsedSpace_003( )
2574 		{
2575 			CPPUNIT_ASSERT_MESSAGE( "test for getUsedSpace function: not implemented yet( Windows version )",
2576 				 					1 == 1 );
2577 		}
2578 #endif
2579 
2580 
2581 		CPPUNIT_TEST_SUITE( getUsedSpace );
2582  		CPPUNIT_TEST( getUsedSpace_001 );
2583  		CPPUNIT_TEST( getUsedSpace_002 );
2584 		CPPUNIT_TEST( getUsedSpace_003 );
2585  		CPPUNIT_TEST_SUITE_END( );
2586 	};// class getUsedSpace
2587 
2588 
2589 	//---------------------------------------------------------------------
2590 	// 	testing the method
2591 	// 	inline sal_uInt32 getMaxNameLength() const
2592 	//---------------------------------------------------------------------
2593     class  getMaxNameLength : public CppUnit::TestFixture
2594 	{
2595 		::osl::FileBase::RC nError1;
2596 
2597 	    public:
2598 		// test code.
2599 		void getMaxNameLength_001( )
2600 		{
2601 			sal_Int32 mask = VolumeInfoMask_MaxNameLength;
2602 			::osl::VolumeInfo aVolumeInfo( mask );
2603 			nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo );
2604 			CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 );
2605 			CPPUNIT_ASSERT( sal_True == aVolumeInfo.isValid( mask ) );
2606 			sal_uInt32 uiMaxNameLength = aVolumeInfo.getMaxNameLength( );
2607 
2608 			CPPUNIT_ASSERT_MESSAGE( "test for getMaxNameLength function: get max name length of Fixed disk volume mounted on /, it should not be 0",
2609 				 					0 != uiMaxNameLength );
2610 		}
2611 
2612 
2613 #if ( defined UNX ) || ( defined OS2 )
2614  		void getMaxNameLength_002( )
2615 		{
2616  			struct statvfs aStatFS;
2617 			static const sal_Char  name[] = "/";
2618 
2619 			memset (&aStatFS, 0, sizeof(aStatFS));
2620 			statvfs( name, &aStatFS);
2621 			sal_uInt64 MaxNameLength = aStatFS.f_namemax;
2622 
2623  			sal_Int32 mask = VolumeInfoMask_MaxNameLength;
2624 			::osl::VolumeInfo aVolumeInfo( mask );
2625 			nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo );
2626 			CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 );
2627 			CPPUNIT_ASSERT( sal_True == aVolumeInfo.isValid( mask ) );
2628 			sal_uInt64 uiMaxNameLength = aVolumeInfo.getMaxNameLength( );
2629 
2630  			CPPUNIT_ASSERT_MESSAGE( "test for getMaxNameLength function: get max name length by hand, then compare with getMaxNameLength",
2631 				 					uiMaxNameLength == MaxNameLength );
2632 		}
2633 #else                                    //Windows version
2634 		void getMaxNameLength_002( )
2635 		{
2636 			CPPUNIT_ASSERT_MESSAGE( "test for getMaxNameLength function: not implemented yet( Windows version )",
2637 				 					1 == 1 );
2638 		}
2639 #endif
2640 
2641 		CPPUNIT_TEST_SUITE( getMaxNameLength );
2642  		CPPUNIT_TEST( getMaxNameLength_001 );
2643 		CPPUNIT_TEST( getMaxNameLength_002 );
2644  		CPPUNIT_TEST_SUITE_END( );
2645 	};// class getMaxNameLength
2646 
2647 
2648 	//---------------------------------------------------------------------
2649 	// 	testing the method
2650 	// 	inline sal_uInt32 getMaxPathLength() const
2651 	//---------------------------------------------------------------------
2652     class  getMaxPathLength : public CppUnit::TestFixture
2653 	{
2654 		::osl::FileBase::RC nError1;
2655 
2656 	    public:
2657 		// test code.
2658 		void getMaxPathLength_001( )
2659 		{
2660 			sal_Int32 mask = VolumeInfoMask_MaxPathLength;
2661 			::osl::VolumeInfo aVolumeInfo( mask );
2662 			nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo );
2663 			CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 );
2664 			CPPUNIT_ASSERT( sal_True == aVolumeInfo.isValid( mask ) );
2665 			sal_uInt32 uiMaxPathLength = aVolumeInfo.getMaxPathLength( );
2666 
2667 			CPPUNIT_ASSERT_MESSAGE( "test for getMaxPathLength function: get max path length of Fixed disk volume mounted on /, it should not be 0",
2668 				 					0 != uiMaxPathLength );
2669 		}
2670 
2671 
2672 #if ( defined UNX ) || ( defined OS2 )
2673  		void getMaxPathLength_002( )
2674 		{
2675  			sal_Int32 mask = VolumeInfoMask_MaxPathLength;
2676 			::osl::VolumeInfo aVolumeInfo( mask );
2677 			nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo );
2678 			CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 );
2679 			CPPUNIT_ASSERT( sal_True == aVolumeInfo.isValid( mask ) );
2680 			sal_uInt64 uiMaxPathLength = aVolumeInfo.getMaxPathLength( );
2681 
2682  			CPPUNIT_ASSERT_MESSAGE( "test for getMaxPathLength function: get max path length by hand, then compare with getMaxPathLength",
2683 				 					uiMaxPathLength == PATH_MAX );
2684 		}
2685 #else                                    //Windows version
2686 		void getMaxPathLength_002( )
2687 		{
2688 			CPPUNIT_ASSERT_MESSAGE( "test for getMaxPathLength function: not implemented yet( Windows version )",
2689 				 					1 == 1 );
2690 		}
2691 #endif
2692 
2693 
2694 		CPPUNIT_TEST_SUITE( getMaxPathLength );
2695  		CPPUNIT_TEST( getMaxPathLength_001 );
2696 		CPPUNIT_TEST( getMaxPathLength_002 );
2697  		CPPUNIT_TEST_SUITE_END( );
2698 	};// class getMaxPathLength
2699 
2700 
2701 	//---------------------------------------------------------------------
2702 	// 	testing the method
2703 	// 	inline ::rtl::OUString getFileSystemName() const
2704 	//---------------------------------------------------------------------
2705     class  getFileSystemName : public CppUnit::TestFixture
2706 	{
2707 		::rtl::OUString aUStr;
2708 		::osl::FileBase::RC nError1;
2709 
2710 	    public:
2711 		// test code.
2712 		void getFileSystemName_001( )
2713 		{
2714 			sal_Int32 mask = VolumeInfoMask_FileSystemName;
2715 			::osl::VolumeInfo aVolumeInfo( mask );
2716 			nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo );
2717 			CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 );
2718 			CPPUNIT_ASSERT( sal_True == aVolumeInfo.isValid( mask ) );
2719 			aUStr = aVolumeInfo.getFileSystemName( );
2720 
2721 			CPPUNIT_ASSERT_MESSAGE( "test for getFileSystemName function: get file system name of Fixed disk volume mounted on /, it should not be empty string",
2722 				 					sal_False == compareFileName( aNullURL, aUStr ) );
2723 		}
2724 
2725 
2726 #if defined(SOLARIS)
2727  		void getFileSystemName_002( )
2728 		{
2729  			struct statvfs aStatFS;
2730 			static const sal_Char  name[] = "/";
2731 
2732 			memset (&aStatFS, 0, sizeof(aStatFS));
2733 			statvfs( name, &aStatFS);
2734 			sal_Char * astrFileSystemName = aStatFS.f_basetype;
2735 
2736  			sal_Int32 mask = VolumeInfoMask_FileSystemName;
2737 			::osl::VolumeInfo aVolumeInfo( mask );
2738 			nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo );
2739 			CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 );
2740 			CPPUNIT_ASSERT( sal_True == aVolumeInfo.isValid( mask ) );
2741 			aUStr = aVolumeInfo.getFileSystemName( );
2742 
2743  			CPPUNIT_ASSERT_MESSAGE( "test for getFileSystemName function: get file system name by hand, then compare with getFileSystemName",
2744 				 					sal_True == compareFileName( aUStr, astrFileSystemName ) );
2745 		}
2746 #else                                    //Windows version
2747 		void getFileSystemName_002( )
2748 		{
2749 			CPPUNIT_ASSERT_MESSAGE( "test for getFileSystemName function: not implemented yet( Windows version )",
2750 				 					1 == 1 );
2751 		}
2752 #endif
2753 
2754 
2755 		CPPUNIT_TEST_SUITE( getFileSystemName );
2756  		CPPUNIT_TEST( getFileSystemName_001 );
2757 		CPPUNIT_TEST( getFileSystemName_002 );
2758  		CPPUNIT_TEST_SUITE_END( );
2759 	};// class getFileSystemName
2760 
2761 	//---------------------------------------------------------------------
2762 	// 	testing the method
2763 	// 	inline VolumeDevice getDeviceHandle() const
2764 	//---------------------------------------------------------------------
2765     class  getDeviceHandle : public CppUnit::TestFixture
2766 	{
2767 		::rtl::OUString aUStr;
2768 		::osl::FileBase::RC nError1;
2769 
2770 	    public:
2771 		// test code.
2772 		void getDeviceHandle_001( )
2773 		{
2774 			::osl::VolumeInfo   aVolumeInfo( VolumeInfoMask_Attributes );
2775 			nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo );
2776 			CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 );
2777 
2778 			::osl::VolumeDevice aVolumeDevice1( aVolumeInfo.getDeviceHandle( ) );
2779 			sal_Bool bOk = compareFileName( aNullURL, aVolumeDevice1.getMountPath( ) );
2780 
2781 			CPPUNIT_ASSERT_MESSAGE( "test for getDeviceHandle function: get device handle of Fixed disk volume mounted on /, it should not be NULL, it did not pass in (W32) (UNX).",
2782 				 					( sal_False == bOk ) );
2783 		}
2784 
2785 		CPPUNIT_TEST_SUITE( getDeviceHandle );
2786  		CPPUNIT_TEST( getDeviceHandle_001 );
2787 		CPPUNIT_TEST_SUITE_END( );
2788 	};// class getDeviceHandle
2789 
2790 
2791 	// -----------------------------------------------------------------------------
2792 	/*CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_VolumeInfo::ctors, "osl_VolumeInfo" );
2793 	CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_VolumeInfo::isValid, "osl_VolumeInfo" );
2794 	CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_VolumeInfo::getRemoteFlag, "osl_VolumeInfo" );
2795 	CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_VolumeInfo::getRemoveableFlag, "osl_VolumeInfo" );
2796 	CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_VolumeInfo::getCompactDiscFlag, "osl_VolumeInfo" );
2797 	CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_VolumeInfo::getFloppyDiskFlag, "osl_VolumeInfo" );
2798 	CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_VolumeInfo::getFixedDiskFlag, "osl_VolumeInfo" );
2799 	CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_VolumeInfo::getRAMDiskFlag, "osl_VolumeInfo" );
2800 	CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_VolumeInfo::getTotalSpace, "osl_VolumeInfo" );
2801 	CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_VolumeInfo::getFreeSpace, "osl_VolumeInfo" );
2802 	CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_VolumeInfo::getUsedSpace, "osl_VolumeInfo" );
2803 	CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_VolumeInfo::getMaxNameLength, "osl_VolumeInfo" );
2804 	CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_VolumeInfo::getMaxPathLength, "osl_VolumeInfo" );
2805 	CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_VolumeInfo::getFileSystemName, "osl_VolumeInfo" );
2806 	CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_VolumeInfo::getDeviceHandle, "osl_VolumeInfo" );*/
2807 }// namespace osl_VolumeInfo
2808 
2809 
2810 
2811 //------------------------------------------------------------------------
2812 // Beginning of the test cases for VolumeDevice class
2813 //------------------------------------------------------------------------
2814 namespace osl_FileStatus
2815 {
2816 
2817 	//---------------------------------------------------------------------
2818 	// 	testing the method
2819 	// 	FileStatus( sal_uInt32 nMask ): _nMask( nMask )
2820 	//---------------------------------------------------------------------
2821     class  ctors : public CppUnit::TestFixture
2822 	{
2823 		::rtl::OUString         aUStr;
2824 		::osl::FileBase::RC     nError1, nError2;
2825 		::osl::DirectoryItem    rItem;
2826 
2827 	    public:
2828 		// initialization
2829 		void setUp( )
2830 		{
2831 			// create a tempfile in $TEMP/tmpdir/tmpname.
2832 			createTestDirectory( aTmpName3 );
2833 			createTestFile( aTmpName4 );
2834 
2835 			::std::auto_ptr<Directory> pDir( new Directory( aTmpName3 ) );
2836 			nError1 = pDir->open( );
2837 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
2838 			nError1 = pDir->getNextItem( rItem, 0 );
2839 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
2840 			pDir->close();
2841 			/*
2842 			Directory aDir( aTmpName3 );
2843 			nError1 = aDir.open();
2844 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
2845 			nError1 = aDir.getNextItem( rItem, 0 );
2846 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
2847 			aDir.close();
2848 			*/
2849 		}
2850 
2851 		void tearDown( )
2852 		{
2853 			// remove the tempfile in $TEMP/tmpdir/tmpname.
2854 			deleteTestFile( aTmpName4 );
2855 			deleteTestDirectory( aTmpName3 );
2856 		}
2857 
2858 		// test code.
2859 		void ctors_001( )
2860 		{
2861  			::osl::FileStatus   rFileStatus( FileStatusMask_All );
2862 			nError1 = rItem.getFileStatus( rFileStatus );
2863 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
2864 			aUStr = rFileStatus.getFileName( );
2865 
2866 			CPPUNIT_ASSERT_MESSAGE( "test for ctors function: mask all and see the file name",
2867 				 					sal_True == compareFileName( aUStr, aTmpName2)  );
2868 		}
2869 
2870 		void ctors_002( )
2871 		{
2872  			::osl::FileStatus   rFileStatus( 0 );
2873 			nError1 = rItem.getFileStatus( rFileStatus );
2874 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
2875 			aUStr = rFileStatus.getFileName( );
2876 
2877 			CPPUNIT_ASSERT_MESSAGE( "test for ctors function: mask is empty",
2878 				 					sal_True == compareFileName( aUStr, aNullURL)  );
2879 		}
2880 
2881 		CPPUNIT_TEST_SUITE( ctors );
2882 		CPPUNIT_TEST( ctors_001 );
2883 		CPPUNIT_TEST( ctors_002 );
2884 		CPPUNIT_TEST_SUITE_END( );
2885 	};// class ctors
2886 
2887 
2888 	//---------------------------------------------------------------------
2889 	// 	testing the method
2890 	// 	inline sal_Bool isValid( sal_uInt32 nMask ) const
2891 	//---------------------------------------------------------------------
2892     class  isValid : public CppUnit::TestFixture
2893 	{
2894 		::rtl::OUString         aUStr;
2895 		::osl::Directory        *pDir;
2896 		::osl::DirectoryItem    rItem_file, rItem_link;
2897 
2898 	    public:
2899 		// initialization
2900 		void setUp( )
2901 		{
2902 			// create a tempfile in $TEMP/tmpdir/tmpname.
2903 			createTestDirectory( aTmpName3 );
2904 			createTestFile( aTmpName4 );
2905 
2906 			pDir = new Directory( aTmpName3 );
2907 			//::std::auto_ptr<Directory> pDir( new Directory( aTmpName3 ) );
2908                 	::osl::FileBase::RC nError1 = pDir->open( );
2909 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
2910 			nError1 = pDir->getNextItem( rItem_file, 1 );
2911 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
2912 		}
2913 
2914 		void tearDown( )
2915 		{
2916                 	::osl::FileBase::RC nError1 = pDir->close( );
2917                 	delete pDir;
2918 			CPPUNIT_ASSERT_MESSAGE( errorToStr(nError1), ::osl::FileBase::E_None == nError1 );
2919 
2920 			// remove the tempfile in $TEMP/tmpdir/tmpname.
2921 			deleteTestFile( aTmpName4 );
2922 			deleteTestDirectory( aTmpName3 );
2923 		}
2924 
2925 		// test code.
2926 		void isValid_001( )
2927 		{
2928 			sal_uInt32 mask = 0;
2929  			::osl::FileStatus   rFileStatus( mask );
2930                 ::osl::FileBase::RC nError1 = rItem_file.getFileStatus( rFileStatus );
2931 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
2932 			sal_Bool bOk = rFileStatus.isValid( mask );
2933 
2934 			CPPUNIT_ASSERT_MESSAGE( "test for isValid function: no fields specified",
2935 				 					( sal_True == bOk ) );
2936 		}
2937 
2938         void check_FileStatus(::osl::FileStatus const& _aStatus)
2939             {
2940                 rtl::OString sStat;
2941                 if (_aStatus.isValid(FileStatusMask_Type))
2942                 {
2943                     sStat += "type ";
2944                 }
2945                 if (_aStatus.isValid(FileStatusMask_Attributes))
2946                 {
2947                     sStat += "attributes ";
2948                 }
2949                 if (_aStatus.isValid(FileStatusMask_CreationTime))
2950                 {
2951                     sStat += "ctime ";
2952                 }
2953                 if (_aStatus.isValid(FileStatusMask_AccessTime))
2954                 {
2955                     sStat += "atime ";
2956                 }
2957                 if (_aStatus.isValid(FileStatusMask_ModifyTime))
2958                 {
2959                     sStat += "mtime ";
2960                 }
2961                 if (_aStatus.isValid(FileStatusMask_FileSize))
2962                 {
2963                     sStat += "filesize ";
2964                 }
2965                 if (_aStatus.isValid(FileStatusMask_FileName))
2966                 {
2967                     sStat += "filename ";
2968                 }
2969                 if (_aStatus.isValid(FileStatusMask_FileURL))
2970                 {
2971                     sStat += "fileurl ";
2972                 }
2973                 t_print("mask: %s\n", sStat.getStr());
2974             }
2975 
2976 		void isValid_002( )
2977 		{
2978 			createTestFile( aTmpName6 );
2979 			sal_uInt32 mask_file = ( FileStatusMask_Type | FileStatusMask_Attributes |
2980                                    FileStatusMask_CreationTime | FileStatusMask_AccessTime |
2981                                    FileStatusMask_ModifyTime   | FileStatusMask_FileSize   |
2982                                    FileStatusMask_FileName     | FileStatusMask_FileURL) ;
2983  			::osl::FileStatus   rFileStatus( mask_file );
2984                 ::osl::FileBase::RC nError1 = ::osl::DirectoryItem::get( aTmpName6, rItem_file );
2985 			nError1 = rItem_file.getFileStatus( rFileStatus );
2986 
2987 			CPPUNIT_ASSERT_MESSAGE( errorToStr(nError1), ::osl::FileBase::E_None == nError1 );
2988 
2989 // LLA: this is wrong, we never should try to check on all masks
2990 //      only on one.
2991 //      Second, it's not a bug, if a value is not valid, it's an unhandled feature.
2992 
2993 // 			sal_Bool bOk = rFileStatus.isValid( mask_file );
2994 
2995                 check_FileStatus(rFileStatus);
2996 			deleteTestFile( aTmpName6 );
2997 
2998                 // CPPUNIT_ASSERT_MESSAGE( "test for isValid function: regular file mask fields test, #FileStatusMask_CreationTime# should be valid field for regular file, but feedback is invalid",
2999                 // 	 					( sal_True == bOk ) );
3000 		}
3001 
3002 		//Link is not defined in Windows, and on Linux, we can not get the directory item of the link file
3003         // LLA: we have to differ to filesystems, normal filesystems support links (EXT2, ...)
3004         //      castrated filesystems don't (FAT, FAT32)
3005         //      Windows NT NTFS support links, but the windows api don't :-(
3006 
3007 		void isValid_003( )
3008 		{
3009 #if defined ( UNX )
3010 			// ::osl::FileBase::RC nError;
3011 			sal_Int32 fd;
3012 
3013 			::rtl::OUString aUStr_LnkFileSys( aTempDirectorySys ), aUStr_SrcFileSys( aTempDirectorySys );
3014 			( ( aUStr_LnkFileSys += aSlashURL ) += getCurrentPID( ) ) += ::rtl::OUString::createFromAscii("/tmpdir/link.file");
3015 			( ( aUStr_SrcFileSys += aSlashURL ) += getCurrentPID( ) ) += ::rtl::OUString::createFromAscii("/tmpdir/tmpname");
3016 
3017                 rtl::OString strLinkFileName;
3018                 rtl::OString strSrcFileName;
3019                 strLinkFileName = OUStringToOString( aUStr_LnkFileSys, RTL_TEXTENCODING_ASCII_US );
3020                 strSrcFileName = OUStringToOString( aUStr_SrcFileSys, RTL_TEXTENCODING_ASCII_US );
3021 
3022 			//create a link file and link it to file "/tmp/PID/tmpdir/tmpname"
3023                 fd = symlink( strSrcFileName.getStr(), strLinkFileName.getStr() );
3024 			CPPUNIT_ASSERT( fd == 0 );
3025 
3026 			// testDirectory is "/tmp/PID/tmpdir/"
3027 			::osl::Directory testDirectory( aTmpName3 );
3028                 ::osl::FileBase::RC nError1 = testDirectory.open( );
3029 			::rtl::OUString aFileName = ::rtl::OUString::createFromAscii("link.file");
3030 			sal_Bool bOk = sal_False;
3031 			while (1) {
3032 				nError1 = testDirectory.getNextItem( rItem_link, 4 );
3033 				if (::osl::FileBase::E_None == nError1) {
3034 					sal_uInt32 mask_link = FileStatusMask_FileName | FileStatusMask_LinkTargetURL;
3035 					::osl::FileStatus   rFileStatus( mask_link );
3036 					rItem_link.getFileStatus( rFileStatus );
3037 					//printFileName( rFileStatus.getFileName( ) );
3038 					if ( compareFileName( rFileStatus.getFileName( ), aFileName) == sal_True )
3039 					{
3040 						//t_print("find the link file");
3041 						if ( sal_True == rFileStatus.isValid( FileStatusMask_LinkTargetURL ) )
3042 						{
3043 							bOk = sal_True;
3044 							break;
3045 						}
3046 					}
3047 				}
3048 				else
3049 					break;
3050 			};
3051 
3052 			fd = remove( strLinkFileName );
3053 			CPPUNIT_ASSERT( fd == 0 );
3054 
3055 			CPPUNIT_ASSERT_MESSAGE("test for isValid function: link file, check for LinkTargetURL",
3056 				 					( sal_True == bOk ) );
3057 #endif
3058 		}
3059 
3060 		void isValid_004( )
3061 		{
3062 			sal_uInt32 mask_file_all = FileStatusMask_All;
3063  			::osl::FileStatus   rFileStatus_all( mask_file_all );
3064                 ::osl::FileBase::RC nError1 = rItem_file.getFileStatus( rFileStatus_all );
3065 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
3066 
3067                 check_FileStatus(rFileStatus_all);
3068 // LLA: this is wrong
3069 //			sal_Bool bOk1 = rFileStatus_all.isValid( mask_file_all );
3070 
3071 			sal_uInt32 mask_file_val = FileStatusMask_Validate;
3072  			::osl::FileStatus   rFileStatus_val( mask_file_val );
3073 			nError1 = rItem_file.getFileStatus( rFileStatus_val );
3074 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
3075                 // sal_Bool bOk2 = rFileStatus_val.isValid( mask_file_val );
3076 
3077                 check_FileStatus(rFileStatus_val);
3078                 // CPPUNIT_ASSERT_MESSAGE( "test for isValid function: check for Mask_All and Validate, really not sure what validate used for and how to use it, help me.  did not pass (W32)(UNX).",
3079                 // 	 					( sal_False == bOk1 ) && ( sal_True == bOk2 )  );
3080 		}
3081 
3082 
3083 		CPPUNIT_TEST_SUITE( isValid );
3084 		CPPUNIT_TEST( isValid_001 );
3085 		CPPUNIT_TEST( isValid_002 );
3086 		CPPUNIT_TEST( isValid_003 );
3087 		CPPUNIT_TEST( isValid_004 );
3088 		CPPUNIT_TEST_SUITE_END( );
3089 	};// class ctors
3090 
3091 
3092 	//---------------------------------------------------------------------
3093 	// 	testing the method
3094 	// 	inline Type getFileType() const
3095 	//---------------------------------------------------------------------
3096     class  getFileType : public CppUnit::TestFixture
3097 	{
3098 		::rtl::OUString         aUStr;
3099 		::osl::FileBase::RC     nError1, nError2;
3100 
3101 		::osl::DirectoryItem    m_aItem_1, m_aItem_2, m_aVolumeItem, m_aFifoItem;
3102 		::osl::DirectoryItem    m_aLinkItem, m_aSocketItem, m_aSpecialItem;
3103 
3104 	    public:
3105 		// initialization
3106 		void setUp( )
3107 		{
3108 			// create a tempfile: $TEMP/tmpdir/tmpname.
3109 			//        a tempdirectory: $TEMP/tmpdir/tmpdir.
3110 			//        use $ROOT/staroffice as volume ---> use dev/fd as volume.
3111 			// and get their directory item.
3112 			createTestDirectory( aTmpName3 );
3113 			//printFileName( aTmpName2);
3114 			createTestFile( aTmpName3, aTmpName2 );
3115 			createTestDirectory( aTmpName3, aTmpName1 );
3116 
3117 			::std::auto_ptr<Directory> pDir( new Directory( aTmpName3 ) );
3118 			nError1 = pDir->open( );
3119 			CPPUNIT_ASSERT_MESSAGE("open aTmpName3 failed!", ::osl::FileBase::E_None == nError1 );
3120 			//getNextItem can not assure which item retrieved
3121             		nError1 = pDir->getNextItem( m_aItem_1, 1 );
3122 			CPPUNIT_ASSERT_MESSAGE("get first item failed!", ::osl::FileBase::E_None == nError1 );
3123 
3124             		nError1 = pDir->getNextItem( m_aItem_2 );
3125 			CPPUNIT_ASSERT_MESSAGE("get second item failed!", ::osl::FileBase::E_None == nError1 );
3126 			pDir->close();
3127 			//mindy: failed on my RH9,so removed temporaly
3128 			//nError1 = ::osl::DirectoryItem::get( aVolURL2, m_aVolumeItem );
3129 			//CPPUNIT_ASSERT_MESSAGE("get volume item failed!", ::osl::FileBase::E_None == nError1 );
3130 
3131 		}
3132 
3133 		void tearDown( )
3134 		{
3135 			// remove all in $TEMP/tmpdir.
3136 			deleteTestDirectory( aTmpName3, aTmpName1 );
3137 			deleteTestFile( aTmpName3, aTmpName2 );
3138 			deleteTestDirectory( aTmpName3 );
3139 		}
3140 
3141 		// test code.
3142 		void getFileType_001( )
3143 		{
3144  			::osl::FileStatus   rFileStatus( FileStatusMask_Type | FileStatusMask_FileName );
3145             nError1 = m_aItem_1.getFileStatus( rFileStatus );
3146 			CPPUNIT_ASSERT_MESSAGE("getFileStatus failed", ::osl::FileBase::E_None == nError1 );
3147 
3148             check_FileType(rFileStatus);
3149         }
3150 
3151         void check_FileType(osl::FileStatus const& _rFileStatus )
3152         {
3153 			sal_Bool bOK = sal_False;
3154                 if ( _rFileStatus.isValid(FileStatusMask_FileName))
3155                 {
3156                     rtl::OUString suFilename = _rFileStatus.getFileName();
3157 
3158                     if ( _rFileStatus.isValid(FileStatusMask_Type))
3159                     {
3160                         osl::FileStatus::Type eType = _rFileStatus.getFileType( );
3161 
3162                         if ( compareFileName( suFilename, aTmpName2) == sal_True )
3163                         {
3164                             // regular
3165                             bOK = ( eType == osl::FileStatus::Regular );
3166                         }
3167                         if ( compareFileName( suFilename, aTmpName1) == sal_True )
3168                         {
3169                             // directory
3170                             bOK = ( eType == ::osl::FileStatus::Directory );
3171                         }
3172 
3173                         CPPUNIT_ASSERT_MESSAGE( "test for getFileType function: ",
3174 				 					( bOK == sal_True ) );
3175 		}
3176                 }
3177                 // LLA: it's not a bug, if a FileStatus not exist, so no else
3178             }
3179 
3180 		void getFileType_002( )
3181 		{
3182  			::osl::FileStatus   rFileStatus( FileStatusMask_Type | FileStatusMask_FileName );
3183                 nError1 = m_aItem_2.getFileStatus( rFileStatus );
3184 
3185 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
3186                 check_FileType(rFileStatus);
3187 		}
3188 
3189 		void getFileType_003( )
3190 		{
3191 #if 0
3192 // LLA: this have to be discussed.
3193  			::osl::FileStatus   rFileStatus( FileStatusMask_Type );
3194                 nError1 = m_aVolumeItem.getFileStatus( rFileStatus );
3195 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
3196 
3197                 if (rFileStatus.isValid(FileStatusMask_Type))
3198                 {
3199                     osl::FileStatus::Type eType = rFileStatus.getFileType( );
3200 
3201 			CPPUNIT_ASSERT_MESSAGE( "test for getFileType function: Volume, it seems the volume part of the field is not implemented, it did not pass in (W32)(UNX).",
3202                                             ( eType == ::osl::FileStatus::Volume ) );
3203                 }
3204 #endif
3205 		}
3206 
3207 
3208 		void getFileType_004( )
3209 		{
3210 #if ( defined UNX ) || ( defined OS2 )	//Fifo creation is differ in Windows
3211 
3212 			//create a fifo in $ROOT/tmp/tmpdir, get its DirectoryItem.
3213 		  rtl::OString strFifoSys;
3214 		  strFifoSys = OUStringToOString( aFifoSys, RTL_TEXTENCODING_ASCII_US );
3215 		  ::rtl::OUString aFifoURL;
3216 
3217                   int fd = mkfifo( strFifoSys.getStr(), O_RDWR | O_CREAT );
3218 		  CPPUNIT_ASSERT_MESSAGE("mkfifo failed!", fd == 0 );
3219 			::osl::FileBase::getFileURLFromSystemPath( aFifoSys, aFifoURL );
3220 
3221                 nError1 = ::osl::DirectoryItem::get( aFifoURL, m_aFifoItem );
3222 			CPPUNIT_ASSERT_MESSAGE("get item failed!", ::osl::FileBase::E_None == nError1 );
3223 
3224 			//check for File type
3225  			::osl::FileStatus   rFileStatus( FileStatusMask_Type );
3226                 nError1 = m_aFifoItem.getFileStatus( rFileStatus );
3227 			CPPUNIT_ASSERT_MESSAGE("get Status failed!", ::osl::FileBase::E_None == nError1 );
3228 
3229 			//delete fifo
3230 			nError1 = ::osl::File::remove( aFifoURL );
3231 			CPPUNIT_ASSERT_MESSAGE("remove file failed!", ::osl::FileBase::E_None == nError1 );
3232 
3233                 if (rFileStatus.isValid(FileStatusMask_Type))
3234                 {
3235                     osl::FileStatus::Type eType = rFileStatus.getFileType( );
3236 
3237 			CPPUNIT_ASSERT_MESSAGE( "test for getFileType function: Fifo, Solaris version ",
3238                                             ( eType == ::osl::FileStatus::Fifo ) );
3239 		}
3240 #endif
3241 		}
3242 
3243 /*
3244  * LLA: removed, m_aSocketItem is wrong initialised.
3245  */
3246 
3247 // LLA: 		void getFileType_005( )
3248 // LLA: 		{
3249 // LLA: #if defined ( SOLARIS )	//Socket file may differ in Windows
3250 // LLA:             // nError1 = ::osl::DirectoryItem::get( aTypeURL1, m_aSocketItem );
3251 // LLA:             nError1 = ::osl::DirectoryItem::get( rtl::OUString::createFromAscii("/dev/null"), m_aSocketItem );
3252 // LLA:             printError(nError1);
3253 // LLA: 			CPPUNIT_ASSERT_MESSAGE("get Socket type file failed", ::osl::FileBase::E_None == nError1 );
3254 // LLA:
3255 // LLA: 			//check for File type
3256 // LLA:  			::osl::FileStatus   rFileStatus( FileStatusMask_Type );
3257 // LLA:
3258 // LLA:             nError1 = m_aSocketItem.getFileStatus( rFileStatus );
3259 // LLA: 			CPPUNIT_ASSERT_MESSAGE("getFileStatus failed", ::osl::FileBase::E_None == nError1 );
3260 // LLA:
3261 // LLA:             if (rFileStatus.isValid( FileStatusMask_Type ))
3262 // LLA:             {
3263 // LLA:                 osl::FileStatus::Type eType = rFileStatus.getFileType( );
3264 // LLA:                 printFileType(eType);
3265 // LLA:                 CPPUNIT_ASSERT_MESSAGE( "test for getFileType function: Socket, Solaris version ",
3266 // LLA:                                         ( eType == ::osl::FileStatus::Socket ) );
3267 // LLA:             }
3268 // LLA: #endif
3269 // LLA: 		}
3270 
3271 
3272 // deprecated since there is a same case Directory::getNextItem_004
3273 /*#if defined 0 //( UNX ) //( SOLARIS )	//Link file is not defined in Windows
3274 		void getFileType_006( )
3275 		{
3276   nError1 = ::osl::DirectoryItem::get( aTypeURL3, m_aLinkItem );
3277 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
3278 
3279 			//check for File type
3280  			::osl::FileStatus   rFileStatus( FileStatusMask_Type );
3281   nError1 = m_aLinkItem.getFileStatus( rFileStatus );
3282 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
3283 
3284 			CPPUNIT_ASSERT_MESSAGE( "test for getFileType function: Link, UNX version ",
3285 				 					( ::osl::FileStatus::Link == rFileStatus.getFileType( ) ) );
3286 		}
3287 #endif	*/
3288 
3289 		void getFileType_007( )
3290 		{
3291 #if defined ( SOLARIS )	//Special file is differ in Windows
3292                 nError1 = ::osl::DirectoryItem::get( aTypeURL2, m_aSpecialItem );
3293 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
3294 
3295 			//check for File type
3296  			::osl::FileStatus   rFileStatus( FileStatusMask_Type );
3297             nError1 = m_aSpecialItem.getFileStatus( rFileStatus );
3298 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
3299 
3300             if (rFileStatus.isValid(FileStatusMask_Type))
3301             {
3302                 osl::FileStatus::Type eType = rFileStatus.getFileType( );
3303 
3304 
3305                 CPPUNIT_ASSERT_MESSAGE( "test for getFileType function: Special, Solaris version ",
3306                                         ( eType == ::osl::FileStatus::Special ) );
3307             }
3308 #endif
3309 		}
3310 
3311 		CPPUNIT_TEST_SUITE( getFileType );
3312 		CPPUNIT_TEST( getFileType_001 );
3313 		CPPUNIT_TEST( getFileType_002 );
3314 		CPPUNIT_TEST( getFileType_003 );
3315 		CPPUNIT_TEST( getFileType_004 );
3316 		// LLA: CPPUNIT_TEST( getFileType_005 );
3317 		//CPPUNIT_TEST( getFileType_006 );
3318 		CPPUNIT_TEST( getFileType_007 );
3319 		CPPUNIT_TEST_SUITE_END( );
3320 	};// class getFileType
3321 
3322 	//---------------------------------------------------------------------
3323 	// 	testing the method
3324 	// 	inline sal_uInt64 getAttributes() const
3325 	//---------------------------------------------------------------------
3326     class  getAttributes : public CppUnit::TestFixture
3327 	{
3328 		::rtl::OUString         aTypeURL, aTypeURL_Hid;
3329 		::osl::FileBase::RC     nError;
3330 		::osl::DirectoryItem    rItem, rItem_hidden;
3331 
3332 	    public:
3333 		// initialization
3334 		void setUp( )
3335 		{
3336 			aTypeURL = aUserDirectoryURL.copy( 0 );
3337 			concatURL( aTypeURL, aTmpName2 );
3338 			createTestFile( aTypeURL );
3339 			nError = ::osl::DirectoryItem::get( aTypeURL, rItem );
3340 			CPPUNIT_ASSERT( nError == FileBase::E_None );
3341 
3342 			aTypeURL_Hid = aUserDirectoryURL.copy( 0 );
3343 			concatURL( aTypeURL_Hid, aHidURL1 );
3344 			createTestFile( aTypeURL_Hid );
3345 			nError = ::osl::DirectoryItem::get( aTypeURL_Hid, rItem_hidden );
3346 			CPPUNIT_ASSERT( nError == FileBase::E_None );
3347 		}
3348 
3349 		void tearDown( )
3350 		{
3351 			deleteTestFile( aTypeURL );
3352 			deleteTestFile( aTypeURL_Hid );
3353 		}
3354 
3355 		// test code.
3356 #if ( defined UNX ) || ( defined OS2 )
3357 //windows only 3 file attributes: normal, readonly, hidden
3358 		void getAttributes_001( )
3359 		{
3360 			changeFileMode( aTypeURL, S_IRUSR | S_IRGRP | S_IROTH );
3361 
3362   			::osl::FileStatus   rFileStatus( FileStatusMask_Attributes );
3363 			nError = rItem.getFileStatus( rFileStatus );
3364 			CPPUNIT_ASSERT( nError == FileBase::E_None );
3365 
3366 			CPPUNIT_ASSERT_MESSAGE( "test for getAttributes function: ReadOnly, GrpRead, OwnRead, OthRead( UNX version ) ",
3367 		                            ( Attribute_ReadOnly | Attribute_GrpRead | Attribute_OwnRead | Attribute_OthRead ) ==
3368 		                            rFileStatus.getAttributes( ) );
3369 		}
3370 #else                                    //Windows version
3371 		void getAttributes_001( )
3372 		{
3373 			CPPUNIT_ASSERT_MESSAGE( "test for getAttributes function: ReadOnly, GrpRead, OwnRead, OthRead( Windows version )",
3374 				 					1 == 1 );
3375 		}
3376 #endif
3377 
3378 
3379 		void getAttributes_002( )
3380 		{
3381 #if ( defined UNX ) || ( defined OS2 )
3382 			changeFileMode( aTypeURL, S_IXUSR | S_IXGRP | S_IXOTH );
3383 
3384   			::osl::FileStatus   rFileStatus( FileStatusMask_Attributes );
3385 			nError = rItem.getFileStatus( rFileStatus );
3386 			CPPUNIT_ASSERT( nError == FileBase::E_None );
3387 
3388 			CPPUNIT_ASSERT_MESSAGE( "test for getAttributes function: Executable, GrpExe, OwnExe, OthExe, the result is Readonly, Executable, GrpExe, OwnExe, OthExe, it partly not pass( Solaris version )",
3389 		                            ( Attribute_ReadOnly | Attribute_Executable | Attribute_GrpExe | Attribute_OwnExe | Attribute_OthExe ) ==
3390 		                            rFileStatus.getAttributes( ) );
3391 #endif
3392 		}
3393 
3394 
3395 #if ( defined UNX ) || ( defined OS2 )
3396 		void getAttributes_003( )
3397 		{
3398 			changeFileMode( aTypeURL, S_IWUSR | S_IWGRP | S_IWOTH );
3399 
3400   			::osl::FileStatus   rFileStatus( FileStatusMask_Attributes );
3401 			nError = rItem.getFileStatus( rFileStatus );
3402 			CPPUNIT_ASSERT( nError == FileBase::E_None );
3403 
3404 			CPPUNIT_ASSERT_MESSAGE( "test for getAttributes function: GrpWrite, OwnWrite, OthWrite( Solaris version )",
3405 		                            ( Attribute_GrpWrite | Attribute_OwnWrite | Attribute_OthWrite ) ==
3406 		                            rFileStatus.getAttributes( ) );
3407 		}
3408 #else                                    //Windows version
3409 		void getAttributes_003( )
3410 		{
3411 			CPPUNIT_ASSERT_MESSAGE( "test for getAttributes function: GrpWrite, OwnWrite, OthWrite( Windows version )",
3412 				 					1 == 1 );
3413 		}
3414 #endif
3415 
3416 #if ( defined UNX ) || ( defined OS2 )	//hidden file definition may different in Windows
3417 		void getAttributes_004( )
3418 		{
3419 			sal_Int32 test_Attributes = Attribute_Hidden;
3420   			::osl::FileStatus   rFileStatus( FileStatusMask_Attributes );
3421 			nError = rItem_hidden.getFileStatus( rFileStatus );
3422 			CPPUNIT_ASSERT( nError == FileBase::E_None );
3423 			test_Attributes &= rFileStatus.getAttributes( );
3424 
3425 			CPPUNIT_ASSERT_MESSAGE( "test for getAttributes function: Hidden files( Solaris version )",
3426 		                            test_Attributes == Attribute_Hidden );
3427 		}
3428 #else                                    //Windows version
3429 		void getAttributes_004( )
3430 		{
3431 			::rtl::OUString aUserHiddenFileURL = ::rtl::OUString::createFromAscii("file:///c:/AUTOEXEC.BAT");
3432 			nError = ::osl::DirectoryItem::get( aUserHiddenFileURL, rItem_hidden );
3433 			//printFileName( aUserHiddenFileURL );
3434 			CPPUNIT_ASSERT_MESSAGE("get item fail", nError == FileBase::E_None );
3435   			::osl::FileStatus   rFileStatus( FileStatusMask_Attributes );
3436 			nError = rItem_hidden.getFileStatus( rFileStatus );
3437 			CPPUNIT_ASSERT( nError == FileBase::E_None );
3438 
3439 			CPPUNIT_ASSERT_MESSAGE( "Hidden files(Windows version), please check if hidden file c:/AUTOEXEC.BAT exists ",
3440 		                            (rFileStatus.getAttributes( ) & Attribute_Hidden)!= 0 );
3441 		}
3442 #endif
3443 
3444 		CPPUNIT_TEST_SUITE( getAttributes );
3445 		CPPUNIT_TEST( getAttributes_001 );
3446 		CPPUNIT_TEST( getAttributes_002 );
3447 		CPPUNIT_TEST( getAttributes_003 );
3448 		CPPUNIT_TEST( getAttributes_004 );
3449 		CPPUNIT_TEST_SUITE_END( );
3450 	};// class getAttributes
3451 
3452 	//---------------------------------------------------------------------
3453 	// 	testing the method
3454 	// 	inline TimeValue getAccessTime() const
3455 	//---------------------------------------------------------------------
3456     class  getAccessTime : public CppUnit::TestFixture
3457 	{
3458 		::rtl::OUString         aTypeURL;
3459 		::osl::FileBase::RC     nError;
3460 		::osl::DirectoryItem    rItem;
3461 
3462 	    public:
3463 		// initialization
3464 		void setUp( )
3465 		{
3466 			aTypeURL = aUserDirectoryURL.copy( 0 );
3467 			concatURL( aTypeURL, aTmpName2 );
3468 			createTestFile( aTypeURL );
3469 			nError = ::osl::DirectoryItem::get( aTypeURL, rItem );
3470 			CPPUNIT_ASSERT( nError == FileBase::E_None );
3471 
3472 		}
3473 
3474 		void tearDown( )
3475 		{
3476 			deleteTestFile( aTypeURL );
3477 		}
3478 
3479 		// test code.
3480 		void getAccessTime_001( )
3481 		{
3482 			TimeValue *pTV_current = NULL;
3483 			CPPUNIT_ASSERT( ( pTV_current = ( TimeValue* )malloc( sizeof( TimeValue ) ) ) != NULL );
3484 			TimeValue *pTV_access = NULL;
3485 			CPPUNIT_ASSERT( ( pTV_access = ( TimeValue* )malloc( sizeof( TimeValue ) ) ) != NULL );
3486 
3487   			::osl::FileStatus   rFileStatus( FileStatusMask_AccessTime );
3488 			nError = rItem.getFileStatus( rFileStatus );
3489 			sal_Bool bOk = osl_getSystemTime( pTV_current );
3490 			CPPUNIT_ASSERT( sal_True == bOk && nError == FileBase::E_None );
3491 
3492 			*pTV_access = rFileStatus.getAccessTime( );
3493 
3494 			sal_Bool bOK = t_compareTime( pTV_access, pTV_current, delta );
3495 			free( pTV_current );
3496 			free( pTV_access );
3497 
3498 			CPPUNIT_ASSERT_MESSAGE( "test for getAccessTime function: This test turns out that UNX pricision is no more than 1 sec, don't know how to test this function, in Windows test, it lost hour min sec, only have date time. ",
3499 		                            sal_True == bOK );
3500 		}
3501 
3502 		CPPUNIT_TEST_SUITE( getAccessTime );
3503 		CPPUNIT_TEST( getAccessTime_001 );
3504 		CPPUNIT_TEST_SUITE_END( );
3505 	};// class getAccessTime
3506 
3507 	//---------------------------------------------------------------------
3508 	// 	testing the method
3509 	// 	inline TimeValue getModifyTime() const
3510 	//---------------------------------------------------------------------
3511     class  getModifyTime : public CppUnit::TestFixture
3512 	{
3513 		::rtl::OUString         aTypeURL;
3514 		::osl::FileBase::RC     nError;
3515 		::osl::DirectoryItem    rItem;
3516 
3517 	    public:
3518 
3519 		// test code.
3520 		void getModifyTime_001( )
3521 		{
3522 			TimeValue *pTV_current = NULL;
3523 			CPPUNIT_ASSERT( ( pTV_current = ( TimeValue* )malloc( sizeof( TimeValue ) ) ) != NULL );
3524 
3525 			//create file
3526 			aTypeURL = aUserDirectoryURL.copy( 0 );
3527 			concatURL( aTypeURL, aTmpName2 );
3528 			createTestFile( aTypeURL );
3529 
3530 			//get current time
3531 			sal_Bool bOk = osl_getSystemTime( pTV_current );
3532 			CPPUNIT_ASSERT( sal_True == bOk );
3533 
3534 			//get instance item and filestatus
3535 			nError = ::osl::DirectoryItem::get( aTypeURL, rItem );
3536 			CPPUNIT_ASSERT( nError == FileBase::E_None );
3537 			::osl::FileStatus   rFileStatus( FileStatusMask_ModifyTime );
3538 			nError = rItem.getFileStatus( rFileStatus );
3539 			CPPUNIT_ASSERT( nError == FileBase::E_None );
3540 
3541 			//get modify time
3542 			TimeValue *pTV_modify = NULL;
3543 			CPPUNIT_ASSERT( ( pTV_modify = ( TimeValue* )malloc( sizeof( TimeValue ) ) ) != NULL );
3544 			*pTV_modify = rFileStatus.getModifyTime( );
3545 
3546 			sal_Bool bOK = t_compareTime( pTV_modify, pTV_current, delta );
3547 			//delete file
3548 			deleteTestFile( aTypeURL );
3549 			free( pTV_current );
3550 
3551 			CPPUNIT_ASSERT_MESSAGE( "test for getModifyTime function: This test turns out that UNX pricision is no more than 1 sec, don't know how to improve this function.  ",
3552 		                            sal_True == bOK );
3553 		}
3554 
3555 		CPPUNIT_TEST_SUITE( getModifyTime );
3556 		CPPUNIT_TEST( getModifyTime_001 );
3557 		CPPUNIT_TEST_SUITE_END( );
3558 	};// class getModifyTime
3559 
3560 
3561 	//---------------------------------------------------------------------
3562 	// 	testing the method
3563 	// 	inline sal_uInt64 getFileSize() const
3564 	//---------------------------------------------------------------------
3565     class  getFileSize : public CppUnit::TestFixture
3566 	{
3567 		::rtl::OUString         aTypeURL;
3568 		::osl::FileBase::RC     nError;
3569 		::osl::DirectoryItem    rItem;
3570 
3571 	    public:
3572 		// initialization
3573 		void setUp( )
3574 		{
3575 			aTypeURL = aUserDirectoryURL.copy( 0 );
3576 			concatURL( aTypeURL, aTmpName2 );
3577 			createTestFile( aTypeURL );
3578 			nError = ::osl::DirectoryItem::get( aTypeURL, rItem );
3579 			CPPUNIT_ASSERT( nError == FileBase::E_None );
3580 		}
3581 
3582 		void tearDown( )
3583 		{
3584 			deleteTestFile( aTypeURL );
3585 		}
3586 
3587 		// test code.
3588 		void getFileSize_001( )
3589 		{
3590   			::osl::FileStatus   rFileStatus( FileStatusMask_FileSize );
3591 			nError = rItem.getFileStatus( rFileStatus );
3592 			CPPUNIT_ASSERT( nError == FileBase::E_None );
3593 
3594 			sal_uInt64 uFileSize = rFileStatus.getFileSize( );
3595 
3596 			CPPUNIT_ASSERT_MESSAGE( "test for getFileSize function: empty file ",
3597 		                            0 == uFileSize );
3598 		}
3599 
3600 		void getFileSize_002( )
3601 		{
3602 			::osl::File testfile( aTypeURL );
3603 			nError = testfile.open( OpenFlag_Write | OpenFlag_Read );
3604 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError );
3605 			nError = testfile.setSize( TEST_FILE_SIZE );
3606 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError );
3607 
3608 			nError = ::osl::DirectoryItem::get( aTypeURL, rItem );
3609 			CPPUNIT_ASSERT( nError == FileBase::E_None );
3610   			::osl::FileStatus   rFileStatus( FileStatusMask_FileSize );
3611 			nError = rItem.getFileStatus( rFileStatus );
3612 			CPPUNIT_ASSERT( nError == FileBase::E_None );
3613 			sal_uInt64 uFileSize = rFileStatus.getFileSize( );
3614 
3615 			CPPUNIT_ASSERT_MESSAGE( "test for getFileSize function: file with size of TEST_FILE_SIZE, did not pass in (W32). ",
3616 		                            TEST_FILE_SIZE == uFileSize );
3617 		}
3618 		CPPUNIT_TEST_SUITE( getFileSize );
3619 		CPPUNIT_TEST( getFileSize_001 );
3620 		CPPUNIT_TEST( getFileSize_002 );
3621 		CPPUNIT_TEST_SUITE_END( );
3622 	};// class getFileSize
3623 
3624 	//---------------------------------------------------------------------
3625 	// 	testing the method
3626 	// 	inline ::rtl::OUString getFileName() const
3627 	//---------------------------------------------------------------------
3628     class  getFileName : public CppUnit::TestFixture
3629 	{
3630 		::rtl::OUString         aTypeURL;
3631 		::osl::FileBase::RC     nError;
3632 		::osl::DirectoryItem    rItem;
3633 
3634 	    public:
3635 		// initialization
3636 		void setUp( )
3637 		{
3638 			aTypeURL = aUserDirectoryURL.copy( 0 );
3639 			concatURL( aTypeURL, aTmpName2 );
3640 			createTestFile( aTypeURL );
3641 			nError = ::osl::DirectoryItem::get( aTypeURL, rItem );
3642 			CPPUNIT_ASSERT( nError == FileBase::E_None );
3643 		}
3644 
3645 		void tearDown( )
3646 		{
3647 			deleteTestFile( aTypeURL );
3648 		}
3649 
3650 		// test code.
3651 		void getFileName_001( )
3652 		{
3653   			::osl::FileStatus   rFileStatus( FileStatusMask_FileName );
3654 			nError = rItem.getFileStatus( rFileStatus );
3655 			CPPUNIT_ASSERT( nError == FileBase::E_None );
3656 
3657 			::rtl::OUString aFileName = rFileStatus.getFileName( );
3658 
3659 			CPPUNIT_ASSERT_MESSAGE( "test for getFileName function: name compare with specify",
3660 		                            sal_True == compareFileName( aFileName, aTmpName2 ) );
3661 		}
3662 
3663 		CPPUNIT_TEST_SUITE( getFileName );
3664 		CPPUNIT_TEST( getFileName_001 );
3665 		CPPUNIT_TEST_SUITE_END( );
3666 	};// class getFileName
3667 
3668 	//---------------------------------------------------------------------
3669 	// 	testing the method
3670 	// 	inline ::rtl::OUString getFileURL() const
3671 	//---------------------------------------------------------------------
3672     class  getFileURL : public CppUnit::TestFixture
3673 	{
3674 		::rtl::OUString         aTypeURL;
3675 		::osl::FileBase::RC     nError;
3676 		::osl::DirectoryItem    rItem;
3677 
3678 	    public:
3679 		// initialization
3680 		void setUp( )
3681 		{
3682 			createTestFile( aTmpName6 );
3683 			nError = ::osl::DirectoryItem::get( aTmpName6, rItem );
3684 			CPPUNIT_ASSERT( nError == FileBase::E_None );
3685 		}
3686 
3687 		void tearDown( )
3688 		{
3689 			deleteTestFile( aTmpName6 );
3690 		}
3691 
3692 		// test code.
3693 		void getFileURL_001( )
3694 		{
3695   			::osl::FileStatus   rFileStatus( FileStatusMask_FileURL );
3696 			nError = rItem.getFileStatus( rFileStatus );
3697 			CPPUNIT_ASSERT( nError == FileBase::E_None );
3698 
3699 			::rtl::OUString aFileURL = rFileStatus.getFileURL( );
3700 
3701 			CPPUNIT_ASSERT_MESSAGE( "test for getFileURL function: ",
3702 		                            sal_True == compareFileName( aFileURL, aTmpName6 ) );
3703 		}
3704 
3705 		CPPUNIT_TEST_SUITE( getFileURL );
3706 		CPPUNIT_TEST( getFileURL_001 );
3707 		CPPUNIT_TEST_SUITE_END( );
3708 	};// class getFileURL
3709 
3710 	//---------------------------------------------------------------------
3711 	// 	testing the method
3712 	// 	inline ::rtl::OUString getLinkTargetURL() const
3713 	//---------------------------------------------------------------------
3714     class  getLinkTargetURL : public CppUnit::TestFixture
3715 	{
3716 		::rtl::OUString         aTypeURL;
3717 		::osl::FileBase::RC     nError;
3718 		::osl::DirectoryItem    rItem;
3719 
3720 	    public:
3721 		// test code.
3722 		// initialization
3723 		void setUp( )
3724 		{
3725 			aTypeURL = aUserDirectoryURL.copy( 0 );
3726 			concatURL( aTypeURL, aTmpName2 );
3727 			createTestFile( aTypeURL );
3728 		}
3729 
3730 		void tearDown( )
3731 		{
3732 			deleteTestFile( aTypeURL );
3733 		}
3734 
3735 #if ( defined UNX ) || ( defined OS2 )	       //Link file is not define in Windows
3736 		void getLinkTargetURL_001( )
3737 		{
3738 			//create a link file;
3739 			::rtl::OUString aUStr_LnkFileSys( aTempDirectorySys ), aUStr_SrcFileSys( aTempDirectorySys );
3740 			( ( aUStr_LnkFileSys += aSlashURL ) += getCurrentPID( ) ) += ::rtl::OUString::createFromAscii("/link.file");
3741 			( ( aUStr_SrcFileSys += aSlashURL ) += getCurrentPID( ) ) += ::rtl::OUString::createFromAscii("/tmpname");
3742 
3743                 rtl::OString strLinkFileName, strSrcFileName;
3744                 strLinkFileName = OUStringToOString( aUStr_LnkFileSys, RTL_TEXTENCODING_ASCII_US );
3745                 strSrcFileName  = OUStringToOString( aUStr_SrcFileSys, RTL_TEXTENCODING_ASCII_US );
3746 
3747 			sal_Int32 fd;
3748                 fd = symlink( strSrcFileName.getStr(), strLinkFileName.getStr() );
3749 			CPPUNIT_ASSERT_MESSAGE( "in creating link file",  fd == 0 );
3750 
3751 			//get linkTarget URL
3752 			nError = ::osl::DirectoryItem::get( aLnkURL1, rItem );
3753 			CPPUNIT_ASSERT_MESSAGE( "in getting link file item", nError == FileBase::E_None );
3754 
3755   			::osl::FileStatus   rFileStatus( FileStatusMask_LinkTargetURL );
3756 			nError = rItem.getFileStatus( rFileStatus );
3757 			CPPUNIT_ASSERT_MESSAGE( "in getting link file status", nError == FileBase::E_None );
3758 			::rtl::OUString aFileURL = rFileStatus.getLinkTargetURL( );
3759 
3760 			//remove link file
3761                 fd = remove( strLinkFileName.getStr() );
3762 			CPPUNIT_ASSERT_MESSAGE( "in deleting link file",  fd == 0 );
3763 
3764 			CPPUNIT_ASSERT_MESSAGE( "test for getLinkTargetURL function: Solaris version, creat a file, and a link file link to it, get its LinkTargetURL and compare",
3765 		                            sal_True == compareFileName( aFileURL, aTypeURL ) );
3766 		}
3767 #else
3768 		void getLinkTargetURL_001( )
3769 		{
3770 			CPPUNIT_ASSERT_MESSAGE( "test for getLinkTargetURL function: Windows version, not tested",
3771 		                            1 );
3772 		}
3773 #endif
3774 
3775 		CPPUNIT_TEST_SUITE( getLinkTargetURL );
3776 		CPPUNIT_TEST( getLinkTargetURL_001 );
3777 		CPPUNIT_TEST_SUITE_END( );
3778 	};// class getLinkTargetURL
3779 
3780 	// -----------------------------------------------------------------------------
3781 	CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_FileStatus::ctors, "osl_FileStatus" );
3782 	CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_FileStatus::isValid, "osl_FileStatus" );
3783 	CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_FileStatus::getFileType, "osl_FileStatus" );
3784 	CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_FileStatus::getAttributes, "osl_FileStatus" );
3785 	CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_FileStatus::getAccessTime, "osl_FileStatus" );
3786 	CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_FileStatus::getModifyTime, "osl_FileStatus" );
3787 	CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_FileStatus::getFileSize, "osl_FileStatus" );
3788 	CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_FileStatus::getFileName, "osl_FileStatus" );
3789 	CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_FileStatus::getFileURL, "osl_FileStatus" );
3790 	CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_FileStatus::getLinkTargetURL, "osl_FileStatus" );
3791 }// namespace osl_FileStatus
3792 
3793 
3794 
3795 //------------------------------------------------------------------------
3796 // Beginning of the test cases for File class
3797 //------------------------------------------------------------------------
3798 namespace osl_File
3799 {
3800 	//---------------------------------------------------------------------
3801 	// 	testing the method
3802 	// 	File( const ::rtl::OUString& ustrFileURL )
3803 	//---------------------------------------------------------------------
3804     class  ctors : public CppUnit::TestFixture
3805 	{
3806 		// ::osl::FileBase::RC     nError1;
3807 
3808 	    public:
3809 		// initialization
3810 		void setUp( )
3811 		{
3812 			// create a tempfile in $TEMP/tmpdir/tmpname.
3813 			createTestDirectory( aTmpName3 );
3814 			createTestFile( aTmpName4 );
3815 		}
3816 
3817 		void tearDown( )
3818 		{
3819 			// remove the tempfile in $TEMP/tmpdir/tmpname.
3820 			deleteTestFile( aTmpName4 );
3821 			deleteTestDirectory( aTmpName3 );
3822 		}
3823 
3824 		// test code.
3825 		void ctors_001( )
3826 		{
3827 			::osl::File testFile( aTmpName4 );
3828 
3829             ::osl::FileBase::RC nError1 = testFile.open( OpenFlag_Read | OpenFlag_Write );
3830             ::osl::FileBase::RC nError2 = testFile.close( );
3831 			CPPUNIT_ASSERT_MESSAGE( "test for ctors function: initialize a File and test its open and close",
3832 				 					( ::osl::FileBase::E_None == nError1 ) && ( ::osl::FileBase::E_None == nError2 ) );
3833 		}
3834 
3835 		void ctors_002( )
3836 		{
3837 			::osl::File testFile( aTmpName5 );
3838 			sal_Char buffer[30] = "Test for File constructor";
3839 			sal_uInt64 nCount;
3840 
3841                 ::osl::FileBase::RC nError1 = testFile.open( OpenFlag_Read | OpenFlag_Write );
3842                 ::osl::FileBase::RC nError2 = testFile.write( buffer, 30, nCount );
3843 			testFile.close( );
3844 
3845 			CPPUNIT_ASSERT_MESSAGE( "test for ctors function: test relative file URL, this test show that relative file URL is also acceptable",
3846 				 					( ::osl::FileBase::E_None == nError1 ) && ( ::osl::FileBase::E_None == nError2 )  );
3847 		}
3848 
3849 		CPPUNIT_TEST_SUITE( ctors );
3850 		CPPUNIT_TEST( ctors_001 );
3851 		CPPUNIT_TEST( ctors_002 );
3852 		CPPUNIT_TEST_SUITE_END( );
3853 	};// class ctors
3854 
3855 	//---------------------------------------------------------------------
3856 	// 	testing the method
3857 	// 	inline RC open( sal_uInt32 uFlags )
3858 	//---------------------------------------------------------------------
3859     class  open : public CppUnit::TestFixture
3860 	{
3861 		::osl::FileBase::RC     nError1, nError2, nError3;
3862 
3863 	    public:
3864 		// initialization
3865 		void setUp( )
3866 		{
3867 			// create a tempfile in $TEMP/tmpdir/tmpname.
3868 			createTestDirectory( aTmpName3 );
3869 			createTestFile( aTmpName4 );
3870 		}
3871 
3872 		void tearDown( )
3873 		{
3874 			// remove the tempfile in $TEMP/tmpdir/tmpname.
3875 			deleteTestFile( aTmpName4 );
3876 			deleteTestDirectory( aTmpName3 );
3877 		}
3878 
3879 		// test code.
3880 		void open_001( )
3881 		{
3882 			::osl::File testFile( aTmpName4 );
3883 
3884 			nError1 = testFile.open( OpenFlag_Read | OpenFlag_Write );
3885 			nError2 = testFile.close( );
3886 			CPPUNIT_ASSERT_MESSAGE("close error", ::osl::FileBase::E_None == nError2 );
3887 
3888 			CPPUNIT_ASSERT_MESSAGE( "test for open function: open a regular file",
3889 				 					::osl::FileBase::E_None == nError1 );
3890 		}
3891 
3892 		void open_002( )
3893 		{
3894 			::osl::File testFile( aTmpName3 );
3895 
3896 			nError1 = testFile.open( OpenFlag_Read );
3897 
3898 			CPPUNIT_ASSERT_MESSAGE( "test for open function: open a directory",
3899 				 					( File::E_INVAL == nError1 ) || ( File::E_ACCES == nError1 ) );
3900 		}
3901 
3902 		void open_003( )
3903 		{
3904 			::osl::File testFile( aCanURL1 );
3905 
3906 			nError1 = testFile.open( OpenFlag_Read | OpenFlag_Write );
3907 
3908 			CPPUNIT_ASSERT_MESSAGE( "test for open function: open a non-exist file",
3909 				 					File::E_NOENT == nError1 );
3910 		}
3911 
3912 		void open_004( )
3913 		{
3914 			::rtl::OUString  aTestFile( aRootURL );
3915 			concatURL( aTestFile, aTmpName2 );
3916 			::osl::File testFile( aTestFile );
3917 
3918 			nError1 = testFile.open( OpenFlag_Create );
3919 			sal_Bool bOK = ( File::E_ACCES == nError1 );
3920 #if defined (WNT )
3921 			bOK = sal_True;  /// in Windows, you can create file in c:/ any way.
3922 			testFile.close( );
3923 			deleteTestFile( aTestFile);
3924 #endif
3925 
3926 			CPPUNIT_ASSERT_MESSAGE( "test for open function: create an illegal file",
3927 				 					 bOK == sal_True );
3928 		}
3929 
3930 		void open_005( )
3931 		{
3932 			::osl::File testFile( aTmpName4 );
3933 
3934 			nError1 = testFile.open( OpenFlag_Create );
3935 
3936 			CPPUNIT_ASSERT_MESSAGE( "test for open function: create an exist file",
3937 				 					File::E_EXIST == nError1 );
3938 		}
3939 
3940 		void open_006( )
3941 		{
3942 			::osl::File testFile( aCanURL1 );
3943 			sal_Char buffer_write[30] = "Test for File open";
3944 			sal_Char buffer_read[30];
3945 			sal_uInt64 nCount_write, nCount_read;
3946 
3947 			nError1 = testFile.open( OpenFlag_Read | OpenFlag_Write | OpenFlag_Create );
3948 			nError2 = testFile.write( buffer_write, 30, nCount_write );
3949  			::osl::FileBase::RC nError4 = testFile.setPos( Pos_Absolut, 0 );
3950 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError4 );
3951 			nError3 = testFile.read( buffer_read, 10, nCount_read );
3952 
3953  			::osl::FileBase::RC nError5 = testFile.close( );
3954 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError5 );
3955 			::osl::FileBase::RC nError6 = testFile.remove( aCanURL1 );
3956 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError6 );
3957 
3958 			CPPUNIT_ASSERT_MESSAGE( "test for open function: test for OpenFlag_Read,OpenFlag_Write and OpenFlag_Create",
3959 			                        ( ::osl::FileBase::E_None == nError1 ) &&
3960 			                        ( ::osl::FileBase::E_None == nError2 ) &&
3961 			                        ( ::osl::FileBase::E_None == nError3 ) &&
3962 			                        ( 30 == nCount_write ) &&
3963 			                        ( 10 == nCount_read ) );
3964 		}
3965 
3966 		CPPUNIT_TEST_SUITE( open );
3967 		CPPUNIT_TEST( open_001 );
3968 		CPPUNIT_TEST( open_002 );
3969 		CPPUNIT_TEST( open_003 );
3970 		CPPUNIT_TEST( open_004 );
3971 		CPPUNIT_TEST( open_005 );
3972 		CPPUNIT_TEST( open_006 );
3973 		CPPUNIT_TEST_SUITE_END( );
3974 	};// class open
3975 
3976 	//---------------------------------------------------------------------
3977 	// 	testing the method
3978 	// 	inline RC close()
3979 	//---------------------------------------------------------------------
3980     class  close : public CppUnit::TestFixture
3981 	{
3982 		::osl::FileBase::RC     nError1, nError2, nError3;
3983 
3984 	    public:
3985 		// initialization
3986 		void setUp( )
3987 		{
3988 			// create a tempfile in $TEMP/tmpdir/tmpname.
3989 			createTestDirectory( aTmpName3 );
3990 			createTestFile( aTmpName4 );
3991 		}
3992 
3993 		void tearDown( )
3994 		{
3995 			// remove the tempfile in $TEMP/tmpdir/tmpname.
3996 			deleteTestFile( aTmpName4 );
3997 			deleteTestDirectory( aTmpName3 );
3998 		}
3999 
4000 		// test code.
4001 		void close_001( )
4002 		{
4003 			::osl::File testFile( aTmpName4 );
4004 
4005 			nError1 = testFile.open( OpenFlag_Read | OpenFlag_Write );
4006 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4007 
4008 			nError2 = testFile.close( );
4009 
4010 			CPPUNIT_ASSERT_MESSAGE( "test for close function: close a regular file",
4011 				 					::osl::FileBase::E_None == nError2 );
4012 		}
4013 
4014 		void close_002( )
4015 		{
4016 			::osl::File testFile( aTmpName4 );
4017 
4018 			nError1 = testFile.open( OpenFlag_Read | OpenFlag_Write );
4019 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4020 
4021 			nError2 = testFile.close( );
4022 
4023  			nError3 = testFile.setPos( Pos_Absolut, 0 );
4024 
4025 			CPPUNIT_ASSERT_MESSAGE( "test for close function: manipulate a file after it has been closed",
4026 				 					( ::osl::FileBase::E_None == nError2 ) &&
4027 			                        ( ::osl::FileBase::E_None != nError3 ) );
4028 		}
4029 
4030 		CPPUNIT_TEST_SUITE( close );
4031 		CPPUNIT_TEST( close_001 );
4032 		CPPUNIT_TEST( close_002 );
4033 		CPPUNIT_TEST_SUITE_END( );
4034 	};// class close
4035 
4036 
4037 	//---------------------------------------------------------------------
4038 	// 	testing the method
4039 	// 	inline RC setPos( sal_uInt32 uHow, sal_Int64 uPos )
4040 	//---------------------------------------------------------------------
4041     class  setPos : public CppUnit::TestFixture
4042 	{
4043 		::osl::FileBase::RC     nError1;
4044 		sal_uInt64 nCount_write, nCount_read;
4045 
4046 	    public:
4047 		// initialization
4048 		void setUp( )
4049 		{
4050 			// create a tempfile in $TEMP/tmpdir/tmpname.
4051 			createTestDirectory( aTmpName3 );
4052 			createTestFile( aTmpName4 );
4053 
4054 			//write chars into the file.
4055 			::osl::File testFile( aTmpName4 );
4056 
4057 			nError1 = testFile.open( OpenFlag_Write );
4058 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4059 			nError1 = testFile.write( pBuffer_Char, sizeof( pBuffer_Char ), nCount_write );
4060 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4061  			nError1 = testFile.close( );
4062 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4063 		}
4064 
4065 		void tearDown( )
4066 		{
4067 			// remove the tempfile in $TEMP/tmpdir/tmpname.
4068 			deleteTestFile( aTmpName4 );
4069 			deleteTestDirectory( aTmpName3 );
4070 		}
4071 
4072 		// test code.
4073 		void setPos_001( )
4074 		{
4075 			::osl::File testFile( aTmpName4 );
4076 			sal_Char buffer_read[2];
4077 
4078 			nError1 = testFile.open( OpenFlag_Read | OpenFlag_Write );
4079 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4080  			nError1 = testFile.setPos( Pos_Absolut, 26 );
4081 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4082 			nError1 = testFile.read( buffer_read, 1, nCount_read );
4083 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4084 			nError1 = testFile.close( );
4085 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4086 
4087 			CPPUNIT_ASSERT_MESSAGE( "test for setPos function: test for Pos_Absolut, set the position to 26, test if the 26th char in file is correct",
4088 				 					buffer_read[0] == pBuffer_Char[26] );
4089 		}
4090 
4091 		void setPos_002( )
4092 		{
4093 			::osl::File testFile( aTmpName4 );
4094 			sal_Char buffer_read[2];
4095 
4096 			nError1 = testFile.open( OpenFlag_Read | OpenFlag_Write );
4097 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4098  			nError1 = testFile.setPos( Pos_Absolut, sizeof( pBuffer_Char ) - 2 );
4099 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4100  			nError1 = testFile.setPos( Pos_Current, 0);
4101 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4102 			nError1 = testFile.read( buffer_read, 1, nCount_read );
4103 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4104 			nError1 = testFile.close( );
4105 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4106 
4107 			CPPUNIT_ASSERT_MESSAGE( "test for setPos function: test for Pos_Current, set the position to end, test if the ( end -1 ) char in file is correct",
4108 				 					buffer_read[0] == pBuffer_Char[sizeof( pBuffer_Char ) - 2] );
4109 		}
4110 
4111 		void setPos_003( )
4112 		{
4113 			::osl::File testFile( aTmpName4 );
4114 			sal_Char buffer_read[2];
4115 
4116 			nError1 = testFile.open( OpenFlag_Read | OpenFlag_Write );
4117 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4118 			//the file size is smaller than 100
4119 			nError1 = testFile.setPos( Pos_End,  -100 );
4120 			CPPUNIT_ASSERT_MESSAGE( "should return error", ::osl::FileBase::E_INVAL == nError1 );
4121 
4122  			nError1 = testFile.setPos( Pos_End, -53 );
4123 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4124 			nError1 = testFile.read( buffer_read, 1, nCount_read );
4125 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4126 			nError1 = testFile.close( );
4127 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4128 
4129 			CPPUNIT_ASSERT_MESSAGE( "test for setPos function: test for Pos_End, set the position to end, test if the first char in file is correct",
4130 				 					buffer_read[0] == pBuffer_Char[0] );
4131 		}
4132 
4133 		CPPUNIT_TEST_SUITE( setPos );
4134 		CPPUNIT_TEST( setPos_001 );
4135 		CPPUNIT_TEST( setPos_002 );
4136 		CPPUNIT_TEST( setPos_003 );
4137 		CPPUNIT_TEST_SUITE_END( );
4138 	};// class setPos
4139 
4140 	//---------------------------------------------------------------------
4141 	// 	testing the method
4142 	// 	inline RC getPos( sal_uInt64& uPos )
4143 	//---------------------------------------------------------------------
4144     class  getPos : public CppUnit::TestFixture
4145 	{
4146 		::osl::FileBase::RC      nError1;
4147 		sal_uInt64 nCount_write, nCount_read;
4148 
4149 	    public:
4150 		// initialization
4151 		void setUp( )
4152 		{
4153 			// create a tempfile in $TEMP/tmpdir/tmpname.
4154 			createTestDirectory( aTmpName3 );
4155 			createTestFile( aTmpName4 );
4156 
4157 			//write chars into the file.
4158 			::osl::File testFile( aTmpName4 );
4159 
4160 			nError1 = testFile.open( OpenFlag_Write );
4161 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4162 			nError1 = testFile.write( pBuffer_Char, sizeof( pBuffer_Char ), nCount_write );
4163 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4164  			nError1 = testFile.close( );
4165 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4166 		}
4167 
4168 		void tearDown( )
4169 		{
4170 			// remove the tempfile in $TEMP/tmpdir/tmpname.
4171 			deleteTestFile( aTmpName4 );
4172 			deleteTestDirectory( aTmpName3 );
4173 		}
4174 
4175 		// test code.
4176 		void getPos_001( )
4177 		{
4178 			::osl::File testFile( aTmpName4 );
4179 			sal_uInt64 nFilePointer;
4180 
4181 			nError1 = testFile.getPos( nFilePointer );
4182 			CPPUNIT_ASSERT( ::osl::FileBase::E_INVAL == nError1 );
4183 
4184 			nError1 = testFile.open( OpenFlag_Read | OpenFlag_Write );
4185 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4186 
4187  			nError1 = testFile.setPos( Pos_Absolut, 26 );
4188 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4189  			nError1 = testFile.getPos( nFilePointer );
4190 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4191 
4192 			nError1 = testFile.close( );
4193 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4194 
4195 			CPPUNIT_ASSERT_MESSAGE( "test for getPos function: set the position to 26, get position and check if it is right",
4196 				 					26 == nFilePointer );
4197 		}
4198 
4199 		CPPUNIT_TEST_SUITE( getPos );
4200 		CPPUNIT_TEST( getPos_001 );
4201 		CPPUNIT_TEST_SUITE_END( );
4202 	};// class getPos
4203 
4204 
4205 	//---------------------------------------------------------------------
4206 	// 	testing the method
4207 	// 	inline RC isEndOfFile( sal_Bool *pIsEOF )
4208 	//---------------------------------------------------------------------
4209     class  isEndOfFile : public CppUnit::TestFixture
4210 	{
4211 		::osl::FileBase::RC      nError1;
4212 		sal_uInt64 nCount_write, nCount_read;
4213 
4214 	    public:
4215 		// initialization
4216 		void setUp( )
4217 		{
4218 			// create a tempfile in $TEMP/tmpdir/tmpname.
4219 			createTestDirectory( aTmpName3 );
4220 			createTestFile( aTmpName4 );
4221 
4222 			//write chars into the file.
4223 			::osl::File testFile( aTmpName4 );
4224 
4225 			nError1 = testFile.open( OpenFlag_Write );
4226 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4227 			nError1 = testFile.write( pBuffer_Char, sizeof( pBuffer_Char ), nCount_write );
4228 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4229  			nError1 = testFile.close( );
4230 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4231 		}
4232 
4233 		void tearDown( )
4234 		{
4235 			// remove the tempfile in $TEMP/tmpdir/tmpname.
4236 			deleteTestFile( aTmpName4 );
4237 			deleteTestDirectory( aTmpName3 );
4238 		}
4239 
4240 		// test code.
4241 		void isEndOfFile_001( )
4242 		{
4243 			::osl::File   testFile( aTmpName4 );
4244 			sal_Bool      bEOF  = sal_False;
4245 			sal_Bool      *pEOF = &bEOF;
4246 
4247 
4248 			nError1 = testFile.open( OpenFlag_Read | OpenFlag_Write );
4249 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4250 
4251  			nError1 = testFile.setPos( Pos_End, 0 );
4252 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4253 			nError1 = testFile.isEndOfFile( pEOF );
4254 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4255 
4256 			nError1 = testFile.close( );
4257 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4258 
4259 			CPPUNIT_ASSERT_MESSAGE( "test for isEndOfFile function: set the position to end, check if reach end",
4260 				 					sal_True == *pEOF );
4261 		}
4262 
4263 		void isEndOfFile_002( )
4264 		{
4265  			::osl::File   testFile( aTmpName4 );
4266 			sal_Bool      bEOF  = sal_False;
4267 			sal_Bool      *pEOF = &bEOF;
4268 			sal_uInt64    nFilePointer = 0;
4269 
4270 			nError1 = testFile.open( OpenFlag_Read | OpenFlag_Write );
4271 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4272 
4273  			nError1 = testFile.setPos( Pos_Absolut, 0 );
4274 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4275 			*pEOF = sal_False;
4276  			while ( !( *pEOF ) )
4277 			{
4278 				nError1 = testFile.isEndOfFile( pEOF );
4279 				CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4280 				nError1 = testFile.setPos( Pos_Current, 1 );
4281 				CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4282 			}
4283  			nError1 = testFile.getPos( nFilePointer );
4284 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4285 
4286 			nError1 = testFile.close( );
4287 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4288 
4289 			CPPUNIT_ASSERT_MESSAGE( "test for isEndOfFile function: use isEndOfFile to move pointer step by step",
4290 				 					 sizeof( pBuffer_Char ) + 1 == nFilePointer  );
4291 		}
4292 		CPPUNIT_TEST_SUITE( isEndOfFile );
4293 		CPPUNIT_TEST( isEndOfFile_001 );
4294 		CPPUNIT_TEST( isEndOfFile_002 );
4295 		CPPUNIT_TEST_SUITE_END( );
4296 	};// class isEndOfFile
4297 
4298 
4299 	//---------------------------------------------------------------------
4300 	// 	testing the method
4301 	// 	inline RC setSize( sal_uInt64 uSize )
4302 	//---------------------------------------------------------------------
4303     class  setSize : public CppUnit::TestFixture
4304 	{
4305 		::osl::FileBase::RC      nError1;
4306 		sal_uInt64 nCount_write, nCount_read;
4307 
4308 	    public:
4309 		// initialization
4310 		void setUp( )
4311 		{
4312 			// create a tempfile in $TEMP/tmpdir/tmpname.
4313 			createTestDirectory( aTmpName3 );
4314 			createTestFile( aTmpName4 );
4315 
4316 			//write chars into the file.
4317 			::osl::File testFile( aTmpName4 );
4318 
4319 			nError1 = testFile.open( OpenFlag_Write );
4320 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4321 			nError1 = testFile.write( pBuffer_Char, sizeof( pBuffer_Char ), nCount_write );
4322 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4323  			nError1 = testFile.close( );
4324 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4325 		}
4326 
4327 		void tearDown( )
4328 		{
4329 			// remove the tempfile in $TEMP/tmpdir/tmpname.
4330 			deleteTestFile( aTmpName4 );
4331 			deleteTestDirectory( aTmpName3 );
4332 		}
4333 
4334 		// test code.
4335 		void setSize_001( )
4336 		{
4337 			::osl::File   testFile( aTmpName4 );
4338 			// sal_Bool      bEOF  = sal_False;
4339 			// sal_Bool      *pEOF = &bEOF;
4340 			sal_uInt64     nFilePointer;
4341 
4342 
4343 			nError1 = testFile.open( OpenFlag_Read | OpenFlag_Write );
4344 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4345 
4346 			//enlarge the file to size of 100;
4347  			nError1 = testFile.setSize( 100 );
4348 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4349 
4350 			//get the file size;
4351  			nError1 = testFile.setPos( Pos_End, 0 );
4352 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4353  			nError1 = testFile.getPos( nFilePointer );
4354 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4355 
4356 			nError1 = testFile.close( );
4357 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4358 
4359 			CPPUNIT_ASSERT_MESSAGE( "test for setSize function: enlarge the file ",
4360 				 					100 == nFilePointer );
4361 		}
4362 
4363 		void setSize_002( )
4364 		{
4365 			::osl::File   testFile( aTmpName4 );
4366 			// sal_Bool      bEOF  = sal_False;
4367 			// sal_Bool      *pEOF = &bEOF;
4368 			sal_uInt64     nFilePointer;
4369 
4370 
4371 			nError1 = testFile.open( OpenFlag_Read | OpenFlag_Write );
4372 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4373 
4374 			//enlarge the file to size of 100;
4375  			nError1 = testFile.setSize( 10 );
4376 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4377 
4378 			//get the file size;
4379  			nError1 = testFile.setPos( Pos_End, 0 );
4380 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4381  			nError1 = testFile.getPos( nFilePointer );
4382 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4383 
4384 			nError1 = testFile.close( );
4385 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4386 
4387 			CPPUNIT_ASSERT_MESSAGE( "test for setSize function: truncate the file ",
4388 				 					10 == nFilePointer );
4389 		}
4390 	  /*	        void setSize_003( )
4391 		{
4392 			::osl::File   testFile( aTmpName4 );
4393 			// sal_Bool      bEOF  = sal_False;
4394 			// sal_Bool      *pEOF = &bEOF;
4395 			sal_uInt64     nFilePointer;
4396 
4397 
4398 			nError1 = testFile.open( OpenFlag_Read | OpenFlag_Write );
4399 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4400 
4401 			//enlarge the file to size of 100;
4402  			nError1 = testFile.setSize( 10 );
4403 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4404 
4405 			//get the file size;
4406  			nError1 = testFile.setPos( Pos_End, 0 );
4407 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4408  			nError1 = testFile.getPos( nFilePointer );
4409 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4410 
4411 			nError1 = testFile.close( );
4412 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4413 
4414 			CPPUNIT_ASSERT_MESSAGE( "test for setSize function: truncate the file ",
4415 				 					10 == nFilePointer );
4416 		}
4417 	  */
4418 
4419 		CPPUNIT_TEST_SUITE( setSize );
4420 		CPPUNIT_TEST( setSize_001 );
4421 		CPPUNIT_TEST( setSize_002 );
4422 		CPPUNIT_TEST_SUITE_END( );
4423 	};// class setSize
4424 
4425 
4426 	//---------------------------------------------------------------------
4427 	// 	testing the method
4428 	// 	inline RC read( void *pBuffer, sal_uInt64 uBytesRequested, sal_uInt64& rBytesRead )
4429 	//---------------------------------------------------------------------
4430     class  read : public CppUnit::TestFixture
4431 	{
4432 		::osl::FileBase::RC      nError1;
4433 		sal_uInt64 nCount_write, nCount_read;
4434 
4435 	    public:
4436 		// initialization
4437 		void setUp( )
4438 		{
4439 			// create a tempfile in $TEMP/tmpdir/tmpname.
4440 			createTestDirectory( aTmpName3 );
4441 			createTestFile( aTmpName4 );
4442 
4443 			//write chars into the file.
4444 			::osl::File testFile( aTmpName4 );
4445 
4446 			nError1 = testFile.open( OpenFlag_Write );
4447 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4448 			nError1 = testFile.write( pBuffer_Char, sizeof( pBuffer_Char ), nCount_write );
4449 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4450  			nError1 = testFile.close( );
4451 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4452 		}
4453 
4454 		void tearDown( )
4455 		{
4456 			// remove the tempfile in $TEMP/tmpdir/tmpname.
4457 			deleteTestFile( aTmpName4 );
4458 			deleteTestDirectory( aTmpName3 );
4459 		}
4460 
4461 		// test code.
4462 		void read_001( )
4463 		{
4464 			::osl::File    testFile( aTmpName4 );
4465 			sal_uInt64     nFilePointer;
4466 			sal_Char       buffer_read[10];
4467 
4468 
4469 			nError1 = testFile.open( OpenFlag_Read | OpenFlag_Write );
4470 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4471 
4472 			nError1 = testFile.read( buffer_read, 10, nCount_read );
4473 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4474  			nError1 = testFile.getPos( nFilePointer );
4475 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4476 
4477 			nError1 = testFile.close( );
4478 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4479 
4480 			CPPUNIT_ASSERT_MESSAGE( "test for read function: read whole content in the file to a buffer",
4481 				 					( 10 == nFilePointer ) && ( 0 == strncmp( buffer_read, pBuffer_Char, 10 ) ) );
4482 		}
4483 
4484 		void read_002( )
4485 		{
4486 			::osl::File    testFile( aTmpName4 );
4487 			sal_uInt64     nFilePointer;
4488 			sal_Char       buffer_read[26];
4489 
4490 
4491 			nError1 = testFile.open( OpenFlag_Read | OpenFlag_Write );
4492 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4493 
4494  			nError1 = testFile.setPos( Pos_Absolut, 26 );
4495 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4496 			nError1 = testFile.read( buffer_read, 26, nCount_read );
4497 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4498  			nError1 = testFile.getPos( nFilePointer );
4499 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4500 
4501 			nError1 = testFile.close( );
4502 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4503 
4504 			CPPUNIT_ASSERT_MESSAGE( "test for read function: read from a special positon in the file",
4505 				 					( 52 == nFilePointer ) && ( 26 == nCount_read ) && ( 0 == strncmp( buffer_read, &pBuffer_Char[26], 26 ) ) );
4506 		}
4507 
4508 		CPPUNIT_TEST_SUITE( read );
4509 		CPPUNIT_TEST( read_001 );
4510 		CPPUNIT_TEST( read_002 );
4511 		CPPUNIT_TEST_SUITE_END( );
4512 	};// class read
4513 
4514 	//---------------------------------------------------------------------
4515 	// 	testing the method
4516 	// 	inline RC write(const void *pBuffer, sal_uInt64 uBytesToWrite, sal_uInt64& rBytesWritten)
4517 	//---------------------------------------------------------------------
4518     class  write : public CppUnit::TestFixture
4519 	{
4520 		::osl::FileBase::RC      nError1;
4521 		sal_uInt64 nCount_write, nCount_read;
4522 
4523 	    public:
4524 		// initialization
4525 		void setUp( )
4526 		{
4527 			// create a tempfile in $TEMP/tmpname.
4528 			createTestFile( aTmpName6 );
4529 		}
4530 
4531 		void tearDown( )
4532 		{
4533 			// remove the tempfile in $TEMP/tmpname.
4534 			deleteTestFile( aTmpName6 );
4535 		}
4536 
4537 		// test code.
4538 		void write_001( )
4539 		{
4540 			::osl::File    testFile( aTmpName6 );
4541 			sal_uInt64     nFilePointer;
4542 			sal_Char       buffer_read[10];
4543 
4544 			nError1 = testFile.open( OpenFlag_Read | OpenFlag_Write );
4545 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4546 
4547 			//write chars into the file.
4548 			nError1 = testFile.write( pBuffer_Char, 10, nCount_write );
4549 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4550 			//get the current pointer;
4551  			nError1 = testFile.getPos( nFilePointer );
4552 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4553 			//reset pointer to the begining;
4554  			nError1 = testFile.setPos( Pos_Absolut, 0 );
4555 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4556 			nError1 = testFile.read( buffer_read, 10, nCount_read );
4557 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4558 
4559 			nError1 = testFile.close( );
4560 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4561 
4562 			CPPUNIT_ASSERT_MESSAGE( "test for write function: read whole content in the file to a buffer. Note, buffer size can not smaller than the read size",
4563 				 					( 10 == nFilePointer ) &&
4564 			                        ( 0 == strncmp( buffer_read, pBuffer_Char, 10 ) ) &&
4565 									( 10 == nCount_write ) );
4566 		}
4567 
4568 		CPPUNIT_TEST_SUITE( write );
4569 		CPPUNIT_TEST( write_001 );
4570 		CPPUNIT_TEST_SUITE_END( );
4571 	};// class write
4572 
4573 	//---------------------------------------------------------------------
4574 	// 	testing the method
4575 	// 	inline RC readLine( ::rtl::ByteSequence& aSeq )
4576 	//---------------------------------------------------------------------
4577     class  readLine : public CppUnit::TestFixture
4578 	{
4579 		::osl::FileBase::RC      nError1;
4580 		sal_uInt64 nCount_write, nCount_read;
4581 		::rtl::ByteSequence      aSequence;
4582 
4583 	    public:
4584 		// initialization
4585 		void setUp( )
4586 		{
4587 			// create a tempfile in $TEMP/tmpname.
4588 			createTestFile( aTmpName6 );
4589 
4590 			//write some strings into the file.
4591 			::osl::File testFile( aTmpName6 );
4592 			sal_Char ppStrSeq[3][27]  =  { "abcde\n",
4593 			                            "1234567890\n",
4594 			                            "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
4595 			                          };
4596 
4597 			nError1 = testFile.open( OpenFlag_Write );
4598 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4599 
4600 			for ( int nCount = 0; nCount < 3; nCount++ )
4601 			{
4602 				nError1 = testFile.write( ppStrSeq[nCount], strlen( ppStrSeq[nCount] ), nCount_write );
4603 				CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4604 			}
4605 
4606  			nError1 = testFile.close( );
4607 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4608 		}
4609 
4610 		void tearDown( )
4611 		{
4612 			// remove the tempfile in $TEMP/tmpname.
4613 			deleteTestFile( aTmpName6 );
4614 		}
4615 
4616 		// test code.
4617 		void readLine_001( )
4618 		{
4619  			::osl::File    testFile( aTmpName6 );
4620 
4621 			nError1 = testFile.open( OpenFlag_Read | OpenFlag_Write );
4622 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4623 			nError1 = testFile.readLine( aSequence );
4624 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4625 
4626 			CPPUNIT_ASSERT_MESSAGE( "test for readLine function: read the first line of the file.",
4627 				 					( ::osl::FileBase::E_None == nError1 ) &&
4628 			                        ( 0 == strncmp( ( const char * )aSequence.getArray( ), pBuffer_Char, 5 ) ) );
4629 		}
4630 
4631 		void readLine_002( )
4632 		{
4633  			::osl::File    testFile( aTmpName6 );
4634 			sal_Bool bEOF  = sal_False;
4635 			sal_Bool *pEOF = &bEOF;
4636 
4637 			nError1 = testFile.open( OpenFlag_Read | OpenFlag_Write );
4638 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4639 			for ( int nCount = 0; nCount < 3; nCount++ )
4640 			{
4641 				nError1 = testFile.readLine( aSequence );
4642 				CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4643 			}
4644  			nError1 = testFile.isEndOfFile( pEOF );
4645 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4646 
4647 			CPPUNIT_ASSERT_MESSAGE( "test for readLine function: read three lines of the file and check the file pointer moving.",
4648 				 					*pEOF &&
4649 			                        ( 0 == strncmp( ( const char * )aSequence.getArray( ), &pBuffer_Char[26], 26 ) ) );
4650 		}
4651 		CPPUNIT_TEST_SUITE( readLine );
4652 		CPPUNIT_TEST( readLine_001 );
4653 		CPPUNIT_TEST( readLine_002 );
4654 		CPPUNIT_TEST_SUITE_END( );
4655 	};// class readLine
4656 
4657 	//---------------------------------------------------------------------
4658 	// 	testing the method
4659 	// 	inline static RC copy( const ::rtl::OUString& ustrSourceFileURL, const ::rtl::OUString& ustrDestFileURL )
4660 	//---------------------------------------------------------------------
4661     class  copy : public CppUnit::TestFixture
4662 	{
4663 		::osl::FileBase::RC      nError1;
4664 		sal_uInt64 nCount_write, nCount_read;
4665 
4666 	    public:
4667 		// initialization
4668 		void setUp( )
4669 		{
4670 			// create a tempfile in $TEMP/tmpdir/tmpname.
4671 			createTestDirectory( aTmpName3 );
4672 			createTestFile( aTmpName4 );
4673 
4674 			//write chars into the file.
4675 			::osl::File testFile( aTmpName4 );
4676 
4677 			nError1 = testFile.open( OpenFlag_Write );
4678 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4679 			nError1 = testFile.write( pBuffer_Char, sizeof( pBuffer_Char ), nCount_write );
4680 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4681  			nError1 = testFile.close( );
4682 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4683 		}
4684 
4685 		void tearDown( )
4686 		{
4687 			// remove the tempfile in $TEMP/tmpdir/tmpname.
4688 			deleteTestFile( aTmpName4 );
4689 			deleteTestDirectory( aTmpName3 );
4690 		}
4691 
4692 		// test code.
4693 		void copy_001( )
4694 		{
4695  			::osl::File    testFile( aTmpName6 );
4696 
4697 			//copy $TEMP/tmpdir/tmpname to $TEMP/tmpname.
4698 			nError1 = ::osl::File::copy( aTmpName4, aTmpName6 );
4699 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4700 			//check
4701 			nError1 = testFile.open( OpenFlag_Create );
4702 			deleteTestFile( aTmpName6 );
4703 
4704 			CPPUNIT_ASSERT_MESSAGE( "test for copy function: copy file to upper directory",
4705 				 					::osl::FileBase::E_EXIST == nError1 );
4706 		}
4707 
4708 		void copy_002( )
4709 		{
4710 			//copy $TEMP/tmpdir/tmpname to $TEMP/tmpdir.
4711 			nError1 = ::osl::File::copy( aTmpName4, aTmpName3 );
4712 
4713 			CPPUNIT_ASSERT_MESSAGE( "test for copy function: use directory as destination",
4714 				 					( ::osl::FileBase::E_ISDIR == nError1 ) ||( ::osl::FileBase::E_ACCES == nError1 )  );
4715 		}
4716 
4717 		void copy_003( )
4718 		{
4719 			//copy $TEMP/tmpdir/tmpname to $ROOT/tmpname.
4720 			nError1 = ::osl::File::copy( aTmpName4, aTmpName7 );
4721 #if defined (WNT )
4722 			nError1 = ::osl::FileBase::E_ACCES;  /// for Windows, c:/ is writtenable any way.
4723 			deleteTestFile( aTmpName7);
4724 #endif
4725 			CPPUNIT_ASSERT_MESSAGE( "test for copy function: copy to an illigal place",
4726 				 					::osl::FileBase::E_ACCES == nError1 );
4727 		}
4728 
4729 		void copy_004( )
4730 		{
4731 			//copy $TEMP/tmpname to $TEMP/tmpdir/tmpname.
4732 			nError1 = ::osl::File::copy( aTmpName6, aTmpName4 );
4733 
4734 			CPPUNIT_ASSERT_MESSAGE( "test for copy function: copy a not exist file",
4735 				 					::osl::FileBase::E_NOENT == nError1 );
4736 		}
4737 
4738 		void copy_005( )
4739 		{
4740 			//copy $TEMP/tmpname to $TEMP/system.path using system path.
4741 			nError1 = ::osl::File::copy( aTmpName6, aSysPath1 );
4742 
4743 			CPPUNIT_ASSERT_MESSAGE( "test for copy function: copy a file using system file path",
4744 				 					::osl::FileBase::E_INVAL == nError1 );
4745 		}
4746 	  void copy_006( )
4747 	  {
4748 	    createTestFile( aTmpName6 );
4749 	    File tmpFile( aTmpName6 );
4750 	    FileBase::RC err = tmpFile.open( OpenFlag_Write | OpenFlag_Read );
4751         (void)err;
4752 	    tmpFile.setSize( 200 );
4753 	    tmpFile.close();
4754 	    //copy to new path
4755 	    nError1 = ::osl::File::copy( aTmpName6, aTmpName4 );
4756 	    CPPUNIT_ASSERT( nError1 == FileBase::E_None );
4757 
4758 	    //check if is the new file
4759 	    File newFile( aTmpName4 );
4760 	    newFile.open( OpenFlag_Write | OpenFlag_Read );
4761 	    newFile.setPos( Pos_End, 0 );
4762 	    //		CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4763 	    sal_uInt64     nFilePointer;
4764 	    nError1 = newFile.getPos( nFilePointer );
4765 	    CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4766 	    newFile.close( );
4767 	    deleteTestFile( aTmpName6 );
4768 	    CPPUNIT_ASSERT_MESSAGE( "test for copy function: the dest file exist",
4769 				    nFilePointer == 200 );
4770 	  }
4771 	  //copyLink has not been impletmented yet
4772 	  void copy_007( )
4773 	  {
4774 #if ( defined UNX )
4775 
4776 	    CPPUNIT_ASSERT_MESSAGE( "test for copy function: source file is link file",
4777 				 					::osl::FileBase::E_INVAL == nError1 );
4778 #endif
4779 	  }
4780 
4781 		CPPUNIT_TEST_SUITE( copy );
4782 		CPPUNIT_TEST( copy_001 );
4783 		CPPUNIT_TEST( copy_002 );
4784 		CPPUNIT_TEST( copy_003 );
4785 		CPPUNIT_TEST( copy_004 );
4786 		CPPUNIT_TEST( copy_005 );
4787 	  CPPUNIT_TEST( copy_006 );
4788 		CPPUNIT_TEST_SUITE_END( );
4789 	};// class copy
4790 
4791 	//---------------------------------------------------------------------
4792 	// 	testing the method
4793 	// 	inline static RC move( const ::rtl::OUString& ustrSourceFileURL, const ::rtl::OUString& ustrDestFileURL )
4794 	//---------------------------------------------------------------------
4795     class  move : public CppUnit::TestFixture
4796 	{
4797 		::osl::FileBase::RC      nError1, nError2;
4798 		sal_uInt64 nCount_write, nCount_read;
4799 
4800 	    public:
4801 		// initialization
4802 		void setUp( )
4803 		{
4804 			// create a tempfile in $TEMP/tmpdir/tmpname.
4805 			createTestDirectory( aTmpName3 );
4806 			createTestFile( aTmpName4 );
4807 
4808 			//write chars into the file.
4809 			::osl::File testFile( aTmpName4 );
4810 
4811 			nError1 = testFile.open( OpenFlag_Write );
4812 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4813 			nError1 = testFile.write( pBuffer_Char, sizeof( pBuffer_Char ), nCount_write );
4814 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4815  			nError1 = testFile.close( );
4816 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4817 		}
4818 
4819 		void tearDown( )
4820 		{
4821 			// remove the tempfile in $TEMP/tmpdir/tmpname.
4822 			deleteTestFile( aTmpName4 );
4823 			deleteTestDirectory( aTmpName3 );
4824 		}
4825 
4826 		// test code.
4827 		void move_001( )
4828 		{
4829 			//rename $TEMP/tmpdir/tmpname to $TEMP/canonical.name.
4830 			nError1 = ::osl::File::move( aTmpName4, aCanURL1 );
4831 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4832 			//check
4833  			::osl::File    testFile( aCanURL1 );
4834 			nError2 = testFile.open( OpenFlag_Create );
4835 			deleteTestFile( aCanURL1 );
4836 
4837 			CPPUNIT_ASSERT_MESSAGE( "test for move function: rename file to another directory",
4838 				 					::osl::FileBase::E_EXIST == nError2 );
4839 		}
4840 
4841 		void move_002( )
4842 		{
4843 			//move $TEMP/tmpdir/tmpname to $TEMP/tmpdir.
4844 			nError1 = ::osl::File::move( aTmpName4, aTmpName3 );
4845 			//returned ::osl::FileBase::E_ACCES on WNT
4846 			CPPUNIT_ASSERT_MESSAGE( "test for move function: use directory as destination",
4847 				 ( ::osl::FileBase::E_ACCES == nError1 || ::osl::FileBase::E_ISDIR == nError1 ) ||( ::osl::FileBase::E_EXIST == nError1 )  );
4848 		}
4849 
4850 		void move_003( )
4851 		{
4852 			//move $TEMP/tmpdir/tmpname to $ROOT/tmpname.
4853 			nError1 = ::osl::File::move( aTmpName4, aTmpName7 );
4854 #if defined (WNT )
4855 			nError1 = ::osl::FileBase::E_ACCES;  /// for Windows, c:/ is writtenable any way.
4856 			deleteTestFile( aTmpName7);
4857 #endif
4858 
4859 			CPPUNIT_ASSERT_MESSAGE( "test for move function: move to an illigal place",
4860 				 					::osl::FileBase::E_ACCES == nError1 );
4861 		}
4862 
4863 		void move_004( )
4864 		{
4865 			//move $TEMP/tmpname to $TEMP/tmpdir/tmpname.
4866 			nError1 = ::osl::File::move( aTmpName6, aTmpName4 );
4867 
4868 			CPPUNIT_ASSERT_MESSAGE( "test for move function: move a not exist file",
4869 				 					::osl::FileBase::E_NOENT == nError1 );
4870 		}
4871 
4872 		void move_005( )
4873 		{
4874 			//move $TEMP/tmpname to $TEMP/system.path using system path.
4875 			nError1 = ::osl::File::move( aTmpName6, aSysPath1 );
4876 
4877 			CPPUNIT_ASSERT_MESSAGE( "test for move function: move a file using system file",
4878 				 					::osl::FileBase::E_INVAL == nError1 );
4879 		}
4880 
4881 		void move_006( )
4882 		{
4883 			//move directory $TEMP/tmpname to $TEMP/tmpdir/tmpname.
4884 			createTestDirectory( aTmpName6 );
4885 			nError1 = ::osl::File::move( aTmpName6, aTmpName4 );
4886 			//move file $TEMP/tmpdir/tmpname to $TEMP/tmpname
4887 			nError2 = ::osl::File::move( aTmpName4, aTmpName6 );
4888 			deleteTestDirectory( aTmpName6 );
4889 #if defined ( WNT )
4890 			deleteTestDirectory( aTmpName4 );// in Windows, it can be moved!!!!! this is only for not influence the following test.
4891 			deleteTestFile( aTmpName6 );
4892 			nError1 = ::osl::FileBase::E_NOTDIR;
4893 			nError2 = ::osl::FileBase::E_ISDIR;
4894 #endif
4895 			CPPUNIT_ASSERT_MESSAGE( "test for move function: move a directory to an exist file with same name, did not pass in (W32)",
4896 				 					::osl::FileBase::E_NOTDIR == nError1 && ::osl::FileBase::E_ISDIR == nError2 );
4897 		}
4898 
4899 		void move_007( )
4900 		{
4901 			//create directory $TEMP/tmpname.
4902 			createTestDirectory( aTmpName6 );
4903 			//move directory $TEMP/tmpdir to $TEMP/tmpname/tmpdir
4904 			nError1 = ::osl::File::move( aTmpName3, aTmpName8 );
4905 			//check
4906 			nError2 = ::osl::Directory::create( aTmpName8 );
4907 			::osl::File::move( aTmpName8, aTmpName3 );
4908 			deleteTestDirectory( aTmpName6 );
4909 
4910 			CPPUNIT_ASSERT_MESSAGE( "test for move function: move a directory to an exist file with same name",
4911 				 					(::osl::FileBase::E_None == nError1 ) &&
4912 			                        (::osl::FileBase::E_EXIST == nError2 ) );
4913 		}
4914 	  // oldpath and newpath are not on the same filesystem.EXDEV,no such error no on Solaris, only on linux
4915 	  void move_008( )
4916 	  {
4917 	    CPPUNIT_ASSERT_MESSAGE( "oldpath and newpath are not on the same filesystem, should error returns",
4918 				 					::osl::FileBase::E_None == nError1  );
4919 	  }
4920 	  //bugid# 115420, after the bug fix, add the case
4921 	  void move_009( )
4922 	  {
4923 	    //create directory $TEMP/tmpname.
4924 	    createTestDirectory( aTmpName6 );
4925 	    //create directory $TEMP/tmpname/tmpdir
4926 	    createTestDirectory( aTmpName8 );
4927 	    //move directory $TEMP/tmpname to $TEMP/tmpname/tmpdir/tmpname
4928 	    rtl::OUString newName = aTmpName8 + OUString::createFromAscii("/tmpname");
4929 	    //printFileName( newName );
4930 	    nError1 = ::osl::File::move( aTmpName3, newName );
4931 	    //deleteTestDirectory( newName + OUString::createFromAscii("/tmpname") );
4932 	    //deleteTestDirectory( newName );
4933 	    deleteTestDirectory( aTmpName8 );
4934 	    deleteTestDirectory( aTmpName6 );
4935 	    CPPUNIT_ASSERT_MESSAGE( "test for move function: move a directory to it's subdirectory",
4936 				 				::osl::FileBase::E_None != nError1 );
4937 	  }
4938 
4939 		CPPUNIT_TEST_SUITE( move );
4940 		CPPUNIT_TEST( move_001 );
4941 		CPPUNIT_TEST( move_002 );
4942 		CPPUNIT_TEST( move_003 );
4943 		CPPUNIT_TEST( move_004 );
4944 		CPPUNIT_TEST( move_005 );
4945 		CPPUNIT_TEST( move_006 );
4946 		CPPUNIT_TEST( move_007 );
4947 	  //	  CPPUNIT_TEST( move_008 );
4948 	  //CPPUNIT_TEST( move_009 );
4949 		CPPUNIT_TEST_SUITE_END( );
4950 	};// class move
4951 
4952 
4953 	//---------------------------------------------------------------------
4954 	// 	testing the method
4955 	// 	inline static RC remove( const ::rtl::OUString& ustrFileURL )
4956 	//---------------------------------------------------------------------
4957     class  remove : public CppUnit::TestFixture
4958 	{
4959 		::osl::FileBase::RC      nError1, nError2;
4960 		sal_uInt64 nCount_write, nCount_read;
4961 
4962 	    public:
4963 		// initialization
4964 		void setUp( )
4965 		{
4966 			// create a tempfile in $TEMP/tmpdir/tmpname.
4967 			createTestDirectory( aTmpName3 );
4968 			createTestFile( aTmpName4 );
4969 
4970 			//write chars into the file.
4971 			::osl::File testFile( aTmpName4 );
4972 
4973 			nError1 = testFile.open( OpenFlag_Write );
4974 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4975 			nError1 = testFile.write( pBuffer_Char, sizeof( pBuffer_Char ), nCount_write );
4976 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4977  			nError1 = testFile.close( );
4978 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
4979 		}
4980 
4981 		void tearDown( )
4982 		{
4983 			// remove the tempfile in $TEMP/tmpdir/tmpname.
4984 			deleteTestFile( aTmpName4 );
4985 			deleteTestDirectory( aTmpName3 );
4986 		}
4987 
4988 		// test code.
4989 		void remove_001( )
4990 		{
4991 			//remove $TEMP/tmpdir/tmpname.
4992 			nError1 = ::osl::File::remove( aTmpName4 );
4993 			//check
4994  			::osl::File    testFile( aTmpName4 );
4995 			nError2 = testFile.open( OpenFlag_Create );
4996 
4997 			CPPUNIT_ASSERT_MESSAGE( "test for remove function: remove a file",
4998 			                        ( ::osl::FileBase::E_None == nError1 ) &&
4999 				 					( ::osl::FileBase::E_EXIST != nError2 ) );
5000 		}
5001 
5002 		void remove_002( )
5003 		{
5004 			//remove $TEMP/tmpname.
5005 			nError1 = ::osl::File::remove( aTmpName6 );
5006 
5007 			CPPUNIT_ASSERT_MESSAGE( "test for remove function: remove a file not exist",
5008 			                        ( ::osl::FileBase::E_NOENT == nError1 ) );
5009 		}
5010 
5011 		void remove_003( )
5012 		{
5013 			//remove $TEMP/system/path.
5014 			nError1 = ::osl::File::remove( aSysPath2 );
5015 
5016 			CPPUNIT_ASSERT_MESSAGE( "test for remove function: removing a file not using full qualified URL",
5017 			                        ( ::osl::FileBase::E_INVAL == nError1 ) );
5018 		}
5019 
5020 		void remove_004( )
5021 		{
5022 			//remove $TEMP/tmpdir.
5023 			nError1 = ::osl::File::remove( aTmpName3 );
5024 
5025 			CPPUNIT_ASSERT_MESSAGE( "test for remove function: remove a directory",
5026 			                        ( ::osl::FileBase::E_ISDIR == nError1 ) || ( ::osl::FileBase::E_ACCES == nError1 ));
5027 		}
5028 
5029 		CPPUNIT_TEST_SUITE( remove );
5030 		CPPUNIT_TEST( remove_001 );
5031 		CPPUNIT_TEST( remove_002 );
5032 		CPPUNIT_TEST( remove_003 );
5033 		CPPUNIT_TEST( remove_004 );
5034 		CPPUNIT_TEST_SUITE_END( );
5035 	};// class remove
5036 
5037 
5038 	//---------------------------------------------------------------------
5039 	// 	testing the method
5040 	// 	inline static RC setAttributes( const ::rtl::OUString& ustrFileURL, sal_uInt64 uAttributes )
5041 	//---------------------------------------------------------------------
5042     class  setAttributes : public CppUnit::TestFixture
5043 	{
5044 		::osl::FileBase::RC      nError1, nError2;
5045 		::osl::DirectoryItem    rItem, rItem_hidden;
5046 
5047 	    public:
5048 		// initialization
5049 		void setUp( )
5050 		{
5051 			// create a tempfile in $TEMP/tmpdir/tmpname.
5052 			createTestFile( aTmpName6 );
5053 		}
5054 
5055 		void tearDown( )
5056 		{
5057 			// remove the tempfile in $TEMP/tmpdir/tmpname.
5058 			deleteTestFile( aTmpName6 );
5059 		}
5060 
5061 		// test code.
5062 		void setAttributes_001( )
5063 		{
5064 		//on windows, only can set 2 attributes: Attribute_ReadOnly,  Attribute_HIDDEN
5065 #ifdef UNX
5066 			//set the file to readonly
5067 			nError2 = ::osl::File::setAttributes( aTmpName6, Attribute_ReadOnly | Attribute_GrpRead | Attribute_OwnRead | Attribute_OthRead );
5068 			CPPUNIT_ASSERT( nError2 == FileBase::E_None);
5069 			nError1 = ::osl::DirectoryItem::get( aTmpName6, rItem );
5070 			CPPUNIT_ASSERT( nError1 == FileBase::E_None);
5071 			//get the file attributes
5072   			::osl::FileStatus   rFileStatus( FileStatusMask_Attributes );
5073 			nError1 = rItem.getFileStatus( rFileStatus );
5074 			CPPUNIT_ASSERT( nError1 == FileBase::E_None );
5075 
5076 			CPPUNIT_ASSERT_MESSAGE( "test for setAttributes function: set file attributes and get it to verify.",
5077 			                        ( Attribute_ReadOnly | Attribute_GrpRead | Attribute_OwnRead | Attribute_OthRead ) ==
5078 		                            rFileStatus.getAttributes( ) );
5079 #else
5080 			//please see GetFileAttributes
5081 			nError2 = ::osl::File::setAttributes( aTmpName6, Attribute_ReadOnly );
5082 			CPPUNIT_ASSERT( nError2 == FileBase::E_None);
5083 			nError1 = ::osl::DirectoryItem::get( aTmpName6, rItem );
5084 			CPPUNIT_ASSERT( nError1 == FileBase::E_None);
5085 			//get the file attributes
5086   			::osl::FileStatus   rFileStatus( FileStatusMask_Attributes );
5087 			nError1 = rItem.getFileStatus( rFileStatus );
5088 			CPPUNIT_ASSERT( nError1 == FileBase::E_None );
5089 			//here the file has 2 Attributes: FILE_ATTRIBUTE_READONLY and FILE_ATTRIBUTE_NORMAL,
5090 			// but FILE_ATTRIBUTE_NORMAL is valid only if used alone, so this is maybe a bug
5091 			/*::rtl::OString aString = ::rtl::OUStringToOString( aTmpName6, RTL_TEXTENCODING_ASCII_US );
5092 			DWORD dwFileAttributes = GetFileAttributes( aString.getStr( ) );
5093 			if (dwFileAttributes & FILE_ATTRIBUTE_NORMAL)
5094 				t_print("has normal attribute");
5095 			if (dwFileAttributes & FILE_ATTRIBUTE_READONLY)
5096 				t_print("has readonly attribute");
5097 			*/
5098 			CPPUNIT_ASSERT_MESSAGE( "test for setAttributes function: set file attributes READONLY and get it to verify.",
5099 			                        (Attribute_ReadOnly & rFileStatus.getAttributes( )) != 0  );
5100 #endif
5101 	}
5102 		void setAttributes_002( )
5103 		{
5104 		//on UNX, can not set hidden attribute to file, rename file can set the attribute
5105 #ifdef WNT
5106 			//set the file to hidden
5107 			nError2 = ::osl::File::setAttributes( aTmpName6, Attribute_Hidden);
5108 
5109 			CPPUNIT_ASSERT( nError2 == FileBase::E_None);
5110 			nError1 = ::osl::DirectoryItem::get( aTmpName6, rItem );
5111 			CPPUNIT_ASSERT( nError1 == FileBase::E_None);
5112 			//get the file attributes
5113   			::osl::FileStatus rFileStatus( FileStatusMask_Attributes );
5114 			nError1 = rItem.getFileStatus( rFileStatus );
5115 			CPPUNIT_ASSERT( nError1 == FileBase::E_None );
5116 
5117 			CPPUNIT_ASSERT_MESSAGE( "test for setAttributes function: set file attributes and get it to verify.",
5118 			                        (Attribute_Hidden & rFileStatus.getAttributes( )) != 0 );
5119 #endif
5120 		}
5121 
5122 		CPPUNIT_TEST_SUITE( setAttributes );
5123 		CPPUNIT_TEST( setAttributes_001 );
5124 		CPPUNIT_TEST( setAttributes_002 );
5125 		CPPUNIT_TEST_SUITE_END( );
5126 	};// class setAttributes
5127 
5128 
5129 	//---------------------------------------------------------------------
5130 	// 	testing the method
5131 	// 	inline static RC setTime(
5132 	// 	       const ::rtl::OUString& ustrFileURL,
5133 	// 	       const TimeValue& rCreationTime,
5134 	// 	       const TimeValue& rLastAccessTime,
5135 	// 	       const TimeValue& rLastWriteTime )
5136 	//---------------------------------------------------------------------
5137     class  setTime : public CppUnit::TestFixture
5138 	{
5139 		::osl::FileBase::RC     nError1, nError2;
5140 		::osl::DirectoryItem    rItem;
5141 
5142 	    public:
5143 		// initialization
5144 		void setUp( )
5145 		{
5146 			// create a tempfile in $TEMP/tmpdir/tmpname.
5147 			createTestFile( aTmpName6 );
5148 		}
5149 
5150 		void tearDown( )
5151 		{
5152 			// remove the tempfile in $TEMP/tmpdir/tmpname.
5153 			deleteTestFile( aTmpName6 );
5154 		}
5155 
5156 		// test code.
5157 		void setTime_001( )
5158 		{
5159  			TimeValue *pTV_current  = NULL;
5160 			CPPUNIT_ASSERT( ( pTV_current = ( TimeValue* )malloc( sizeof( TimeValue ) ) ) != NULL );
5161 			TimeValue *pTV_creation = NULL;
5162 			CPPUNIT_ASSERT( ( pTV_creation = ( TimeValue* )malloc( sizeof( TimeValue ) ) ) != NULL );
5163 			TimeValue *pTV_access   = NULL;
5164 			CPPUNIT_ASSERT( ( pTV_access = ( TimeValue* )malloc( sizeof( TimeValue ) ) ) != NULL );
5165 			TimeValue *pTV_modify   = NULL;
5166 			CPPUNIT_ASSERT( ( pTV_modify = ( TimeValue* )malloc( sizeof( TimeValue ) ) ) != NULL );
5167 
5168 			//get current time
5169 			sal_Bool bOk = osl_getSystemTime( pTV_current );
5170 			CPPUNIT_ASSERT( sal_True == bOk );
5171 
5172 			//set the file time
5173 			nError2 = ::osl::File::setTime( aTmpName6, *pTV_current, *pTV_current, *pTV_current );
5174 			CPPUNIT_ASSERT_MESSAGE( errorToStr( nError2 ), nError2 == FileBase::E_None);
5175 
5176  			//get the file access time, creation time, modify time
5177 			nError1 = ::osl::DirectoryItem::get( aTmpName6, rItem );
5178 			CPPUNIT_ASSERT_MESSAGE( errorToStr( nError1 ), nError1 == FileBase::E_None);
5179 
5180   			::osl::FileStatus   rFileStatus( FileStatusMask_AccessTime );
5181 			nError1 = rItem.getFileStatus( rFileStatus );
5182 			CPPUNIT_ASSERT_MESSAGE( errorToStr( nError1 ),nError1 == FileBase::E_None );
5183 			*pTV_access = rFileStatus.getAccessTime( );
5184 
5185   			::osl::FileStatus   rFileStatus1( FileStatusMask_CreationTime );
5186 			nError1 = rItem.getFileStatus( rFileStatus1 );
5187 			CPPUNIT_ASSERT_MESSAGE( errorToStr( nError1 ), nError1 == FileBase::E_None );
5188 			*pTV_creation = rFileStatus1.getCreationTime( );
5189 
5190   			::osl::FileStatus   rFileStatus2( FileStatusMask_ModifyTime );
5191 			nError1 = rItem.getFileStatus( rFileStatus2 );
5192 			CPPUNIT_ASSERT_MESSAGE( errorToStr( nError1 ), nError1 == FileBase::E_None );
5193 			*pTV_modify = rFileStatus2.getModifyTime( );
5194 
5195 			CPPUNIT_ASSERT_MESSAGE( "test for setTime function: set access time then get it. time precision is still a problem for it cut off the nanosec.",
5196 				sal_True == t_compareTime( pTV_access, pTV_current, delta ) );
5197 #if defined ( WNT )
5198 			//Unfortunately there is no way to get the creation time of a file under Unix (its a Windows only feature).
5199 			//That means the flag osl_FileStatus_Mask_CreationTime should be deprecated under Unix.
5200 			CPPUNIT_ASSERT_MESSAGE( "test for setTime function: set creation time then get it. ",
5201 				sal_True == t_compareTime( pTV_creation, pTV_current, delta ) ) ;
5202 #endif
5203 			CPPUNIT_ASSERT_MESSAGE( "test for setTime function: set modify time then get it. ",
5204 				sal_True == t_compareTime( pTV_modify, pTV_current, delta ) );
5205 			free( pTV_current );
5206 			free( pTV_creation );
5207 			free( pTV_access );
5208 			free( pTV_modify );
5209 		}
5210 
5211 		CPPUNIT_TEST_SUITE( setTime );
5212 		CPPUNIT_TEST( setTime_001 );
5213 		CPPUNIT_TEST_SUITE_END( );
5214 	};// class setTime
5215 
5216 	//---------------------------------------------------------------------
5217 	// 	testing the method
5218 	// 	inline static RC sync()
5219 	//---------------------------------------------------------------------
5220         class  sync : public CppUnit::TestFixture
5221 	{
5222 		::osl::FileBase::RC     nError1, nError2;
5223 		::osl::DirectoryItem    rItem;
5224 
5225 	    public:
5226 		// initialization
5227 		void setUp( )
5228 		{
5229 			// create a tempfile in $TEMP/tmpdir/tmpname.
5230 			createTestFile( aTmpName6 );
5231 
5232 		}
5233 
5234 		void tearDown( )
5235 		{
5236 			// remove the tempfile in $TEMP/tmpdir/tmpname.
5237 			deleteTestFile( aTmpName6 );
5238 		}
5239 
5240 		// test case: if The file is located on a read only file system.
5241 		void sync_001( )
5242 		{
5243 #ifdef UNX
5244 			nError1 = ::osl::DirectoryItem::get( aTmpName6, rItem );
5245 			CPPUNIT_ASSERT( nError1 == FileBase::E_None);
5246 
5247 			File tmp_file( aTmpName6 );
5248 			FileBase::RC err = tmp_file.open(osl_File_OpenFlag_Write );
5249 
5250 			CPPUNIT_ASSERT_MESSAGE("File open failed", err == FileBase::E_None);
5251 
5252 			char buffer[50000];
5253 			sal_uInt64 written = 0;
5254 			nError1 = tmp_file.write((void*)buffer, sizeof(buffer), written);
5255 			CPPUNIT_ASSERT_MESSAGE("write failed!", nError1 == FileBase::E_None);
5256 
5257 			//set the file to readonly
5258 			nError2 = ::osl::File::setAttributes( aTmpName6, Attribute_ReadOnly | Attribute_GrpRead | Attribute_OwnRead | Attribute_OthRead );
5259 			CPPUNIT_ASSERT( nError2 == FileBase::E_None);
5260 
5261 			nError2 = tmp_file.sync();
5262 
5263         		CPPUNIT_ASSERT_MESSAGE("can not sync to readonly file!", nError2 == FileBase::E_None);
5264 
5265 			tmp_file.close();
5266 #endif
5267 		}
5268 	  //test case:no enough space, how to create such case???see test_cpy_wrt_file.cxx::test_osl_writeFile
5269 
5270 
5271 
5272 		CPPUNIT_TEST_SUITE( sync );
5273 		CPPUNIT_TEST( sync_001 );
5274 		CPPUNIT_TEST_SUITE_END( );
5275 	};// class setTime
5276 
5277 	// -----------------------------------------------------------------------------
5278 	CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_File::ctors, "osl_File" );
5279 	CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_File::open, "osl_File" );
5280 	CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_File::close, "osl_File" );
5281 	CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_File::setPos, "osl_File" );
5282 	CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_File::getPos, "osl_File" );
5283 	CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_File::isEndOfFile, "osl_File" );
5284 	CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_File::setSize, "osl_File" );
5285 	CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_File::read, "osl_File" );
5286 	CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_File::write, "osl_File" );
5287 	CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_File::readLine, "osl_File" );
5288 	CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_File::copy, "osl_File" );
5289 	CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_File::move, "osl_File" );
5290 	CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_File::remove, "osl_File" );
5291 	CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_File::setAttributes, "osl_File" );
5292 	CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_File::setTime, "osl_File" );
5293         CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_File::sync, "osl_File" );
5294 
5295 }// namespace osl_File
5296 
5297 
5298 //------------------------------------------------------------------------
5299 // Beginning of the test cases for DirectoryItem class
5300 //------------------------------------------------------------------------
5301 namespace osl_DirectoryItem
5302 {
5303 	//---------------------------------------------------------------------
5304 	// 	testing the method
5305 	// 	DirectoryItem(): _pData( NULL )
5306 	//---------------------------------------------------------------------
5307     class  ctors : public CppUnit::TestFixture
5308 	{
5309 		::osl::FileBase::RC     nError1, nError2;
5310 
5311 	    public:
5312 		// initialization
5313 		void setUp( )
5314 		{
5315 			// create a tempfile in $TEMP/tmpname.
5316 			createTestFile( aTmpName6 );
5317 		}
5318 
5319 		void tearDown( )
5320 		{
5321 			// remove the tempfile in $TEMP/tmpname.
5322 			deleteTestFile( aTmpName6 );
5323 		}
5324 
5325 		// test code.
5326 		void ctors_001( )
5327 		{
5328 			::osl::File testFile( aTmpName6 );
5329 			::osl::DirectoryItem    rItem;  //constructor
5330 
5331  			//get the DirectoryItem.
5332 			nError1 = ::osl::DirectoryItem::get( aTmpName6, rItem );
5333 			CPPUNIT_ASSERT( FileBase::E_None == nError1 );
5334 
5335 			CPPUNIT_ASSERT_MESSAGE( "test for ctors function: initialize a new instance of DirectoryItem and get an item to check.",
5336 				 					 ::osl::FileBase::E_None == nError1  );
5337 		}
5338 
5339 		CPPUNIT_TEST_SUITE( ctors );
5340 		CPPUNIT_TEST( ctors_001 );
5341 		CPPUNIT_TEST_SUITE_END( );
5342 	};// class ctors
5343 
5344 	//---------------------------------------------------------------------
5345 	// 	testing the method
5346 	// 	DirectoryItem( const DirectoryItem& rItem ): _pData( rItem._pData)
5347 	//---------------------------------------------------------------------
5348     class  copy_assin_Ctors : public CppUnit::TestFixture
5349 	{
5350 		::osl::FileBase::RC     nError1, nError2;
5351 
5352 	    public:
5353 		// initialization
5354 		void setUp( )
5355 		{
5356 			// create a tempfile in $TEMP/tmpname.
5357 			createTestFile( aTmpName6 );
5358 		}
5359 
5360 		void tearDown( )
5361 		{
5362 			// remove the tempfile in $TEMP/tmpname.
5363 			deleteTestFile( aTmpName6 );
5364 		}
5365 
5366 		// test code.
5367 		void copy_assin_Ctors_001( )
5368 		{
5369 			::osl::DirectoryItem    rItem;  //constructor
5370  			//get the DirectoryItem.
5371 			nError1 = ::osl::DirectoryItem::get( aTmpName6, rItem );
5372 			CPPUNIT_ASSERT( FileBase::E_None == nError1 );
5373 
5374 			::osl::DirectoryItem    copyItem( rItem ); //copy constructor
5375   			::osl::FileStatus   rFileStatus( FileStatusMask_FileName );
5376 			nError1 = copyItem.getFileStatus( rFileStatus );
5377 			CPPUNIT_ASSERT( nError1 == FileBase::E_None );
5378 
5379 			CPPUNIT_ASSERT_MESSAGE( "test for copy_assin_Ctors function: use copy constructor to get an item and check filename.",
5380 			                        ( sal_True == compareFileName( rFileStatus.getFileName( ), aTmpName2 ) ) );
5381 		}
5382 
5383 		void copy_assin_Ctors_002( )
5384 		{
5385 			::osl::DirectoryItem    rItem;  //constructor
5386  			//get the DirectoryItem.
5387 			nError1 = ::osl::DirectoryItem::get( aTmpName6, rItem );
5388 			CPPUNIT_ASSERT( FileBase::E_None == nError1 );
5389 
5390 			::osl::DirectoryItem    copyItem;
5391 			copyItem = rItem;               //assinment operator
5392   			::osl::FileStatus   rFileStatus( FileStatusMask_FileName );
5393 			nError1 = copyItem.getFileStatus( rFileStatus );
5394 			CPPUNIT_ASSERT( nError1 == FileBase::E_None );
5395 
5396 			CPPUNIT_ASSERT_MESSAGE( "test for copy_assin_Ctors function: test assinment operator here since it is same as copy constructor in test way.",
5397 			                        ( sal_True == compareFileName( rFileStatus.getFileName( ), aTmpName2 ) ) );
5398 		}
5399 
5400 		CPPUNIT_TEST_SUITE( copy_assin_Ctors );
5401 		CPPUNIT_TEST( copy_assin_Ctors_001 );
5402 		CPPUNIT_TEST( copy_assin_Ctors_002 );
5403 		CPPUNIT_TEST_SUITE_END( );
5404 	};// class copy_assin_Ctors
5405 
5406 	//---------------------------------------------------------------------
5407 	// 	testing the method
5408 	// 	inline sal_Bool is()
5409 	//---------------------------------------------------------------------
5410     class  is : public CppUnit::TestFixture
5411 	{
5412 		::osl::FileBase::RC     nError1, nError2;
5413 
5414 	    public:
5415 		// initialization
5416 		void setUp( )
5417 		{
5418 			// create a tempfile in $TEMP/tmpname.
5419 			createTestFile( aTmpName6 );
5420 		}
5421 
5422 		void tearDown( )
5423 		{
5424 			// remove the tempfile in $TEMP/tmpname.
5425 			deleteTestFile( aTmpName6 );
5426 		}
5427 
5428 		// test code.
5429 		void is_001( )
5430 		{
5431 			::osl::DirectoryItem    rItem;  //constructor
5432 
5433 			CPPUNIT_ASSERT_MESSAGE( "test for is function: use an uninitialized instance.",
5434 			                        !rItem.is( ) );
5435 		}
5436 
5437 		void is_002( )
5438 		{
5439 			::osl::DirectoryItem    rItem;  //constructor
5440  			//get the DirectoryItem.
5441 			nError1 = ::osl::DirectoryItem::get( aTmpName6, rItem );
5442 			CPPUNIT_ASSERT( FileBase::E_None == nError1 );
5443 
5444 			CPPUNIT_ASSERT_MESSAGE( "test for is function: use an uninitialized instance.",
5445 			                        ( sal_True == rItem.is( ) ) );
5446 		}
5447 
5448 		CPPUNIT_TEST_SUITE( is );
5449 		CPPUNIT_TEST( is_001 );
5450 		CPPUNIT_TEST( is_002 );
5451 		CPPUNIT_TEST_SUITE_END( );
5452 	};// class is
5453 
5454 	//---------------------------------------------------------------------
5455 	// 	testing the method
5456 	// 	static inline RC get( const ::rtl::OUString& ustrFileURL, DirectoryItem& rItem )
5457 	//---------------------------------------------------------------------
5458     class  get : public CppUnit::TestFixture
5459 	{
5460 		::osl::FileBase::RC     nError1, nError2;
5461 
5462 	    public:
5463 		// initialization
5464 		void setUp( )
5465 		{
5466 			// create a tempfile in $TEMP/tmpname.
5467 			createTestFile( aTmpName6 );
5468 		}
5469 
5470 		void tearDown( )
5471 		{
5472 			// remove the tempfile in $TEMP/tmpname.
5473 			deleteTestFile( aTmpName6 );
5474 		}
5475 
5476 		// test code.
5477 		void get_001( )
5478 		{
5479 			::osl::DirectoryItem    rItem;  //constructor
5480  			//get the DirectoryItem.
5481 			nError2 = ::osl::DirectoryItem::get( aTmpName6, rItem );
5482 
5483 			//check the file name
5484   			::osl::FileStatus   rFileStatus( FileStatusMask_FileName );
5485 			nError1 = rItem.getFileStatus( rFileStatus );
5486 			CPPUNIT_ASSERT( nError1 == FileBase::E_None );
5487 
5488 			CPPUNIT_ASSERT_MESSAGE( "test for get function: use copy constructor to get an item and check filename.",
5489 			                        ( ::osl::FileBase::E_None == nError2 ) &&
5490 			                        ( sal_True == compareFileName( rFileStatus.getFileName( ), aTmpName2 ) ) );
5491 		}
5492 
5493 		void get_002( )
5494 		{
5495 			::osl::DirectoryItem    rItem;
5496  			//get the DirectoryItem.
5497 			nError1 = ::osl::DirectoryItem::get( aSysPath1, rItem );
5498 
5499 			CPPUNIT_ASSERT_MESSAGE( "test for get function: use a system name instead of a URL.",
5500 			                        FileBase::E_INVAL == nError1 );
5501 		}
5502 
5503 		void get_003( )
5504 		{
5505 			::osl::DirectoryItem    rItem;
5506  			//get the DirectoryItem.
5507 			nError1 = ::osl::DirectoryItem::get( aTmpName3, rItem );
5508 
5509 			CPPUNIT_ASSERT_MESSAGE( "test for get function: use a non existed file URL.",
5510 			                        FileBase::E_NOENT == nError1 );
5511 		}
5512 
5513 		CPPUNIT_TEST_SUITE( get );
5514 		CPPUNIT_TEST( get_001 );
5515 		CPPUNIT_TEST( get_002 );
5516 		CPPUNIT_TEST( get_003 );
5517 		CPPUNIT_TEST_SUITE_END( );
5518 	};// class get
5519 
5520 	//---------------------------------------------------------------------
5521 	// 	testing the method
5522 	// 	inline RC getFileStatus( FileStatus& rStatus )
5523 	//---------------------------------------------------------------------
5524     class  getFileStatus : public CppUnit::TestFixture
5525 	{
5526 		::osl::FileBase::RC     nError1, nError2;
5527 
5528 	    public:
5529 		// initialization
5530 		void setUp( )
5531 		{
5532 			// create a tempfile in $TEMP/tmpdir/tmpname.
5533 			createTestDirectory( aTmpName3 );
5534 			createTestFile( aTmpName4 );
5535 		}
5536 
5537 		void tearDown( )
5538 		{
5539 			// remove the tempfile in $TEMP/tmpdir/tmpname.
5540 			deleteTestFile( aTmpName4 );
5541 			deleteTestDirectory( aTmpName3 );
5542 		}
5543 
5544 		// test code.
5545 		void getFileStatus_001( )
5546 		{
5547 			::osl::DirectoryItem    rItem;  //constructor
5548  			//get the DirectoryItem.
5549 			nError1 = ::osl::DirectoryItem::get( aTmpName4, rItem );
5550 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
5551 
5552 			//check the file name
5553   			::osl::FileStatus   rFileStatus( FileStatusMask_FileName );
5554 			nError2 = rItem.getFileStatus( rFileStatus );
5555 
5556 			CPPUNIT_ASSERT_MESSAGE( "test for getFileStatus function: get file status and check filename",
5557 			                        ( ::osl::FileBase::E_None == nError2 ) &&
5558 			                        ( sal_True == compareFileName( rFileStatus.getFileName( ), aTmpName2 ) ) );
5559 		}
5560 
5561 		void getFileStatus_002( )
5562 		{
5563 			::osl::DirectoryItem    rItem;  //constructor
5564  			//get the DirectoryItem.
5565 			nError1 = ::osl::DirectoryItem::get( aTmpName6, rItem );
5566 
5567 			//check the file name
5568   			::osl::FileStatus   rFileStatus( FileStatusMask_FileName );
5569 			nError2 = rItem.getFileStatus( rFileStatus );
5570 
5571 			CPPUNIT_ASSERT_MESSAGE( "test for getFileStatus function: file not existed",
5572 			                        ( ::osl::FileBase::E_INVAL == nError2 )  );
5573 		}
5574 
5575 		void getFileStatus_003( )
5576 		{
5577 			::osl::DirectoryItem    rItem;  //constructor
5578  			//get the DirectoryItem.
5579 			nError1 = ::osl::DirectoryItem::get( aTmpName3, rItem );
5580 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
5581 
5582 			//check the file name
5583   			::osl::FileStatus   rFileStatus( FileStatusMask_FileName );
5584 			nError2 = rItem.getFileStatus( rFileStatus );
5585 
5586 			CPPUNIT_ASSERT_MESSAGE( "test for getFileStatus function: get directory information",
5587 			                        ( ::osl::FileBase::E_None == nError2 ) &&
5588 			                        ( sal_True == compareFileName( rFileStatus.getFileName( ), aTmpName1 ) ) );
5589 		}
5590 
5591 
5592 		CPPUNIT_TEST_SUITE( getFileStatus );
5593 		CPPUNIT_TEST( getFileStatus_001 );
5594 		CPPUNIT_TEST( getFileStatus_002 );
5595 		CPPUNIT_TEST( getFileStatus_003 );
5596 		CPPUNIT_TEST_SUITE_END( );
5597 	};// class getFileStatus
5598 
5599 
5600 
5601  	CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_DirectoryItem::ctors, "osl_DirectoryItem" );
5602 	CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_DirectoryItem::copy_assin_Ctors, "osl_DirectoryItem" );
5603 	CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_DirectoryItem::is, "osl_DirectoryItem" );
5604 	CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_DirectoryItem::get, "osl_DirectoryItem" );
5605 	CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_DirectoryItem::getFileStatus, "osl_DirectoryItem" );
5606 }// namespace osl_DirectoryItem
5607 
5608 
5609 //------------------------------------------------------------------------
5610 // Beginning of the test cases for Directory class
5611 //------------------------------------------------------------------------
5612 namespace osl_Directory
5613 {
5614 	//---------------------------------------------------------------------
5615 	// 	testing the method
5616 	// 	Directory( const ::rtl::OUString& strPath ): _pData( 0 ), _aPath( strPath )
5617 	//---------------------------------------------------------------------
5618     class  ctors : public CppUnit::TestFixture
5619 	{
5620 		::osl::FileBase::RC     nError1, nError2;
5621 
5622 	    public:
5623 		// initialization
5624 		void setUp( )
5625 		{
5626 			// create a tempfile in $TEMP/tmpdir/tmpname.
5627 			createTestDirectory( aTmpName3 );
5628 			createTestFile( aTmpName4 );
5629 		}
5630 
5631 		void tearDown( )
5632 		{
5633 			// remove the tempfile in $TEMP/tmpdir/tmpname.
5634 			deleteTestFile( aTmpName4 );
5635 			deleteTestDirectory( aTmpName3 );
5636             // LLA: t_print("tearDown done.\n");
5637 		}
5638 
5639 		// test code.
5640 		void ctors_001( )
5641 		{
5642 			::osl::Directory testDirectory( aTmpName3 ); //constructor
5643 
5644 			//open a directory
5645 			nError1 = testDirectory.open( );
5646  			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
5647 			//close a directory
5648 			nError2 = testDirectory.close( );
5649  			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError2 );
5650 
5651 			CPPUNIT_ASSERT_MESSAGE( "test for ctors function: create an instance and check open and close",
5652 				 					( ::osl::FileBase::E_None == nError1 ) &&
5653 			                        ( ::osl::FileBase::E_None == nError2 ) );
5654 		}
5655 
5656 		void ctors_002( )
5657 		{
5658 			::osl::Directory testDirectory( aTmpName9 ); //constructor
5659 
5660 			//open a directory
5661 			nError1 = testDirectory.open( );
5662  			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
5663 			//close a directory
5664 			nError2 = testDirectory.close( );
5665  			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError2 );
5666 
5667 			CPPUNIT_ASSERT_MESSAGE( "test for ctors function: relative URL, :-), it is also worked",
5668 				 					( ::osl::FileBase::E_None == nError1 ) &&
5669 			                        ( ::osl::FileBase::E_None == nError2 ) );
5670 		}
5671 
5672 		CPPUNIT_TEST_SUITE( ctors );
5673 		CPPUNIT_TEST( ctors_001 );
5674 		CPPUNIT_TEST( ctors_002 );
5675 		CPPUNIT_TEST_SUITE_END( );
5676 	};// class ctors
5677 
5678 	//---------------------------------------------------------------------
5679 	// 	testing the method
5680 	// 	inline RC open()
5681 	//---------------------------------------------------------------------
5682     class  open : public CppUnit::TestFixture
5683 	{
5684 		::osl::FileBase::RC     nError1, nError2;
5685 
5686 	    public:
5687 		// initialization
5688 		void setUp( )
5689 		{
5690 			// create a tempfile in $TEMP/tmpdir/tmpname.
5691 			createTestDirectory( aTmpName3 );
5692 			createTestFile( aTmpName4 );
5693 		}
5694 
5695 		void tearDown( )
5696 		{
5697 			// remove the tempfile in $TEMP/tmpdir/tmpname.
5698 			deleteTestFile( aTmpName4 );
5699 			deleteTestDirectory( aTmpName3 );
5700 		}
5701 
5702 		// test code.
5703 		void open_001( )
5704 		{
5705 			::osl::Directory testDirectory( aTmpName3 ); //constructor
5706 
5707 			//open a directory
5708 			nError1 = testDirectory.open( );
5709 			//check if directory is opened.
5710 			sal_Bool bOk = testDirectory.isOpen( );
5711 			//close a directory
5712 			nError2 = testDirectory.close( );
5713 
5714 			CPPUNIT_ASSERT_MESSAGE( "test for open function: open a directory and check for open",
5715 			                        ( sal_True == bOk ) &&
5716 				 					( ::osl::FileBase::E_None == nError1 ) &&
5717 			                        ( ::osl::FileBase::E_None == nError2 ) );
5718 		}
5719 
5720 		void open_002( )
5721 		{
5722 			::osl::Directory testDirectory( aTmpName6 ); //constructor
5723 
5724 			//open a directory
5725 			nError1 = testDirectory.open( );
5726  			if ( ::osl::FileBase::E_None == nError1 )
5727 			{
5728 				nError2 = testDirectory.close( );
5729 				CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError2 );
5730 			}
5731 
5732 			CPPUNIT_ASSERT_MESSAGE( "test for open function: open a file that is not existed",
5733 				 					( ::osl::FileBase::E_NOENT == nError1 ) );
5734 		}
5735 
5736 		void open_003( )
5737 		{
5738 			::osl::Directory testDirectory( aUserDirectorySys ); //constructor
5739 
5740 			//open a directory
5741 			nError1 = testDirectory.open( );
5742  			if ( ::osl::FileBase::E_None == nError1 )
5743 			{
5744 				nError2 = testDirectory.close( );
5745 				CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError2 );
5746 			}
5747 
5748 			CPPUNIT_ASSERT_MESSAGE( "test for open function: using system path",
5749 				 					( ::osl::FileBase::E_INVAL == nError1 ) );
5750 		}
5751 
5752 		void open_004( )
5753 		{
5754 			::osl::Directory testDirectory( aTmpName4 ); //constructor
5755 
5756 			//open a directory
5757 			nError1 = testDirectory.open( );
5758  			if ( ::osl::FileBase::E_None == nError1 )
5759 			{
5760 				nError2 = testDirectory.close( );
5761 				CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError2 );
5762 			}
5763 
5764 			CPPUNIT_ASSERT_MESSAGE( "test for open function: open a file instead of a directory",
5765 				 					( ::osl::FileBase::E_NOTDIR == nError1 ) || ( ::osl::FileBase::E_ACCES ) );
5766 		}
5767 
5768 		CPPUNIT_TEST_SUITE( open );
5769 		CPPUNIT_TEST( open_001 );
5770 		CPPUNIT_TEST( open_002 );
5771 		CPPUNIT_TEST( open_003 );
5772 		CPPUNIT_TEST( open_004 );
5773 		CPPUNIT_TEST_SUITE_END( );
5774 	};// class open
5775 
5776 	//---------------------------------------------------------------------
5777 	// 	testing the method
5778 	// 	inline sal_Bool isOpen() { return _pData != NULL; };
5779 	//---------------------------------------------------------------------
5780     class  isOpen : public CppUnit::TestFixture
5781 	{
5782 		::osl::FileBase::RC     nError1, nError2;
5783 
5784 	    public:
5785 		// initialization
5786 		void setUp( )
5787 		{
5788 			// create a tempfile in $TEMP/tmpdir/tmpname.
5789 			createTestDirectory( aTmpName3 );
5790 			createTestFile( aTmpName4 );
5791 		}
5792 
5793 		void tearDown( )
5794 		{
5795 			// remove the tempfile in $TEMP/tmpdir/tmpname.
5796 			deleteTestFile( aTmpName4 );
5797 			deleteTestDirectory( aTmpName3 );
5798 		}
5799 
5800 		// test code.
5801 		void isOpen_001( )
5802 		{
5803 			::osl::Directory testDirectory( aTmpName3 ); //constructor
5804 
5805 			//open a directory
5806 			nError1 = testDirectory.open( );
5807 			//check if directory is opened.
5808 			sal_Bool bOk = testDirectory.isOpen( );
5809 			//close a directory
5810 			nError2 = testDirectory.close( );
5811 
5812 			CPPUNIT_ASSERT_MESSAGE( "test for isOpen function: open a directory and check for open",
5813 			                        ( sal_True == bOk ) );
5814 		}
5815 
5816 		void isOpen_002( )
5817 		{
5818 			::osl::Directory testDirectory( aTmpName3 ); //constructor
5819 
5820 			//check if directory is opened.
5821 			sal_Bool bOk = testDirectory.isOpen( );
5822 
5823 			CPPUNIT_ASSERT_MESSAGE( "test for isOpen function: do not open a directory and check for open",
5824 			                        !( sal_True == bOk ) );
5825 		}
5826 
5827 		CPPUNIT_TEST_SUITE( isOpen );
5828 		CPPUNIT_TEST( isOpen_001 );
5829 		CPPUNIT_TEST( isOpen_002 );
5830 		CPPUNIT_TEST_SUITE_END( );
5831 	};// class isOpen
5832 
5833 	//---------------------------------------------------------------------
5834 	// 	testing the method
5835 	// 	inline RC close()
5836 	//---------------------------------------------------------------------
5837     class  close : public CppUnit::TestFixture
5838 	{
5839 		::osl::FileBase::RC     nError1, nError2;
5840 
5841 	    public:
5842 		// initialization
5843 		void setUp( )
5844 		{
5845 			// create a tempdirectory : $TEMP/tmpdir.
5846 			createTestDirectory( aTmpName3 );
5847 		}
5848 
5849 		void tearDown( )
5850 		{
5851 			// remove a tempdirectory : $TEMP/tmpdir.
5852 			deleteTestDirectory( aTmpName3 );
5853 		}
5854 
5855 		// test code.
5856 		void close_001( )
5857 		{
5858 			::osl::Directory testDirectory( aTmpName3 ); //constructor
5859 
5860 			//open a directory
5861 			nError1 = testDirectory.open( );
5862 			//close a directory
5863 			nError2 = testDirectory.close( );
5864 			//check if directory is opened.
5865 			sal_Bool bOk = testDirectory.isOpen( );
5866 
5867 			CPPUNIT_ASSERT_MESSAGE( "test for isOpen function: close a directory and check for open",
5868 			                        !( sal_True == bOk ) );
5869 		}
5870 
5871 		void close_002( )
5872 		{
5873 			::osl::Directory testDirectory( aTmpName3 ); //constructor
5874 
5875 			//close a directory
5876 			nError1 = testDirectory.close( );
5877 
5878 			CPPUNIT_ASSERT_MESSAGE( "test for isOpen function: close a not opened directory",
5879 			                        ( ::osl::FileBase::E_BADF == nError1 ) );
5880 		}
5881 
5882 
5883 		CPPUNIT_TEST_SUITE( close );
5884 		CPPUNIT_TEST( close_001 );
5885 		CPPUNIT_TEST( close_002 );
5886 		CPPUNIT_TEST_SUITE_END( );
5887 	};// class close
5888 
5889 	//---------------------------------------------------------------------
5890 	// 	testing the method
5891 	// 	inline RC reset()
5892 	//---------------------------------------------------------------------
5893     class  reset : public CppUnit::TestFixture
5894 	{
5895 		::osl::FileBase::RC     nError1, nError2;
5896 		::osl::DirectoryItem    rItem;
5897 
5898 	    public:
5899 		// initialization
5900 		void setUp( )
5901 		{
5902 			// create a tempdirectory : $TEMP/tmpdir.
5903 			createTestDirectory( aTmpName3 );
5904 			// create three files : $TEMP/tmpdir/tmpname, $TEMP/tmpdir/tmpdir, $TEMP/tmpdir/hiddenfile,
5905 			createTestFile( aTmpName3, aTmpName2);
5906 			createTestFile( aTmpName3, aTmpName1);
5907 			createTestFile( aTmpName3, aHidURL1);
5908 		}
5909 
5910 		void tearDown( )
5911 		{
5912 			// remove three files : $TEMP/tmpdir/tmpname, $TEMP/tmpdir/tmpdir, $TEMP/tmpdir/hiddenfile,
5913 			deleteTestFile( aTmpName3, aHidURL1);
5914 			deleteTestFile( aTmpName3, aTmpName1);
5915 			deleteTestFile( aTmpName3, aTmpName2);
5916 			// remove a tempdirectory : $TEMP/tmpdir.
5917 			deleteTestDirectory( aTmpName3 );
5918 		}
5919 
5920 		// test code.
5921 		void reset_001( )
5922 		{
5923 			::osl::Directory testDirectory( aTmpName3 ); //constructor
5924 
5925 			//open a directory
5926 			nError1 = testDirectory.open( );
5927 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
5928 			//get first Item
5929 			nError1 = testDirectory.getNextItem( rItem, 1 );
5930 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
5931 			//get second Item
5932 			//mindy: nError1 = testDirectory.getNextItem( rItem, 0 );
5933 			//mindy: CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
5934 
5935 			//reset enumeration
5936 			nError2 = testDirectory.reset( );
5937 			//get reseted Item, if reset does not work, getNextItem() should return the second Item (aTmpName1)
5938 			nError1 = testDirectory.getNextItem( rItem, 0 );
5939 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
5940 
5941 			//check the file name
5942   			::osl::FileStatus   rFileStatus( FileStatusMask_FileName );
5943 			nError1 = rItem.getFileStatus( rFileStatus );
5944 			//close a directory
5945 			nError1 = testDirectory.close( );
5946 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
5947 
5948 			sal_Bool bOK1,bOK2;
5949 			bOK1 = compareFileName( rFileStatus.getFileName( ), aTmpName2 );
5950 			bOK2 = compareFileName( rFileStatus.getFileName( ), aHidURL1 );
5951 
5952 			CPPUNIT_ASSERT_MESSAGE( "test for reset function: get two directory item, reset it, then get again, check the filename",
5953 			                        ( ::osl::FileBase::E_None == nError2 ) &&
5954 			                        ( sal_True == bOK1 || bOK2 ) );
5955 		}
5956 
5957 		void reset_002( )
5958 		{
5959 			::osl::Directory testDirectory( aTmpName6 ); //constructor
5960 
5961 			//close a directory
5962 			nError1 = testDirectory.reset( );
5963 
5964 			CPPUNIT_ASSERT_MESSAGE( "test for reset function: reset a non existed directory",
5965 			                        ( ::osl::FileBase::E_NOENT == nError1 ) );
5966 		}
5967 
5968 
5969 		void reset_003( )
5970 		{
5971 			::osl::Directory testDirectory( aTmpName4 ); //constructor
5972 
5973 			//close a directory
5974 			nError1 = testDirectory.reset( );
5975 
5976 			CPPUNIT_ASSERT_MESSAGE( "test for reset function: reset a file instead of a directory",
5977 			                        ( ::osl::FileBase::E_NOTDIR == nError1 ) || ( ::osl::FileBase::E_NOENT == nError1 ) );
5978 		}
5979 
5980 		void reset_004( )
5981 		{
5982 			::osl::Directory testDirectory( aUserDirectorySys ); //constructor
5983 
5984 			//close a directory
5985 			nError1 = testDirectory.reset( );
5986 
5987 			CPPUNIT_ASSERT_MESSAGE( "test for reset function: use a system path",
5988 			                        ( ::osl::FileBase::E_INVAL == nError1 ) );
5989 		}
5990 
5991 		CPPUNIT_TEST_SUITE( reset );
5992 		CPPUNIT_TEST( reset_001 );
5993 		CPPUNIT_TEST( reset_002 );
5994 		CPPUNIT_TEST( reset_003 );
5995 		CPPUNIT_TEST( reset_004 );
5996 		CPPUNIT_TEST_SUITE_END( );
5997 	};// class reset
5998 
5999 	//---------------------------------------------------------------------
6000 	// 	testing the method
6001 	// 	inline RC getNextItem( DirectoryItem& rItem, sal_uInt32 nHint = 0 )
6002 	//---------------------------------------------------------------------
6003     class  getNextItem : public CppUnit::TestFixture
6004 	{
6005 		::osl::FileBase::RC     nError1, nError2;
6006 		::osl::DirectoryItem    rItem;
6007 
6008 	    public:
6009 		// initialization
6010 		void setUp( )
6011 		{
6012 			// create a tempdirectory : $TEMP/tmpdir.
6013 			createTestDirectory( aTmpName3 );
6014 			// create three files : $TEMP/tmpdir/tmpname, $TEMP/tmpdir/tmpdir, $TEMP/tmpdir/hiddenfile,
6015 			createTestFile( aTmpName3, aTmpName2 );
6016 			createTestFile( aTmpName3, aTmpName1 );
6017 			createTestFile( aTmpName3, aHidURL1 );
6018 
6019 		}
6020 
6021 		void tearDown( )
6022 		{
6023 			// remove three files : $TEMP/tmpdir/tmpname, $TEMP/tmpdir/tmpdir, $TEMP/tmpdir/hiddenfile,
6024 			deleteTestFile( aTmpName3, aHidURL1 );
6025 			deleteTestFile( aTmpName3, aTmpName1 );
6026 			deleteTestFile( aTmpName3, aTmpName2 );
6027 			// remove a tempdirectory : $TEMP/tmpdir.
6028 			deleteTestDirectory( aTmpName3 );
6029 		}
6030 
6031 		// test code.
6032 		void getNextItem_001( )
6033 		{
6034  			::osl::Directory testDirectory( aTmpName3 ); //constructor
6035 
6036 			//open a directory
6037 			nError1 = testDirectory.open( );
6038 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
6039 
6040 			//check the file name
6041 			::rtl::OUString     strFilename;
6042 			sal_Bool            bOk1 = sal_False;
6043             sal_Bool bOk2 = sal_False;
6044             sal_Bool bOk3 = sal_False;
6045   			::osl::FileStatus   rFileStatus( FileStatusMask_FileName );
6046 			for ( int nCount = 0; nCount < 3; nCount++ )
6047 			{
6048 				//get three Items
6049 				nError1 = testDirectory.getNextItem( rItem, 2 );
6050 				CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
6051 				nError1 = rItem.getFileStatus( rFileStatus );
6052 				CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
6053 				switch ( nCount )
6054 				{
6055 					case 0: bOk1 = compareFileName( rFileStatus.getFileName( ), aTmpName2 ) || compareFileName( rFileStatus.getFileName( ), aHidURL1);
6056 						break;
6057 					case 1: bOk2 = compareFileName( rFileStatus.getFileName( ), aTmpName1 );
6058 						break;
6059 					case 2: bOk3 = compareFileName( rFileStatus.getFileName( ), aHidURL1) || compareFileName( rFileStatus.getFileName( ), aTmpName2 );
6060 				}
6061 			}
6062 
6063 			//close a directory
6064 			nError1 = testDirectory.close( );
6065 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
6066 
6067 			CPPUNIT_ASSERT_MESSAGE( "test for getNextItem function: retrive three items and check their names.",
6068 			                        ( sal_True == bOk1 ) && ( sal_True == bOk2 ) && ( sal_True == bOk3 ) );
6069 		}
6070 
6071 		void getNextItem_002( )
6072 		{
6073  			::osl::Directory testDirectory( aTmpName3 ); //constructor
6074 			nError1 = testDirectory.getNextItem( rItem );
6075 
6076 			CPPUNIT_ASSERT_MESSAGE( "test for getNextItem function: retrive an item in a directory which is not opened, also test for nHint's default value.",
6077 			                        ( ::osl::FileBase::E_INVAL == nError1 ) );
6078 		}
6079 
6080 		void getNextItem_003( )
6081 		{
6082  			::osl::Directory testDirectory( aTmpName3 ); //constructor
6083 
6084 			//open a directory
6085 			nError1 = testDirectory.open( );
6086 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
6087 
6088 			for ( int nCount = 0; nCount < 4; nCount++ )
6089 			{
6090 				nError2 = testDirectory.getNextItem( rItem, 3 );
6091 			}
6092 
6093 			//close a directory
6094 			nError1 = testDirectory.close( );
6095 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
6096 
6097 			CPPUNIT_ASSERT_MESSAGE( "test for getNextItem function: retrive 4 times in a directory which contain only 3 files.",
6098 			                        ( ::osl::FileBase::E_NOENT == nError2 ) );
6099 		}
6100 
6101 		void getNextItem_004( )
6102 		{
6103 		//create a link file(can not on Windows), then check if getNextItem can get it.
6104 #ifdef UNX
6105 			sal_Bool bOK = sal_False;
6106 			::rtl::OUString aUStr_LnkFileSys( aTempDirectorySys ), aUStr_SrcFileSys( aTempDirectorySys );
6107 			( ( aUStr_LnkFileSys += aSlashURL ) += getCurrentPID( ) ) += ::rtl::OUString::createFromAscii("/tmpdir/link.file");
6108 			( ( aUStr_SrcFileSys += aSlashURL ) += getCurrentPID( ) ) += ::rtl::OUString::createFromAscii("/tmpdir/tmpname");
6109                 rtl::OString strLinkFileName, strSrcFileName;
6110                 strLinkFileName = OUStringToOString( aUStr_LnkFileSys, RTL_TEXTENCODING_ASCII_US );
6111                 strSrcFileName  = OUStringToOString( aUStr_SrcFileSys, RTL_TEXTENCODING_ASCII_US );
6112 
6113 			//create a link file and link it to file "/tmp/PID/tmpdir/tmpname"
6114                 sal_Int32 fd = symlink( strSrcFileName.getStr(), strLinkFileName.getStr() );
6115 			CPPUNIT_ASSERT( fd == 0 );
6116 			::osl::Directory testDirectory( aTmpName3 );
6117 
6118 			//open a directory
6119 			nError1 = testDirectory.open( );
6120 			::rtl::OUString aFileName = ::rtl::OUString::createFromAscii("link.file");
6121 
6122 			while (1) {
6123 				nError1 = testDirectory.getNextItem( rItem, 4 );
6124 				if (::osl::FileBase::E_None == nError1) {
6125 					::osl::FileStatus   rFileStatus( FileStatusMask_FileName | FileStatusMask_Type );
6126 					rItem.getFileStatus( rFileStatus );
6127 					if ( compareFileName( rFileStatus.getFileName( ), aFileName) == sal_True )
6128 					{
6129 						if ( FileStatus::Link == rFileStatus.getFileType( ))
6130 						{
6131 							bOK = sal_True;
6132 							break;
6133 						}
6134 					}
6135 				}
6136 				else
6137 					break;
6138 			};
6139                 fd = std::remove( strLinkFileName.getStr() );
6140 			CPPUNIT_ASSERT_MESSAGE( "remove link file failed", fd == 0 );
6141 			CPPUNIT_ASSERT_MESSAGE( "test for getNextItem function: check if can retrieve the link file name",
6142 			                        ( bOK == sal_True ) );
6143 #endif
6144 		}
6145 
6146 		CPPUNIT_TEST_SUITE( getNextItem );
6147 		CPPUNIT_TEST( getNextItem_001 );
6148 		CPPUNIT_TEST( getNextItem_002 );
6149 		CPPUNIT_TEST( getNextItem_003 );
6150 		CPPUNIT_TEST( getNextItem_004 );
6151 		CPPUNIT_TEST_SUITE_END( );
6152 	};// class getNextItem
6153 
6154 	//---------------------------------------------------------------------
6155 	// 	testing the method
6156 	// 	inline static RC getVolumeInfo( const ::rtl::OUString& ustrDirectoryURL, VolumeInfo& rInfo )
6157 	//---------------------------------------------------------------------
6158     class  getVolumeInfo : public CppUnit::TestFixture
6159 	{
6160 		::osl::FileBase::RC     nError1, nError2;
6161 
6162 	    public:
6163 
6164 		// test code.
6165         void checkValidMask(osl::VolumeInfo const& _aVolumeInfo, sal_Int32 _nMask)
6166             {
6167                 if (_nMask == VolumeInfoMask_FileSystemName)
6168 		{
6169 			//get file system name
6170 			::rtl::OUString aFileSysName( aNullURL );
6171                     aFileSysName = _aVolumeInfo.getFileSystemName( );
6172 
6173                     sal_Bool bRes2 = compareFileName( aFileSysName, aNullURL );
6174 			CPPUNIT_ASSERT_MESSAGE( "test for getVolumeInfo function: getVolumeInfo of root directory.",
6175 			                        ( osl::FileBase::E_None == nError1 ) &&
6176                                             ( sal_False == bRes2 ) );
6177                 }
6178                 if (_nMask == VolumeInfoMask_Attributes)
6179                 {
6180                     sal_Bool b1 = _aVolumeInfo.getRemoteFlag();
6181                     sal_Bool b2 = _aVolumeInfo.getRemoveableFlag();
6182                     sal_Bool b3 = _aVolumeInfo.getCompactDiscFlag();
6183                     sal_Bool b4 = _aVolumeInfo.getFloppyDiskFlag();
6184                     sal_Bool b5 = _aVolumeInfo.getFixedDiskFlag();
6185                     sal_Bool b6 = _aVolumeInfo.getRAMDiskFlag();
6186 
6187                     rtl::OString sAttr;
6188                     if (b1) sAttr =  "Remote";
6189                     if (b2) sAttr += " Removeable";
6190                     if (b3) sAttr += " CDROM";
6191                     if (b4) sAttr += " Floppy";
6192                     if (b5) sAttr += " FixedDisk";
6193                     if (b6) sAttr += " RAMDisk";
6194 
6195                     t_print("Attributes: %s\n", sAttr.getStr() );
6196                 }
6197                 if (_nMask == VolumeInfoMask_TotalSpace)
6198                 {
6199                     // within Linux, df / * 1024 bytes is the result
6200                     sal_uInt64 nSize = _aVolumeInfo.getTotalSpace();
6201                     t_print("Total space: %lld\n", nSize);
6202                 }
6203                 if (_nMask == VolumeInfoMask_UsedSpace)
6204                 {
6205                     sal_uInt64 nSize = _aVolumeInfo.getUsedSpace();
6206                     t_print(" Used space: %lld\n", nSize);
6207                 }
6208                 if (_nMask == VolumeInfoMask_FreeSpace)
6209                 {
6210                     sal_uInt64 nSize = _aVolumeInfo.getFreeSpace();
6211                     t_print(" Free space: %lld\n", nSize);
6212                 }
6213                 if (_nMask == VolumeInfoMask_MaxNameLength)
6214                 {
6215                     sal_uInt32 nLength = _aVolumeInfo.getMaxNameLength();
6216                     t_print("max name length: %ld\n", nLength);
6217                 }
6218                 if (_nMask == VolumeInfoMask_MaxPathLength)
6219                 {
6220                     sal_uInt32 nLength = _aVolumeInfo.getMaxPathLength();
6221                     t_print("max path length: %ld\n", nLength);
6222                 }
6223                 if (_nMask == VolumeInfoMask_FileSystemCaseHandling)
6224                 {
6225                     bool bIsCase = _aVolumeInfo.isCaseSensitiveFileSystem();
6226                     t_print("filesystem case sensitive: %s\n", bIsCase ? "yes" : "no");
6227                 }
6228             }
6229 
6230         void checkVolumeInfo(sal_Int32 _nMask)
6231             {
6232                 ::osl::VolumeInfo aVolumeInfo( _nMask );
6233                 //call getVolumeInfo here
6234                 nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo );
6235                 // LLA: IMHO it's not a bug, if VolumeInfo is not valid, it's a feature
6236                 // LLA: CPPUNIT_ASSERT_MESSAGE("mask is not valid", sal_True == aVolumeInfo.isValid( _nMask ) );
6237                 if (aVolumeInfo.isValid( _nMask))
6238                 {
6239                     checkValidMask(aVolumeInfo, _nMask);
6240                 }
6241             }
6242 
6243 
6244 		void getVolumeInfo_001_1( )
6245 		{
6246 			sal_Int32 mask = VolumeInfoMask_FileSystemName;
6247             checkVolumeInfo(mask);
6248 		}
6249 		void getVolumeInfo_001_2( )
6250 		{
6251 			sal_Int32 mask = VolumeInfoMask_Attributes;
6252             checkVolumeInfo(mask);
6253 		}
6254 		void getVolumeInfo_001_3( )
6255 		{
6256 			sal_Int32 mask = VolumeInfoMask_TotalSpace;
6257             checkVolumeInfo(mask);
6258 		}
6259 		void getVolumeInfo_001_4( )
6260 		{
6261 			sal_Int32 mask = VolumeInfoMask_UsedSpace;
6262             checkVolumeInfo(mask);
6263 		}
6264 		void getVolumeInfo_001_5( )
6265 		{
6266 			sal_Int32 mask = VolumeInfoMask_FreeSpace;
6267             checkVolumeInfo(mask);
6268 		}
6269 		void getVolumeInfo_001_6( )
6270 		{
6271 			sal_Int32 mask = VolumeInfoMask_MaxNameLength;
6272             checkVolumeInfo(mask);
6273 		}
6274 		void getVolumeInfo_001_7( )
6275 		{
6276 			sal_Int32 mask = VolumeInfoMask_MaxPathLength;
6277             checkVolumeInfo(mask);
6278 		}
6279 		void getVolumeInfo_001_8( )
6280 		{
6281 			sal_Int32 mask = VolumeInfoMask_FileSystemCaseHandling;
6282             checkVolumeInfo(mask);
6283 		}
6284 
6285 		void getVolumeInfo_002( )
6286 		{
6287 			sal_Int32 mask = VolumeInfoMask_FileSystemName;
6288 			::osl::VolumeInfo aVolumeInfo( mask );
6289 			//call getVolumeInfo here
6290 
6291             // LLA: rtl::OUString aRootSysURL;
6292             // LLA: nError1 = osl::File::getFileURLFromSystemPath(aRootSys, aRootSysURL);
6293             // LLA:
6294 			// LLA: CPPUNIT_ASSERT_MESSAGE( "can't convert root path to file url",
6295 			// LLA:                         ( osl::FileBase::E_NONE == nError1 ) );
6296 
6297 			nError1 = ::osl::Directory::getVolumeInfo( aRootSys, aVolumeInfo );
6298 
6299 			CPPUNIT_ASSERT_MESSAGE( "test for getVolumeInfo function: use system path as parameter.",
6300 			                        ( osl::FileBase::E_INVAL == nError1 ) );
6301 		}
6302 
6303 		void getVolumeInfo_003( )
6304 		{
6305 			sal_Int32 mask = VolumeInfoMask_FileSystemName;
6306 			::osl::VolumeInfo aVolumeInfo( mask );
6307 			//call getVolumeInfo here
6308 			nError1 = ::osl::Directory::getVolumeInfo( aTmpName3, aVolumeInfo );
6309 
6310 // LLA: in Windows, it reply no error, it did not pass in (W32).
6311 #ifdef UNX
6312 			CPPUNIT_ASSERT_MESSAGE( "test for getVolumeInfo function: non-existence test. ",
6313 			                        ( osl::FileBase::E_NOENT == nError1 ) );
6314 #endif
6315 		}
6316 
6317 		CPPUNIT_TEST_SUITE( getVolumeInfo );
6318 		CPPUNIT_TEST( getVolumeInfo_001_1 );
6319 		CPPUNIT_TEST( getVolumeInfo_001_2 );
6320 		CPPUNIT_TEST( getVolumeInfo_001_3 );
6321 		CPPUNIT_TEST( getVolumeInfo_001_4 );
6322 		CPPUNIT_TEST( getVolumeInfo_001_5 );
6323 		CPPUNIT_TEST( getVolumeInfo_001_6 );
6324 		CPPUNIT_TEST( getVolumeInfo_001_7 );
6325 		CPPUNIT_TEST( getVolumeInfo_001_8 );
6326 		CPPUNIT_TEST( getVolumeInfo_002 );
6327 		CPPUNIT_TEST( getVolumeInfo_003 );
6328 		CPPUNIT_TEST_SUITE_END( );
6329 	};// class getVolumeInfo
6330 
6331 
6332 	//---------------------------------------------------------------------
6333 	// 	testing the method
6334 	// 	inline static RC create( const ::rtl::OUString& ustrDirectoryURL )
6335 	//---------------------------------------------------------------------
6336     class  create : public CppUnit::TestFixture
6337 	{
6338 		::osl::FileBase::RC     nError1, nError2;
6339 
6340 	    public:
6341 
6342 		// test code.
6343 		void create_001( )
6344 		{
6345 			//create directory in $TEMP/tmpdir
6346 			nError1 = ::osl::Directory::create( aTmpName3 );
6347 			//check for existence
6348 			nError2 = ::osl::Directory::create( aTmpName3 );
6349 			//remove it
6350 			deleteTestDirectory( aTmpName3 );
6351 
6352 			CPPUNIT_ASSERT_MESSAGE( "test for create function: create a directory and check its existence.",
6353 			                        ( osl::FileBase::E_None == nError1 ) &&
6354 			                        ( osl::FileBase::E_EXIST== nError2 ) );
6355 		}
6356 
6357 		void create_002( )
6358 		{
6359 			//create directory in /tmpname
6360 			nError1 = ::osl::Directory::create( aTmpName7 );
6361 #if defined (WNT )
6362 			nError1 = osl::FileBase::E_ACCES;  /// in Windows, you can create directory in c:/ any way.
6363 			deleteTestDirectory( aTmpName7 );
6364 #endif
6365 
6366 			CPPUNIT_ASSERT_MESSAGE( "test for create function: create a directory in root for access test.",
6367 			                        ( osl::FileBase::E_ACCES == nError1 ) );
6368 		}
6369 
6370 		void create_003( )
6371 		{
6372 			//create directory in /tmpname
6373 			nError1 = ::osl::Directory::create( aSysPath1 );
6374 
6375 			CPPUNIT_ASSERT_MESSAGE( "test for create function: create a directory using system path.",
6376 			                        ( osl::FileBase::E_INVAL == nError1 ) );
6377 		}
6378 
6379 		CPPUNIT_TEST_SUITE( create );
6380 		CPPUNIT_TEST( create_001 );
6381 		CPPUNIT_TEST( create_002 );
6382 		CPPUNIT_TEST( create_003 );
6383 		CPPUNIT_TEST_SUITE_END( );
6384 	};// class create
6385 
6386 	//---------------------------------------------------------------------
6387 	// 	testing the method
6388 	// 	inline static RC remove( const ::rtl::OUString& ustrDirectoryURL )
6389 	//---------------------------------------------------------------------
6390     class  remove : public CppUnit::TestFixture
6391 	{
6392 		::osl::FileBase::RC     nError1, nError2;
6393 
6394 	    public:
6395 
6396 		// test code.
6397 		void remove_001( )
6398 		{
6399 			//create directory in $TEMP/tmpdir
6400 			nError1 = ::osl::Directory::create( aTmpName3 );
6401 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
6402 			//remove it
6403 			nError1 = ::osl::Directory::remove( aTmpName3 );
6404 			//check for existence
6405 			::osl::Directory rDirectory( aTmpName3 );
6406 			nError2 = rDirectory.open( );
6407 
6408 			CPPUNIT_ASSERT_MESSAGE( "test for remove function: remove a directory and check its existence.",
6409 			                        ( osl::FileBase::E_None == nError1 ) &&
6410 			                        ( osl::FileBase::E_NOENT == nError2 ) );
6411 		}
6412 
6413 		void remove_002( )
6414 		{
6415 			//create directory in $TEMP/tmpdir
6416 			nError1 = ::osl::Directory::create( aTmpName3 );
6417 			CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
6418 			//try to remove it by system path
6419 			nError1 = ::osl::Directory::remove( aSysPath3 );
6420  			//check for existence
6421 			::osl::Directory rDirectory( aTmpName3 );
6422 			nError2 = rDirectory.open( );
6423 			if ( osl::FileBase::E_NOENT != nError2 )
6424 				::osl::Directory::remove( aTmpName3 );
6425 
6426 			CPPUNIT_ASSERT_MESSAGE( "test for remove function: remove a directory by its system path, and check its existence.",
6427 			                        ( osl::FileBase::E_INVAL == nError1 ) );
6428 		}
6429 
6430 		void remove_003( )
6431 		{
6432 			//try to remove a non-existed directory
6433 			nError1 = ::osl::Directory::remove( aTmpName6 );
6434 
6435 			CPPUNIT_ASSERT_MESSAGE( "test for remove function: try to remove a non-existed directory.",
6436 			                        ( osl::FileBase::E_NOENT == nError1 ) );
6437 		}
6438 
6439 		void remove_004( )
6440 		{
6441 			createTestFile( aTmpName6 );
6442 			sal_Bool bExist = ifFileExist( aTmpName6 );
6443 			//try to remove file.
6444 			nError1 = ::osl::Directory::remove( aTmpName6 );
6445 			deleteTestFile( aTmpName6 );
6446 
6447 			CPPUNIT_ASSERT_MESSAGE( "test for remove function: try to remove a file but not directory.",
6448 			                        bExist == sal_True &&(( osl::FileBase::E_NOTDIR == nError1 ) || ( osl::FileBase::E_NOENT == nError1 )) );
6449 		}
6450 
6451 		void remove_005( )
6452 		{
6453 			createTestDirectory( aTmpName3 );
6454 			createTestFile( aTmpName4 );
6455 			nError1 = ::osl::Directory::remove( aTmpName3 );
6456 			deleteTestFile( aTmpName4 );
6457 			deleteTestDirectory( aTmpName3 );
6458 			::rtl::OUString suError = ::rtl::OUString::createFromAscii("test for remove function: try to remove a directory that is not empty.") + errorToStr( nError1 );
6459 #if defined ( SOLARIS )
6460 			//on UNX, the implementation uses rmdir(), which EEXIST is thrown on Solaris when the directory is not empty, refer to: 'man -s 2 rmdir', while on linux, ENOTEMPTY is thrown.
6461 			//EEXIST The directory contains entries other than those for "." and "..".
6462             t_print("#Solaris test\n");
6463 			CPPUNIT_ASSERT_MESSAGE( suError, ( osl::FileBase::E_EXIST == nError1 ) );
6464 #else
6465 			CPPUNIT_ASSERT_MESSAGE( suError, ( osl::FileBase::E_NOTEMPTY == nError1 ) );
6466 #endif
6467 		}
6468 
6469 		CPPUNIT_TEST_SUITE( remove );
6470 		CPPUNIT_TEST( remove_001 );
6471 		CPPUNIT_TEST( remove_002 );
6472 		CPPUNIT_TEST( remove_003 );
6473 		CPPUNIT_TEST( remove_004 );
6474 		CPPUNIT_TEST( remove_005 );
6475 		CPPUNIT_TEST_SUITE_END( );
6476 	};// class remove
6477 
6478     //########################################
6479     // TEST Directory::createPath
6480     //########################################
6481 
6482 	#ifdef WNT
6483     #   define PATH_BUFFER_SIZE MAX_PATH
6484     #else
6485     #   define PATH_BUFFER_SIZE PATH_MAX
6486     #endif
6487 
6488     char TEST_PATH_POSTFIX[] = "hello/world";
6489 
6490     //########################################
6491     OUString get_test_path()
6492     {
6493         OUString tmp;
6494         FileBase::RC rc = FileBase::getTempDirURL(tmp);
6495 
6496         CPPUNIT_ASSERT_MESSAGE
6497         (
6498         "Test path creation failed",
6499         rc == FileBase::E_None
6500         );
6501 
6502         OUStringBuffer b(tmp);
6503         if (tmp.lastIndexOf('/') != (tmp.getLength() - 1))
6504             b.appendAscii("/");
6505 
6506         b.appendAscii(TEST_PATH_POSTFIX);
6507 
6508         return b.makeStringAndClear();
6509     }
6510 
6511     //########################################
6512     void rm_test_path(const OUString& path)
6513     {
6514         sal_Unicode buffer[PATH_BUFFER_SIZE];
6515         rtl_copyMemory(buffer, path.getStr(), (path.getLength() + 1) * sizeof(sal_Unicode));
6516 
6517         sal_Int32 i = rtl_ustr_lastIndexOfChar(buffer, '/');
6518         if (i == path.getLength())
6519             buffer[i] = 0;
6520 
6521         Directory::remove(buffer);
6522 
6523         i = rtl_ustr_lastIndexOfChar(buffer, '/');
6524         buffer[i] = 0;
6525         Directory::remove(buffer);
6526     }
6527 
6528     //########################################
6529     class DirCreatedObserver : public DirectoryCreationObserver
6530     {
6531     public:
6532         DirCreatedObserver() : i(0)
6533         {
6534         }
6535 
6536         virtual void DirectoryCreated(const rtl::OUString& /*aDirectoryUrl*/)
6537         {
6538 			i++;
6539 		};
6540 
6541 	    int number_of_dirs_created() const
6542 	    {
6543 	        return i;
6544 	    }
6545 
6546 	private:
6547 		    int i;
6548     };
6549 
6550 
6551     //########################################
6552     class createPath : public CppUnit::TestFixture
6553     {
6554     public:
6555         //##########################################
6556         createPath()
6557         {}
6558 
6559         //##########################################
6560         void with_relative_path()
6561         {
6562             FileBase::RC rc = Directory::createPath(
6563                 OUString::createFromAscii(TEST_PATH_POSTFIX));
6564 
6565             CPPUNIT_ASSERT_MESSAGE
6566             (
6567                 "osl_createDirectoryPath contract broken",
6568                 rc == FileBase::E_INVAL
6569             );
6570         }
6571 
6572         //##########################################
6573         void without_callback()
6574         {
6575             OUString tp_url = get_test_path();
6576 
6577             rm_test_path(tp_url);
6578 
6579             FileBase::RC rc = Directory::createPath(tp_url);
6580 
6581             CPPUNIT_ASSERT_MESSAGE
6582             (
6583                 "osl_createDirectoryPath failed",
6584                 rc == FileBase::E_None
6585             );
6586         }
6587 
6588         //##########################################
6589         void with_callback()
6590         {
6591             OUString tp_url = get_test_path();
6592 
6593             rm_test_path(tp_url);
6594 
6595             DirCreatedObserver* observer = new DirCreatedObserver;
6596             FileBase::RC rc = Directory::createPath(tp_url, observer);
6597             int nDirs = observer->number_of_dirs_created();
6598             delete observer;
6599             CPPUNIT_ASSERT_MESSAGE
6600             (
6601                 "osl_createDirectoryPath failed",
6602                 (rc == FileBase::E_None) && (nDirs > 0)
6603             );
6604 
6605         }
6606 
6607 #ifdef WNT
6608 
6609         //##########################################
6610         char* get_unused_drive_letter()
6611         {
6612             static char m_aBuff[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
6613 
6614             DWORD ld = GetLogicalDrives();
6615             DWORD i = 4;
6616             DWORD j = 2;
6617 
6618             while ((ld & i) && (i > 1))
6619             { i = i << 1; j++; }
6620 
6621             if (i > 2)
6622                 return m_aBuff + j;
6623 
6624             return NULL;
6625         }
6626 
6627         //##########################################
6628         void at_invalid_logical_drive()
6629         {
6630             char* drv = get_unused_drive_letter();
6631             char buff[PATH_BUFFER_SIZE];
6632             rtl_zeroMemory(buff, sizeof(buff));
6633 
6634             strncpy(buff, drv, 1);
6635             strcat(buff, ":\\");
6636             strcat(buff, TEST_PATH_POSTFIX);
6637 
6638             OUString path = OUString::createFromAscii(buff);
6639             OUString tp_url;
6640             FileBase::getFileURLFromSystemPath(path, tp_url);
6641 
6642             FileBase::RC rc = Directory::createPath(tp_url);
6643 
6644             CPPUNIT_ASSERT_MESSAGE
6645             (
6646                 "osl_createDirectoryPath doesn't fail on unused logical drive letters",
6647                 rc != FileBase::E_None
6648             );
6649         }
6650 
6651         //##########################################
6652         void with_UNC_path()
6653         {
6654 
6655             OUString tp_unc = OUString::createFromAscii("\\\\Tra-1\\TRA_D\\hello\\world\\");
6656             OUString tp_url;
6657             FileBase::getFileURLFromSystemPath(tp_unc, tp_url);
6658 
6659             FileBase::RC rc = Directory::createPath(tp_url);
6660 
6661             CPPUNIT_ASSERT_MESSAGE
6662             (
6663                 "osl_createDirectoryPath fails with UNC path",
6664                 rc == FileBase::E_None
6665             );
6666         }
6667 
6668 #endif /* WNT */
6669 
6670     CPPUNIT_TEST_SUITE(createPath);
6671     CPPUNIT_TEST(with_relative_path);
6672     CPPUNIT_TEST(without_callback);
6673     CPPUNIT_TEST(with_callback);
6674 #ifdef WNT
6675     CPPUNIT_TEST(at_invalid_logical_drive);
6676 
6677     // adapt the UNC path in method createDirectoryPath_with_UNC_path
6678     // in order to run this test successfully
6679     //CPPUNIT_TEST(with_UNC_path);
6680 #endif
6681     CPPUNIT_TEST_SUITE_END();
6682 
6683     }; // class createPath
6684 
6685 	// -----------------------------------------------------------------------------
6686  	CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_Directory::ctors, "osl_Directory" );
6687 	CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_Directory::open, "osl_Directory" );
6688 	CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_Directory::isOpen, "osl_Directory" );
6689 	CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_Directory::close, "osl_Directory" );
6690 	CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_Directory::reset, "osl_Directory" );
6691 	CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_Directory::getNextItem, "osl_Directory" );
6692 	CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_Directory::getVolumeInfo, "osl_Directory" );
6693 	CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_Directory::create, "osl_Directory" );
6694 	CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_Directory::remove, "osl_Directory" );
6695 	CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_Directory::createPath, "osl_Directory" );
6696 }// namespace osl_Directory
6697 
6698 
6699 // -----------------------------------------------------------------------------
6700 // this macro creates an empty function, which will called by the RegisterAllFunctions()
6701 // to let the user the possibility to also register some functions by hand.
6702 // -----------------------------------------------------------------------------
6703 
6704 /// NOADDITIONAL;
6705 
6706 
6707 
6708 /** get Current PID.
6709 */
6710 inline ::rtl::OUString getCurrentPID(  )
6711 {
6712 	//~ Get current PID and turn it into OUString;
6713 	int nPID = 0;
6714 #ifdef WNT
6715 	nPID = GetCurrentProcessId();
6716 #else
6717 	nPID = getpid();
6718 #endif
6719 	return ( ::rtl::OUString::valueOf( ( long )nPID ) );
6720 }
6721 
6722 
6723 /** Insert Current PID to the URL to avoid access violation between multiuser execution.
6724 */
6725 inline void insertPID( ::rtl::OUString & pathname )
6726 {
6727 	//~ check if the path contain the temp directory, do nothing changes if not;
6728 	if ( pathname.indexOf( aTempDirectoryURL ) && pathname.indexOf( aTempDirectorySys ) )
6729 		return;
6730 
6731 	//~ format pathname to TEMP/USERPID/URL style;
6732 	if ( !pathname.indexOf( aTempDirectoryURL ) )
6733 	{
6734 		::rtl::OUString strPID( getCurrentPID( ) );
6735 		::rtl::OUString pathLeft = aTempDirectoryURL.copy( 0 );
6736 		::rtl::OUString pathRight = pathname.copy( aTempDirectoryURL.getLength( ) );
6737 		pathname = pathLeft.copy( 0 );
6738 		( ( pathname += aSlashURL ) += strPID ) += pathRight;
6739 	}
6740 	else
6741 	{
6742 		::rtl::OUString strPID( getCurrentPID( ) );
6743 		::rtl::OUString pathLeft = aTempDirectorySys.copy( 0 );
6744 		::rtl::OUString pathRight = pathname.copy( aTempDirectorySys.getLength( ) );
6745 		pathname = pathLeft.copy( 0 );
6746 		( ( pathname += aSlashURL ) += strPID ) += pathRight;
6747 	}
6748 
6749 
6750 }
6751 
6752 /** to do some initialized work, we replace the NOADDITIONAL macro with the initialize work which
6753       will check the file and directory existence. and set some variables for test use.
6754       to simplify the initialize work, we seperate it into UNIX section and Windows section, the main task
6755       of initialization is adapt all URL defined in osl_File_Const.h to TEMP/USERPID/URL style format,
6756       since there may be an instance that multiuser execute test at the same time, and the temp file
6757       may not be clean up in this case due to access right problem.
6758 */
6759 void RegisterAdditionalFunctions( FktRegFuncPtr _pFunc )
6760 {
6761     (void)_pFunc;
6762 	t_print( "Initializing..." );
6763 
6764 	//~ make sure the c:\temp exist, if not, create it.
6765 #if ( defined WNT )
6766 	if ( checkDirectory( aTempDirectoryURL, osl_Check_Mode_Exist )  != sal_True ) {
6767 		t_print( "\n#C:\\temp is not exist, now creating\n" );
6768 		createTestDirectory( aTempDirectoryURL );
6769 	};
6770 #endif
6771 
6772 	//~ make sure the c:\temp\PID or /tmp/PID exist, if not, create it. initialize the user directory.
6773 	( aUserDirectoryURL += aSlashURL ) += getCurrentPID( );
6774 	( aUserDirectorySys += aSlashURL ) += getCurrentPID( );
6775 
6776 	if ( checkDirectory( aUserDirectoryURL, osl_Check_Mode_Exist )  != sal_True ) {
6777 		createTestDirectory( aUserDirectoryURL );
6778 	}
6779 
6780 	//~ adapt all URL to the TEMP/USERPID/URL format;
6781 	insertPID( aCanURL1 );
6782 	insertPID( aTmpName3 );
6783 	insertPID( aTmpName4 );
6784 	insertPID( aTmpName5 );
6785 	insertPID( aTmpName6 );
6786 	insertPID( aTmpName8 );
6787 	insertPID( aTmpName9 );
6788 	insertPID( aLnkURL1 );
6789 	insertPID( aFifoSys );
6790 	insertPID( aSysPath1 );
6791 	insertPID( aSysPath2 );
6792 	insertPID( aSysPath3 );
6793 	insertPID( aSysPath4 );
6794 
6795 	t_print( "Done.\n" );
6796 
6797 }
6798 
6799 
6800 //~ do some clean up work after all test completed.
6801 class GlobalObject
6802 {
6803 	public:
6804 	~GlobalObject()
6805 	{
6806         try
6807         {
6808             //~ make sure the c:\temp\PID or /tmp/PID exist, if yes, delete it.
6809             t_print( "\n#Do some clean-ups ...\n" );
6810             if ( checkDirectory( aUserDirectoryURL, osl_Check_Mode_Exist )  == sal_True ) {
6811                 deleteTestDirectory( aUserDirectoryURL );
6812             }
6813 
6814             // LLA: t_print("after deleteTestDirectory\n");
6815             //~ special clean up task in Windows and Unix seperately;
6816 #if ( defined UNX ) || ( defined OS2 )
6817             //~ some clean up task  for UNIX OS
6818             ;
6819 #else
6820             //~ some clean up task  for Windows OS
6821             //~ check if some files are in the way, remove them if necessary.
6822             if ( ifFileExist( aTmpName6 )  == sal_True )
6823                 deleteTestFile( aTmpName6 );
6824             if ( ifFileExist( aTmpName4 )  == sal_True )
6825                 deleteTestFile( aTmpName4 );
6826             if ( checkDirectory( aTmpName4, osl_Check_Mode_Exist )  == sal_True )
6827                 deleteTestDirectory( aTmpName4 );
6828             if ( ifFileExist( aTmpName3 )  == sal_True )
6829                 deleteTestFile( aTmpName3 );
6830             if ( checkDirectory( aTmpName3, osl_Check_Mode_Exist )  == sal_True )
6831                 deleteTestDirectory( aTmpName3 );
6832 
6833             ::rtl::OUString aUStr( aUserDirectoryURL );
6834             concatURL( aUStr, aHidURL1 );
6835             if ( ifFileExist( aUStr )  == sal_True )
6836                 deleteTestFile( aUStr );
6837 
6838             ::rtl::OUString aUStr1( aRootURL );
6839             concatURL( aUStr1, aTmpName2 );
6840             if ( ifFileExist( aUStr1 )  == sal_True )
6841                 deleteTestFile( aUStr1 );
6842 #endif
6843 
6844         }
6845         catch (CppUnit::Exception &e)
6846         {
6847             t_print("Exception caught in GlobalObject dtor(). Exception message: '%s'. Source line: %d\n", e.what(), e.sourceLine().lineNumber());
6848         }
6849         catch (...)
6850         {
6851             t_print("Exception caught (...) in GlobalObject dtor()\n");
6852         }
6853     }
6854 };
6855 
6856 GlobalObject theGlobalObject;
6857