home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <string.h>
-
- #include "SWI.swiv.h"
-
- #include "DeskLib:Error.h"
- #include "DeskLib:File.h"
-
- #include "Shell.Printf.h"
-
- #include "ScanPipeFS.h"
- #include "ScanFile.h"
-
-
- #define BUFFER_SIZE 4096
- #define NUMFILES_REQUESTED 4096
-
-
-
-
- void ScanPipeFS( const char *rootpath, apps_anchorblock *apps)
- {
- char buffer[ BUFFER_SIZE];
- os_error *error;
- int numitems, offset;
-
- error = swix( SWI_OS_GBPB, IN(R0|R1|R2|R3|R4|R5|R6) | OUT(R3|R4),
- 10, rootpath, buffer, NUMFILES_REQUESTED, 0, BUFFER_SIZE, NULL,
- &numitems, &offset
- );
- if (error) Error_Report( 0, error->errmess);
-
- else if (numitems && !error) {
- char *c;
- int i;
- char path[ 256];
- int len = strlen( rootpath);
-
- strcpy( path, rootpath);
- if ( rootpath[ len-1]!=':') path[len++] = '.';
-
- for ( i=0, c=buffer; i<numitems; i++) {
- int *cc = (int *) c;
- strcpy( path+len, c+20);
- /*
- Shell_Printf( "File info is %i %i %i %i %i\n",
- cc[0], cc[1], cc[2], cc[3], cc[4]
- );
- */
-
- if ( cc[4]==1) {
- file_handle file;
-
- file = File_Open( path, file_READ);
- if ( file) {
- ReadFromFile( file, path, cc[2], apps);
- File_Close( file);
- }
- /*else Shell_Printf( "Couldn't open file %s\n", path);*/
- }
-
- c += 24 + 4*( strlen( c+20)/4);
- }
- }
- return;
- }
-
-