🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.amiga.tech
Article #5811

Re: CurrentDir

#5811
From: Ralph Babel
Date: Thu, 11 Oct 1990 13:12
36 lines
1534 bytes
In article <1990Oct11.012013.24234@hoss.unl.edu>
252u3130@fergvax.unl.edu (Phil Dietz) writes:

> I'm using Lattice 'C' and I'm changing the current
> directory in it. Well, when the program quits, the SHELL
> path and the current directory are off.  I need to find
> out what the command is to read the name of the current
> directory so I can chdir to it at the end of the program.

Except for built-in shell commands (e.g. CD), no-one is
allowed to change the current directory permanently: The
pr_CurrentDir field of the process structure must be the
same on exit() as it was on main(), i.e. it must not only
refer to the same directory, but it must also be the _same_
lock, not just a copy of it! (As far as I remember, this is
also true for Workbench processes.)

The easiest way to achieve this, would be:

main()
 {
 BPTR orig_cd, cd;

 if(cd = Lock("", ACCESS_READ))
  {
  orig_cd = CurrentDir(cd);

  /* now you can chdir() as often as you like */

  UnLock(CurrentDir(orig_cd));
  }
 }

True, this _should_ be done by the compiler's startup-code.

Ralph
Technical Details
Message-ID: <04411.AA04411@babylon.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!decwrl!shelby!rutgers!cbmvax!cbmehq!babylon!rbabel
References: <1990Oct11.012013.24234@hoss.unl.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!decwrl!shelby!rutgers!cbmvax!cbmehq!babylon!rbabel
From: rbabel@babylon.UUCP (Ralph Babel)
Newsgroups: comp.sys.amiga.tech
Subject: Re: CurrentDir
Message-ID: <04411.AA04411@babylon.UUCP>
Date: 11 Oct 90 13:12:51 GMT
References: <1990Oct11.012013.24234@hoss.unl.edu>
Reply-To: cbmvax.commodore.com!cbmehq!babylon!rbabel (Ralph Babel)
Lines: 36