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