00001
00002
00003
00004
00005
00006
00007 #include <iostream>
00008 #include <unistd.h>
00009 #include <string.h>
00010 #include <stdlib.h>
00011
00012 #include "ComPlusPlus/ComPlusPlus"
00013
00014 int main( int argc, char * argv [] ) {
00015
00016 if ( argc < 2 ) {
00017 std::cout << "usage: ExampleDirectoy Dir [regexp]\n";
00018 exit (1);
00019 }
00020
00021 try {
00022 if ( ! compp::DirEntry::Exist ( argv [1] ) ) {
00023 std::cout << argv [1] << " does not exist.\n";
00024 exit (1);
00025 }
00026
00027 compp::Directory dir ;
00028
00029 if ( argc == 2 )
00030 dir.setPath ( argv [ 1 ] );
00031 else
00032 dir.setPath ( argv [ 1 ], argv [ 2 ] );
00033
00034 dir.setSortDesc();
00035 dir.SortName();
00036 std::list<compp::DirEntry>::iterator it = dir.getFirst();
00037
00038 while ( it != dir.end() ) {
00039 compp::DirEntry ent = *it;
00040 std::cout << ent.getName() << "\n";
00041 ++ it;
00042 }
00043
00044 } catch ( syspp::ComException & e ) {
00045 std::cout << "Exception " << e.what() << "\n";
00046 }
00047 return 0;
00048 }