home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / sys / amiga / programm / 11484 < prev    next >
Encoding:
Internet Message Format  |  1992-07-22  |  2.2 KB

  1. Path: sparky!uunet!usc!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!rutgers!cbmvax!mks
  2. From: mks@cbmvax.commodore.com (Michael Sinz)
  3. Newsgroups: comp.sys.amiga.programmer
  4. Subject: Re: Changing Directories
  5. Message-ID: <33240@cbmvax.commodore.com>
  6. Date: 22 Jul 92 15:53:44 GMT
  7. References: <1992Jul14.054208.2398@samba.oit.unc.edu>
  8. Reply-To: mks@cbmvax.commodore.com (Michael Sinz)
  9. Organization: Commodore, West Chester, PA
  10. Lines: 49
  11.  
  12. Frederick.Theilig@bbs.oit.unc.edu (Frederick Theilig) writes:
  13. >
  14. >     I appoligize if this is a too frequently asked question, but I have
  15. > a need to change directories.  And I need the result to be effected
  16. > after my program terminates.  What I am doing is Norton's NCD.  It is
  17. > working perfectly, except I can't change directories.  Please tell me
  18. > what is wrong with this code:
  19. >
  20. >#include <stdio.h>
  21. >#include <ctype.h>
  22. >#include <dos/dos.h>
  23. >#include <dos/dostags.h>
  24. >#include <dos/dosextens.h>
  25. >
  26. >main()
  27. >{
  28. >   char Path[32] = "DH0:\0";
  29. >   struct FileLock *lock;
  30. >
  31. >   lock = (struct FileLock *) Lock(Path, SHARED_LOCK);
  32. >   if (lock == NULL)  puts("Dogs and cats living together!");
  33. >   else
  34. >   {
  35. >      CurrentDir(lock);
  36. >      UnLock(lock);
  37. >   }
  38. >}
  39.  
  40. Well, lets start with the fact that you are UnLock()ing the lock that
  41. is now your CurrentDir().  This is a very good way to cause crashes.
  42. You would need to do something like:
  43.  
  44.     oldlock=CurrentDir(lock);
  45.     UnLock(oldlock);
  46.  
  47. You could actually use:  UnLock(CurrentDir(lock));
  48.  
  49. Anyway, in addition to that, if this is for the shell, the CLI's string
  50. representation of the CurrentDir() path needs to be updated in the correct
  51. manner.  (And the old one thrown away in the proper manner)  Under 2.x,
  52. this is a bit easier than 1.x, but you still need to do the work.
  53.  
  54. /----------------------------------------------------------------------\
  55. |      /// Michael Sinz  -  Senior Amiga Systems Engineer              |
  56. |     ///                   Operating System Development Group         |
  57. |    ///   BIX:  msinz      UUNET:  mks@cbmvax.commodore.com           |
  58. |\\\///                                                                |
  59. | \XX/                      Eloquence is vehement simplicity           |
  60. \----------------------------------------------------------------------/
  61.