DataDirector API
DDD_DirectoryTraverser.h
Go to the documentation of this file.
1 /*! \file DDD_DirectoryTraverser.h
2 
3  \brief Class for managing traversing a directory and processing all files that match
4  an extension
5 
6  \par Copyright Information
7 
8  Copyright (c) 2012 The DiSTI Corporation.<br>
9  11301 Corporate Blvd; Suite 100<br>
10  Orlando, Florida 32817<br>
11  USA<br>
12  <br>
13  All rights reserved.<br>
14 
15  This Software contains proprietary trade secrets of DiSTI and may not be
16 reproduced, in whole or part, in any form, or by any means of electronic,
17 mechanical, or otherwise, without the written permission of DiSTI. Said
18 permission may be derived through the purchase of applicable DiSTI product
19 licenses which detail the distribution rights of this content and any
20 Derivative Works based on this or other copyrighted DiSTI Software.
21 
22  NO WARRANTY. THE SOFTWARE IS PROVIDED "AS-IS," WITHOUT WARRANTY OF ANY KIND,
23 AND ANY USE OF THIS SOFTWARE PRODUCT IS AT YOUR OWN RISK. TO THE MAXIMUM EXTENT
24 PERMITTED BY APPLICABLE LAW, DISTI AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES
25 AND CONDITIONS, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
26 IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY AND/OR FITNESS FOR A
27 PARTICULAR PURPOSE, TITLE, AND NON-INFRINGEMENT, WITH REGARD TO THE SOFTWARE.
28 
29  LIMITATION OF LIABILITY. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW,
30 IN NO EVENT SHALL DISTI OR ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
31 INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION,
32 DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS
33 INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR
34 INABILITY TO USE THE SOFTWARE, EVEN IF DISTI HAS BEEN ADVISED OF THE POSSIBLITY
35 OF SUCH DAMAGES. DISTI'S ENTIRE LIABILITY AND YOUR EXCLUSIVE REMEDY SHALL NOT
36 EXCEED FIVE DOLLARS (US$5.00).
37 
38  The aforementioned terms and restrictions are governed by the laws of the
39 State of Florida and the United States of America.
40 
41 */
42 
43 #ifndef DDD_DIRECTORY_TRAVERSER_H
44 #define DDD_DIRECTORY_TRAVERSER_H
45 
46 #include "DDD_Include.h"
47 #include "DDD_LogFacade.h"
48 #include <string>
49 
50 class dirent;
51 
52 namespace disti
53 {
54 
55 class DDD_EXPORT DDD_DirectoryTraverser : public DDD_LogFacade
56 {
57 protected:
58  std::string _fileExtension; /**< The file extension to search for when traversing. Must take the form of a
59  * dot followed by a single extension, e.g. ".xyz" or ".xyzLinux"
60  */
61 
62  /** ProcessFile is called whenever a file with a matching extension is found by the traverser
63  * Subclasses will provide their own implementation of this method to do whatever processing
64  * is needed for each file
65  * \param fileName The name of the file that was found with the matching extension
66  * \return True if the file was successfully processed, false otherwise
67  */
68  virtual bool ProcessFile(const std::string &fileName)=0;
69 
70  /** Helper method used by TraverseDirectory. Processes the file list from the directory,
71  * calling ProcessFile on each file that matched the extension
72  * \param numberOfFilesInDirectory The number of files that are in the next parameter
73  * \param files Data stucture containing the list of files in the directory
74  */
75  void ProcessFiles(int numberOfFilesInDirectory,dirent **files);
76 public:
77 
78  DDD_DirectoryTraverser(const std::string &fileExtension) :
79  _fileExtension(fileExtension)
80  {
81  }
82 
83  /** Searches a directory, then if the directory was readable and has files in it, processes the file list
84  * from the directory
85  * \param pathToTraverse The directory to Process
86  * \return True if the path was successfully searched
87  */
88  bool TraverseDirectory(const std::string &pathToTraverse);
89 };
90 
91 } // end of namespace disti
92 
93 #endif
94 
Facade to provide a simpler interface to the DDD_Log singleton. Its second purpose is for decoupling;...
Definition: DDD_LogFacade.h:50
Definition: DDD_DirectoryTraverser.h:55
std::string _fileExtension
Definition: DDD_DirectoryTraverser.h:58
Definition: AttributeChangedEmitter.h:46