source: dev/branches/egtra/ab5.0/jenga/include/common/Path.h@ 820

Last change on this file since 820 was 818, checked in by イグトランス (egtra), 14 years ago

Jenga/common/String.hに対するテストを追加

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