/************************************************************************ ** ** FILE : changepath.c ** ** ZWECK : - enthaelt Funktion ChangePath der DirFunktionen ** Aendert den Pfadeintrag in der Datendtruktur DirInh ** Der neue Pfadeintrag wird durch den Index bestimmt, ** der entweder auf EIN Verzeichnis des bisherigen Pfades ** verweist oder der auf ein Unterverzeichnis verweist. ** Bei diesem Vorgang wird nicht auf Existenz ueberprueft. ** ** AUTOR : Michael C. Ancutici ** Universitaet Stuttgart, Fakultaet Informatik ** ** DATUM : 14.03.93 ** *************************************************************************/ #include "dir.H" #include "misc.h" /************************************************************************* ** ** FUNKTION: ChangePath ** Zweck: s.o. ** INPUT: DirInh ** GotoPath aus [0 .. nSubDir-1] als Index auf das ** Zielverzeichnis ** OUTPUT: TRUE falls Pfad erfolgreich geaendert ** *************************************************************************/ BOOLEAN ChangePath( DirInh, GotoPath) register DIRECTORY *DirInh; int GotoPath; { char *g; register char *p; int i; STRING temp="/"; if (GotoPath >= DirInh->nPfad) { /* runter ins Unterverzeichnis */ strcat( DirInh->Pfad, (DirInh->Name[ GotoPath])+strlen(FillSpace)); SetPath( DirInh, DirInh->Pfad); } else { /* hoch */ if (GotoPath==0) { /* nach ROOT */ DirInh->nPfad = 0; DirInh->nextBuffer = DirInh->Buffer; strcpy( FillSpace, ""); strcpy( DirInh->Pfad, "/"); return OK; } else if (GotoPath == DirInh->nPfad-1) return NOT_OK; /* aktueller Pfad */ else { DirInh->nPfad = GotoPath+1; DirInh->nextBuffer = DirInh->Name[ DirInh->nPfad]; for (i=0, strcpy(FillSpace, ""); i<=GotoPath; i++, strcat(FillSpace, FILLPATT)); for (p=(DirInh->Pfad)+1; GotoPath>0; p++) if (*p==SLASH) GotoPath--; *(p++)=EOL; return OK; } }; }