update emoji autocorrect entries from po-files
[LibreOffice.git] / sal / workben / testfile.cxx
blobaddb1b6b8603a3cb7a26570f6897cec4e47e6aa8
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #define UNICODE
22 #include <osl/file.hxx>
23 #include <osl/process.h>
24 #include <osl/time.h>
25 #include <rtl/alloc.h>
26 #include <rtl/ustring.hxx>
27 #include <stdio.h>
28 #include <string.h>
29 #include <time.h>
31 #ifdef UNX
32 #include <wchar.h>
33 #endif
35 #ifdef WNT
36 #include <windows.h>
37 #endif
39 using namespace osl;
41 rtl::OUString root;
43 rtl::OUString dir1;
44 rtl::OUString dir2;
45 rtl::OUString dir_on_server;
46 rtl::OUString dir_not_exist;
47 rtl::OUString dir_not_exist_on_server;
48 rtl::OUString dir_wrong_semantic;
50 rtl::OUString file1;
51 rtl::OUString file2;
52 rtl::OUString file3;
53 rtl::OUString file_on_server;
54 rtl::OUString file_not_exist;
56 void print_error(const ::rtl::OString& str, FileBase::RC rc);
58 void PressKey()
60 printf("\nPress Return !\n");
61 getchar();
64 void printFileName(const ::rtl::OUString& str)
66 rtl::OString aString;
68 aString = rtl::OUStringToOString( str, RTL_TEXTENCODING_ASCII_US );
70 printf( "%s", aString.getStr() );
72 return;
75 // Initialization
77 sal_Bool testLineBreak( sal_Char *pCount , sal_uInt64 nLen , sal_uInt32 *cLineBreak )
79 sal_Bool fSuccess=sal_False;
80 *cLineBreak=0;
82 if (nLen==0)
83 return fSuccess;
85 if ( *pCount==13 )
87 if (nLen>=1 && *(pCount+1)==10)
88 *cLineBreak=2;
89 else
90 *cLineBreak=1;
92 if (nLen>=2 && *(pCount+2)==10)
93 (*cLineBreak)++;
95 fSuccess=sal_True;
97 else if ( *pCount==10 )
99 *cLineBreak=1;
100 fSuccess=sal_True;
103 return fSuccess;
106 // Initialization
108 sal_Bool Initialize()
110 DirectoryItem aItem;
111 FileStatus aStatus( osl_FileStatus_Mask_All );
112 rtl_uString *strExeFileURL=NULL;
113 oslProcessError ProcessError;
115 rtl::OUString iniFileURL;
116 File *pFile;
118 FileBase::RC rc;
120 sal_uInt64 uBytesRequested;
121 sal_uInt64 uBytesRead;
122 sal_Char *pBuffer;
123 sal_Char *pBegin;
124 sal_Char *pCount;
126 rtl::OUString dir[12];
128 // Open to the ini-file
130 ProcessError=osl_getExecutableFile(&strExeFileURL);
132 if ( ProcessError == osl_Process_E_None)
134 sal_Unicode *pExeFileCount=rtl_uString_getStr(strExeFileURL)+rtl_uString_getLength(strExeFileURL);
136 // Search for the last slash in the Path
137 while (*pExeFileCount!=L'/' && pExeFileCount>rtl_uString_getStr(strExeFileURL))
138 pExeFileCount--;
140 // iniFileURL = strExeFileURL without the filename of the exe-File
141 iniFileURL=rtl::OUString( rtl_uString_getStr(strExeFileURL) ,(int) (pExeFileCount-rtl_uString_getStr(strExeFileURL)) );
143 // add "/testfile.ini" to iniFileURL
144 iniFileURL+=rtl::OUString("/testfile.ini");
146 // Open the ini-File
147 pFile=new File( iniFileURL );
148 rc=pFile->open( osl_File_OpenFlag_Read | osl_File_OpenFlag_Write );
149 if ( rc!=FileBase::E_None )
151 rtl_uString_release(strExeFileURL);
152 return sal_False;
155 else
157 rtl_uString_release(strExeFileURL);
158 return sal_False;
161 // Get filesize of the ini-File
163 rc=DirectoryItem::get( iniFileURL, aItem );
164 if ( rc!=FileBase::E_None )
165 return sal_False;
167 rc=aItem.getFileStatus( aStatus );
168 if ( rc!=FileBase::E_None )
169 return sal_False;
171 uBytesRequested=aStatus.getFileSize();
173 // read ini-File
174 rc=pFile->setPos( osl_Pos_Absolut, 0 );
175 pBuffer=(sal_Char*) rtl_allocateMemory( (sal_uInt32) (uBytesRequested+1)*sizeof(sal_Char) );
176 memset( pBuffer, 0, (sal_uInt32)(uBytesRequested+1)*sizeof(sal_Char) );
178 rc=pFile->read( pBuffer , uBytesRequested , uBytesRead );
179 if ( rc!=FileBase::E_None )
180 return sal_False;
182 pBegin=pBuffer;
183 pCount=pBegin;
185 for ( int i=0 ; i<12 ; i++ )
187 sal_uInt32 cLineBrake=0;
188 while ( (static_cast<sal_uInt64>(pCount-pBuffer) < uBytesRead) && *pCount!='=')
189 pCount++;
191 pCount++;
192 pBegin=pCount;
194 while ( (static_cast<sal_uInt64>(pCount-pBuffer) < uBytesRead) && !testLineBreak(pCount,uBytesRead-(pCount-pBuffer), &cLineBrake))
195 pCount++;
197 dir[i]=rtl::OUString(pBegin, pCount-pBegin, RTL_TEXTENCODING_ASCII_US);
199 pCount+=cLineBrake;
200 pBegin=pCount;
203 root=rtl::OUString(dir[0]);
204 dir1=rtl::OUString(dir[1]);
205 dir2=rtl::OUString(dir[2]);
206 dir_on_server=rtl::OUString(dir[3]);
207 dir_not_exist=rtl::OUString(dir[4]);
208 dir_not_exist_on_server=rtl::OUString(dir[5]);
209 dir_wrong_semantic=rtl::OUString(dir[6]);
211 file1=rtl::OUString(dir[7]);
212 file2=rtl::OUString(dir[8]);
213 file3=rtl::OUString(dir[9]);
214 file_on_server=rtl::OUString(dir[10]);
215 file_not_exist=rtl::OUString(dir[11]);
217 // close the ini-file
218 rc=pFile->close();
220 rtl_freeMemory( pBuffer );
222 // Create directories
223 rc=Directory::create( dir1 );
224 if ( rc!=FileBase::E_None )
225 return sal_False;
227 rc=Directory::create( dir2 );
228 if ( rc!=FileBase::E_None )
229 return sal_False;
231 rc=Directory::create( dir_on_server );
232 if ( rc!=FileBase::E_None )
233 return sal_False;
235 pFile=new File( file1 );
236 rc=pFile->open( osl_File_OpenFlag_Write | osl_File_OpenFlag_Create );
237 if ( rc!=FileBase::E_None )
238 return sal_False;
239 rc=pFile->close();
240 delete pFile;
242 pFile=new File( file2 );
243 rc=pFile->open( osl_File_OpenFlag_Write | osl_File_OpenFlag_Create );
244 if ( rc!=FileBase::E_None )
245 return sal_False;
246 rc=pFile->close();
247 delete pFile;
249 pFile=new File( file_on_server );
250 rc=pFile->open( osl_File_OpenFlag_Write | osl_File_OpenFlag_Create );
251 if ( rc!=FileBase::E_None )
252 return sal_False;
253 rc=pFile->close();
254 delete pFile;
256 return sal_True;
259 // Shutdown
261 sal_Bool Shutdown()
263 sal_Bool fSuccess=sal_True;
264 FileBase::RC rc;
265 File *pFile;
267 // remove created files
269 pFile=new File( file1 );
270 rc=pFile->remove( file1 );
271 if ( rc!=FileBase::E_None )
272 fSuccess=sal_False;
273 delete pFile;
275 pFile=new File( file2 );
276 rc=pFile->remove( file2 );
277 if ( rc!=FileBase::E_None )
278 fSuccess=sal_False;
279 delete pFile;
281 // remove created directories
283 rc=Directory::remove( dir1 );
284 if ( rc!=FileBase::E_None )
285 fSuccess=sal_False;
287 rc=Directory::remove( dir2 );
288 if ( rc!=FileBase::E_None )
289 fSuccess=sal_False;
291 // remove created file on the server
293 pFile=new File( file_on_server );
294 rc=pFile->remove( file_on_server );
295 if ( rc!=FileBase::E_None )
296 fSuccess=sal_False;
297 delete pFile;
299 // remove created directory on the server
301 rc=Directory::remove( dir_on_server );
302 if ( rc!=FileBase::E_None )
303 fSuccess=sal_False;
305 return fSuccess;
308 // helper functions
310 // Show FileType
311 void showFileType( FileStatus::Type aType )
313 if ( aType==FileStatus::Directory )
314 printf( "FileType: Directory \n" );
315 else if ( aType==FileStatus::Volume )
316 printf( "FileType: Volume \n" );
317 else if ( aType==FileStatus::Regular )
318 printf( "FileType: Regular \n" );
319 else if ( aType==FileStatus::Unknown )
320 printf( "FileType: Unknown \n" );
324 // Show Attributes
325 void showAttributes( sal_uInt64 uAttributes )
327 if ( uAttributes==0 )
328 printf( "No Attributes \n" );
329 if ( uAttributes & osl_File_Attribute_ReadOnly )
330 printf( "Attribute: ReadOnly \n" );
331 if ( uAttributes & osl_File_Attribute_Hidden )
332 printf( "Attribute: Hidden \n" );
333 if ( uAttributes & osl_File_Attribute_Executable )
334 printf( "Attribute: Executable \n");
335 if ( uAttributes & osl_File_Attribute_GrpWrite )
336 printf( "Attribute: GrpWrite \n");
337 if ( uAttributes & osl_File_Attribute_GrpRead )
338 printf( "Attribute: GrpRead \n" );
339 if ( uAttributes & osl_File_Attribute_GrpExe )
340 printf( "Attribute: GrpExe \n" );
341 if ( uAttributes & osl_File_Attribute_OwnWrite )
342 printf( "Attribute: OwnWrite \n");
343 if ( uAttributes & osl_File_Attribute_OwnRead )
344 printf( "Attribute: OwnRead \n" );
345 if ( uAttributes & osl_File_Attribute_OwnExe )
346 printf( "Attribute: OwnExe \n" );
347 if ( uAttributes & osl_File_Attribute_OthWrite )
348 printf( "Attribute: OthWrite \n" );
349 if ( uAttributes & osl_File_Attribute_OthRead )
350 printf( "Attribute: OthRead \n");
351 if ( uAttributes & osl_File_Attribute_OthExe )
352 printf( "Attribute: OthExe \n" );
354 return;
357 // Show Time
358 void showTime( TimeValue aTime )
360 TimeValue aLocalTimeVal, aSystemTimeVal , aSysTimeVal;
361 oslDateTime aDateTime, aSystemTime;
363 if ( osl_getLocalTimeFromSystemTime( &aTime, &aLocalTimeVal ) )
365 if ( osl_getDateTimeFromTimeValue( &aLocalTimeVal, &aDateTime ) )
367 printf("\t%02i.%02i.%4i , %02i.%02i.%02i Uhr\n", aDateTime.Day, aDateTime.Month, aDateTime.Year, aDateTime.Hours, aDateTime.Minutes, aDateTime.Seconds);
369 else
370 printf("Error !\n");
373 if ( osl_getDateTimeFromTimeValue( &aTime, &aSystemTime ) )
375 printf("SystemTime: \t\t%02i.%02i.%4i , %02i.%02i.%02i Uhr\n", aSystemTime.Day, aSystemTime.Month, aSystemTime.Year, aSystemTime.Hours, aSystemTime.Minutes, aSystemTime.Seconds);
377 else
378 printf("Error !\n");
380 //Verify
382 if ( osl_getTimeValueFromDateTime( &aSystemTime, &aSystemTimeVal ) )
384 if ( ( aSystemTimeVal.Seconds == aTime.Seconds ) && ( aSystemTimeVal.Nanosec == aTime.Nanosec ))
385 printf ("Verify : TimeValue : ok! \n");
386 else
388 printf ("Verify : TimeValue : Error! \n");
389 printf ("aTime : %u \n", aTime.Seconds);
390 printf ("aSystemTimeVal : %u \n", aSystemTimeVal.Seconds);
393 else
394 printf ("Verify : TimeValue : Error! \n");
396 if ( osl_getSystemTimeFromLocalTime( &aLocalTimeVal , &aSysTimeVal ) )
398 if ( ( aSysTimeVal.Seconds == aTime.Seconds ) && ( aSysTimeVal.Nanosec == aTime.Nanosec ))
399 printf ("Verify : SystemTime : ok! \n");
400 else
402 printf ("Verify : SystemTime : Error! \n");
403 printf ("aTime : %u\n", aTime.Seconds);
404 printf ("aSystemTimeVal : %u\n", aSysTimeVal.Seconds);
407 else
408 printf ("Verify : SystemTime : Error! \n");
410 return;
413 TimeValue getSystemTime()
415 TimeValue aTime;
416 time_t ltime;
418 time( &ltime );
420 aTime.Seconds = ltime;
421 aTime.Nanosec = 0;
423 return aTime;
426 // DirectoryOpenAndCloseTest
428 void DirectoryOpenAndCloseTest()
430 FileBase::RC rc;
431 Directory *pDir;
433 printf( "--------------------------------------------\n");
434 printf( "Directory-Open-And-Close-Test\n");
435 printf( "--------------------------------------------\n\n");
437 // open an existing directory
439 pDir=new Directory( dir1 );
440 printf( "Open an existing directory: ");
441 printFileName( dir1 );
442 printf( "\n" );
444 rc= pDir->open();
445 print_error( rtl::OString( "Open Directory" ), rc );
447 if ( pDir->isOpen() )
449 print_error( rtl::OString( "Directory is Open" ), rc );
452 // Close Directory
453 rc=pDir->close();
454 print_error( rtl::OString( "Close Directory" ), rc );
456 delete pDir;
457 printf( "\n" );
459 // open a not existing directory
461 pDir=new Directory( dir_not_exist );
463 printf( "Open a not existing directory: ");
464 printFileName( dir_not_exist );
465 printf( "\n" );
467 rc= pDir->open();
469 print_error( rtl::OString( "Open Directory" ), rc );
471 delete pDir;
473 printf( "\n" );
475 // open a directory with a wrong semantic
477 pDir=new Directory( dir_wrong_semantic );
479 printf( "Open a directory with a wrong semantic: ");
480 printFileName( dir_wrong_semantic );
481 printf( "\n" );
483 rc= pDir->open();
484 print_error( rtl::OString( "Open Directory" ), rc );
486 delete pDir;
488 printf( "\n" );
490 // open an existing directory on a server
492 pDir=new Directory( dir_on_server );
494 printf( "Open an existing directory on a server: ");
495 printFileName( dir_on_server );
496 printf( "\n" );
498 rc= pDir->open();
499 print_error( rtl::OString( "Open Directory" ), rc );
501 // Close Directory
502 rc=pDir->close();
503 print_error( rtl::OString( "Close Directory" ), rc );
505 delete pDir;
506 printf( "\n" );
508 // open a not existing directory on a server
510 pDir=new Directory( dir_not_exist_on_server );
512 printf( "Open a not existing directory on a server: ");
513 printFileName( dir_not_exist_on_server );
514 printf( "\n" );
516 rc= pDir->open();
517 print_error( rtl::OString( "Open Directory" ), rc );
519 delete pDir;
520 printf( "\n" );
522 // Close a not existing directory
524 pDir=new Directory( dir_not_exist );
525 printf( "Close a not existing directory: ");
526 printFileName( dir_not_exist );
527 printf( "\n" );
529 rc=pDir->close();
530 print_error( rtl::OString( "Close Directory" ), rc );
532 PressKey();
533 return;
537 // DirectoryCreateAndRemoveTest
539 void DirectoryCreateAndRemoveTest()
541 FileBase::RC rc,rc1;
542 Directory *pDir;
544 printf( "--------------------------------------------\n" );
545 printf( "Directory-Create-And-Remove-Test\n" );
546 printf( "--------------------------------------------\n\n" );
548 // Create directory
550 printf( "Create a not existing directory: ");
551 printFileName( dir_not_exist );
552 printf( "\n" );
554 rc=Directory::create( dir_not_exist) ;
555 print_error( rtl::OString( "Create Directory" ), rc );
557 // Verify
558 pDir=new Directory( dir_not_exist );
560 rc= pDir->open();
561 print_error( rtl::OString( "Verify" ), rc );
562 pDir->close();
563 delete pDir;
565 printf( "\n" );
567 // Create a directory on a server
569 printf( "Create a not existing directory on a server: ");
570 printFileName( dir_not_exist_on_server );
571 printf( "\n" );
573 rc=Directory::create( dir_not_exist_on_server );
574 print_error( rtl::OString( "Create Directory" ), rc );
576 // Verify
577 pDir=new Directory( dir_not_exist_on_server );
578 rc= pDir->open();
579 print_error( rtl::OString( "Verify" ), rc );
580 pDir->close();
581 delete pDir;
583 printf( "\n" );
585 // Remove Directories
587 printf( "Remove the created directories: \n" );
589 rc=Directory::remove( dir_not_exist );
591 rc1=Directory::remove( dir_not_exist_on_server );
593 if ( rc==FileBase::E_None && rc1==FileBase::E_None )
594 print_error( rtl::OString( "Remove Directories" ), FileBase::E_None );
595 else if ( rc!=FileBase::E_None )
596 print_error( rtl::OString( "Remove local Directory" ),rc );
597 else
598 print_error( rtl::OString( "Remove Directory on a server" ),rc1 );
600 printf( "\n" );
602 // Remove a not existing directory
604 printf( "Remove a not existing directory: ");
605 printFileName( dir_not_exist );
606 printf( "\n" );
608 rc=Directory::remove( dir_not_exist );
609 print_error( rtl::OString( "Remove" ),rc );
611 PressKey();
612 return;
615 // FileOpenAndCloseTest
617 static void FileOpenAndCloseTest()
619 FileBase::RC rc;
621 printf( "--------------------------------------------\n" );
622 printf( "File-Open-And-Close-Test\n" );
623 printf( "--------------------------------------------\n\n" );
625 File *pFile;
627 pFile=new File( file1 );
629 printf( "Open an existing file: ");
630 printFileName( file1 );
631 printf( "\n" );
633 // open an existing file (Read)
635 rc=pFile->open( osl_File_OpenFlag_Read );
636 print_error( rtl::OString( "Open File (Read)" ), rc );
638 // close the file
640 rc=pFile->close();
641 print_error( rtl::OString( "Close File" ), rc );
643 printf( "\n" );
645 // open an existing file (Write)
647 rc=pFile->open( osl_File_OpenFlag_Write );
648 print_error( rtl::OString( "Open File (Write)" ), rc );
650 // close the file
652 rc=pFile->close();
653 print_error( rtl::OString( "Close File" ), rc );
655 printf( "\n" );
657 // close the file a second time
659 rc=pFile->close();
660 print_error( rtl::OString( "Close the file a second time" ), rc );
662 delete pFile;
663 PressKey();
666 // FileCreateAndRemoveTest
668 void FileCreateAndRemoveTest()
670 FileBase::RC rc;
671 File *pFile;
673 printf( "--------------------------------------------\n" );
674 printf( "File-Create-And-Remove-Test\n" );
675 printf( "--------------------------------------------\n\n" );
677 pFile=new File( file_not_exist );
679 printf( "Create File: ");
680 printFileName( file_not_exist );
681 printf( "\n" );
683 // open (create) a not existing file (Read and write)
685 rc = pFile->open( osl_File_OpenFlag_Read | osl_File_OpenFlag_Write | osl_File_OpenFlag_Create );
687 print_error( rtl::OString( "Create and Open File (Read & Write)" ), rc );
689 // close the file
691 rc=pFile->close();
692 print_error( rtl::OString( "Close File" ), rc );
694 // remove the file
696 rc=pFile->remove( file_not_exist );
697 print_error( rtl::OString(" Remove File" ), rc );
699 printf( "\n" );
701 // remove the same file a second time
703 rc=pFile->remove( file_not_exist );
704 print_error( rtl::OString( "Remove a not existing File" ), rc );
706 // remove an open file
708 pFile->open( osl_File_OpenFlag_Read | osl_File_OpenFlag_Write | osl_File_OpenFlag_Create );
710 rc=pFile->remove( file_not_exist );
711 print_error( rtl::OString( "Remove an open File" ), rc );
713 pFile->close();
714 pFile->remove( file_not_exist );
716 PressKey();
718 return;
721 // FileWriteAndReadTest
723 void FileWriteAndReadTest()
725 FileBase::RC rc;
727 sal_uInt64 uWritten;
728 sal_uInt64 uRead;
729 const sal_Char *pWriteBuffer="Hier kommt der Osterhase !";
730 sal_uInt64 nLen=strlen( pWriteBuffer );
731 sal_Char *pReadBuffer;
733 printf( "--------------------------------------------\n" );
734 printf( "File-Write-And-Read-Test\n" );
735 printf( "--------------------------------------------\n\n" );
737 File *pFile;
739 pFile=new File( file_not_exist );
741 printf( "Create File: ");
742 printFileName( file_not_exist );
743 printf("\n");
745 // open (create) a not existing file (Read and write)
747 rc = pFile->open( osl_File_OpenFlag_Read | osl_File_OpenFlag_Write | osl_File_OpenFlag_Create );
749 print_error( rtl::OString( "Create and Open File (Read & Write)" ), rc );
751 printf( "\n" );
753 // write a string to the file
755 rc=pFile->write( pWriteBuffer , nLen , uWritten );
756 print_error( rtl::OString( "Write File" ), rc );
758 if(uWritten==nLen)
759 printf( "Verify: OK! \n" );
760 else
761 printf( "Verify: Error\n" );
763 printf( "\n" );
765 // move the filepointer to the beginning
767 rc=pFile->setPos( osl_Pos_Absolut , 0 );
768 print_error( rtl::OString( "Set FilePointer to the beginning of the file" ), rc );
770 printf( "\n" );
772 // read the string
774 pReadBuffer=(sal_Char*) rtl_allocateMemory( (sal_uInt32)(nLen+1)*sizeof(sal_Char) );
775 memset( pReadBuffer, 0, (sal_uInt32)(nLen+1)*sizeof(sal_Char) );
776 rc=pFile->read( pReadBuffer , nLen,uRead );
777 print_error( rtl::OString( "Read File" ), rc );
779 if (strcmp(pWriteBuffer, pReadBuffer)==0)
781 printf( "Verify: OK !\n" );
782 printf( "Text: %s\n",pReadBuffer );
784 else
785 printf( "Verify: Error\n" );
787 rtl_freeMemory( pReadBuffer );
789 printf( "\n" );
791 // close the file
792 rc=pFile->close();
793 print_error( rtl::OString( "Close File" ), rc );
795 // remove the file
796 rc=pFile->remove( file_not_exist );
797 print_error( rtl::OString( "Remove File" ), rc );
799 PressKey();
801 return;
805 // FileCopyMoveTest
807 void FileCopyAndMoveTest()
809 FileBase::RC rc;
811 printf( "--------------------------------------------\n" );
812 printf( "File-Copy-Move-Test\n" );
813 printf( "--------------------------------------------\n\n" );
815 File *pFile;
816 rtl::OUString destPath(dir2);
818 // FileCopyTest
820 destPath+=rtl::OUString("/");
821 destPath+=file3;
823 printf( "Copy the file ");
824 printFileName( file1 );
825 printf( " to ");
826 printFileName( destPath );
827 printf( "\n" );
829 rc=File::copy( file1 , destPath );
830 print_error( rtl::OString( "FileCopy" ), rc );
832 pFile=new File( destPath );
834 rc=pFile->open( osl_File_OpenFlag_Read );
835 if ( rc == FileBase::E_None)
837 printf( "Verify: OK!\n" );
838 pFile->close();
839 File::remove( destPath );
841 else
842 printf( "Verify: Error!\n" );
844 delete pFile;
846 printf( "\n" );
848 // Copy a file to a not existing directory
850 destPath=rtl::OUString( dir_not_exist );
851 destPath+=rtl::OUString("/");
852 destPath+=file3;
854 printf( "Copy a file to a not existing directory \n");
855 printf( "Copy the file %s to %s\n",
856 rtl::OUStringToOString( file1, RTL_TEXTENCODING_ASCII_US ).getStr(),
857 rtl::OUStringToOString( destPath, RTL_TEXTENCODING_ASCII_US ).getStr() );
859 rc=File::copy( file1, destPath );
860 print_error( rtl::OString( "FileCopy" ), rc );
862 printf( "\n" );
864 // Copy a directory
866 printf( "Copy the directory: ");
867 printFileName( dir1 );
868 printf( " to ");
869 printFileName( dir2 );
870 printf( "\n" );
872 rc=File::copy( dir1 , dir2 );
873 print_error( rtl::OString( "FileCopy" ), rc );
875 printf( "\n" );
877 // FileMoveTest
879 destPath=rtl::OUString( dir2 );
880 destPath+=rtl::OUString("/");
881 destPath+=file3;
883 printf( "Move the file ");
884 printFileName( file1 );
885 printf( " to ");
886 printFileName( destPath );
887 printf( "\n" );
889 rc=File::move( file1, destPath );
890 print_error( rtl::OString( "FileMove" ), rc );
892 pFile=new File( destPath );
894 rc=pFile->open( osl_File_OpenFlag_Read );
895 if ( rc==FileBase::E_None )
897 pFile->close();
899 delete pFile;
900 pFile=new File( file1 );
902 rc=pFile->open( osl_File_OpenFlag_Read );
904 if ( rc!=FileBase::E_None )
906 printf( "Verify: OK!\n" );
907 File::move( destPath, file1 );
909 else
911 printf( "Verify: Error!\n" );
912 pFile->close();
913 File::remove( destPath );
916 else
917 printf( "Verify: Error!\n" );
919 delete pFile;
921 printf( "\n" );
923 // Move a file to a not existing directory
925 destPath=rtl::OUString( dir_not_exist );
926 destPath+=rtl::OUString("/");
927 destPath+=file3;
929 printf( "Move a file to a not existing directory: \n");
930 printf( "Move the file ");
931 printFileName( file1 );
932 printf( " to ");
933 printFileName( destPath );
934 printf( "\n" );
936 rc=File::move( file1 , destPath );
937 print_error( rtl::OString( "FileMove" ), rc );
939 printf( "\n" );
941 // Move a directory
943 printf( "Move a directory: \n");
945 printf( "Move the directory ");
946 printFileName( dir1 );
947 printf( " to ");
948 printFileName( dir_not_exist );
949 printf( "\n" );
951 rc=File::move( dir1 , dir_not_exist);
952 print_error( rtl::OString( "FileMove" ), rc );
954 if ( rc == FileBase::E_None )
955 File::move( dir_not_exist , dir1);
957 printf( "\n" );
959 PressKey();
960 return;
963 // FileSizeTest
965 void FileSizeTest()
967 FileBase::RC rc;
968 sal_uInt64 filesize;
969 DirectoryItem aItem;
971 printf( "--------------------------------------------\n" );
972 printf( "File-Size-Test\n" );
973 printf( "--------------------------------------------\n\n" );
975 File aFile( file_not_exist );
977 printf( "Create File: ");
978 printFileName( file_not_exist );
979 printf( "\n\n");
981 rc = aFile.open( osl_File_OpenFlag_Read | osl_File_OpenFlag_Write | osl_File_OpenFlag_Create );
982 print_error( rtl::OString( "Create and Open File (Read & Write)" ), rc );
983 printf( "\n" );
985 if ( rc == FileBase::E_None )
988 // Set Filesize to 5000
990 printf( "Set FileSize to 5000\n" );
991 rc=aFile.setSize( 5000 );
992 print_error( rtl::OString( "Set FileSize" ), rc );
994 printf( "\n" );
995 printf( "Verify:\n" );
997 // Check whether Filesize is set to 5000
999 rc=DirectoryItem::get( file_not_exist, aItem );
1000 print_error( rtl::OString( "Get DirectoryItem" ), rc );
1002 if ( rc == FileBase::E_None )
1004 FileStatus rStatus( osl_FileStatus_Mask_FileSize );
1005 rc=aItem.getFileStatus( rStatus );
1006 print_error( rtl::OString( "Get FileStatus" ), rc );
1008 if ( rc == FileBase::E_None )
1010 filesize=rStatus.getFileSize();
1012 if ( filesize == 5000 )
1013 printf( "\nOK : FileSize: %" SAL_PRIuUINT64 "\n", filesize );
1014 else
1015 printf( "\nError : FileSize: %" SAL_PRIuUINT64 "\n", filesize );
1019 printf( "\n" );
1021 // Set Filesize to -1
1023 printf( "Set FileSize to -1\n" );
1024 rc=aFile.setSize( -1 );
1025 print_error( rtl::OString( "Set FileSize" ), rc );
1027 printf( "\n" );
1029 // close the file
1030 rc=aFile.close();
1031 print_error( rtl::OString( "Close File" ), rc );
1033 // remove the file
1034 rc=File::remove( file_not_exist );
1035 print_error( rtl::OString( "Remove File" ), rc );
1038 PressKey();
1040 return;
1043 // FilePointerTest
1045 void FilePointerTest()
1047 FileBase::RC rc;
1048 sal_uInt64 filepointer;
1050 printf( "--------------------------------------------\n" );
1051 printf( "File-Pointer-Test\n" );
1052 printf( "--------------------------------------------\n\n" );
1054 File rFile( file_not_exist );
1056 printf( "Create File: ");
1057 printFileName( file_not_exist );
1058 printf( "\n\n");
1060 rc = rFile.open( osl_File_OpenFlag_Read | osl_File_OpenFlag_Write | osl_File_OpenFlag_Create );
1061 print_error( rtl::OString( "Create and Open File (Read & Write) "), rc );
1062 printf( "\n" );
1064 if ( rc==FileBase::E_None )
1067 // get the position of the filepointer
1069 rc =rFile.getPos( filepointer );
1070 print_error( rtl::OString( "GetPos" ), rc );
1071 printf( "Position of the FilePointer: %" SAL_PRIuUINT64 "\n", filepointer );
1073 printf( "\n" );
1075 // set the filepointer at the end of a file
1077 printf( "Set FileSize to 5000\n" );
1078 rFile.setSize( 5000 );
1080 printf( "Set the FilePointer at the end of the file (5000)\n" );
1081 rc=rFile.setPos( osl_Pos_End,0 );
1082 print_error( rtl::OString( "SetPos" ), rc );
1084 rc=rFile.getPos( filepointer );
1086 if ( filepointer==5000 )
1088 print_error( rtl::OString( "GetPos" ), rc );
1089 printf( "\nVerify: OK !\n" );
1090 printf( "Filepointer-Position: %" SAL_PRIuUINT64 "\n",filepointer );
1092 else
1094 print_error( rtl::OString( "GetPos" ), rc );
1095 printf( "\nFilePointer-Test: Error\n" );
1096 printf( "Filepointer-Position: %" SAL_PRIuUINT64 " != 5000 \n",filepointer );
1099 printf( "\n" );
1101 // close the file
1102 rc=rFile.close();
1103 print_error( rtl::OString( "Close File" ), rc );
1105 // remove the file
1106 rc=File::remove( file_not_exist );
1107 print_error( rtl::OString( "Remove File" ), rc );
1110 PressKey();
1112 return;
1115 // FileAttributesTest
1117 void verifyFileAttributes()
1119 FileBase::RC rc;
1120 DirectoryItem aItem;
1121 FileStatus rStatus( osl_FileStatus_Mask_Attributes );
1123 printf( "\nVerify:\n" );
1125 rc=DirectoryItem::get( file1, aItem );
1127 if ( rc==FileBase::E_None )
1129 rc=aItem.getFileStatus( rStatus );
1131 if ( rc==FileBase::E_None )
1133 sal_uInt64 uAttributes=rStatus.getAttributes();
1134 showAttributes(uAttributes);
1135 printf( "\n" );
1137 else
1138 print_error( rtl::OString( "Get FileStatus" ), rc );
1140 else
1141 print_error( rtl::OString( "Get DirectoryItem" ), rc );
1143 return;
1146 #ifdef UNX
1147 void FileAttributesTest()
1149 FileBase::RC rc;
1151 printf( "--------------------------------------------\n" );
1152 printf( "File-Attributes-Test\n" );
1153 printf( "--------------------------------------------\n\n" );
1155 printf( "File: ");
1156 printFileName( file1 );
1157 printf( "\n\n" );
1159 rc=File::setAttributes( file1, osl_File_Attribute_GrpWrite );
1160 print_error( rtl::OString( "Set Attribute: GrpWrite" ), rc );
1162 verifyFileAttributes();
1164 rc=File::setAttributes( file1, 0 );
1165 if ( rc!=FileBase::E_None )
1166 print_error( rtl::OString( "Reset Attributes" ), rc );
1168 rc=File::setAttributes( file1, osl_File_Attribute_GrpRead );
1169 print_error( rtl::OString( "Set Attribute: GrpRead" ), rc );
1171 verifyFileAttributes();
1173 rc=File::setAttributes( file1, 0 );
1174 if ( rc!=FileBase::E_None )
1175 print_error( rtl::OString( "Reset Attributes" ), rc );
1177 rc=File::setAttributes( file1, osl_File_Attribute_GrpExe );
1178 print_error( rtl::OString( "Set Attribute: GrpExe" ), rc );
1180 verifyFileAttributes();
1182 rc=File::setAttributes( file1, 0 );
1183 if ( rc!=FileBase::E_None )
1184 print_error( rtl::OString( "Reset Attributes" ), rc );
1186 rc=File::setAttributes( file1, osl_File_Attribute_OwnWrite );
1187 print_error( rtl::OString( "Set Attribute: OwnWrite" ), rc );
1189 verifyFileAttributes();
1191 rc=File::setAttributes( file1, 0 );
1192 if ( rc!=FileBase::E_None )
1193 print_error( rtl::OString( "Reset Attributes" ), rc );
1195 rc=File::setAttributes( file1, osl_File_Attribute_OwnRead );
1196 print_error( rtl::OString( "Set Attribute: OwnRead" ), rc );
1198 verifyFileAttributes();
1200 rc=File::setAttributes( file1, 0 );
1201 if ( rc!=FileBase::E_None )
1202 print_error( rtl::OString( "Reset Attributes" ), rc );
1204 rc=File::setAttributes( file1, osl_File_Attribute_OwnExe );
1205 print_error( rtl::OString( "Set Attribute: OwnExe" ), rc );
1207 verifyFileAttributes();
1209 rc=File::setAttributes( file1, 0 );
1210 if ( rc!=FileBase::E_None )
1211 print_error( rtl::OString( "Reset Attributes" ), rc );
1213 rc=File::setAttributes( file1, osl_File_Attribute_OthWrite );
1214 print_error( rtl::OString( "Set Attribute: OthWrite" ), rc );
1216 verifyFileAttributes();
1218 rc=File::setAttributes( file1, 0 );
1219 if ( rc!=FileBase::E_None )
1220 print_error( rtl::OString( "Reset Attributes" ), rc );
1222 rc=File::setAttributes( file1, osl_File_Attribute_OthRead );
1223 print_error( rtl::OString( "Set Attribute: OthRead" ), rc );
1225 verifyFileAttributes();
1227 rc=File::setAttributes( file1, 0 );
1228 if ( rc!=FileBase::E_None )
1229 print_error( rtl::OString( "Reset Attributes" ), rc );
1231 rc=File::setAttributes( file1, osl_File_Attribute_OthExe );
1232 print_error( rtl::OString( "Set Attribute: OthExe" ), rc );
1234 verifyFileAttributes();
1236 rc=File::setAttributes( file1, 0 );
1237 if ( rc!=FileBase::E_None )
1238 print_error( rtl::OString( "Reset Attributes" ), rc );
1240 rc=File::setAttributes( file1, osl_File_Attribute_GrpWrite | osl_File_Attribute_GrpRead | osl_File_Attribute_GrpExe | osl_File_Attribute_OwnWrite | osl_File_Attribute_OwnRead | osl_File_Attribute_OwnExe | osl_File_Attribute_OthWrite | osl_File_Attribute_OthRead | osl_File_Attribute_OthExe );
1241 print_error( rtl::OString( "Set all Attributes" ), rc );
1243 verifyFileAttributes();
1245 PressKey();
1247 return;
1249 #endif
1251 #ifdef WNT
1252 void FileAttributesTest()
1254 FileBase::RC rc;
1256 printf( "--------------------------------------------\n" );
1257 printf( "File-Attributes-Test\n" );
1258 printf( "--------------------------------------------\n\n" );
1260 printf( "File: ");
1261 printFileName( file1 );
1262 printf( "\n\n" );
1264 rc=File::setAttributes( file1, osl_File_Attribute_ReadOnly );
1265 print_error( rtl::OString( "Set Attribute: ReadOnly" ), rc );
1267 verifyFileAttributes();
1269 rc=File::setAttributes( file1, 0 );
1270 print_error( rtl::OString( "Reset Attributes" ), rc );
1272 verifyFileAttributes();
1274 rc=File::setAttributes( file1, osl_File_Attribute_Hidden );
1275 print_error( rtl::OString( "Set Attribute: Hidden" ), rc );
1277 verifyFileAttributes();
1279 rc=File::setAttributes( file1, 0 );
1280 print_error( rtl::OString( "Reset Attributes" ), rc );
1282 verifyFileAttributes();
1284 rc=File::setAttributes( file1, osl_File_Attribute_Hidden | osl_File_Attribute_ReadOnly );
1285 print_error( rtl::OString( "Set Attribute: Hidden & ReadOnly" ), rc );
1287 verifyFileAttributes();
1289 rc=File::setAttributes( file1, 0 );
1290 print_error( rtl::OString( "Reset Attributes") , rc );
1292 verifyFileAttributes();
1294 PressKey();
1296 return;
1298 #endif
1300 // FileTimeTest
1302 void FileTimeTest()
1304 FileBase::RC rc;
1306 DirectoryItem aItem;
1308 struct tm sSysCreationTime;
1309 sSysCreationTime.tm_sec = 0;
1310 sSysCreationTime.tm_min = 20;
1311 sSysCreationTime.tm_hour = 12;
1312 sSysCreationTime.tm_mday = 4;
1313 sSysCreationTime.tm_mon = 9;
1314 sSysCreationTime.tm_year = 99;
1316 struct tm sSysAccessTime;
1317 sSysAccessTime.tm_sec = 0;
1318 sSysAccessTime.tm_min = 40;
1319 sSysAccessTime.tm_hour = 1;
1320 sSysAccessTime.tm_mday = 6;
1321 sSysAccessTime.tm_mon = 5;
1322 sSysAccessTime.tm_year = 98;
1324 struct tm sSysModifyTime;
1325 sSysModifyTime.tm_sec = 0;
1326 sSysModifyTime.tm_min = 1;
1327 sSysModifyTime.tm_hour = 24;
1328 sSysModifyTime.tm_mday = 13;
1329 sSysModifyTime.tm_mon = 11;
1330 sSysModifyTime.tm_year = 95;
1332 sal_uInt32 aSysCreationTime = mktime( &sSysCreationTime );
1333 sal_uInt32 aSysAccessTime = mktime( &sSysAccessTime );
1334 sal_uInt32 aSysModifyTime = mktime( &sSysModifyTime );
1336 TimeValue aCreationTime = { aSysCreationTime, 0};
1337 TimeValue aAccessTime = { aSysAccessTime, 0};
1338 TimeValue aModifyTime = { aSysModifyTime, 0};
1340 TimeValue aCreationTimeRead;
1341 TimeValue aAccessTimeRead;
1342 TimeValue aModifyTimeRead;
1344 printf( "--------------------------------------------\n" );
1345 printf( "File-Time-Test\n" );
1346 printf( "--------------------------------------------\n\n" );
1348 printf( "File: ");
1349 printFileName( file1 );
1350 printf( "\n\n" );
1352 printf( "CreationTime \t : ");
1353 showTime( aCreationTime );
1355 printf( "\nAccessTime \t : ");
1356 showTime( aAccessTime );
1358 printf( "\nModifyTime \t : ");
1359 showTime( aModifyTime );
1361 // setTime
1363 printf( "\n" );
1364 rc=File::setTime( file1 , aCreationTime , aAccessTime , aModifyTime );
1365 print_error( rtl::OString( "SetTime" ), rc );
1367 // Verify
1369 FileStatus rStatus( osl_FileStatus_Mask_CreationTime | osl_FileStatus_Mask_AccessTime | osl_FileStatus_Mask_ModifyTime);
1371 printf( "\nVerify:\n" );
1373 rc=DirectoryItem::get( file1, aItem );
1374 print_error( rtl::OString( "Get DirectoryItem" ), rc );
1376 if ( rc==FileBase::E_None )
1378 rc=aItem.getFileStatus( rStatus );
1379 print_error( rtl::OString( "Get FileStatus" ), rc );
1380 printf( "\n" );
1382 if ( rc==FileBase::E_None )
1385 // GetCreationTime
1387 aCreationTimeRead=rStatus.getCreationTime();
1388 #ifdef WNT
1389 if ( aCreationTime.Seconds == aCreationTimeRead.Seconds && aCreationTime.Nanosec == aCreationTimeRead.Nanosec )
1390 printf( "GetCreationTime: ok : " );
1391 else
1392 printf( "GetCreationTime: Error : " );
1394 showTime( aCreationTimeRead );
1395 printf( "\n" );
1396 #endif
1398 // GetAccessTime
1400 aAccessTimeRead=rStatus.getAccessTime();
1402 if ( aAccessTime.Seconds == aAccessTimeRead.Seconds && aAccessTime.Nanosec == aAccessTimeRead.Nanosec )
1403 printf( "GetAccessTime: ok : " );
1404 else
1405 printf( "GetAccessTime: Error : " );
1407 showTime( aAccessTimeRead );
1408 printf( "\n" );
1410 // GetModifyTime
1412 aModifyTimeRead=rStatus.getModifyTime();
1414 if ( aModifyTime.Seconds == aModifyTimeRead.Seconds && aModifyTime.Nanosec == aModifyTimeRead.Nanosec )
1415 printf( "GetModifyTime: ok : " );
1416 else
1417 printf( "GetModifyTime: Error : " );
1419 showTime( aModifyTimeRead );
1420 printf( "\n" );
1424 PressKey();
1425 return;
1428 // DirectoryItemTest
1430 void DirectoryItemTest()
1432 FileBase::RC rc;
1433 Directory *pDir;
1434 DirectoryItem aItem;
1435 FileStatus *pStatus;
1436 File *pFile;
1438 printf( "--------------------------------------------\n" );
1439 printf( "Directory-Item-Test\n" );
1440 printf( "--------------------------------------------\n\n" );
1442 // get DirectoryItem from an existing directory
1444 printf( "Get DirectoryItem from an existing Directory: ");
1445 printFileName( dir1 );
1446 printf( "\n");
1448 rc=DirectoryItem::get( dir1 , aItem );
1449 print_error( rtl::OString( "GetDirectoryItem" ), rc );
1451 pStatus=new FileStatus( osl_FileStatus_Mask_All );
1452 rc=aItem.getFileStatus( *pStatus );
1454 if ( rc==FileBase::E_None )
1456 printf( "GetFileStatus: FileURL: ");
1457 printFileName(pStatus->getFileURL() );
1458 printf( "\n" );
1461 delete pStatus;
1463 printf( "\n" );
1465 // get DirectoryItem from a not existing directory
1467 printf( "Get DirectoryItem from a not existing Directory: ");
1468 printFileName( dir_not_exist );
1469 printf( "\n" );
1471 rc=DirectoryItem::get( dir_not_exist , aItem );
1472 print_error( rtl::OString( "Get DirectoryItem" ), rc );
1474 printf( "\n" );
1476 // get DirectoryItem from an existing file
1478 printf( "Get DirectoryItem from an existing File: ");
1479 printFileName( file1 );
1480 printf( "\n" );
1482 rc=DirectoryItem::get( file1 , aItem );
1483 print_error( rtl::OString( "GetDirectoryItem" ), rc );
1485 pStatus=new FileStatus( osl_FileStatus_Mask_All );
1486 rc=aItem.getFileStatus( *pStatus );
1488 if ( rc==FileBase::E_None )
1490 printf( "GetFileStatus: FileURL: ");
1491 printFileName( pStatus->getFileURL() );
1492 printf( "\n" );
1495 delete pStatus;
1497 printf( "\n" );
1499 // get DirectoryItem from a not existing file
1501 printf( "Get DirectoryItem from a not existing File: ");
1502 printFileName( file_not_exist );
1503 printf( "\n" );
1505 rc=DirectoryItem::get( file_not_exist , aItem );
1506 print_error( rtl::OString( "Get DirectoryItem" ), rc );
1508 printf( "\n" );
1510 // get DirectoryItem from a directory with a wrong semantic
1512 printf( "Get DirectoryItem from a Directory with a wrong semantic: ");
1513 printFileName( dir_not_exist );
1514 printf( "\n" );
1516 rc=DirectoryItem::get( dir_wrong_semantic, aItem );
1517 print_error( rtl::OString( "Get DirectoryItem" ),rc );
1519 printf( "\n" );
1521 // get DirectoryItem from a file-handle
1523 pFile=new File( file1 );
1525 rc=pFile->open( osl_File_OpenFlag_Read );
1526 if ( rc==FileBase::E_None )
1528 printf( "Get DirectoryItem from a File-Handle: ");
1529 printFileName( file1 );
1530 printf( "\n" );
1532 rc=DirectoryItem::get( file1 , aItem );
1533 print_error( rtl::OString( "GetDirectoryItem" ), rc );
1535 pStatus=new FileStatus( osl_FileStatus_Mask_All );
1536 rc=aItem.getFileStatus( *pStatus );
1538 if ( rc==FileBase::E_None )
1540 printf( "GetFileStatus: FileURL: ");
1541 printFileName( pStatus->getFileURL() );
1542 printf( "\n");
1545 delete pStatus;
1547 pFile->close();
1550 delete pFile;
1552 printf( "\n" );
1554 // get DirectoryItem
1556 printf( "Get DirectoryItem from an empty File-Handle\n" );
1557 rc=DirectoryItem::get( file1 , aItem );
1558 print_error( rtl::OString( "GetDirectoryItem" ), rc );
1560 printf( "\n" );
1562 // GetNextItem from a directory
1564 pDir=new Directory( dir1 );
1565 printf( "Get next DirectoryItem from a directory: ");
1566 printFileName( dir1);
1567 printf( "\n" );
1569 rc= pDir->open();
1570 print_error( rtl::OString( "Open Directory" ), rc );
1572 printf( "\n" );
1574 if ( pDir->isOpen() )
1577 // get all files from the directory
1579 rtl::OUString str;
1580 rtl::OUString str1[2];
1582 aItem=DirectoryItem();
1583 rc=pDir->getNextItem( aItem );
1584 print_error( rtl::OString( "GetNextItem" ),rc );
1586 while( rc==FileBase::E_None )
1589 FileStatus rStatus( osl_FileStatus_Mask_All );
1590 aItem.getFileStatus( rStatus );
1592 str=rStatus.getFileName();
1593 printf( "Filename: ");
1594 printFileName( str );
1595 printf( "\n");
1597 aItem=DirectoryItem();
1598 rc=pDir->getNextItem( aItem );
1599 print_error( rtl::OString( "GetNextItem" ),rc );
1602 printf( "\n" );
1604 // Reset-Test
1606 for (int i=0; i<2; i++)
1608 aItem=DirectoryItem();
1609 rc=pDir->reset();
1610 rc=pDir->getNextItem( aItem );
1612 FileStatus rStatus( osl_FileStatus_Mask_All );
1613 aItem.getFileStatus( rStatus );
1615 str1[i]=rStatus.getFileName();
1618 if ( str1[0] == str1[1] )
1619 print_error( rtl::OString( "Reset" ),FileBase::E_None );
1620 else
1621 print_error( rtl::OString( "Reset" ),FileBase::E_invalidError );
1623 printf( "\n" );
1625 // Close Directory
1626 rc=pDir->close();
1627 print_error( rtl::OString( "Close Directory" ), rc );
1630 printf( "\n");
1632 // GetNextItem from a closed directory
1634 printf( "Get next DirectoryItem from a closed directory: ");
1635 printFileName( dir1 );
1636 printf( "\n" );
1638 aItem=DirectoryItem();
1639 rc=pDir->getNextItem( aItem );
1640 print_error( rtl::OString( "GetNextItem" ),rc );
1642 delete pDir;
1644 PressKey();
1645 return;
1648 // FileStatusTest (for different types)
1650 void FileStatusTest( FileStatus *pStatus )
1653 // GetFileType of the directory
1655 FileStatus::Type aType;
1657 printf( "\ngetFileType:\n" );
1658 aType=pStatus->getFileType();
1659 showFileType( aType );
1661 // GetAttributes
1663 sal_uInt64 uAttributes;
1665 printf( "\ngetAttributes:\n" );
1666 uAttributes=pStatus->getAttributes();
1667 showAttributes( uAttributes );
1669 // GetCreationTime
1671 TimeValue aCreationTime;
1673 printf( "\ngetCreationTime:\n" );
1674 aCreationTime=pStatus->getCreationTime();
1676 printf( "CreationTime: " );
1677 showTime( aCreationTime );
1679 // GetAccessTime
1681 TimeValue aAccessTime;
1683 printf( "\ngetAccessTime:\n" );
1684 aAccessTime=pStatus->getAccessTime();
1686 printf( "AccessTime: " );
1687 showTime( aAccessTime );
1689 // GetModifyTime
1691 TimeValue aModifyTime;
1693 printf( "\ngetModifyTime:\n" );
1694 aModifyTime=pStatus->getModifyTime();
1696 printf( "ModifyTime: " );
1697 showTime( aModifyTime );
1699 // GetFileSize
1701 sal_uInt64 FileSize;
1703 printf( "\ngetFileSize:\n" );
1705 FileSize=pStatus->getFileSize();
1706 printf( "FileSize: %" SAL_PRIuUINT64 "\n", FileSize);
1708 // GetFileName
1710 rtl::OUString FileName;
1712 printf( "\ngetFileName:\n" );
1714 FileName=pStatus->getFileName();
1715 printf( "FileName: ");
1716 printFileName( FileName );
1717 printf( "\n" );
1719 // GetFileURL
1721 rtl::OUString FileURL;
1723 printf( "\ngetFileURL:\n" );
1725 FileURL=pStatus->getFileURL();
1726 printf( "FileURL: ");
1727 printFileName( FileURL );
1728 printf( "\n" );
1730 // GetLinkTargetURL
1732 rtl::OUString LinkTargetURL;
1734 printf( "\ngetLinkTargetURL:\n");
1736 LinkTargetURL=pStatus->getLinkTargetURL();
1737 printf( "LinkTargetURL: ");
1738 printFileName( LinkTargetURL );
1739 printf( "\n" );
1741 return;
1744 // DirectoryFileStatusTest
1746 void DirectoryFileStatusTest()
1748 FileBase::RC rc;
1749 DirectoryItem aItem;
1751 printf( "--------------------------------------------\n" );
1752 printf( "Directory-FileStatus-Test\n" );
1753 printf( "--------------------------------------------\n\n" );
1755 printf( "FileStatus of the directory: ");
1756 printFileName( dir1 );
1757 printf( "\n" );
1759 aItem=DirectoryItem();
1761 rc=DirectoryItem::get( dir1, aItem );
1762 print_error( rtl::OString( "Get DirectoryItem" ), rc );
1764 if ( rc==FileBase::E_None )
1766 FileStatus *pStatus=new FileStatus( osl_FileStatus_Mask_All );
1767 rc=aItem.getFileStatus( *pStatus );
1769 FileStatusTest( pStatus );
1771 delete pStatus;
1774 printf( "\n" );
1776 PressKey();
1777 return;
1780 // FileFileStatusTest
1782 void FileFileStatusTest()
1784 FileBase::RC rc;
1785 DirectoryItem aItem;
1787 printf( "--------------------------------------------\n" );
1788 printf( "File-FileStatus-Test\n" );
1789 printf( "--------------------------------------------\n\n" );
1791 printf( "FileStatus of the file: ");
1792 printFileName( file1 );
1793 printf( "\n" );
1795 aItem=DirectoryItem();
1797 rc=DirectoryItem::get( file1 , aItem );
1798 print_error( rtl::OString( "Get DirectoryItem" ), rc );
1800 if ( rc==FileBase::E_None )
1802 FileStatus *pStatus=new FileStatus( osl_FileStatus_Mask_All );
1803 rc=aItem.getFileStatus( *pStatus );
1805 FileStatusTest( pStatus );
1807 delete pStatus;
1810 printf( "\n" );
1812 PressKey();
1813 return;
1816 // VolumeFileStatusTest
1818 void VolumeFileStatusTest()
1820 FileBase::RC rc;
1821 DirectoryItem aItem;
1823 printf( "--------------------------------------------\n" );
1824 printf( "Volume-FileStatus-Test\n" );
1825 printf( "--------------------------------------------\n\n" );
1827 printf( "FileStatus of the Volume: ");
1828 printFileName( root );
1829 printf( "\n" );
1831 aItem=DirectoryItem();
1833 rc=DirectoryItem::get( root , aItem );
1834 print_error( rtl::OString( "Get DirectoryItem" ), rc );
1836 if ( rc==FileBase::E_None )
1838 FileStatus *pStatus=new FileStatus( osl_FileStatus_Mask_All) ;
1839 rc=aItem.getFileStatus( *pStatus );
1841 FileStatusTest( pStatus );
1843 delete pStatus;
1846 printf( "\n" );
1848 PressKey();
1849 return;
1852 // VolumeInfoTest
1854 void VolumeInfoTest()
1856 FileBase::RC rc;
1858 printf( "--------------------------------------------\n" );
1859 printf( "Volume-Info-Test\n" );
1860 printf( "--------------------------------------------\n\n" );
1862 printf( "VolumeInfo of the volume ");
1863 printFileName( root );
1865 printf( "\n" );
1867 VolumeInfo rInfo( osl_VolumeInfo_Mask_FreeSpace );
1868 rc=Directory::getVolumeInfo( root , rInfo );
1869 print_error( rtl::OString( "GetVolumeInfo" ),rc );
1871 printf( "\n" );
1873 // getRemoteFlag
1875 if ( rInfo.getRemoteFlag() )
1876 printf( "RemoteFlag: Yes\n" );
1877 else
1878 printf( "RemoteFlag: No\n" );
1880 // getRemoveableFlag
1882 if ( rInfo.getRemoveableFlag() )
1883 printf( "RemoveableFlag: Yes\n" );
1884 else
1885 printf( "RemoveableFlag: No\n" );
1887 // getTotalSpace
1889 sal_uInt64 TotalSpace;
1890 TotalSpace=rInfo.getTotalSpace();
1891 printf( "Total Space: %" SAL_PRIuUINT64 "\n",TotalSpace );
1893 // getFreeSpace
1895 sal_uInt64 FreeSpace;
1896 FreeSpace=rInfo.getFreeSpace();
1897 printf( "Free Space: %" SAL_PRIuUINT64 "\n",FreeSpace );
1899 // getUsedSpace
1901 sal_uInt64 UsedSpace;
1902 UsedSpace=rInfo.getUsedSpace();
1903 printf( "Used Space: %" SAL_PRIuUINT64 "\n",UsedSpace );
1905 // getMaxNameLength
1907 sal_uInt32 MaxNameLength;
1908 MaxNameLength=rInfo.getMaxNameLength();
1909 printf( "MaxNameLength: %" SAL_PRIuUINT32 "\n",MaxNameLength );
1911 // getMaxPathLength
1913 sal_uInt32 MaxPathLength;
1914 MaxPathLength=rInfo.getMaxPathLength();
1915 printf( "MaxPathLength: %" SAL_PRIuUINT32 "\n",MaxPathLength );
1917 // getFileSystemName
1919 rtl::OUString FileSystemName;
1920 FileSystemName=rInfo.getFileSystemName();
1921 printf( "File-System-Name: ");
1922 printFileName( FileSystemName );
1923 printf( "\n" );
1925 PressKey();
1926 return;
1929 // FileBaseTest
1931 void ConvertPathTest(rtl::OUString& strPath)
1933 FileBase::RC rc;
1935 rtl::OUString strNormPath;
1936 rtl::OUString strFileURL;
1937 rtl::OUString strNormPathFromFileURL;
1938 rtl::OUString strSystemPath;
1940 // normalizePath
1942 rc=FileBase::getFileURLFromSystemPath( strPath, strNormPath );
1944 if ( rc == FileBase::E_None )
1946 printf( "Normalized Path: \t\t");
1947 printFileName( strNormPath );
1948 printf( "\n" );
1950 else
1951 printf( "normalizePath: Error \n" );
1953 // getFileURLFromSystemPath
1955 if ( !strNormPath.isEmpty() )
1957 rc=FileBase::getFileURLFromSystemPath( strNormPath, strFileURL );
1959 if ( rc == FileBase::E_None )
1961 printf( "File-URL: \t\t\t");
1962 printFileName( strFileURL );
1963 printf( "\n" );
1965 else
1966 printf( "getFileURLFromSystemPath: Error \n" );
1968 else
1969 printf( "getFileURLFromSystemPath: not tested \n" );
1971 // getNormalizedPathFromFileURL
1973 if ( !strFileURL.isEmpty() )
1975 rc=FileBase::getSystemPathFromFileURL( strFileURL, strNormPathFromFileURL );
1977 if ( rc == FileBase::E_None )
1979 printf( "Normalized Path from File-URL: \t");
1980 printFileName( strNormPathFromFileURL );
1981 printf( "\n" );
1983 else
1984 printf( "getNormalizedPathFromFileURL: Error \n" );
1986 else
1987 printf( "getNormalizedPathFromFileURL: not tested \n" );
1989 // getSystemPathFromFileURL
1991 if ( !strNormPath.isEmpty() )
1993 rc=FileBase::getSystemPathFromFileURL( strNormPath, strSystemPath );
1995 if ( rc == FileBase::E_None )
1997 printf( "System-Path: \t\t\t");
1998 printFileName( strSystemPath );
1999 printf( "\n");
2001 else
2002 printf( "getSystemPathFromFileURL: Error \n" );
2004 else
2005 printf( "getSystemPathFromFileURL: not tested \n" );
2007 // Verify
2009 if ( strNormPathFromFileURL == strNormPath )
2010 printf( "\nVerify: OK ! ( Normalized-Path == Normalized-Path-From-File-URL )\n" );
2011 else
2012 printf( "\nVerify: Error ! ( Normalized-Path != Normalized-Path-From-File-URL )\n" );
2014 return;
2017 void FileBaseTest()
2019 printf( "--------------------------------------------\n" );
2020 printf( "FileBase-Test\n" );
2021 printf( "--------------------------------------------\n\n" );
2023 // ConvertPath-Test (Local File)
2025 printf( "- Local File: ");
2026 printFileName( file1 );
2027 printf( "\n\n" );
2029 ConvertPathTest(file1);
2031 // ConvertPath-Test (File on a server)
2033 printf( "\n- File on server: ");
2034 printFileName( file_on_server );
2035 printf( "\n\n" );
2036 ConvertPathTest(file_on_server);
2038 PressKey();
2040 return;
2043 // AbsolutePathTest
2045 void DoAbsolutePathTest(rtl::OUString strDirBase, rtl::OUString strRelative)
2047 FileBase::RC rc;
2049 rtl::OUString strAbsolute;
2051 printf( "Base-Directory: \t");
2052 printFileName( strDirBase );
2053 printf( "\n" );
2054 printf( "Relative-Path: \t\t");
2055 printFileName ( strRelative );
2056 printf( "\n" );
2058 rc=FileBase::getAbsoluteFileURL( strDirBase, strRelative, strAbsolute );
2060 if ( rc == FileBase::E_None )
2062 printf( "Absolute-Path: \t\t");
2063 printFileName ( strAbsolute );
2064 printf( "\n" );
2066 else
2067 printf( "Absolute-Path: Error \n" );
2069 printf( "\n" );
2070 return;
2073 void AbsolutePathTest()
2075 printf( "--------------------------------------------\n" );
2076 printf( "AbsolutePath-Test\n" );
2077 printf( "--------------------------------------------\n\n" );
2079 DoAbsolutePathTest(dir1, rtl::OUString("."));
2080 DoAbsolutePathTest(dir1, rtl::OUString(".."));
2081 DoAbsolutePathTest(dir1, rtl::OUString("../.."));
2082 DoAbsolutePathTest(dir1, rtl::OUString("../HUHU"));
2084 DoAbsolutePathTest(dir_on_server, rtl::OUString("."));
2085 DoAbsolutePathTest(dir_on_server, rtl::OUString(".."));
2086 DoAbsolutePathTest(dir_on_server, rtl::OUString("../.."));
2087 DoAbsolutePathTest(dir_on_server, rtl::OUString("../HUHU"));
2089 PressKey();
2090 return;
2093 // searchPathTest
2095 void SearchPathTest()
2097 FileBase::RC rc;
2099 rtl::OUString strNormPath(file1);
2100 rtl::OUString strFileURL;
2101 rtl::OUString strSystemPath;
2102 rtl::OUString strResultPath;
2104 printf( "--------------------------------------------\n" );
2105 printf( "SearchPath-Test\n" );
2106 printf( "--------------------------------------------\n\n" );
2108 rc=FileBase::getFileURLFromSystemPath( strNormPath, strFileURL );
2109 print_error( rtl::OString( "getFileURLFromSystemPath" ), rc );
2110 rc=FileBase::getSystemPathFromFileURL( strNormPath, strSystemPath );
2111 print_error( rtl::OString( "getSystemPathFromFileURL" ), rc );
2113 // searchFileURL (with a normalized path)
2115 if ( !strNormPath.isEmpty() )
2117 printf( "\nSearch-Normalized-Path (with a normalized path) : ");
2118 printFileName ( strNormPath );
2119 printf( "\n" );
2121 rc=FileBase::searchFileURL( strNormPath , rtl::OUString() , strResultPath );
2123 if ( rc == FileBase::E_None )
2125 printf( "Result: \t\t\t");
2126 printFileName ( strResultPath );
2127 printf( "\n" );
2129 else
2130 printf( "searchFileURL (with a normalized path): Error\n" );
2132 else
2133 printf( "searchFileURL (with a normalized path): not tested\n" );
2135 // searchFileURL (with a File-URL)
2137 if ( !strFileURL.isEmpty() )
2139 printf( "\nSearch-Normalized-Path (with a FileURL) : ");
2140 printFileName( strFileURL );
2141 printf( "\n" );
2143 rc=FileBase::searchFileURL( strFileURL , rtl::OUString() , strResultPath );
2145 if ( rc == FileBase::E_None )
2147 printf( "Result: \t\t\t");
2148 printFileName ( strResultPath );
2149 printf( "\n" );
2151 else
2152 printf( "searchFileURL (with a FileURL path): Error\n" );
2154 else
2155 printf( "searchFileURL (with a FileURL path): not tested\n" );
2157 // searchFileURL (with a systempath)
2159 if ( !strSystemPath.isEmpty() )
2161 printf( "\nSearch-Normalized-Path (with a SystemPath) : ");
2162 printFileName( strSystemPath );
2163 printf( "\n" );
2165 rc=FileBase::searchFileURL( strSystemPath , rtl::OUString() , strResultPath );
2167 if ( rc == FileBase::E_None )
2169 printf( "Result: \t\t\t");
2170 printFileName( strResultPath );
2171 printf( "\n" );
2173 else
2174 printf( "searchFileURL (with a systempath): Error\n" );
2176 else
2177 printf( "searchFileURL (with a systempath): not tested\n" );
2179 // searchFileURL (File and no searchpath)
2181 printf( "\nsearchFileURL: File (no searchpath) : ");
2182 printFileName( file3 );
2183 printf( "\n" );
2185 rc=FileBase::searchFileURL( file3 , rtl::OUString("") , strResultPath );
2187 if ( rc == FileBase::E_None )
2189 printf( "Result: \t\t\t");
2190 printFileName( strResultPath );
2191 printf( "\n" );
2193 else
2194 printf( "searchFileURL: File not found: OK ! \n" );
2196 // searchFileURL (File and Path)
2198 printf( "\nsearchFileURL: File : ");
2199 printFileName( file3 );
2200 printf( "\tSearchPath ");
2201 printFileName( dir1 );
2202 printf( "\n");
2204 rc=FileBase::searchFileURL( file3 , dir1 , strResultPath );
2206 if ( rc == FileBase::E_None )
2208 printf( "Result: \t\t\t");
2209 printFileName( strResultPath );
2210 printf( "\n");
2212 else
2213 printf( "searchFileURL: File not found: Error\n" );
2215 // searchFileURL (File and searchpath with two entries)
2217 rtl::OUString strSearchPath( dir_not_exist );
2218 strSearchPath+=rtl::OUString(";");
2219 strSearchPath+=dir_on_server;
2221 printf( "\nsearchFileURL: File : ");
2222 printFileName( file3 );
2223 printf( "SearchPath ");
2224 printFileName( strSearchPath );
2225 printf( "\n");
2227 rc=FileBase::searchFileURL( file3 , strSearchPath , strResultPath );
2229 if ( rc == FileBase::E_None )
2231 printf( "Result: \t\t\t");
2232 printFileName( strResultPath );
2233 printf( "\n" );
2235 else
2236 printf( "searchFileURL: File not found: Error\n" );
2238 // searchFileURL (File and searchpath (with a wrong semantic))
2240 strSearchPath=rtl::OUString( dir_wrong_semantic );
2242 printf( "\nsearchFileURL: File : ");
2243 printFileName( file3 );
2244 printf( "SearchPath ");
2245 printFileName( strSearchPath );
2246 printf( "\n");
2248 rc=FileBase::searchFileURL( file3 , strSearchPath , strResultPath );
2250 if ( rc == FileBase::E_None )
2251 printf( "Error: Wrong Semantich but no error occurs !\n" );
2252 else
2253 printf( "searchFileURL: File not found: OK !\n" );
2255 return;
2258 // CanonicalNameTest
2260 void getCanonicalNameTest(rtl::OUString strPath)
2262 FileBase::RC rc;
2264 rtl::OUString strValid;
2266 printf( "Original-Name: \t\t");
2267 printFileName( strPath );
2268 printf( "\n" );
2270 rc=FileBase::getCanonicalName( strPath, strValid );
2272 if ( rc == FileBase::E_None)
2274 printf( "Canonical-Name: \t");
2275 printFileName( strValid );
2276 printf( "\n");
2279 else
2280 printf( "Canonical-Name: Error \n" );
2282 printf( "\n" );
2283 return;
2286 void CanonicalNameTest()
2288 printf( "--------------------------------------------\n" );
2289 printf( "CanonicalName-Test\n" );
2290 printf( "--------------------------------------------\n\n" );
2292 getCanonicalNameTest( dir1 );
2293 getCanonicalNameTest( dir_on_server );
2294 getCanonicalNameTest( file1 );
2295 getCanonicalNameTest( file_on_server );
2297 PressKey();
2298 return;
2301 // print_error
2303 void print_error( const ::rtl::OString& str, FileBase::RC rc )
2306 printf( "%s : ", str.getStr() );
2307 switch(rc)
2309 case FileBase::E_None:
2310 printf("OK !\n");
2311 break;
2312 case FileBase::E_PERM:
2313 printf("E_PERM\n");
2314 break;
2315 case FileBase::E_NOENT:
2316 printf("E_NOENT\n");
2317 break;
2318 case FileBase::E_SRCH:
2319 printf("E_SRCH\n");
2320 break;
2321 case FileBase::E_INTR:
2322 printf("E_INTR\n");
2323 break;
2324 case FileBase::E_IO:
2325 printf("E_IO\n");
2326 break;
2327 case FileBase::E_NXIO:
2328 printf("E_NXIO\n");
2329 break;
2330 case FileBase::E_2BIG:
2331 printf("E_2BIG\n");
2332 break;
2333 case FileBase::E_NOEXEC:
2334 printf("E_NOEXEC\n");
2335 break;
2336 case FileBase::E_BADF:
2337 printf("E_BADF\n");
2338 break;
2339 case FileBase::E_CHILD:
2340 printf("E_CHILD\n");
2341 break;
2342 case FileBase::E_AGAIN:
2343 printf("E_AGAIN\n");
2344 break;
2345 case FileBase::E_NOMEM:
2346 printf("E_NOMEM\n");
2347 break;
2348 case FileBase::E_ACCES:
2349 printf("E_ACCES\n");
2350 break;
2351 case FileBase::E_FAULT:
2352 printf("E_FAULT\n");
2353 break;
2354 case FileBase::E_BUSY:
2355 printf("E_BUSY\n");
2356 break;
2357 case FileBase::E_EXIST:
2358 printf("E_EXIST\n");
2359 break;
2360 case FileBase::E_XDEV:
2361 printf("E_XDEV\n");
2362 break;
2363 case FileBase::E_NODEV:
2364 printf("E_NODEV\n");
2365 break;
2366 case FileBase::E_NOTDIR:
2367 printf("E_NOTDIR\n");
2368 break;
2369 case FileBase::E_ISDIR:
2370 printf("E_ISDIR\n");
2371 break;
2372 case FileBase::E_INVAL:
2373 printf("E_INVAL\n");
2374 break;
2375 case FileBase::E_NFILE:
2376 printf("E_NFILE\n");
2377 break;
2378 case FileBase::E_MFILE:
2379 printf("E_MFILE\n");
2380 break;
2381 case FileBase::E_NOTTY:
2382 printf("E_NOTTY\n");
2383 break;
2384 case FileBase::E_FBIG:
2385 printf("E_FBIG\n");
2386 break;
2387 case FileBase::E_NOSPC:
2388 printf("E_NOSPC\n");
2389 break;
2390 case FileBase::E_SPIPE:
2391 printf("E_SPIPE\n");
2392 break;
2393 case FileBase::E_ROFS:
2394 printf("E_ROFS\n");
2395 break;
2396 case FileBase::E_MLINK:
2397 printf("E_MLINK\n");
2398 break;
2399 case FileBase::E_PIPE:
2400 printf("E_PIPE\n");
2401 break;
2402 case FileBase::E_DOM:
2403 printf("E_DOM\n");
2404 break;
2405 case FileBase::E_RANGE:
2406 printf("E_RANGE\n");
2407 break;
2408 case FileBase::E_DEADLK:
2409 printf("E_DEADLK\n");
2410 break;
2411 case FileBase::E_NAMETOOLONG:
2412 printf("E_NAMETOOLONG\n");
2413 break;
2414 case FileBase::E_NOLCK:
2415 printf("E_NOLCK\n");
2416 break;
2417 case FileBase::E_NOSYS:
2418 printf("E_NOSYS\n");
2419 break;
2420 case FileBase::E_NOTEMPTY:
2421 printf("E_NOTEMPTY\n");
2422 break;
2423 case FileBase::E_LOOP:
2424 printf("E_LOOP\n");
2425 break;
2426 case FileBase::E_ILSEQ:
2427 printf("E_ILSEQ\n");
2428 break;
2429 case FileBase::E_NOLINK:
2430 printf("E_NOLINK\n");
2431 break;
2432 case FileBase::E_MULTIHOP:
2433 printf("E_MULTIHOP\n");
2434 break;
2435 case FileBase::E_USERS:
2436 printf("E_USERS\n");
2437 break;
2438 case FileBase::E_OVERFLOW:
2439 printf("E_OVERFLOW\n");
2440 break;
2441 default:
2442 printf("E_Unknown\n");
2443 break;
2445 return;
2448 // main
2450 #if defined WNT
2451 #define MAIN _cdecl main
2452 #else
2453 #define MAIN main
2454 #endif
2456 int MAIN( int argc, char* argv[] )
2458 sal_Bool fSuccess=sal_False;
2460 //Initialization
2461 fSuccess=Initialize();
2462 if ( !fSuccess )
2464 printf("Error during Initialization");
2465 return -1;
2468 if (argc==1)
2470 DirectoryOpenAndCloseTest();
2471 DirectoryCreateAndRemoveTest();
2473 FileOpenAndCloseTest();
2474 FileCreateAndRemoveTest();
2475 FileWriteAndReadTest();
2476 FileCopyAndMoveTest();
2477 FileSizeTest();
2478 FilePointerTest();
2479 FileAttributesTest();
2480 FileTimeTest();
2481 DirectoryItemTest();
2482 DirectoryFileStatusTest();
2483 VolumeFileStatusTest();
2484 FileFileStatusTest();
2485 VolumeInfoTest();
2486 FileBaseTest();
2487 SearchPathTest();
2488 AbsolutePathTest();
2489 CanonicalNameTest();
2491 // command line arguments ?
2492 else
2494 int i=1;
2496 while (i<argc)
2498 if (strcmp(argv[i], "doc")==0)
2499 DirectoryOpenAndCloseTest();
2500 else if (strcmp(argv[i], "dcr")==0)
2501 DirectoryCreateAndRemoveTest();
2502 else if (strcmp(argv[i], "foc")==0)
2503 FileOpenAndCloseTest();
2504 else if (strcmp(argv[i], "fcr")==0)
2505 FileCreateAndRemoveTest();
2506 else if (strcmp(argv[i], "fwr")==0)
2507 FileWriteAndReadTest();
2508 else if (strcmp(argv[i], "fcm")==0)
2509 FileCopyAndMoveTest();
2510 else if (strcmp(argv[i], "fs")==0)
2511 FileSizeTest();
2512 else if (strcmp(argv[i], "fp")==0)
2513 FilePointerTest();
2514 else if (strcmp(argv[i], "fa")==0)
2515 FileAttributesTest();
2516 else if (strcmp(argv[i], "ft")==0)
2517 FileTimeTest();
2518 else if (strcmp(argv[i], "di")==0)
2519 DirectoryItemTest();
2520 else if (strcmp(argv[i], "dfs")==0)
2521 DirectoryFileStatusTest();
2522 else if (strcmp(argv[i], "vfs")==0)
2523 VolumeFileStatusTest();
2524 else if (strcmp(argv[i], "ffs")==0)
2525 FileFileStatusTest();
2526 else if (strcmp(argv[i], "vi")==0)
2527 VolumeInfoTest();
2528 else if (strcmp(argv[i], "fb")==0)
2529 FileBaseTest();
2530 else if (strcmp(argv[i], "sp")==0)
2531 SearchPathTest();
2532 else if (strcmp(argv[i], "ap")==0)
2533 AbsolutePathTest();
2534 else if (strcmp(argv[i], "cn")==0)
2535 CanonicalNameTest();
2537 i++;
2541 // Shutdown
2542 fSuccess=Shutdown();
2543 if ( !fSuccess )
2545 printf("Error during Shutdown");
2546 return -1;
2549 return 0;
2552 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */