home *** CD-ROM | disk | FTP | other *** search
/ RISC DISC 2 / RISC_DISC_2.iso / pd_share / program / code / stubshack / HeapGraph / !HeapDisp / c / ScanPipeFS < prev    next >
Encoding:
Text File  |  1994-09-01  |  1.2 KB  |  68 lines

  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. #include "SWI.swiv.h"
  5.  
  6. #include "DeskLib:Error.h"
  7. #include "DeskLib:File.h"
  8.  
  9. #include "Shell.Printf.h"
  10.  
  11. #include "ScanPipeFS.h"
  12. #include "ScanFile.h"
  13.  
  14.  
  15. #define BUFFER_SIZE        4096
  16. #define NUMFILES_REQUESTED    4096
  17.  
  18.  
  19.  
  20.  
  21. void    ScanPipeFS( const char *rootpath, apps_anchorblock *apps)
  22. {
  23. char        buffer[ BUFFER_SIZE];
  24. os_error    *error;
  25. int        numitems, offset;
  26.  
  27. error = swix( SWI_OS_GBPB, IN(R0|R1|R2|R3|R4|R5|R6) | OUT(R3|R4),
  28.     10, rootpath, buffer, NUMFILES_REQUESTED, 0, BUFFER_SIZE, NULL,
  29.     &numitems, &offset
  30.     );
  31. if (error)    Error_Report( 0, error->errmess);
  32.  
  33. else if (numitems && !error)    {
  34.     char    *c;
  35.     int    i;
  36.     char    path[ 256];
  37.     int    len = strlen( rootpath);
  38.  
  39.     strcpy( path, rootpath);
  40.     if ( rootpath[ len-1]!=':')    path[len++] = '.';
  41.  
  42.     for ( i=0, c=buffer; i<numitems; i++)    {
  43.         int    *cc = (int *) c;
  44.         strcpy( path+len, c+20);
  45.         /*
  46.         Shell_Printf( "File info is %i %i %i %i %i\n",
  47.             cc[0], cc[1], cc[2], cc[3], cc[4]
  48.             );
  49.         */
  50.  
  51.         if ( cc[4]==1)    {
  52.             file_handle    file;
  53.  
  54.             file = File_Open( path, file_READ);
  55.             if ( file)    {
  56.                 ReadFromFile( file, path, cc[2], apps);
  57.                 File_Close( file);
  58.                 }
  59.             /*else    Shell_Printf( "Couldn't open file %s\n", path);*/
  60.             }
  61.  
  62.         c += 24 + 4*( strlen( c+20)/4);
  63.         }
  64.     }
  65. return;
  66. }
  67.  
  68.