C++ File helper Class File Control



주요 함수
  1. ///////////////////////////////////////////////////////////////////
  2. //               FileManip.h
  3. //
  4. // CFileManip, an API wrapping class that is developed to make file
  5. // manipulation simpler and easier.
  6. //
  7. // The class itself basically offers "DOS command like" methods which
  8. // are very similar to related DOS commands in both names and
  9. // functionalities, I hope they bring you back to the good old time
  10. // of DOS age.:-) Being able to using functions such as "xcopy" and
  11. // "deltree" in my C++ code is what I always wanted to.
  12. //
  13. // Progress windows are provided automatically during lengthy tasks
  14. // by operating system. This class does not require MFC, so it can be
  15. // used in any Win32 applications.
  16. //
  17. // Copyright 2002, Bin Liu
  18. // All rights reserved.
  19. //
  20. // Version history:
  21. //
  22. // 7/28/2002 - Initial release.
  23. // 7/30/2002 - Use strncpy to duplicate strings instead of strcpy.
  24. //             Suggested by jbarton.
  25. // 2/08/2003 - The class has been made unicode-compliant.
  26. //
  27. ///////////////////////////////////////////////////////////////////
  28.  
  29. #ifndef __FILEMANIP_H__
  30. #define __FILEMANIP_H__
  31.  
  32. #include <windows.h>
  33.  
  34. // User difined error code, it will be returned by ::GetLastError()
  35. // if a "file-only" operation attempts to modify a directory.
  36. #define ERR_DIRECTORY   0x10000000
  37.  
  38. class CFileManip
  39. {
  40. public:
  41.  
  42.         // File-only operations
  43.         static BOOL Copy(LPCTSTR lpSource, LPCTSTR lpDestination, BOOL bHidePrompt = TRUE);
  44.         static BOOL Del(LPCTSTR lpSource, BOOL bHidePrompt = TRUE);
  45.         static BOOL Ren(LPCTSTR lpSource, LPCTSTR lpDestination, BOOL bHidePrompt = TRUE);
  46.  
  47.         // File/directory operations
  48.         static BOOL XCopy(LPCTSTR lpSource, LPCTSTR lpDestination, BOOL bHidePrompt = TRUE);
  49.         static BOOL DelTree(LPCTSTR lpSource, BOOL bHidePrompt = TRUE);
  50.         static BOOL Move(LPCTSTR lpSource, LPCTSTR lpDestination, BOOL bHidePrompt = TRUE);
  51.        
  52.         // Directory-only operations
  53.         static BOOL MkDir(LPCTSTR lpDirectory);
  54.         static BOOL RmDir(LPCTSTR lpDirectory);
  55.  
  56.         // File/directory attributes access
  57.         static BOOL SetAttribute(LPCTSTR lpSource, DWORD dwNewAttr);
  58.         static DWORD GetAttribute(LPCTSTR lpSource);
  59.  
  60.         // File/directory existence check
  61.         enum { FM_NOTEXIST = 0, FM_DIRECTORY, FM_FILE};
  62.         static int Existence(LPCTSTR lpSource);
  63.  
  64.         // Directory travelling and checking
  65.         static BOOL CdDotDot(LPTSTR lpCurDirectory = NULL);
  66.         static TCHAR IsRoot(LPCTSTR lpDirectory);
  67.         static BOOL IsParentDirectory(LPCTSTR lpParent, LPCTSTR lpSubDirectory);
  68. };
  69.  
  70. #endif


덧글

댓글 입력 영역


통계 위젯 (블랙)

08
98
411790