From: Ramon F Herrera on 27 Dec 2009 00:10 The closest I have is this: getenv("PWD"); But that only tells the value of such environment variable at the time the program was started. I need to know (for debugging purposes) the current working directory, dynamically. TIA, -Ramon
From: Ramon F Herrera on 27 Dec 2009 00:12 On Dec 27, 12:10 am, Ramon F Herrera <ra...(a)conexus.net> wrote: > The closest I have is this: > > getenv("PWD"); > > But that only tells the value of such environment variable at the time > the program was started. > > I need to know (for debugging purposes) the current working directory, > dynamically. > > TIA, > > -Ramon Bonus question: Are the commands 'pushd' and 'popd' implemented programmatically?
From: Gordon Burditt on 27 Dec 2009 01:06 >The closest I have is this: > >getenv("PWD"); That can lie if the invoker of your program is malicious. The invoker of your program might not be a shell, and it might not know to update $PWD or even provide it. >But that only tells the value of such environment variable at the time >the program was started. Look at getcwd() (POSIX). This can fail due to permissions problems (having x but not r permission on directories, for example.) >I need to know (for debugging purposes) the current working directory, >dynamically.
From: Ramon F Herrera on 27 Dec 2009 02:17 On Dec 27, 1:06 am, gordonb.pr...(a)burditt.org (Gordon Burditt) wrote: > >The closest I have is this: > > >getenv("PWD"); > > That can lie if the invoker of your program is malicious. > The invoker of your program might not be a shell, and it might > not know to update $PWD or even provide it. > > >But that only tells the value of such environment variable at the time > >the program was started. > > Look at getcwd() (POSIX). My program works great now, thanks Gordon! -Ramon
From: Ramon F Herrera on 27 Dec 2009 10:04 On Dec 27, 12:12 am, Ramon F Herrera <ra...(a)conexus.net> wrote: > On Dec 27, 12:10 am, Ramon F Herrera <ra...(a)conexus.net> wrote: > > > The closest I have is this: > > > getenv("PWD"); > > > But that only tells the value of such environment variable at the time > > the program was started. > > > I need to know (for debugging purposes) the current working directory, > > dynamically. > > > TIA, > > > -Ramon > > Bonus question: > > Are the commands 'pushd' and 'popd' implemented programmatically? I guess a good way to achieve the above is through a combination of `getcwd()' and a std::vector which behaves like a stack. That should be simple enough, at least for those of the C++ persuasion. Thx, -Ramon
|
Pages: 1 Prev: Did the prophet copy the Holy Quran from the H Next: standard close behavior |