home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!usc!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!rutgers!cbmvax!mks
- From: mks@cbmvax.commodore.com (Michael Sinz)
- Newsgroups: comp.sys.amiga.programmer
- Subject: Re: Changing Directories
- Message-ID: <33240@cbmvax.commodore.com>
- Date: 22 Jul 92 15:53:44 GMT
- References: <1992Jul14.054208.2398@samba.oit.unc.edu>
- Reply-To: mks@cbmvax.commodore.com (Michael Sinz)
- Organization: Commodore, West Chester, PA
- Lines: 49
-
- Frederick.Theilig@bbs.oit.unc.edu (Frederick Theilig) writes:
- >
- > I appoligize if this is a too frequently asked question, but I have
- > a need to change directories. And I need the result to be effected
- > after my program terminates. What I am doing is Norton's NCD. It is
- > working perfectly, except I can't change directories. Please tell me
- > what is wrong with this code:
- >
- >#include <stdio.h>
- >#include <ctype.h>
- >#include <dos/dos.h>
- >#include <dos/dostags.h>
- >#include <dos/dosextens.h>
- >
- >main()
- >{
- > char Path[32] = "DH0:\0";
- > struct FileLock *lock;
- >
- > lock = (struct FileLock *) Lock(Path, SHARED_LOCK);
- > if (lock == NULL) puts("Dogs and cats living together!");
- > else
- > {
- > CurrentDir(lock);
- > UnLock(lock);
- > }
- >}
-
- Well, lets start with the fact that you are UnLock()ing the lock that
- is now your CurrentDir(). This is a very good way to cause crashes.
- You would need to do something like:
-
- oldlock=CurrentDir(lock);
- UnLock(oldlock);
-
- You could actually use: UnLock(CurrentDir(lock));
-
- Anyway, in addition to that, if this is for the shell, the CLI's string
- representation of the CurrentDir() path needs to be updated in the correct
- manner. (And the old one thrown away in the proper manner) Under 2.x,
- this is a bit easier than 1.x, but you still need to do the work.
-
- /----------------------------------------------------------------------\
- | /// Michael Sinz - Senior Amiga Systems Engineer |
- | /// Operating System Development Group |
- | /// BIX: msinz UUNET: mks@cbmvax.commodore.com |
- |\\\/// |
- | \XX/ Eloquence is vehement simplicity |
- \----------------------------------------------------------------------/
-