delint
[AROS.git] / test / scantest.c
blob5aa0d7a8f97a8ae6ce6828c3bd73b32171f2276a
1 /*
2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <dos/dosasl.h>
7 #include <dos/dos.h>
8 #include <proto/dos.h>
9 #include <exec/types.h>
10 #include <exec/memory.h>
11 #include <proto/exec.h>
13 #include <stdio.h>
14 #include <string.h>
16 void ReadAll(BPTR lock)
18 struct FileInfoBlock * FIB = AllocVec(sizeof(struct FileInfoBlock), MEMF_CLEAR);
19 BOOL success;
20 int count = 1;
22 success = Examine(lock, FIB);
23 if (FIB->fib_DirEntryType < 0)
24 success = FALSE;
25 if (success)
26 success = ExNext(lock, FIB);
27 while (success)
29 printf("%s",FIB->fib_FileName);
30 if (FIB->fib_DirEntryType > 0)
32 printf(" (Dir)\n");
33 count++;
34 if (count > 1)
36 char * name = AllocVec(1024,0);
37 BPTR tmplock;
38 NameFromLock(lock,name,1024);
39 AddPart(name,FIB->fib_FileName,1024);
40 printf("Entering %s\n",name);
41 tmplock = Lock(name , ACCESS_READ);
42 ReadAll(tmplock);
43 NameFromLock(lock,name,1024);
44 printf("Returning to %s\n",name);
45 UnLock(tmplock);
46 FreeVec(name);
49 else
51 printf("\n");
53 success = ExNext(lock,FIB);
55 FreeVec(FIB);
58 int main(int argc, char *argv[])
60 BPTR lock;
62 printf("Trying to scan %s \n",argv[1]);
63 lock = Lock(argv[1],ACCESS_READ);
64 if (lock)
66 ReadAll(lock);
67 UnLock(lock);
69 else
70 printf("no such directory/assign!\n");
72 return 0;