tdir.pp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. { Program to test OS-specific features of the system unit }
  2. { routines to test: }
  3. { mkdir() }
  4. { chdir() }
  5. { This program shoulf not be executed in a root directory }
  6. { Creates the following directory, and sets it as the }
  7. { current directory. }
  8. { ../testdir }
  9. Program tdir;
  10. {$I-}
  11. procedure test(value, required: longint);
  12. begin
  13. if value <> required then
  14. begin
  15. writeln('Got ',value,' instead of ',required);
  16. halt(1);
  17. end;
  18. end;
  19. var
  20. s: string;
  21. Begin
  22. Write('changing to parent directory...');
  23. chdir('..');
  24. test(IOResult, 0);
  25. WriteLn('Passed!');
  26. Write('making directory...');
  27. mkdir('testdir');
  28. test(IOResult, 0);
  29. WriteLn('Passed!');
  30. Write('going into the newly created directory...');
  31. chdir('testdir');
  32. test(IOResult, 0);
  33. WriteLn('Passed!');
  34. Write('making directory...');
  35. mkdir('testdir2');
  36. test(IOResult, 0);
  37. WriteLn('Passed!');
  38. Write('removing directory ...');
  39. rmdir('testdir2');
  40. test(IOResult, 0);
  41. WriteLn('Passed!');
  42. Write('going directory up ...');
  43. chdir('..');
  44. test(IOResult, 0);
  45. WriteLn('Passed!');
  46. Write('removing directory ...');
  47. rmdir('testdir');
  48. test(IOResult, 0);
  49. WriteLn('Passed!');
  50. WriteLn('getting current directory...');
  51. getdir(0,s);
  52. WriteLn(s);
  53. end.