sysos.inc 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2001 by Free Pascal development team
  4. This file implements all the base types and limits required
  5. for a minimal POSIX compliant subset required to port the compiler
  6. to a new OS.
  7. See the file COPYING.FPC, included in this distribution,
  8. for details about the copyright.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  12. **********************************************************************}
  13. { * Turn on AmigaOS4 mode on PowerPC * }
  14. {$IFDEF CPUPOWERPC}
  15. {$DEFINE AMIGAOS4}
  16. {$ENDIF}
  17. {*****************************************************************************
  18. AmigaOS structures
  19. *****************************************************************************}
  20. {$include execd.inc}
  21. {$include timerd.inc}
  22. {$include doslibd.inc}
  23. {*****************************************************************************
  24. AmigaOS functions
  25. *****************************************************************************}
  26. { exec.library functions }
  27. {$include execf.inc}
  28. {$include doslibf.inc}
  29. {$IFDEF AMIGAOS4}
  30. // Required to allow opening of utility library interface...
  31. {$include utilf.inc}
  32. {$ENDIF}
  33. {*****************************************************************************
  34. System Dependent Structures/Consts
  35. *****************************************************************************}
  36. const
  37. CTRL_C = 20; { Error code on CTRL-C press }
  38. { Used for CTRL_C checking in I/O calls }
  39. procedure checkCTRLC;
  40. begin
  41. if BreakOn then begin
  42. if (SetSignal(0,0) And SIGBREAKF_CTRL_C)<>0 then begin
  43. { Clear CTRL-C signal }
  44. SetSignal(0,SIGBREAKF_CTRL_C);
  45. Halt(CTRL_C);
  46. end;
  47. end;
  48. end;
  49. { Converts a AmigaOS dos.library error code to a TP compatible error code }
  50. { Based on 1.0.x Amiga RTL }
  51. procedure dosError2InOut(errno: LongInt);
  52. begin
  53. case errno of
  54. ERROR_BAD_NUMBER,
  55. ERROR_ACTION_NOT_KNOWN,
  56. ERROR_NOT_IMPLEMENTED : InOutRes := 1;
  57. ERROR_OBJECT_NOT_FOUND : InOutRes := 2;
  58. ERROR_DIR_NOT_FOUND : InOutRes := 3;
  59. ERROR_DISK_WRITE_PROTECTED : InOutRes := 150;
  60. ERROR_OBJECT_WRONG_TYPE : InOutRes := 151;
  61. ERROR_OBJECT_EXISTS,
  62. ERROR_DELETE_PROTECTED,
  63. ERROR_WRITE_PROTECTED,
  64. ERROR_READ_PROTECTED,
  65. ERROR_OBJECT_IN_USE,
  66. ERROR_DIRECTORY_NOT_EMPTY : InOutRes := 5;
  67. ERROR_NO_MORE_ENTRIES : InOutRes := 18;
  68. ERROR_RENAME_ACROSS_DEVICES : InOutRes := 17;
  69. ERROR_DISK_FULL : InOutRes := 101;
  70. ERROR_INVALID_RESIDENT_LIBRARY : InoutRes := 153;
  71. ERROR_BAD_HUNK : InOutRes := 153;
  72. ERROR_NOT_A_DOS_DISK : InOutRes := 157;
  73. ERROR_NO_DISK,
  74. ERROR_DISK_NOT_VALIDATED,
  75. ERROR_DEVICE_NOT_MOUNTED : InOutRes := 152;
  76. ERROR_SEEK_ERROR : InOutRes := 156;
  77. ERROR_LOCK_COLLISION,
  78. ERROR_LOCK_TIMEOUT,
  79. ERROR_UNLOCK_ERROR,
  80. ERROR_INVALID_LOCK,
  81. ERROR_INVALID_COMPONENT_NAME,
  82. ERROR_BAD_STREAM_NAME,
  83. ERROR_FILE_NOT_OBJECT : InOutRes := 6;
  84. else
  85. InOutRes := errno;
  86. end;
  87. end;
  88. { Converts an Unix-like path to Amiga-like path }
  89. function PathConv(path: string): string; alias: 'PATHCONV'; [public];
  90. var tmppos: longint;
  91. begin
  92. { check for short paths }
  93. if length(path)<=2 then begin
  94. if (path='.') or (path='./') then path:='' else
  95. if path='..' then path:='/' else
  96. if path='*' then path:='#?';
  97. end else begin
  98. { convert parent directories }
  99. tmppos:=pos('../',path);
  100. while tmppos<>0 do begin
  101. { delete .. to have / as parent dir sign }
  102. delete(path,tmppos,2);
  103. tmppos:=pos('../',path);
  104. end;
  105. { convert current directories }
  106. tmppos:=pos('./',path);
  107. while tmppos<>0 do begin
  108. { delete ./ since we doesn't need to sign current directory }
  109. delete(path,tmppos,2);
  110. tmppos:=pos('./',path);
  111. end;
  112. { convert wildstart to #? }
  113. tmppos:=pos('*',path);
  114. while tmppos<>0 do begin
  115. delete(path,tmppos,1);
  116. insert('#?',path,tmppos);
  117. tmppos:=pos('*',path);
  118. end;
  119. end;
  120. PathConv:=path;
  121. end;