sysos.inc 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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. {*****************************************************************************
  14. MorphOS structures
  15. *****************************************************************************}
  16. {$include execd.inc}
  17. {$include timerd.inc}
  18. {$include doslibd.inc}
  19. {*****************************************************************************
  20. MorphOS functions
  21. *****************************************************************************}
  22. { exec.library functions }
  23. {$include execf.inc}
  24. {$include doslibf.inc}
  25. {*****************************************************************************
  26. System Dependent Structures/Consts
  27. *****************************************************************************}
  28. const
  29. CTRL_C = 20; { Error code on CTRL-C press }
  30. { Used for CTRL_C checking in I/O calls }
  31. procedure checkCTRLC;
  32. begin
  33. if BreakOn then begin
  34. if (SetSignal(0,0) And SIGBREAKF_CTRL_C)<>0 then begin
  35. { Clear CTRL-C signal }
  36. SetSignal(0,SIGBREAKF_CTRL_C);
  37. Halt(CTRL_C);
  38. end;
  39. end;
  40. end;
  41. { Converts a MorphOS dos.library error code to a TP compatible error code }
  42. { Based on 1.0.x Amiga RTL }
  43. procedure dosError2InOut(errno: LongInt);
  44. begin
  45. case errno of
  46. ERROR_BAD_NUMBER,
  47. ERROR_ACTION_NOT_KNOWN,
  48. ERROR_NOT_IMPLEMENTED : InOutRes := 1;
  49. ERROR_OBJECT_NOT_FOUND : InOutRes := 2;
  50. ERROR_DIR_NOT_FOUND : InOutRes := 3;
  51. ERROR_DISK_WRITE_PROTECTED : InOutRes := 150;
  52. ERROR_OBJECT_WRONG_TYPE : InOutRes := 151;
  53. ERROR_OBJECT_EXISTS,
  54. ERROR_DELETE_PROTECTED,
  55. ERROR_WRITE_PROTECTED,
  56. ERROR_READ_PROTECTED,
  57. ERROR_OBJECT_IN_USE,
  58. ERROR_DIRECTORY_NOT_EMPTY : InOutRes := 5;
  59. ERROR_NO_MORE_ENTRIES : InOutRes := 18;
  60. ERROR_RENAME_ACROSS_DEVICES : InOutRes := 17;
  61. ERROR_DISK_FULL : InOutRes := 101;
  62. ERROR_INVALID_RESIDENT_LIBRARY : InoutRes := 153;
  63. ERROR_BAD_HUNK : InOutRes := 153;
  64. ERROR_NOT_A_DOS_DISK : InOutRes := 157;
  65. ERROR_NO_DISK,
  66. ERROR_DISK_NOT_VALIDATED,
  67. ERROR_DEVICE_NOT_MOUNTED : InOutRes := 152;
  68. ERROR_SEEK_ERROR : InOutRes := 156;
  69. ERROR_LOCK_COLLISION,
  70. ERROR_LOCK_TIMEOUT,
  71. ERROR_UNLOCK_ERROR,
  72. ERROR_INVALID_LOCK,
  73. ERROR_INVALID_COMPONENT_NAME,
  74. ERROR_BAD_STREAM_NAME,
  75. ERROR_FILE_NOT_OBJECT : InOutRes := 6;
  76. else
  77. InOutres := errno;
  78. end;
  79. end;
  80. { Converts an Unix-like path to Amiga-like path }
  81. function PathConv(path: string): string; alias: 'PATHCONV'; [public];
  82. var tmppos: longint;
  83. begin
  84. { check for short paths }
  85. if length(path)<=2 then begin
  86. if (path='.') or (path='./') then path:='' else
  87. if path='..' then path:='/' else
  88. if path='*' then path:='#?';
  89. end else begin
  90. { convert parent directories }
  91. tmppos:=pos('../',path);
  92. while tmppos<>0 do begin
  93. { delete .. to have / as parent dir sign }
  94. delete(path,tmppos,2);
  95. tmppos:=pos('../',path);
  96. end;
  97. { convert current directories }
  98. tmppos:=pos('./',path);
  99. while tmppos<>0 do begin
  100. { delete ./ since we doesn't need to sign current directory }
  101. delete(path,tmppos,2);
  102. tmppos:=pos('./',path);
  103. end;
  104. { convert wildstar to #? }
  105. tmppos:=pos('*',path);
  106. while tmppos<>0 do begin
  107. delete(path,tmppos,1);
  108. insert('#?',path,tmppos);
  109. tmppos:=pos('*',path);
  110. end;
  111. end;
  112. PathConv:=path;
  113. end;