sysos.inc 4.2 KB

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