tdir.pp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. { %skiptarget=wince }
  10. Program tdir;
  11. {$I-}
  12. procedure test(value, required: longint);
  13. begin
  14. if value <> required then
  15. begin
  16. writeln('Got ',value,' instead of ',required);
  17. halt(1);
  18. end;
  19. end;
  20. var
  21. s: string;
  22. Begin
  23. Write('changing to parent directory...');
  24. chdir('..');
  25. test(IOResult, 0);
  26. WriteLn('Passed!');
  27. Write('making directory...');
  28. mkdir('testdir');
  29. test(IOResult, 0);
  30. WriteLn('Passed!');
  31. Write('going into the newly created directory...');
  32. chdir('testdir');
  33. test(IOResult, 0);
  34. WriteLn('Passed!');
  35. Write('making directory...');
  36. mkdir('testdir2');
  37. test(IOResult, 0);
  38. WriteLn('Passed!');
  39. Write('removing directory ...');
  40. rmdir('testdir2');
  41. test(IOResult, 0);
  42. WriteLn('Passed!');
  43. Write('going directory up ...');
  44. chdir('..');
  45. test(IOResult, 0);
  46. WriteLn('Passed!');
  47. Write('removing directory ...');
  48. rmdir('testdir');
  49. test(IOResult, 0);
  50. WriteLn('Passed!');
  51. WriteLn('getting current directory...');
  52. getdir(0,s);
  53. WriteLn(s);
  54. end.