8
8
#include " Path.h"
9
9
#include " System/DateTime.h"
10
10
#include " OS.h"
11
+ #include " System/IO/FileSystemInfo.h"
11
12
12
13
namespace System
13
14
{
14
15
namespace IO
15
16
{
16
17
// / A file information class
17
- class FileInfo
18
+ class FileInfo : public FileSystemInfo
18
19
{
19
- System::String m_path;
20
-
21
20
public:
22
21
// / constructor
23
22
FileInfo ()
@@ -26,79 +25,6 @@ namespace System
26
25
27
26
// / constructor within the current directory
28
27
FileInfo (const System::String& s);
29
-
30
- // / the full name of the file
31
- System::String FullName () const
32
- {
33
- return m_path;
34
- }
35
-
36
- // / does the file exist
37
- bool Exists () const
38
- {
39
- struct stat statStruct;
40
- bool fileExists =
41
- (stat (m_path.str ().c_str (), &statStruct) == 0 );
42
- return fileExists;
43
- }
44
-
45
- // / the files extension
46
- String Extension () const
47
- {
48
- int dotPos = m_path.LastIndexOf (' .' );
49
- if (dotPos == -1 ) {
50
- return String (" " );
51
- }
52
- // Extension include the "."
53
- String ext = m_path.Substring (dotPos);
54
- return ext;
55
- }
56
-
57
- // / the name of the file
58
- String Name () const
59
- {
60
- // from the end of the path back up to the last / or \\ to strip
61
- // to the filename
62
- int lastForwardSlash = m_path.LastIndexOf (' /' );
63
- int lastBackwardSlash = m_path.LastIndexOf (' \\ ' );
64
-
65
- if (lastForwardSlash == -1 && lastBackwardSlash == -1 ) {
66
- return m_path;
67
- }
68
-
69
- if (lastForwardSlash == -1 ) {
70
- String part = m_path.Substring (lastBackwardSlash + 1 );
71
- return part;
72
- }
73
- if (lastBackwardSlash == -1 ) {
74
- String part = m_path.Substring (lastForwardSlash + 1 );
75
- return part;
76
- }
77
-
78
- String part = m_path.Substring (
79
- Math::Max (lastForwardSlash, lastBackwardSlash) + 1 );
80
- return part;
81
- }
82
-
83
- // / delete the file
84
- virtual void Delete ()
85
- {
86
- int errVal = std::remove (FullName ().str ().c_str ());
87
- if (errVal) {
88
- // an error occurred TODO perhaps it should throw if not
89
- // found)
90
- // throw if a directory
91
- static_cast <void >(errVal);
92
- }
93
- return ;
94
- }
95
-
96
- // / get the creation date of the file
97
- DateTime CreationTime ()
98
- {
99
- throw System::NotImplementedException (
100
- " FileInfo::Creation time not implemented" );
101
- }
102
28
};
103
29
}
104
30
}
0 commit comments