Changeset 482


Ignore:
Timestamp:
Mar 15, 2008, 7:32:54 PM (16 years ago)
Author:
OverTaker
Message:

FileInfoクラス実装

File:
1 edited

Legend:

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

    r466 r482  
    22Namespace IO
    33
     4/*
     5@brief  ファイルの情報取得,操作をするクラス
     6@date   2008/03/14
     7@author OverTaker
     8*/
    49
    510Class FileInfo
    611    Inherits FileSystemInfo
    712Public
     13    /*
     14    @brief  コンストラクタ
     15    @param  ファイルパス
     16    */
    817    Sub FileInfo(path As String)
    918        OriginalPath = path
     
    1120    End Sub
    1221
    13     Sub ~FileInfo()
    14     End Sub
    15 
    1622    '----------------------------------------------------------------
    1723    ' パブリック プロパティ
    1824    '----------------------------------------------------------------
    1925
     26    /*
     27    @brief  ひとう上のフォルダを取得する
     28    @return フォルダを表すDirectoryInfo
     29    */
    2030    Function Directory() As DirectoryInfo
    2131        Return New DirectoryInfo(Path.GetDirectoryName(FullPath))
    2232    End Function
    2333
     34    /*
     35    @brief  ひとつ上のフォルダ名を取得する
     36    @return フォルダを表すファイルパス
     37    */
    2438    Function DirectoryName() As String
    2539        Return Path.GetDirectoryName(FullPath)
    2640    End Function
    2741
     42    /*
     43    @brief  ファイルが読み取り専用かどうかを取得する
     44    @retval True  読み取り専用ファイル
     45    @retval False 読み取り専用ファイルではない
     46    */
    2847    Function IsReadOnly() As Boolean
    2948        If (Attributes and FileAttributes.ReadOnly) = FileAttributes.ReadOnly Then
     
    3453    End Function
    3554
     55    /*
     56    @brief  ファイルサイズを取得する
     57    @return ファイルサイズ
     58    */
    3659    Function Length() As QWord
    3760        Dim hFile = CreateFile(ToTCStr(FullPath), GENERIC_READ, FILE_SHARE_READ Or FILE_SHARE_WRITE, ByVal 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0)
     
    5578    '----------------------------------------------------------------
    5679
    57 /*  Function AppendText() As StreamWriter
    58     End Function*/
    59 
     80    /*
     81    @brief  ファイルにテキストを追加するストリームライターを作成する
     82    @return ストリームライター
     83    */
     84    Function AppendText() As StreamWriter
     85        Return File.AppendText(FullPath)
     86    End Function
     87
     88    /*
     89    @brief  ファイルをコピーする(上書きしない)
     90    @param  コピー先のファイルパス
     91    @return コピー先のファイルを表すFileInfo
     92    */
    6093    Function CopyTo(destFileName As String) As FileInfo
    6194        Return CopyTo(destFileName, False)
    6295    End Function
    6396
     97    /*
     98    @brief  ファイルをコピーする
     99    @param  コピー先のファイルパス
     100    @param  ファイルを上書きするかどうか
     101    @return コピー先のファイルを表すFileInfo
     102    */
    64103    Function CopyTo(destFileName As String, overwrite As Boolean) As FileInfo
    65104        File.Copy(FullPath, destFileName, overwrite)
     
    67106    End Function
    68107
     108    /*
     109    @brief  ファイルを作成する
     110    @return ファイルストリーム
     111    */
    69112    Function Create() As FileStream
    70113        Return File.Create(FullPath)
    71114    End Function
    72115
    73 /*  Function CreateText() As StreamWriter
    74     End Function*/
     116    /*
     117    @brief  ファイルを作成し、そのストリームライターを取得する
     118    @return ストリームライター
     119    */
     120    Function CreateText() As StreamWriter
     121        Return New StreamWriter(Create())
     122    End Function
    75123
    76124/*  Sub Decrypt()
    77125    End Sub*/
    78126
     127    /*
     128    @brief  ファイルを削除する
     129    */
    79130    Override Sub Delete()
    80131        File.Delete(FullPath)
     
    90141    End Function*/
    91142
     143    /*
     144    @brief  ファイルを移動する
     145    @param  移動先のファイルパス
     146    */
    92147    Sub MoveTo(destFileName As String)
    93148        File.Move(FullPath, destFileName)
    94149    End Sub
    95150
     151    /*
     152    @brief  ファイルストリームを作成する
     153    @param  ファイルモード
     154    @return ファイルストリーム
     155    */
    96156    Function Open(mode As FileMode) As FileStream
    97157        Return New FileStream(FullPath, mode)
    98158    End Function
    99159
     160    /*
     161    @brief  ファイルストリームを作成する
     162    @param  ファイルモード
     163    @param  ファイルアクセス
     164    @return ファイルストリーム
     165    */
    100166    Function Open(mode As FileMode, access As FileAccess) As FileStream
    101167        Return New FileStream(FullPath, mode, access)
    102168    End Function
    103169
     170    /*
     171    @brief  ファイルストリームを作成する
     172    @param  ファイルモード
     173    @param  ファイルアクセス
     174    @param  ファイル共有
     175    @return ファイルストリーム
     176    */
    104177    Function Open(mode As FileMode, access As FileAccess, share As FileShare ) As FileStream
    105178        Return New FileStream(FullPath, mode, access, share)
    106179    End Function
    107180
     181    /*
     182    @brief  読み取り専用のファイルストリームを作成する
     183    @return ファイルストリーム
     184    */
    108185    Function OpenRead() As FileStream
    109186        Return Open(FileMode.Open, FileAccess.Read, FileShare.Read)
    110187    End Function
    111188
     189    /*
     190    @brief  読み取り専用のストリームを作成する
     191    @param  ファイルパス
     192    @return ストリームリーダー
     193    */
    112194    Function OpenText() As StreamReader
    113195        Return New StreamReader(FullPath)
    114196    End Function
    115197
     198    /*
     199    @brief  書き込み専用のファイルストリームを作成する
     200    @return ファイルストリーム
     201    */
    116202    Function OpenWrite() As FileStream
    117203        Return Open(FileMode.Open, FileAccess.Write)
    118204    End Function
    119205
    120 /*  Function Replace(destinationFileName As String, destinationBackupFileName As String) As FileInfo
    121     End Function*/
     206    /*
     207    @brief  ファイルを置き換える
     208    @param  置き換え先のファイルパス
     209    @param  置き換えられるファイルのバックアップを作成するファイルパス
     210    */
     211    Function Replace(destinationFileName As String, destinationBackupFileName As String) As FileInfo
     212        File.Replace(FullPath, destinationFileName, destinationBackupFileName)
     213    End Function
    122214
    123215/*  Function Replace(destinationFileName As String, destinationBackupFileName As String, ignoreMetadataErrors As Boolean) As FileInfo
     
    127219    End Sub*/
    128220
     221    /*
     222    @brief  インスタンスを文字列で表す
     223    @return ファイルパス
     224    */
    129225    Override Function ToString() As String
    130226        Return FullPath
Note: See TracChangeset for help on using the changeset viewer.