home *** CD-ROM | disk | FTP | other *** search
/ RISC DISC 1 / RISC_DISC_1.iso / pd_share / code / desklib / Libraries / File / c / LoadTo < prev    next >
Encoding:
Text File  |  1994-05-29  |  1.3 KB  |  50 lines

  1. /*
  2.     ####             #    #     # #
  3.     #   #            #    #       #          The FreeWare C library for 
  4.     #   #  ##   ###  #  # #     # ###             RISC OS machines
  5.     #   # #  # #     # #  #     # #  #   ___________________________________
  6.     #   # ####  ###  ##   #     # #  #                                      
  7.     #   # #        # # #  #     # #  #    Please refer to the accompanying
  8.     ####   ### ####  #  # ##### # ###    documentation for conditions of use
  9.     ________________________________________________________________________
  10.  
  11.     File:    File.LoadTo.c
  12.     Author:  Copyright © 1994 Peter Gaunt
  13.     Version: 1.00 (12 Mar 1994)
  14.     Purpose: Loads a file at a given address.
  15. */
  16.  
  17. #include "kernel.h"
  18. #include "Core.h"
  19. #include "SWI.h"
  20.  
  21. /*
  22.  * Loads a file at an address
  23.  *
  24.  * If size is not NULL then it is set to file size (except on error).
  25.  *
  26.  * Returns NULL or pointer to error.
  27.  */
  28.  
  29. extern os_error *File_LoadTo(char *filename, void *address, int *size )
  30. {
  31.   _kernel_swi_regs r;
  32.   _kernel_oserror  *error;
  33.  
  34.   r.r[0] = 255;
  35.   r.r[1] = (int) filename;
  36.   r.r[2] = (int) address;
  37.   r.r[3] = 0;
  38.  
  39.   error = _kernel_swi( SWI_OS_File, &r, &r );
  40.   
  41.   if (error != NULL)
  42.     return( (os_error *) error );
  43.  
  44.   if (size != NULL)
  45.     *size = r.r[4];
  46.  
  47.   return( NULL );
  48.  
  49. }
  50.