Example #1
0
 /// <summary>
 /// この抽象パス名が示すファイルの名前を変更します。
 /// </summary>
 public bool renameTo( File dest )
 {
     try {
         System.IO.File.Replace( m_path, dest.m_path, m_path + "BAK" );
         return true;
     } catch {
     }
     return false;
 }
Example #2
0
 /// <summary>
 /// この抽象パス名が示すディレクトリにあるファイルおよびディレクトリの中で、指定されたフィルタの基準を満たすものの抽象パス名の配列を返します。
 /// </summary>
 public File[] listFiles( FilenameFilter filter )
 {
     List<File> ret = new List<File>();
     foreach ( string s in list() ) {
         if ( filter.accept( this, s ) ) {
             File f = new File( m_path + separator + s );
             ret.Add( f );
         }
     }
     return ret.ToArray();
 }
Example #3
0
 /// <summary>
 /// 指定されたディレクトリで新しい空のファイルを生成し、その名前には、指定された接頭辞および接尾辞の文字列が使用されます。
 /// </summary>
 public static File createTempFile( string prefix, string suffix, File directory )
 {
     String dir = System.IO.Path.GetTempPath();
     if ( directory != null ) {
         dir = directory.m_path;
     }
     if ( !System.IO.Directory.Exists( dir ) ) {
         throw new System.IO.IOException();
     }
     while ( true ) {
         String f = prefix + System.IO.Path.GetRandomFileName() + suffix;
         String full = System.IO.Path.Combine( dir, f );
         if ( !System.IO.File.Exists( full ) ) {
             System.IO.File.Create( full );
             return new File( full );
         }
     }
     throw new System.IO.IOException();
 }
Example #4
0
 /// <summary>
 /// この抽象パス名が示すディレクトリ内のファイルを示す抽象パス名の配列を返します。
 /// </summary>
 public File[] listFiles()
 {
     string[] files = System.IO.Directory.GetFiles( m_path );
     File[] ret = new File[files.Length];
     for ( int i = 0; i < files.Length; i++ ) {
         ret[i] = new File( m_path + separator + files[i] );
     }
     return ret;
 }
Example #5
0
 /// <summary>
 /// 2 つの抽象パス名を語彙的に比較します。
 /// </summary>
 public int compareTo( File pathname )
 {
     return System.IO.Path.GetFullPath( this.m_path ).CompareTo( System.IO.Path.GetFullPath( pathname.m_path ) );
 }