sysos.inc 3.9 KB

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