home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The C Users' Group Library 1994 August
/
wc-cdrom-cusersgrouplibrary-1994-08.iso
/
vol_200
/
233_01
/
pop.c
< prev
next >
Wrap
Text File
|
1987-06-30
|
1KB
|
27 lines
/* pop.c -- changes to last directory stored in file cdstack.dat (LIFO) */
#include <string.h>
#include <direct.h>
#include <stdio.h>
main()
{
FILE *fi;
char c[67];
int result;
long length, pos;
pos = -(sizeof(c)); /*set to size of 67 chars */
fi = fopen("c:\\cdstack.dat", "r+"); /*open for reading and writing */
/* position filepointer 67 chars from end of file */
result = fseek(fi,pos,SEEK_END);
fscanf(fi,"%s",c); /* read the stored path innto "c" */
chdir(c); /* change to last directory stored with PUSH */
length = filelength(fileno(fi)); /* get size of file in bytes */
/* truncate file by cutting 67 bytes from end */
result = chsize(fileno(fi), (length - (sizeof(c))));
length = filelength(fileno(fi)); /*get new length of cdstack.dat */
fclose (fi);
if (length < 67) /* if cdstack.dat is now less than 67 bytes */
result = remove("c:\\cdstack.dat"); /* erase it*/
}