- Timestamp:
- Mar 8, 2008, 7:33:08 PM (17 years ago)
- Location:
- trunk/Include
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Include/Classes/System/IO/File.ab
r435 r466 4 4 5 5 Enum FileAccess 6 Read = -2147483648 'GENERIC_READ7 ReadWrite = -1073741824 'GENERIC_READ Or GENERIC_WRITE8 Write = 1073741824'GENERIC_WRITE6 Read = GENERIC_READ 7 ReadWrite = GENERIC_READ Or GENERIC_WRITE 8 Write = GENERIC_WRITE 9 9 End Enum 10 10 11 11 Enum FileAttributes 12 Archive = 32 'FILE_ATTRIBUTE_ARCHIVE13 Compressed = 2048 'FILE_ATTRIBUTE_COMPRESSED14 Device = 64 'FILE_ATTRIBUTE_DEVICE15 Directory = 16 'FILE_ATTRIBUTE_DIRECTORY16 Encrypted = 16384 'FILE_ATTRIBUTE_ENCRYPTED17 Hidden = 2 'FILE_ATTRIBUTE_HIDDEN18 Normal = 128 'FILE_ATTRIBUTE_NORMAL19 NotContentIndexed = 8192 'FILE_ATTRIBUTE_NOT_CONTENT_INDEXED20 Offline = 4096 'FILE_ATTRIBUTE_OFFLINE21 ReadOnly = 1 'FILE_ATTRIBUTE_READONLY22 ReparsePoint = 1024 'FILE_ATTRIBUTE_REPARSE_POINT23 SparseFile = 512 'FILE_ATTRIBUTE_SPARSE_FILE24 System = 4 'FILE_ATTRIBUTE_SYSTEM25 Temporary = 256 'FILE_ATTRIBUTE_TEMPORARY12 Archive = FILE_ATTRIBUTE_ARCHIVE 13 Compressed = FILE_ATTRIBUTE_COMPRESSED 14 Device = FILE_ATTRIBUTE_DEVICE 15 Directory = FILE_ATTRIBUTE_DIRECTORY 16 Encrypted = FILE_ATTRIBUTE_ENCRYPTED 17 Hidden = FILE_ATTRIBUTE_HIDDEN 18 Normal = FILE_ATTRIBUTE_NORMAL 19 NotContentIndexed = FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 20 Offline = FILE_ATTRIBUTE_OFFLINE 21 ReadOnly = FILE_ATTRIBUTE_READONLY 22 ReparsePoint = FILE_ATTRIBUTE_REPARSE_POINT 23 SparseFile = FILE_ATTRIBUTE_SPARSE_FILE 24 System = FILE_ATTRIBUTE_SYSTEM 25 Temporary = FILE_ATTRIBUTE_TEMPORARY 26 26 End Enum 27 27 28 28 Enum FileMode 29 Append = 4 'OPEN_ALWAYS30 Create = 2 'CREATE_ALWAYS31 CreateNew = 1 'CREATE_NEW32 Open = 3 'OPEN_EXISTING33 OpenOrCreate = 4 'OPEN_ALWAYS34 Truncate = 5 'TRUNCATE_EXISTING29 Append = OPEN_ALWAYS 30 Create = CREATE_ALWAYS 31 CreateNew = CREATE_NEW 32 Open = OPEN_EXISTING 33 OpenOrCreate = OPEN_ALWAYS 34 Truncate = TRUNCATE_EXISTING 35 35 End Enum 36 36 37 37 Enum FileShare 38 None = 039 Read = FILE_SHARE_READ40 Write = FILE_SHARE_WRITE41 ReadWrite = FILE_SHARE_READ Or FILE_SHARE_WRITE38 None = 0 39 Read = FILE_SHARE_READ 40 Write = FILE_SHARE_WRITE 41 ReadWrite = FILE_SHARE_READ Or FILE_SHARE_WRITE 42 42 DeleteFile = FILE_SHARE_DELETE 43 43 End Enum … … 46 46 Public 47 47 48 Static Sub AppendAllText( path As String, contents As String ) 49 ' TODO: 実装 50 End Sub 48 '---------------------------------------------------------------- 49 ' パブリック メソッド 50 '---------------------------------------------------------------- 51 52 /* Static Sub AppendAllText( path As String, contents As String ) 53 ' TODO: 実装 54 End Sub*/ 51 55 52 56 /* Static Sub AppendAllText( path As String, contents As String, encoding As Encoding ) … … 54 58 End Sub */ 55 59 56 Static Function AppendText( path As String ) As StreamWriter57 ' TODO: 実装 58 End Function 60 /* Static Function AppendText( path As String ) As StreamWriter 61 ' TODO: 実装 62 End Function*/ 59 63 60 64 Static Sub Copy( sourceFileName As String, destFileName As String ) 61 ' TODO: 実装65 Copy(sourceFileName, destFileName, False) 62 66 End Sub 63 67 64 68 Static Sub Copy( sourceFileName As String, destFileName As String, overwrite As Boolean ) 65 ' TODO: 実装 69 If Not CopyFile(Path.GetFullPath(sourceFileName), Path.GetFullPath(destFileName), overwrite) Then 70 Throw New IOException( "FileInfo: Failed to CopyFile." ) 71 End If 66 72 End Sub 67 73 68 74 Static Function Create( path As String ) As FileStream 69 ' TODO: 実装70 End Function 71 72 Static Function Create( path As String, bufferSize As Long ) As FileStream73 ' TODO: 実装 74 End Function 75 Return New FileStream(path, FileMode.CreateNew, FileAccess.ReadWrite) 76 End Function 77 78 /* Static Function Create( path As String, bufferSize As Long ) As FileStream 79 ' TODO: 実装 80 End Function */ 75 81 76 82 /* Static Function Create( path As String, bufferSize As Long, options As FileOptions ) As FileStream … … 82 88 End Function */ 83 89 84 Static Function CreateText( path As String ) As StreamWriter 85 ' TODO: 実装 86 End Function 87 88 Static Sub Decrypt( path As String ) 89 ' TODO: 実装 90 End Sub 91 92 Static Sub DeleteFile( path As String ) 93 ' TODO: 実装 94 End Sub 95 96 Static Sub Encrypt( path As String ) 97 ' TODO: 実装 98 End Sub 90 /* Static Function CreateText( path As String ) As StreamWriter 91 ' TODO: 実装 92 End Function*/ 93 94 /* Static Sub Decrypt( path As String ) 95 ' TODO: 実装 96 End Sub*/ 97 98 Static Sub Delete( path As String ) 99 If Not DeleteFile(path) Then 100 Throw New IOException("File.Delete: Failed to DeleteFile.") 101 End If 102 End Sub 103 104 /* Static Sub Encrypt( path As String ) 105 ' TODO: 実装 106 End Sub*/ 99 107 100 108 Static Function Exists( path As String ) As Boolean 101 ' TODO: 実装 109 Dim data As WIN32_FIND_DATA 110 Dim hFind = FindFirstFile(ToTCStr(path), data) 111 FindClose(hFind) 112 113 If hFind <> INVALID_HANDLE_VALUE Then 114 Return True 115 Else 116 Return False 117 End If 102 118 End Function 103 119 … … 111 127 112 128 Static Function GetAttributes( path As String ) As FileAttributes 113 ' TODO: 実装129 Return New FileAttributes(getFileData(path).dwFileAttributes As Long, "FileAttributes") 114 130 End Function 115 131 116 132 Static Function GetCreationTime( path As String ) As DateTime 117 ' TODO: 実装133 Return System.DateTime.FromFileTime(getFileData(path).ftCreationTime) 118 134 End Function 119 135 120 136 Static Function GetCreationTimeUtc( path As String ) As DateTime 121 ' TODO: 実装137 Return System.DateTime.FromFileTimeUtc(getFileData(path).ftCreationTime) 122 138 End Function 123 139 124 140 Static Function GetLastAccessTime( path As String ) As DateTime 125 ' TODO: 実装141 Return System.DateTime.FromFileTime(getFileData(path).ftLastAccessTime) 126 142 End Function 127 143 128 144 Static Function GetLastAccessTimeUtc( path As String ) As DateTime 129 ' TODO: 実装145 Return System.DateTime.FromFileTimeUtc(getFileData(path).ftLastAccessTime) 130 146 End Function 131 147 132 148 Static Function GetLastWriteTime( path As String ) As DateTime 133 ' TODO: 実装149 Return System.DateTime.FromFileTime(getFileData(path).ftLastWriteTime) 134 150 End Function 135 151 136 152 Static Function GetLastWriteTimeUtc( path As String ) As DateTime 137 ' TODO: 実装153 Return System.DateTime.FromFileTimeUtc(getFileData(path).ftLastWriteTime) 138 154 End Function 139 155 140 156 Static Sub Move( sourceFileName As String, destFileName As String ) 141 ' TODO: 実装 157 If Not MoveFile(Path.GetFullPath(sourceFileName), Path.GetFullPath(destFileName)) Then 158 Throw New IOException("File.Move: Failed to MoveFile.") 159 End If 142 160 End Sub 143 161 144 162 Static Function Open( path As String, mode As FileMode ) As FileStream 145 ' TODO: 実装163 Return New FileStream(path, mode) 146 164 End Function 147 165 148 166 Static Function Open( path As String, mode As FileMode, access As FileAccess ) As FileStream 149 ' TODO: 実装167 Return New FileStream(path, mode, access) 150 168 End Function 151 169 152 170 Static Function Open( path As String, mode As FileMode, access As FileAccess, share As FileShare ) As FileStream 153 ' TODO: 実装171 Return New FileStream(path, mode, access, share) 154 172 End Function 155 173 156 174 Static Function OpenRead( path As String ) As FileStream 157 ' TODO: 実装158 End Function 159 160 'Static Function OpenText( path As String ) As StreamReader161 ' TODO: 実装162 'End Function175 Return Open(path, FileMode.Open, FileAccess.Read, FileShare.Read) 176 End Function 177 178 Static Function OpenText( path As String ) As StreamReader 179 Return New StreamReader(path) 180 End Function 163 181 164 182 Static Function OpenWrite( path As String ) As FileStream 165 ' TODO: 実装166 End Function 167 168 Static Function ReadAllBytes( path As String ) As *Byte169 ' TODO: 実装 170 End Function 183 Return Open(path, FileMode.Open, FileAccess.Write) 184 End Function 185 186 /* Static Function ReadAllBytes( path As String ) As *Byte 187 ' TODO: 実装 188 End Function*/ 171 189 172 190 /* Static Function ReadAllLines( path As String ) As Strings … … 178 196 End Function */ 179 197 180 Static Function ReadAllText( path As String ) As String181 ' TODO: 実装 182 End Function 198 /* Static Function ReadAllText( path As String ) As String 199 ' TODO: 実装 200 End Function*/ 183 201 184 202 /* Static Function ReadAllText( path As String, encoding As Encoding ) As String … … 186 204 End Function */ 187 205 188 Static Sub Replace( sourceFileName As String, destinationFileName As String, destinationBackupFileName As String )189 ' TODO: 実装 190 End Sub 191 192 Static Sub Replace( sourceFileName As String, destinationFileName As String, destinationBackupFileName As String, ignoreMetadataErrors As Boolean )193 ' TODO: 実装 194 End Sub 206 /* Static Sub Replace( sourceFileName As String, destinationFileName As String, destinationBackupFileName As String ) 207 ' TODO: 実装 208 End Sub*/ 209 210 /* Static Sub Replace( sourceFileName As String, destinationFileName As String, destinationBackupFileName As String, ignoreMetadataErrors As Boolean ) 211 ' TODO: 実装 212 End Sub*/ 195 213 196 214 /* Static Sub SetAccessControl( path As String, fileSecurity As FileSecurity ) … … 199 217 200 218 Static Sub SetAttributes( path As String, fileAttributes As FileAttributes ) 201 ' TODO: 実装 219 If Not SetFileAttributes(ToTCStr(path), fileAttributes) Then 220 Throw New IOException("File.SetAttributes: Failed to SetFileAttributes.") 221 End If 202 222 End Sub 203 223 204 224 Static Sub SetCreationTime( path As String, creationTime As DateTime ) 205 ' TODO: 実装 206 End Sub 207 208 Static Sub SetCreationTimeUtc( path As String, creationTime As DateTime ) 209 ' TODO: 実装 225 SetCreationTimeUtc(path, creationTime) 226 End Sub 227 228 Static Sub SetCreationTimeUtc( path As String, creationTimeUtc As DateTime ) 229 Dim hFile = createFileToSetTime(path) As HANDLE 230 SetFileTime(hFile, creationTimeUtc.ToFileTimeUtc(), ByVal 0, ByVal 0) 231 CloseHandle(hFile) 210 232 End Sub 211 233 212 234 Static Sub SetLastAccessTime( path As String, lastAccessTime As DateTime ) 213 ' TODO: 実装235 SetLastAccessTimeUtc(path, lastAccessTime) 214 236 End Sub 215 237 216 238 Static Sub SetLastAccessTimeUtc( path As String, lastAccessTimeUtc As DateTime ) 217 ' TODO: 実装 239 Dim hFile = createFileToSetTime(path) As HANDLE 240 SetFileTime(hFile, ByVal 0, lastAccessTimeUtc.ToFileTimeUtc(), ByVal 0) 241 CloseHandle(hFile) 218 242 End Sub 219 243 220 244 Static Sub SetLastWriteTime( path As String, lastWriteTime As DateTime ) 221 ' TODO: 実装245 SetLastWriteTimeUtc(path, lastWriteTime) 222 246 End Sub 223 247 224 248 Static Sub SetLastWriteTimeUtc( path As String, lastWriteTimeUtc As DateTime ) 225 ' TODO: 実装 226 End Sub 227 228 Static Sub WriteAllBytes( path As String, bytes As *Byte ) 229 ' TODO: 実装 230 End Sub 249 Dim hFile = createFileToSetTime(path) As HANDLE 250 SetFileTime(hFile, ByVal 0, ByVal 0, lastWriteTimeUtc.ToFileTimeUtc()) 251 CloseHandle(hFile) 252 End Sub 253 254 /* Static Sub WriteAllBytes( path As String, bytes As *Byte ) 255 ' TODO: 実装 256 End Sub*/ 231 257 232 258 /* Static Sub WriteAllLines( path As String, contents As Strings ) … … 238 264 End Sub */ 239 265 240 Static Sub WriteAllText( path As String, contents As String )241 ' TODO: 実装 242 End Sub 266 /* Static Sub WriteAllText( path As String, contents As String ) 267 ' TODO: 実装 268 End Sub*/ 243 269 244 270 /* Static Sub WriteAllText( path As String, contents As String, encoding As Enconding ) … … 246 272 End Sub */ 247 273 274 Private 275 276 Static Function getFileData(path As String) As WIN32_FIND_DATA 277 Dim data As WIN32_FIND_DATA 278 Dim hFind = FindFirstFile(ToTCStr(Path.GetFullPath(path)), data) 279 FindClose(hFind) 280 281 If hFind <> INVALID_HANDLE_VALUE Then 282 Return data 283 Else 284 Throw New IOException("File.getFileData: Failed to FindFirstFile.") 285 End If 286 End Function 287 288 Static Function createFileToSetTime(path As String) As HANDLE 289 Dim hFile As HANDLE 290 hFile = CreateFile(ToTCStr(path), GENERIC_WRITE, FILE_SHARE_READ Or FILE_SHARE_WRITE, ByVal 0, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0) 291 If hFile = INVALID_HANDLE_VALUE Then 292 CloseHandle(hFile) 293 Throw New IOException("File.setFileTime: Failed to CreateFile.") 294 Exit Function 295 End If 296 Return hFile 297 End Function 248 298 End Class 249 299 -
trunk/Include/Classes/System/IO/FileInfo.ab
r406 r466 15 15 16 16 '---------------------------------------------------------------- 17 ' Public properties17 ' パブリック プロパティ 18 18 '---------------------------------------------------------------- 19 19 … … 33 33 End If 34 34 End Function 35 36 Function Length() As QWord 37 Dim hFile = CreateFile(ToTCStr(FullPath), GENERIC_READ, FILE_SHARE_READ Or FILE_SHARE_WRITE, ByVal 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0) 38 If hFile = INVALID_HANDLE_VALUE Then 39 Throw New IOException("FileInfo.Length: Failed to CreateFile.") 40 Exit Function 41 End If 42 43 Dim length As QWord 44 If GetFileSizeEx(hFile, VarPtr(length)) Then 45 CloseHandle(hFile) 46 Return length 47 Else 48 CloseHandle(hFile) 49 Throw New IOException("FileInfo.Length: Failed to GetFileSize") 50 End If 51 End Function 52 53 '---------------------------------------------------------------- 54 ' パブリック メソッド 55 '---------------------------------------------------------------- 56 57 /* Function AppendText() As StreamWriter 58 End Function*/ 59 60 Function CopyTo(destFileName As String) As FileInfo 61 Return CopyTo(destFileName, False) 62 End Function 63 64 Function CopyTo(destFileName As String, overwrite As Boolean) As FileInfo 65 File.Copy(FullPath, destFileName, overwrite) 66 Return New FileInfo(destFileName) 67 End Function 68 69 Function Create() As FileStream 70 Return File.Create(FullPath) 71 End Function 72 73 /* Function CreateText() As StreamWriter 74 End Function*/ 75 76 /* Sub Decrypt() 77 End Sub*/ 78 79 Override Sub Delete() 80 File.Delete(FullPath) 81 End Sub 82 83 /* Sub Encrypt() 84 End Sub*/ 85 86 /* Function GetAccessControl() As FileSecurity 87 End Function*/ 88 89 /* Function GetAccessControl(includeSections As AccessControlSections) As FileScurity 90 End Function*/ 91 92 Sub MoveTo(destFileName As String) 93 File.Move(FullPath, destFileName) 94 End Sub 95 96 Function Open(mode As FileMode) As FileStream 97 Return New FileStream(FullPath, mode) 98 End Function 99 100 Function Open(mode As FileMode, access As FileAccess) As FileStream 101 Return New FileStream(FullPath, mode, access) 102 End Function 103 104 Function Open(mode As FileMode, access As FileAccess, share As FileShare ) As FileStream 105 Return New FileStream(FullPath, mode, access, share) 106 End Function 107 108 Function OpenRead() As FileStream 109 Return Open(FileMode.Open, FileAccess.Read, FileShare.Read) 110 End Function 111 112 Function OpenText() As StreamReader 113 Return New StreamReader(FullPath) 114 End Function 115 116 Function OpenWrite() As FileStream 117 Return Open(FileMode.Open, FileAccess.Write) 118 End Function 119 120 /* Function Replace(destinationFileName As String, destinationBackupFileName As String) As FileInfo 121 End Function*/ 122 123 /* Function Replace(destinationFileName As String, destinationBackupFileName As String, ignoreMetadataErrors As Boolean) As FileInfo 124 End Function*/ 125 126 /* Sub SetAccessControl(fileSecurity As FileSecurity) 127 End Sub*/ 128 129 Override Function ToString() As String 130 Return FullPath 131 End Function 132 35 133 End Class 36 37 134 38 135 -
trunk/Include/Classes/System/IO/FileSystemInfo.ab
r462 r466 73 73 */ 74 74 Sub Attributes(value As FileAttributes) 75 If SetFileAttributes(ToTCStr(FullPath), value) = FALSE Then 76 'Exception 77 Debug 75 If Not SetFileAttributes(ToTCStr(FullPath), value) Then 76 Throw New IOException("FileSystemInfo.Attributes: Failed to SetFileAttributes.") 78 77 End If 79 78 End Sub … … 199 198 */ 200 199 Function Exists() As Boolean 201 Dim data As WIN32_FIND_DATA 202 Dim hFind = FindFirstFile(ToTCStr(FullPath), data) 203 FindClose(hFind) 204 205 If hFind <> INVALID_HANDLE_VALUE Then 206 Return True 207 Else 208 Return False 209 End If 200 Return File.Exists(FullPath) 210 201 End Function 211 202 -
trunk/Include/api_system.sbp
r415 r466 562 562 ) As BOOL 563 563 Declare Function GetFileSize Lib "kernel32" (hFile As HANDLE, pFileSizeHigh As *DWord) As DWord 564 Declare Function GetFileSizeEx Lib "kernel32" (hFile As HANDLE, pFileSizeHigh As *QWord) As Boolean 564 565 Declare Function GetFileTime Lib "kernel32" (hFile As HANDLE, ByRef lpCreationTime As FILETIME, ByRef lpLastAccessTime As FILETIME, ByRef lpLastWriteTime As FILETIME) As BOOL 565 566
Note:
See TracChangeset
for help on using the changeset viewer.