source: trunk/Include/Classes/System/IO/DriveInfo.ab@ 435

Last change on this file since 435 was 409, checked in by OverTaker, 16 years ago

DriveInfoのコンストラクタの間違い修整。他、コメント、例外追加。

File size: 2.3 KB
Line 
1Namespace System
2Namespace IO
3
4
5Enum DriveType
6 Unknown = 0
7 NoRootDirectory
8 Removable
9 Fixed
10 CDRom
11 Network
12 Ram
13End Enum
14
15Class DriveInfo
16 m_DriveName As String
17Public
18 Sub DriveInfo(driveName As String)
19 m_DriveName = driveName.ToUpper()
20 End Sub
21
22 Sub ~DriveInfo()
23 End Sub
24
25 'property
26 Function AvailableFreeSpace() As QWord
27 If GetDiskFreeSpaceEx(ToTCStr(m_DriveName), ByVal VarPtr(AvailableFreeSpace) As *ULARGE_INTEGER, ByVal 0, ByVal 0) = FALSE Then
28 Throw New IOException("DriveInfo.AvailableFreeSpace: Failed to GetDiskFreeSpaceEx.")
29 End If
30 End Function
31
32 Function DriveFormat() As String
33 Dim systemName[15] As TCHAR
34 If GetVolumeInformation(ToTCStr(m_DriveName), NULL, 0, NULL, NULL, NULL, systemName, Len (systemName) \ SizeOf (TCHAR)) Then
35 DriveFormat = New String( systemName )
36 Else
37 Throw New IOException("DriveInfo.DriveFormat: Failed to GetVolumeInformation.")
38 End If
39 End Function
40
41 Function DriveType() As Long
42 Return GetDriveType(ToTCStr(m_DriveName))
43 End Function
44
45 Function IsReady() As Boolean
46 If GetVolumeInformation(ToTCStr(m_DriveName), NULL, 0, NULL, NULL, NULL, NULL, 0) Then
47 Return True
48 Else
49 Return False
50 End If
51 End Function
52
53 Function Name() As String
54 Return m_DriveName
55 End Function
56
57/* Function RootDirectory() As DirectoryInfo
58 End Function*/
59
60 Function TotalFreeSpace() As QWord
61 If GetDiskFreeSpaceEx(ToTCStr(m_DriveName), ByVal 0, ByVal 0, ByVal VarPtr(TotalFreeSpace) As *ULARGE_INTEGER) = FALSE Then
62 Throw New IOException("DriveInfo.TotalFreeSpace: Failed to GetDiskFreeSpaceEx.")
63 End If
64 End Function
65
66 Function TotalSize() As QWord
67 If GetDiskFreeSpaceEx(ToTCStr(m_DriveName), ByVal 0, ByVal VarPtr(TotalSize) As *ULARGE_INTEGER, ByVal 0) = FALSE Then
68 Throw New IOException("DriveInfo.TotalSize: Failed to GetDiskFreeSpaceEx.")
69 End If
70 End Function
71
72 Function VolumeLabel() As String
73 Dim volumeName[63] As TCHAR
74 If GetVolumeInformation(ToTCStr(m_DriveName), volumeName, Len (volumeName) \ SizeOf (TCHAR), NULL, NULL, NULL, NULL, 0) Then
75 VolumeLabel = New String( volumeName )
76 Else
77 Throw New IOException("DriveInfo.VolumeLabel: Failed to GetVolumeInformation.")
78 End If
79 End Function
80End Class
81
82
83End Namespace
84End Namespace
Note: See TracBrowser for help on using the repository browser.