![]() |
![]() |
![]() |
![]() |
||||
![]() |
![]() |
![]() |
![]() |
||||
|
00001 /* ///////////////////////////////////////////////////////////////////////// 00002 * File: example_cpp_1.cpp 00003 * 00004 * Purpose: C++ example program for recls/C++. Demonstrates: 00005 * 00006 * - searching for files 00007 * - recursive operation 00008 * - display of full path of each entry 00009 * - handling exceptions and reporting of error information 00010 * - elicitation of entry properties via method calls 00011 * 00012 * Created: 18th June 2006 00013 * Updated: 18th June 2006 00014 * 00015 * www: http://www.recls.org/ 00016 * 00017 * License: Copyright (c) 2006, Synesis Software Pty Ltd. 00018 * All rights reserved. 00019 * 00020 * (Licensed under the Synesis Software Open License) 00021 * 00022 * This source code is placed into the public domain 2006 00023 * by Synesis Software Pty Ltd. There are no restrictions 00024 * whatsoever to your use of the software. 00025 * 00026 * ////////////////////////////////////////////////////////////////////// */ 00027 00028 00029 /* recls Header Files */ 00030 #include <recls/cpp/fileentry.hpp> 00031 #include <recls/cpp/filesearch.hpp> 00032 #include <recls/implicit_link.h> 00033 00034 /* Standard C++ Header Files */ 00035 #include <exception> 00036 #include <iostream> 00037 00038 /* Standard C Header Files */ 00039 #include <stdlib.h> /* for EXIT_SUCCESS / EXIT_FAILURE */ 00040 00041 /* ////////////////////////////////////////////////////////////////////////// */ 00042 00043 int main() 00044 { 00045 try 00046 { 00047 recls::uint32_t flags = recls::RECLS_F_FILES | recls::RECLS_F_RECURSIVE; 00048 recls::cpp::FileSearch srch(".", recls::Recls_GetWildcardsAll(), flags); 00049 00050 for(; srch.HasMoreElements(); srch.GetNext()) 00051 { 00052 recls::cpp::FileEntry entry = srch.GetCurrentEntry(); 00053 00054 std::cout << entry.GetPath() << std::endl; 00055 } 00056 } 00057 catch(recls::cpp::ReclsException &x) 00058 { 00059 std::cerr << "Recls error: " << x.rc() << ", " << x.what() << std::endl; 00060 00061 return EXIT_FAILURE; 00062 } 00063 catch(std::bad_alloc &) 00064 { 00065 std::cerr << "Out of memory" << std::endl; 00066 00067 return EXIT_FAILURE; 00068 } 00069 catch(std::exception &x) 00070 { 00071 std::cerr << "Unhandled error: " << x.what() << std::endl; 00072 00073 return EXIT_FAILURE; 00074 } 00075 catch(...) 00076 { 00077 std::cerr << "Unhandled unknown error" << std::endl; 00078 00079 return EXIT_FAILURE; 00080 } 00081 00082 return EXIT_SUCCESS; 00083 } 00084 00085 /* ////////////////////////////////////////////////////////////////////////// */
|
recls Library documentation © Synesis Software Pty Ltd, 2001-2006 |