Browse Source

Fixed C# implementation of GPFiles.FileList

k-john-gough 7 năm trước cách đây
mục cha
commit
5ce2963133
1 tập tin đã thay đổi với 10 bổ sung3 xóa
  1. 10 3
      libs/csharp/GPFiles.cs

+ 10 - 3
libs/csharp/GPFiles.cs

@@ -19,11 +19,18 @@ public abstract class GPFiles {
     int  ix = 0;
     char ch;
     do {
-	ch = arr[ix]; ix++;
+	  ch = arr[ix]; ix++;
     } while (ch != '\0');
     return new System.String(arr,0,ix-1);
   }
 
+  private static char[] mkArr(System.String str) {
+    char[] rslt = new char[str.Length + 1];
+    str.CopyTo(0, rslt, 0, str.Length);
+    rslt[str.Length] = '\0';
+    return rslt;
+  }
+
   /* ----------------------------------	*/
 
   public static bool isOlder(FILE first, FILE second) {
@@ -40,7 +47,7 @@ public abstract class GPFiles {
     }
 
   public static char[] CurrentDirectory() {
-        return System.IO.Directory.GetCurrentDirectory().ToCharArray();
+        return mkArr(System.IO.Directory.GetCurrentDirectory());
   }
   
   public static bool exists(char[] filName) {
@@ -55,7 +62,7 @@ public abstract class GPFiles {
        else {
            char[][] rslt = new char[files.Length][];
            for (int i = 0; i < files.Length; i++)
-               rslt[i] = files[i].ToCharArray();
+               rslt[i] = mkArr(System.IO.Path.GetFileName(files[i]));
 	   return rslt;
        }
    }