home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.amiga.programmer
- Path: sparky!uunet!munnari.oz.au!metro!cs.uow.edu.au!u9155406
- From: u9155406@cs.uow.edu.au (Gerardo Bentancor)
- Subject: Help with my C program anyone?
- Message-ID: <1992Nov13.065904.1066@cs.uow.edu.au>
- Organization: Dept of Computer Science, Wollongong University, Australia
- Date: Fri, 13 Nov 1992 06:59:04 GMT
- Lines: 75
-
- Hello Everyone,
-
- I am having a few problems with a program I am trying to write ( It is
- just a little dos utility). I am attempting to use the CurrentDir OS routine
- to change directory but it doesn't seem to work.
-
- The following is part of the routine that I am using to accomplish this:
-
- /*
- * EnterDirectory: This function will change the current directory to
- * NewDir[].
- *
- */
-
- void
- EnterDirectory ( char *NewDir )
- {
-
- /* LockDirectory is a function that basically calls the Lock OS
- routine. It does a bit of error checking etc, but it DOES work !
- */
-
- LockDirectory ( AppendDir ( current_dir_name, NewDir ));
-
- /* LockPtr is a global variable that contains the current directory
- lock. It is set with the LockDirectory function */
-
- UnLock ( CurrentDir ( LockPtr ) );
-
- }
-
-
- Please Note: the AppendDir function takes a string say, DF0:, and appends
- the new directory name to the old.
-
- e.g if the current_dir_name is df0: and the NewDir is say "games", then
- the function returns a pointer to the string "df0:games", alternatively if
- the current_dir_name is "df0:games" and NewDir is "shootemups" then the
- function returns "df0:games/shootemups". (I am positive that this function
- works).
-
- Before I enter the above function there is a valid lock on the directory
- current_dir_name (and I can verify this because the program can examine that
- directory with ExNext and Examine).
-
- The Includes and Autodocs manual tells me that the CurrentDir function returns
- the pointer to the previous lock, and so I attempt to unlock it with UnLock.
-
- By now, I assume that the UnLock function has unlocked the previous directory,
- and there is now a valid lock on the new directory, and it has become the
- current directory. Before my program finishes I make sure that it unlocks the
- new current directory.
-
- My problem is this: I get no error messages from any of the OS functions,
- they all seem to work fine, except that the current directory has NOT been
- changed. (I have verified this because the program is run from the CLI and
- I just printf the GetCurrentDirName string).
-
- The main problem is however, that
- a) the directory name on the shell prompt is not the new directory ( I was
- thinking that perhaps this has to be set manually)
-
- b) when I do another disk command such as 'dir' after running my program
- the machine crashes!
-
- I have read and reread the entries on CurrentDir in the autodocs and still
- cannot see what I am doing wrong... So can anyone help me? I have no idea
- what the problem is.... also should I buy the Libraries reference manual?
- Does this book explain how to use the functions?
-
- Any help greatly appreciated,
- Gerardo.
-
-
- u9155406@cs.uow.edu.au
-