getvolumes.pas 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. {
  2. $Id$
  3. Getting list of DOS volumes and assigns
  4. Free Pascal for MorphOS example
  5. Copyright (C) 2005 by Karoly Balogh
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. { * 2005.01.10 * }
  13. { * Needs MorphOS RTL 2005.01.10 or later! * }
  14. program getvolumes;
  15. uses doslib;
  16. { * this function converts a BCPL-style string pointer to * }
  17. { * normal PChar type. * }
  18. function BStr2PChar(bstr: DWord): PChar;
  19. begin
  20. BStr2PChar:=Pointer((bstr shl 2)+1);
  21. end;
  22. procedure dosList(flags: DWord);
  23. var
  24. dosList: PDosList;
  25. begin
  26. { * fetch a list of volumes * }
  27. dosList:=LockDosList(flags or LDF_READ);
  28. { * parse the volumes * }
  29. repeat
  30. dosList:=NextDosEntry(dosList,flags);
  31. if dosList<>NIL then
  32. writeln(BStr2PChar(dosList^.dol_Name));
  33. until dosList=NIL;
  34. UnLockDosList(flags or LDF_READ);
  35. end;
  36. begin
  37. { * dos.library is opened by the RTL startup code, * }
  38. { * so we don't need to open it by ourselves. * }
  39. writeln('Current Volumes: ==========');
  40. dosList(LDF_VOLUMES);
  41. writeln('Current Assigns: ==========');
  42. dosList(LDF_ASSIGNS);
  43. end.
  44. {
  45. $Log$
  46. Revision 1.1 2005-01-10 06:00:47 karoly
  47. * initial revision
  48. }