/* ECP: FILEname=fig13_6.c */ /* 1*/ #include /* 2*/ #include /* 3*/ #include /* 4*/ #include /* For MAXPATHLEN */ /* 5*/ #include /* 6*/ #include /* 7*/ struct stat Slash; /* Stores Info For "/" */ /* 1*/ int /* 2*/ main( void ) /* 3*/ { /* 4*/ if( lstat( "/", &Slash ) < 0 ) /* 5*/ perror( "/" ); /* 6*/ else /* 7*/ Pwd( "." ); /* 8*/ return 0; /* 9*/ } /* 1*/ int /* 2*/ IsMatch( const struct stat *F1, const struct stat *F2 ) /* 3*/ { /* 4*/ return F1->st_ino == F2->st_ino && F1->st_dev == F2->st_dev; /* 5*/ } /* 1*/ void /* 2*/ Pwd( const char *DirName ) /* 3*/ { /* 4*/ struct stat Dot; /* 5*/ if( lstat( DirName, &Dot ) < 0 ) /* 6*/ perror( DirName ); /* 7*/ else /* 8*/ if( IsMatch( &Dot, &Slash ) ) /* 9*/ printf( "/" ); /*10*/ else /*11*/ Pwd1( ".", &Dot ); /*12*/ printf( "\n" ); /*13*/ }