FindFile.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /******************************************************************************
  2. |* THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
  3. |* ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
  4. |* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
  5. |* PARTICULAR PURPOSE.
  6. |*
  7. |* Copyright 1995-2004 Ahead Software AG. All Rights Reserved.
  8. |*-----------------------------------------------------------------------------
  9. |* NeroSDK / NeroCmd
  10. |*
  11. |* PROGRAM: FindFile.h
  12. |*
  13. |* PURPOSE: Helper class for ISO tree handling
  14. ******************************************************************************/
  15. #ifndef _FIND_FILE_H_
  16. #define _FIND_FILE_H_
  17. #include "stdafx.h"
  18. #include <crtdbg.h>
  19. #include <string>
  20. #include <io.h>
  21. using namespace std;
  22. // This class is a helper for enumerating a directory tree.
  23. class CFindFiles
  24. {
  25. private:
  26. std::string m_sWildcard;
  27. protected:
  28. _finddata_t m_fdFile;
  29. _finddata_t m_fdDirectory;
  30. long m_lHandleFile;
  31. long m_lHandleDirectory;
  32. bool m_bValidFile;
  33. bool m_bValidDirectory;
  34. public:
  35. CFindFiles (LPCSTR psPath);
  36. ~CFindFiles ();
  37. inline bool IsValidEntry (void) const;
  38. void FindNext (void);
  39. bool IsSubDir (void) const;
  40. LPCSTR GetName (void) const;
  41. time_t GetCreateTime (void) const;
  42. LPCSTR GetWildcard (void) const;
  43. };
  44. inline time_t CFindFiles::GetCreateTime (void) const
  45. {
  46. _ASSERTE (IsValidEntry ());
  47. return (m_bValidFile)? m_fdFile.time_create: m_fdDirectory.time_create;
  48. }
  49. // Get the name of the file or directory.
  50. //
  51. inline LPCSTR CFindFiles::GetName (void) const
  52. {
  53. _ASSERTE (IsValidEntry ());
  54. return (m_bValidFile)? &m_fdFile.name[0]: &m_fdDirectory.name[0];
  55. }
  56. // Check if entry is valid. This is true if either file or directory
  57. // entry is valid.
  58. //
  59. inline bool CFindFiles::IsValidEntry (void) const
  60. {
  61. return m_bValidFile || m_bValidDirectory;
  62. }
  63. // Check if entry is a subdirectory
  64. inline bool CFindFiles::IsSubDir (void) const
  65. {
  66. _ASSERTE (IsValidEntry ());
  67. return !m_bValidFile && m_bValidDirectory;
  68. }
  69. inline LPCSTR CFindFiles::GetWildcard (void) const
  70. {
  71. return m_sWildcard.c_str ();
  72. }
  73. #endif