#: 18065 S1/General Interest
08-May-93 20:12:45
Sb: get pwd in "C"
Fm: David Breeding 72330,2051
To: 76510,2203
Some time ago, someone - and to the best of my recollection it was you...
asked about how to get the current working directory for usage by a program.
This was something that I was also interested in, but as I remember, no one
came up with a really elegant way of doing it.
Of course, I suppose that by now, you probably have resolved the problem in
some way, I think that I have stumbled across a pretty acceptable solution.
Last night, in reviewing "OS9 Insights", in the section on pipes, the answer
was there. I'm using OSTerm and don't have an ASCII upload ability, so I'll
just briefly go over the algorithm. I'm using a CoCo, not yet having graduated
to OSK, but most things should be similar.. Here goes..
int savout,pippth,pthsz;
pippth=open("/pipe",READ+WRITE);
savout=dup(1); close(1); dup(pippth);
os9fork("pwd"....); from "INsights", OSK calls it a little differently
from OS9
pthsz = readln(pippth,wdir,sizeof(wdir)) (Wdir is defined as char wdir[?]
wdir[pthsz-1] = '\0'; to get rid of cr sent by pwd
.....cleanup....
As I said, this may be too little too late, but it seems to be a pretty neat
solution.
>> David <<
|