GPFiles.java 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. //
  2. // Body of GPFiles interface.
  3. // This file implements the code of the GPFiles.cp file.
  4. // dwc August 1999.
  5. package CP.GPFiles;
  6. import java.io.*;
  7. public class GPFiles {
  8. public static char pathSep = System.getProperty("path.separator").charAt(0);
  9. public static char fileSep = System.getProperty("file.separator").charAt(0);
  10. public static char optChar = '-';
  11. public static boolean isOlder(GPFiles_FILE first, GPFiles_FILE second) {
  12. return (first.f.lastModified() < second.f.lastModified());
  13. }
  14. public static void MakeDirectory(char[] dirName) {
  15. File path = new File(CP.CPJ.CPJ.MkStr(dirName));
  16. if (!path.exists()) {
  17. boolean ok = path.mkdirs();
  18. }
  19. }
  20. public static char[] CurrentDirectory() {
  21. String curDir = System.getProperty("user.dir");
  22. return curDir.toCharArray();
  23. }
  24. public static boolean exists(char[] dirName) {
  25. File path = new File(CP.CPJ.CPJ.MkStr(dirName));
  26. return path.exists();
  27. }
  28. public static char[][] FileList(char[] dirPath) throws IOException {
  29. File theDir = new File(CP.CPJ.CPJ.MkStr(dirPath));
  30. String[] files = theDir.list();
  31. if (files == null || files.length == 0 ) return null;
  32. else {
  33. char[][] rslt = new char[files.length][];
  34. for (int i = 0; i < files.length; i++)
  35. rslt[i] = CP.CPJrts.CPJrts.JavaStrToChrOpen(files[i]);
  36. return rslt;
  37. }
  38. }
  39. }