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

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

_System_CThreadCollectionでのクラスインスタンスへのポインタの使用を除去、参照変数構文へ。

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 If driveName.Length <> 1 Then
20 'ArgumentException
21 debug
22 End If
23 m_DriveName = driveName.ToUpper() + ":\"
24 End Sub
25
26 Sub ~DriveInfo()
27 End Sub
28
29 'property
30 Function AvailableFreeSpace() As QWord
31 If GetDiskFreeSpaceEx(ToTCStr(m_DriveName), ByVal VarPtr(AvailableFreeSpace) As *ULARGE_INTEGER, ByVal 0, ByVal 0) = FALSE Then
32 Throw New IOException("DriveInfo.AvailableFreeSpace: Failed to GetDiskFreeSpaceEx.")
33 End If
34 End Function
35
36 Function DriveFormat() As String
37 Dim systemName[15] As TCHAR
38 If GetVolumeInformation(ToTCStr(m_DriveName), NULL, 0, NULL, NULL, NULL, systemName, Len (systemName) \ SizeOf (TCHAR)) Then
39 DriveFormat = New String( systemName )
40 Else
41 Throw New IOException("DriveInfo.DriveFormat: Failed to GetVolumeInformation.")
42 End If
43 End Function
44
45 Function DriveType() As Long
46 Return GetDriveType(ToTCStr(m_DriveName))
47 End Function
48
49 Function IsReady() As Boolean
50 If GetVolumeInformation(ToTCStr(m_DriveName), NULL, 0, NULL, NULL, NULL, NULL, 0) Then
51 Return True
52 Else
53 Return False
54 End If
55 End Function
56
57 Function Name() As String
58 Return m_DriveName
59 End Function
60
61/* Function RootDirectory() As DirectoryInfo
62 End Function*/
63
64 Function TotalFreeSpace() As QWord
65 If GetDiskFreeSpaceEx(ToTCStr(m_DriveName), ByVal 0, ByVal 0, ByVal VarPtr(TotalFreeSpace) As *ULARGE_INTEGER) = FALSE Then
66 Throw New IOException("DriveInfo.TotalFreeSpace: Failed to GetDiskFreeSpaceEx.")
67 End If
68 End Function
69
70 Function TotalSize() As QWord
71 If GetDiskFreeSpaceEx(ToTCStr(m_DriveName), ByVal 0, ByVal VarPtr(TotalSize) As *ULARGE_INTEGER, ByVal 0) = FALSE Then
72 Throw New IOException("DriveInfo.TotalSize: Failed to GetDiskFreeSpaceEx.")
73 End If
74 End Function
75
76 Function VolumeLabel() As String
77 Dim volumeName[63] As TCHAR
78 If GetVolumeInformation(ToTCStr(m_DriveName), volumeName, Len (volumeName) \ SizeOf (TCHAR), NULL, NULL, NULL, NULL, 0) Then
79 VolumeLabel = New String( volumeName )
80 Else
81 Throw New IOException("DriveInfo.VolumeLabel: Failed to GetVolumeInformation.")
82 End If
83 End Function
84End Class
85
86
87End Namespace
88End Namespace
Note: See TracBrowser for help on using the repository browser.