/****************************************
 *                                      *
 * Programm: GetParent - übergeord. Dir *
 * ==================================== *
 *                                      *
 * Autor:  Datum:      Kommentar:       *
 * ------  ----------  ----------       *
 * Wgb     17.07.1988  ParentDir()      *
 *                                      *
 *                                      *
 ****************************************/

#include <libraries/dos.h>
#include <exec/memory.h>

extern struct DOSLibrary *DOSBase;
VOID                     *AllocMem();

main(argc, argv)
int argc;
char *argv[];
   {
   BOOL Status;
   LONG Error, IoErr();
   int Anzahl = 0;

   struct FileLock      *TestLock, *Lock(), *ParentDir();
   struct FileInfoBlock *InfoBlock=0l;

   if (argc != 2)
      {
      printf("Genau eine File-Angabe ist nötig!\n");
      exit(FALSE);
      }

   InfoBlock = (struct FileInfoBlock *)
      AllocMem ((ULONG) sizeof (struct FileInfoBlock),
                (ULONG) MEMF_PUBLIC | MEMF_CLEAR);

   if (InfoBlock == 0l)
      {
      printf ("Kein Speicher für InfoBlock !\n");
      exit (FALSE);
      }

   TestLock = Lock(argv[1], SHARED_LOCK);

   if (TestLock == NULL)
      {
      Error = IoErr();
      printf("Kein Zugriff unter diesem Namen möglich!\n");
      printf("Fehler %ld!\n", Error);
      exit(FALSE);
      }

   while (TestLock != NULL)
      {
      Status = Examine(TestLock, InfoBlock);

      printf("%-30s\n", InfoBlock->fib_FileName);
      Anzahl ++;

      TestLock = ParentDir(TestLock);
      }

   printf("\nHauptverzeichnis erreicht mit %d Schritten!\n", Anzahl);

   FreeMem (InfoBlock , (ULONG) sizeof (struct FileInfoBlock));

   UnLock(TestLock);

   }

