sipxportlib  Version 3.3
OsPathBase.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 #ifndef _OsPathBase_h_
12 #define _OsPathBase_h_
13 
14 // SYSTEM INCLUDES
15 
16 // APPLICATION INCLUDES
17 #include "os/OsDefs.h"
18 #include "os/OsStatus.h"
19 #include "os/OsFS.h"
20 #include "utl/UtlDefs.h"
21 #include "utl/UtlString.h"
22 
23 // DEFINES
24 // MACROS
25 // EXTERNAL FUNCTIONS
26 // EXTERNAL VARIABLES
27 // CONSTANTS
28 // STRUCTS
29 // TYPEDEFS
30 // FORWARD DECLARATIONS
31 
32 //:OS generic path class. Will massage any input string so separators are correct.
33 //:Also provided functions to
34 class OsPathBase : public UtlString
35 {
36 /* //////////////////////////// PUBLIC //////////////////////////////////// */
37 public:
38 
40  //: platform specific separator (eg. '/' or '\')
41 
42 /* ============================ CREATORS ================================== */
43 
44  OsPathBase();
45  //:Default constructor
46 
47  OsPathBase(const OsPathBase& rOsPath);
48  //:Copy constructor
49 
50  virtual
51  ~OsPathBase();
52  //:Destructor
53 
54  OsPathBase(const UtlString& rPath);
55  //: Copy contructor
56 
57  OsPathBase(const char* pPath);
58  //: Construct OsPath from char*
59 
60  OsPathBase(const UtlString& rVolume, const UtlString& rDirName, const UtlString& rFileName,
61  const UtlString& rExtension);
62  //: Forms a OsPath from discrete parts
63 
64 /* ============================ MANIPULATORS ============================== */
65 
66  OsPathBase& operator=(const OsPathBase& rhs);
67  //:Assignment operator
68 
69  OsPathBase&
70  operator+=(const OsPathBase& rhs);
71  //:+= operator
72 
73  static void setSeparator(UtlString &rSeparator);
74  //: Set path separator for this platform
75 
76  void Split();
77  //: breaks path into its parts
78 
79 /* ============================ ACCESSORS ================================= */
80  UtlString getVolume() const;
81  //: Returns just the volume of this object (eg. for DOS c:,d: etc...)
82 
83  UtlString getDirName() const;
84  //: Returns just the path of this object (without volume or filename)
85 
86  UtlString getFilename() const;
87  //: Retrieves just the filename part of this object
88 
89  UtlString getExt() const;
90  //: Returns just the extension part of this object
91 
92  OsStatus getNativePath(OsPathBase &rFullPath) const;
93  //: Returns TRUE if the full path for the specified platform was
94  //: found to be valid. Returns the full path in rFullPath.
95 
96  static UtlString getSeparator();
97  //: Returns the path separator for this platform
98 
99 /* ============================ INQUIRY =================================== */
100 
102  //:Return TRUE if pathname represented by object is valid for the platform.
103 
104 /* //////////////////////////// PROTECTED ///////////////////////////////// */
105 protected:
107  //: Directory name. Ends with backslash
109  //: Volume (eg. c: d: /sda1)
111  //: Returns the filename (without extension).
112  // If the OsPath object contains just a path, then filename and ext will blank.
114  //: Returns the extension of the file.
115  // If the OsPath object contains just a path, then filename and ext will blank.
116 /* //////////////////////////// PRIVATE /////////////////////////////////// */
117 private:
118 
119  void massage();
120  //: Based on the platform in use, this function manipulates the string
121  // so it reprsents a valid platform path
122 
123 };
124 
125 /* ============================ INLINE METHODS ============================ */
126 
127 #endif // _OsPathBase_h_
OsPathBase & operator+=(const OsPathBase &rhs)
Definition: OsPathBase.cpp:248
OsStatus getNativePath(OsPathBase &rFullPath) const
Definition: OsPathBase.cpp:296
static UtlString separator
Definition: OsPathBase.h:39
UtlString mVolume
Definition: OsPathBase.h:108
static void setSeparator(UtlString &rSeparator)
Definition: OsPathBase.cpp:260
OsStatus
Definition: OsStatus.h:27
UtlBoolean isValid()
Definition: OsPathBase.cpp:347
UtlString getVolume() const
Definition: OsPathBase.cpp:273
UtlString getDirName() const
Definition: OsPathBase.cpp:278
void Split()
Definition: OsPathBase.cpp:354
Definition: UtlString.h:48
UtlString mFilename
Definition: OsPathBase.h:110
UtlString mDirName
Definition: OsPathBase.h:106
UtlString getFilename() const
Definition: OsPathBase.cpp:284
static UtlString getSeparator()
Definition: OsPathBase.cpp:267
int UtlBoolean
Definition: UtlDefs.h:41
OsPathBase & operator=(const OsPathBase &rhs)
Definition: OsPathBase.cpp:235
OsPathBase()
Definition: OsPathBase.cpp:201
UtlString getExt() const
Definition: OsPathBase.cpp:290
virtual ~OsPathBase()
Definition: OsPathBase.cpp:227
Definition: OsPathBase.h:34
UtlString mExtension
Definition: OsPathBase.h:113