home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / sys / amiga / programm / 15778 < prev    next >
Encoding:
Text File  |  1992-11-13  |  3.0 KB  |  85 lines

  1. Newsgroups: comp.sys.amiga.programmer
  2. Path: sparky!uunet!munnari.oz.au!metro!cs.uow.edu.au!u9155406
  3. From: u9155406@cs.uow.edu.au (Gerardo Bentancor)
  4. Subject: Help with my C program anyone?
  5. Message-ID: <1992Nov13.065904.1066@cs.uow.edu.au>
  6. Organization: Dept of Computer Science, Wollongong University, Australia
  7. Date: Fri, 13 Nov 1992 06:59:04 GMT
  8. Lines: 75
  9.  
  10. Hello Everyone,
  11.  
  12.     I am having a few problems with a program I am trying to write ( It is
  13. just a little dos utility). I am attempting to use the CurrentDir OS routine
  14. to change directory but it doesn't seem to work.
  15.  
  16. The following is part of the routine that I am using to accomplish this:
  17.  
  18. /* 
  19.  * EnterDirectory: This function will change the current directory to 
  20.  * NewDir[].
  21.  * 
  22.  */
  23.  
  24.  void
  25.  EnterDirectory ( char *NewDir )
  26.  {
  27.  
  28.     /* LockDirectory is a function that basically calls the Lock OS
  29.            routine. It does a bit of error checking etc, but it DOES work !
  30.         */ 
  31.  
  32.      LockDirectory ( AppendDir ( current_dir_name, NewDir ));
  33.  
  34.     /* LockPtr is a global variable that contains the current directory
  35.        lock. It is set with the LockDirectory function */
  36.  
  37.     UnLock ( CurrentDir ( LockPtr ) );
  38.  
  39.  }
  40.  
  41.  
  42. Please Note: the AppendDir function takes a string say, DF0:, and appends
  43. the new directory name to the old.
  44.  
  45. e.g if the current_dir_name is df0: and the NewDir is say "games", then
  46. the function returns a pointer to the string "df0:games", alternatively if
  47. the current_dir_name is "df0:games" and NewDir is "shootemups" then the 
  48. function returns "df0:games/shootemups". (I am positive that this function
  49. works).
  50.  
  51. Before I enter the above function there is a valid lock on the directory
  52. current_dir_name (and I can verify this because the program can examine that
  53. directory with ExNext and Examine).
  54.  
  55. The Includes and Autodocs manual tells me that the CurrentDir function returns
  56. the pointer to the previous lock, and so I attempt to unlock it with UnLock.
  57.  
  58. By now, I assume that the UnLock function has unlocked the previous directory,
  59. and there is now a valid lock on the new directory, and it has become the
  60. current directory. Before my program finishes I make sure that it unlocks the 
  61. new current directory.
  62.  
  63. My problem is this: I get no error messages from any of the OS functions, 
  64. they all seem to work fine, except that the current directory has NOT been
  65. changed. (I have verified this because the program is run from the CLI and
  66. I just printf the GetCurrentDirName string). 
  67.  
  68. The main problem is however, that 
  69. a) the directory name on the shell prompt is not the new directory ( I was
  70. thinking that perhaps this has to be set manually)
  71.  
  72. b) when I do another disk command such as 'dir' after running my program
  73. the machine crashes!
  74.  
  75. I have read and reread the entries on CurrentDir in the autodocs and still
  76. cannot see what I am doing wrong... So can anyone help me? I have no idea
  77. what the problem is.... also should I buy the Libraries reference manual?
  78. Does this book explain how to use the functions?
  79.  
  80.                     Any help greatly appreciated,
  81.                     Gerardo.
  82.  
  83.  
  84. u9155406@cs.uow.edu.au
  85.