Ignore:
Timestamp:
Mar 9, 2008, 12:00:01 PM (17 years ago)
Author:
イグトランス (egtra)
Message:

TextWriter, StreamWriterの追加。
SPrintfの浮動小数点数変換で、NaN, Infiniteの出力に対応。
PathとDirectoryInfoのCreateDirectoryで、対象が既に存在するときには例外を投げないように修正。
SimpleTestCase内で使用する一時フォルダの場所にGetTempPathで取得する版を追加(コメントアウト)。

Location:
trunk/Include/Classes/System/IO
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Include/Classes/System/IO/DirectoryInfo.ab

    r409 r468  
    5959            Select Case error
    6060                Case ERROR_ALREADY_EXISTS
    61                     Throw New IOException("DirectoryInfo.CreateDirectory: The directory has already existed.")
     61                    Exit Sub 'ディレクトリが既に存在するときは、何もしない。
    6262                Case Else
    6363                    Throw New IOException("DirectoryInfo.CreateDirectory: Failed to CreateDirectory")
  • trunk/Include/Classes/System/IO/Path.ab

    r429 r468  
    8888    */
    8989    Static Function GetFullPath(path As String) As String
    90         Return Combine(System.Environment.CurrentDirectory, path)
     90        If IsPathRooted(path) Then
     91            Return path
     92        Else
     93            Return Combine(System.Environment.CurrentDirectory, path)
     94        End If
    9195    End Function
    9296
     
    172176    Static Function GetTempPath() As String
    173177        Dim size = WIN32API_GetTempPath(0, 0)
    174         Dim p = GC_malloc_atomic(SizeOf (TCHAR) * size) As PCTSTR
    175         Dim len = WIN32API_GetTempPath(size, p)
     178        Dim buf = New Text.StringBuilder(size)
     179        buf.Length = size
     180        Dim len = WIN32API_GetTempPath(size, StrPtr(buf))
    176181        If (len > size) or len = 0 Then
    177182            Throw New IOException("Path.GetTempPath: Failed to GetTempPath.")
    178183        Else
    179             Return New String(p, len As Long)
     184            buf.Length = len
     185            Return buf.ToString
    180186        End If
    181187    End Function
     
    209215    Static Const ExtensionSeparatorChar = &H2E As StrChar
    210216    Static Const InvalidPathChars = Ex"\q<>|\0\t" As String
    211     Static Const UniformNamingConventionString = Ex"\\\\" As String
     217    Static Const UniformNamingConventionString = "\\" As String
    212218
    213219    '----------------------------------------------------------------
     
    227233        Dim i As Long
    228234        For i = 0 To ELM(InvalidPathChars.Length)
    229             If path.Contains(InvalidPathChars.Substring(i, 1)) Then
     235            If path.Contains(InvalidPathChars[i]) Then
    230236                Throw New IOException("Path.CheckPath: The path contains invalidPathChars.")
    231237            End If
  • trunk/Include/Classes/System/IO/Stream.ab

    r432 r468  
    77
    88Public 'Protected
    9     Sub Stream():   End Sub
     9    Sub Stream()
     10    End Sub
    1011Public
    1112    Virtual Sub ~Stream()
     
    5455        Dispose(True)
    5556    End Sub
    56     Virtual Function EndRead(ByRef asyncResult As System.IAsyncResult) As Long: End Function
    57     Virtual Sub EndWrite(ByRef asyncResult As System.IAsyncResult): End Sub
     57    Virtual Function EndRead(ByRef asyncResult As System.IAsyncResult) As Long
     58    End Function
     59    Virtual Sub EndWrite(ByRef asyncResult As System.IAsyncResult)
     60    End Sub
    5861    Abstract Sub Flush()
    5962    Abstract Function Read(buffer As *Byte, offset As Long, count As Long) As Long
     
    7275    Abstract Sub SetLength(value As Int64)
    7376    Abstract Sub Write(buffer As *Byte, offset As Long, count As Long)
    74 
    7577    Virtual Sub WriteByte(b As Byte)
    7678        Write(VarPtr(b), 0, 1)
  • trunk/Include/Classes/System/IO/StreamWriter.ab

    r271 r468  
    44   
    55Class StreamWriter
    6     ' TODO: 実装
     6    Inherits TextWriter
     7Public
     8    /*
     9    @date 2008/02/25
     10    @auther Egtra
     11    */
     12    Sub StreamWriter(path As String)
     13        init(New FileStream(path, FileMode.Create, FileAccess.Write, FileShare.None))
     14    End Sub
     15
     16    /*
     17    @date 2008/02/25
     18    @auther Egtra
     19    */
     20    Sub StreamWriter(stream As Stream)
     21        init(stream)
     22    End Sub
     23
     24    Override Sub Write(str As String)
     25        buf.Append(str)
     26        Dim len = buf.Length
     27        If len >= 2048 Then
     28            s.Write(StrPtr(buf) As *Byte, 0, len)
     29            buf.Length = 0
     30        End If
     31    End Sub
     32
     33    Override Sub Write(x As Boolean)
     34        buf.Append(x)
     35    End Sub
     36   
     37    Override Sub Write(x As Char)
     38        buf.Append(x)
     39    End Sub
     40
     41    Override Sub Write(x As Byte)
     42        buf.Append(x)
     43    End Sub
     44#ifdef UNICODE
     45    Override Sub Write(x As SByte)
     46        buf.Append(x)
     47    End Sub
     48#else
     49    Override Sub Write(x As Word)
     50        buf.Append(x)
     51    End Sub
     52#endif
     53    Override Sub Write(x As Integer)
     54        buf.Append(x)
     55    End Sub
     56
     57    Override Sub Write(x As DWord)
     58        buf.Append(x)
     59    End Sub
     60
     61    Override Sub Write(x As Long)
     62        buf.Append(x)
     63    End Sub
     64
     65    Override Sub Write(x As QWord)
     66        buf.Append(x)
     67    End Sub
     68
     69    Override Sub Write(x As Int64)
     70        buf.Append(x)
     71    End Sub
     72
     73    Override Sub Write(x As Single)
     74        buf.Append(x)
     75    End Sub
     76
     77    Override Sub Write(x As Double)
     78        buf.Append(x)
     79    End Sub
     80
     81    Override Sub Write(x As Object)
     82        Write(x.ToString)
     83    End Sub
     84
     85Protected
     86    Override Sub Dispose(disposing As Boolean)
     87        If disposing Then
     88            s.Dispose()
     89        End If
     90    End Sub
     91
     92Private
     93    Sub init(stream As Stream)
     94        s = stream
     95        buf = New System.Text.StringBuilder(4096)
     96    End Sub
     97
     98    buf As Text.StringBuilder
     99    s As System.IO.Stream
    7100End Class
    8101
  • trunk/Include/Classes/System/IO/TextReader.ab

    r457 r468  
    101101
    102102Protected
    103     Abstract Sub Dispose(disposing As Boolean)
     103    Virtual Sub Dispose(disposing As Boolean)
     104    End Sub
    104105
    105106    /*
Note: See TracChangeset for help on using the changeset viewer.