Line | |
---|
1 | #pragma once
|
---|
2 |
|
---|
3 | namespace Jenga{
|
---|
4 | namespace Common{
|
---|
5 |
|
---|
6 |
|
---|
7 | class Path
|
---|
8 | {
|
---|
9 | std::string fullPath;
|
---|
10 | std::string driveName;
|
---|
11 | std::string dirName;
|
---|
12 | std::string fileName;
|
---|
13 | std::string ext;
|
---|
14 |
|
---|
15 | void Expand()
|
---|
16 | {
|
---|
17 | char szDrive[32], szDir[1024], szFile[1024], szExt[255];
|
---|
18 | _splitpath_s( fullPath.c_str(), szDrive, 32, szDir, 1024, szFile, 1024, szExt, 255 );
|
---|
19 | driveName = szDrive;
|
---|
20 | dirName = szDir;
|
---|
21 | fileName = szFile;
|
---|
22 | ext = szExt;
|
---|
23 | }
|
---|
24 |
|
---|
25 | public:
|
---|
26 | Path( const std::string &fullPath )
|
---|
27 | : fullPath( fullPath )
|
---|
28 | {
|
---|
29 | Expand();
|
---|
30 | }
|
---|
31 | ~Path()
|
---|
32 | {
|
---|
33 | }
|
---|
34 |
|
---|
35 | bool IsExistFile() const;
|
---|
36 |
|
---|
37 | const std::string &GetDriveName() const
|
---|
38 | {
|
---|
39 | return driveName;
|
---|
40 | }
|
---|
41 | const std::string GetDirPath() const
|
---|
42 | {
|
---|
43 | return driveName + dirName;
|
---|
44 | }
|
---|
45 | const std::string &GetFileName() const
|
---|
46 | {
|
---|
47 | return fileName;
|
---|
48 | }
|
---|
49 | const std::string &GetExt() const
|
---|
50 | {
|
---|
51 | return ext;
|
---|
52 | }
|
---|
53 | const std::string GetFullFileName() const
|
---|
54 | {
|
---|
55 | return fileName + ext;
|
---|
56 | }
|
---|
57 | const std::string &GetFullPath() const
|
---|
58 | {
|
---|
59 | return fullPath;
|
---|
60 | }
|
---|
61 | bool IsNetworkPath() const
|
---|
62 | {
|
---|
63 | if( fullPath.size() < 2 )
|
---|
64 | {
|
---|
65 | return false;
|
---|
66 | }
|
---|
67 | return ( ( fullPath[0] == '\\' ) && ( fullPath[1] == '\\' ) );
|
---|
68 | }
|
---|
69 |
|
---|
70 | static std::string MakeFullPath( const std::string &relativePath, const std::string &baseDirPath );
|
---|
71 | static std::string MakeFullPathByCurrentDirectory( const std::string &relativePath );
|
---|
72 | static std::string ExtractDirPath( const std::string &path );
|
---|
73 | };
|
---|
74 |
|
---|
75 |
|
---|
76 | }}
|
---|
Note:
See
TracBrowser
for help on using the repository browser.