sipxportlib  Version 3.3
OsFileSystem.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2004-2006 SIPfoundry Inc.
3 // Licensed by SIPfoundry under the LGPL license.
4 //
5 // Copyright (C) 2004-2006 Pingtel Corp. All rights reserved.
6 // Licensed to SIPfoundry under a Contributor Agreement.
7 //
8 // $$
10 
11 
12 #ifndef _OsFileSystem_h_
13 #define _OsFileSystem_h_
14 
15 // SYSTEM INCLUDES
16 
17 // APPLICATION INCLUDES
18 #include "os/OsDateTime.h"
19 #include "os/OsDefs.h"
20 #include "os/OsStatus.h"
21 #include "os/OsFS.h"
22 
23 // DEFINES
24 // MACROS
25 // EXTERNAL FUNCTIONS
26 // EXTERNAL VARIABLES
27 // CONSTANTS
28 // STRUCTS
29 // TYPEDEFS
30 // FORWARD DECLARATIONS
31 
32 //:Helper class that constructs OsDir and OsFile objects
33 //:for you. This may be expanded to include enumerating versions
34 //:of these functions.
35 
37 {
38 /* //////////////////////////// PUBLIC //////////////////////////////////// */
39 public:
40 
41 /* ============================ CREATORS ================================== */
42 
43 
44 /* ============================ MANIPULATORS ============================== */
45 
46  OsFileSystem& operator=(const OsFileSystem& rhs);
47  //:Assignment operator
48 
49  static OsStatus copy(const OsPath& rSource, const OsPath& rOsPath);
50  //: Returns TRUE if file moved ok
51 
52  static OsStatus remove(const OsPath& rOsPath, UtlBoolean bRecursive = FALSE, UtlBoolean bForce = FALSE);
53  //: Removes the directory or file specified by path
54  //: Specify bForce = TRUE to remove if read-only
55 
56 
57  static OsStatus rename(const OsPath& rSourceFile, const OsPath& rDestFile);
58  //: Renames the directory or file specified by path
59 
60  static OsStatus change(const OsPath& rOsPath);
61  //: Change the current working directory to the specified location
62 
63  static OsStatus createDir(const OsPath& rOsPath, const UtlBoolean createParent = FALSE);
64  //: Creates the specified directory
65  //: Fails if a file by the same name already exists in the directory
66 
67  static OsStatus setReadOnly(const OsPath& rFile, UtlBoolean isReadOnly);
68  //: Sets the read-only flag onthe specified file.
69  //: Set to TRUE to make the file READONLY
70 
71 
72 /* ============================ ACCESSORS ================================= */
73 
74  static OsStatus getFileInfo(OsPath& filespec, OsFileInfo& rfileInfo);
75  //: Retrieve system info for specified directory of file
76 
77 /* ============================ INQUIRY =================================== */
78  static UtlBoolean exists(const OsPath& rFilename);
79  //: Returns true if file exists
80 
81  static OsStatus getWorkingDirectory(OsPath& rOsPath);
82  //: Returns the current working directory
83 
84 /* //////////////////////////// PROTECTED ///////////////////////////////// */
85 protected:
86 
87  OsFileSystem(const OsFileSystem& rOsFileSystem);
88  //:Copy constructor
89 
90  OsFileSystem();
91  //:Default constructor
92 
93  virtual ~OsFileSystem();
94  //:Destructor
95 
96 /* //////////////////////////// PRIVATE /////////////////////////////////// */
97 private:
98 
99  static OsStatus removeTree(const OsPath& rOsPath, UtlBoolean bForce = FALSE);
100  //: Removes a directory, files and all sub-dirs
101  //: Specify bForce = TRUE to remove files and directories
102  //: even if read-only
103 
104  static OsStatus createDirRecursive(const OsPath& rOsPath);
105  //: Recursively creates a directory and its parents if non-existant
106 
107 
108 };
109 
110 /* ============================ INLINE METHODS ============================ */
111 
112 #endif // _OsFileSystem_h_
113 
114 
static OsStatus copy(const OsPath &rSource, const OsPath &rOsPath)
Definition: OsFileSystem.cpp:109
OsStatus
Definition: OsStatus.h:27
OsFileSystem & operator=(const OsFileSystem &rhs)
Definition: OsFileSystem.cpp:77
virtual ~OsFileSystem()
Definition: OsFileSystem.cpp:69
static OsStatus setReadOnly(const OsPath &rFile, UtlBoolean isReadOnly)
Definition: OsFileSystem.cpp:85
static OsStatus change(const OsPath &rOsPath)
Definition: OsFileSystem.cpp:162
static OsStatus createDir(const OsPath &rOsPath, const UtlBoolean createParent=FALSE)
Definition: OsFileSystem.cpp:174
static OsStatus getWorkingDirectory(OsPath &rOsPath)
Definition: OsFileSystem.cpp:192
static OsStatus getFileInfo(OsPath &filespec, OsFileInfo &rfileInfo)
Definition: OsFileSystem.cpp:209
Definition: OsFileSystem.h:36
int UtlBoolean
Definition: UtlDefs.h:41
static UtlBoolean exists(const OsPath &rFilename)
Definition: OsFileSystem.cpp:220
OsFileSystem()
Definition: OsFileSystem.cpp:51
#define FALSE
Definition: UtlDefs.h:21
static OsStatus rename(const OsPath &rSourceFile, const OsPath &rDestFile)
Definition: OsFileSystem.cpp:154