mirror of
				https://gitlab.com/freepascal.org/fpc/source.git
				synced 2025-10-31 04:11:35 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			142 lines
		
	
	
		
			3.9 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			142 lines
		
	
	
		
			3.9 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| {
 | |
|     This file is part of the Free Pascal run time library.
 | |
|     Copyright (c) 2001 by Free Pascal development team
 | |
| 
 | |
|     This file implements all the base types and limits required
 | |
|     for a minimal POSIX compliant subset required to port the compiler
 | |
|     to a new OS.
 | |
| 
 | |
|     See the file COPYING.FPC, included in this distribution,
 | |
|     for details about the copyright.
 | |
| 
 | |
|     This program is distributed in the hope that it will be useful,
 | |
|     but WITHOUT ANY WARRANTY; without even the implied warranty of
 | |
|     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 | |
| 
 | |
|  **********************************************************************}
 | |
| 
 | |
| {*****************************************************************************
 | |
|                            MorphOS structures
 | |
| *****************************************************************************}
 | |
| 
 | |
| {$include execd.inc}
 | |
| {$include timerd.inc}
 | |
| {$include doslibd.inc}
 | |
| 
 | |
| 
 | |
| {*****************************************************************************
 | |
|                            MorphOS functions
 | |
| *****************************************************************************}
 | |
| 
 | |
| { exec.library functions }
 | |
| 
 | |
| {$include execf.inc}
 | |
| {$include doslibf.inc}
 | |
| 
 | |
| 
 | |
| {*****************************************************************************
 | |
|                     System Dependent Structures/Consts
 | |
| *****************************************************************************}
 | |
| 
 | |
| const
 | |
|   CTRL_C           = 20;      { Error code on CTRL-C press }
 | |
| 
 | |
| { Used for CTRL_C checking in I/O calls }
 | |
| procedure checkCTRLC;
 | |
| begin
 | |
|   if BreakOn then begin
 | |
|     if (SetSignal(0,0) And SIGBREAKF_CTRL_C)<>0 then begin
 | |
|       { Clear CTRL-C signal }
 | |
|       SetSignal(0,SIGBREAKF_CTRL_C);
 | |
|       Halt(CTRL_C);
 | |
|     end;
 | |
|   end;
 | |
| end;
 | |
| 
 | |
| 
 | |
| { Converts a MorphOS dos.library error code to a TP compatible error code }
 | |
| { Based on 1.0.x Amiga RTL }
 | |
| procedure dosError2InOut(errno: LongInt);
 | |
| begin
 | |
|   case errno of
 | |
|     ERROR_BAD_NUMBER,
 | |
|     ERROR_ACTION_NOT_KNOWN,
 | |
|     ERROR_NOT_IMPLEMENTED : InOutRes := 1;
 | |
| 
 | |
|     ERROR_OBJECT_NOT_FOUND : InOutRes := 2;
 | |
|     ERROR_DIR_NOT_FOUND :  InOutRes := 3;
 | |
|     ERROR_DISK_WRITE_PROTECTED : InOutRes := 150;
 | |
|     ERROR_OBJECT_WRONG_TYPE : InOutRes := 151;
 | |
| 
 | |
|     ERROR_OBJECT_EXISTS,
 | |
|     ERROR_DELETE_PROTECTED,
 | |
|     ERROR_WRITE_PROTECTED,
 | |
|     ERROR_READ_PROTECTED,
 | |
|     ERROR_OBJECT_IN_USE,
 | |
|     ERROR_DIRECTORY_NOT_EMPTY : InOutRes := 5;
 | |
| 
 | |
|     ERROR_NO_MORE_ENTRIES : InOutRes := 18;
 | |
|     ERROR_RENAME_ACROSS_DEVICES : InOutRes := 17;
 | |
|     ERROR_DISK_FULL : InOutRes := 101;
 | |
|     ERROR_INVALID_RESIDENT_LIBRARY : InoutRes := 153;
 | |
|     ERROR_BAD_HUNK : InOutRes := 153;
 | |
|     ERROR_NOT_A_DOS_DISK : InOutRes := 157;
 | |
| 
 | |
|     ERROR_NO_DISK,
 | |
|     ERROR_DISK_NOT_VALIDATED,
 | |
|     ERROR_DEVICE_NOT_MOUNTED : InOutRes := 152;
 | |
| 
 | |
|     ERROR_SEEK_ERROR : InOutRes := 156;
 | |
| 
 | |
|     ERROR_LOCK_COLLISION,
 | |
|     ERROR_LOCK_TIMEOUT,
 | |
|     ERROR_UNLOCK_ERROR,
 | |
|     ERROR_INVALID_LOCK,
 | |
|     ERROR_INVALID_COMPONENT_NAME,
 | |
|     ERROR_BAD_STREAM_NAME,
 | |
|     ERROR_FILE_NOT_OBJECT : InOutRes := 6;
 | |
|    else
 | |
|     InOutres := errno;
 | |
|   end;
 | |
| end;
 | |
| 
 | |
| 
 | |
| { Converts an Unix-like path to Amiga-like path }
 | |
| function PathConv(path: string): string; alias: 'PATHCONV'; [public];
 | |
| var tmppos: longint;
 | |
| begin
 | |
|   { check for short paths }
 | |
|   if length(path)<=2 then begin
 | |
|     if (path='.') or (path='./') then path:='' else
 | |
|     if path='..' then path:='/' else
 | |
|     if path='*' then path:='#?';
 | |
|   end else begin
 | |
|     { convert parent directories }
 | |
|     tmppos:=pos('../',path);
 | |
|     while tmppos<>0 do begin
 | |
|       { delete .. to have / as parent dir sign }
 | |
|       delete(path,tmppos,2);
 | |
|       tmppos:=pos('../',path);
 | |
|     end;
 | |
|     { convert current directories }
 | |
|     tmppos:=pos('./',path);
 | |
|     while tmppos<>0 do begin
 | |
|       { delete ./ since we doesn't need to sign current directory }
 | |
|       delete(path,tmppos,2);
 | |
|       tmppos:=pos('./',path);
 | |
|     end;
 | |
|     { convert wildstar to #? }
 | |
|     tmppos:=pos('*',path);
 | |
|     while tmppos<>0 do begin
 | |
|       delete(path,tmppos,1);
 | |
|       insert('#?',path,tmppos);
 | |
|       tmppos:=pos('*',path);
 | |
|     end;
 | |
|   end;
 | |
|   PathConv:=path;
 | |
| end;
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | 
