home *** CD-ROM | disk | FTP | other *** search
/ Programming Win32 Under the API / ProgrammingWin32UnderTheApiPatVillani.iso / Chapter9 / cmd32 / CD.C next >
Encoding:
C/C++ Source or Header  |  2000-04-29  |  1.7 KB  |  72 lines

  1.  
  2. /****************************************************************/
  3. /*                                */
  4. /*                    cd.c                */
  5. /*                                */
  6. /*            Copyright (c) 1995            */
  7. /*            Pasquale J. Villani            */
  8. /*            All Rights Reserved            */
  9. /*                                */
  10. /* This file is part of CMD32.                    */
  11. /*                                */
  12. /* CMD32 is free software; you can redistribute it and/or    */
  13. /* modify it under the terms of the GNU General Public License    */
  14. /* as published by the Free Software Foundation; either version    */
  15. /* 2, or (at your option) any later version.            */
  16. /*                                */
  17. /* CMD32 is distributed in the hope that it will be useful, but    */
  18. /* WITHOUT ANY WARRANTY; without even the implied warranty of    */
  19. /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See    */
  20. /* the GNU General Public License for more details.        */
  21. /*                                */
  22. /* You should have received a copy of the GNU General Public    */
  23. /* License along with CMD32; see the file COPYING.  If not,    */
  24. /* write to the Free Software Foundation, 675 Mass Ave,        */
  25. /* Cambridge, MA 02139, USA.                    */
  26. /****************************************************************/
  27.  
  28.  
  29. /* $Logfile$ */
  30.  
  31. /* $Log$
  32.  * $EndLog$ */
  33.  
  34.  
  35. #include <windows.h>
  36. #include "globals.h"
  37. #include "proto.h"
  38.  
  39. #ifdef VERSION_STRINGS
  40. static BYTE *RcsId = "$Header$";
  41. #endif
  42.  
  43. BOOL cd(INT argc, BYTE *argv[])
  44. {
  45.     /* Do command line sanity checks                */
  46.     if(argc > 2)
  47.     {
  48.         error_message(INV_NUM_PARAMS);
  49.         return FALSE;
  50.     }
  51.  
  52.     if(argc == 1)
  53.     {
  54.         BYTE szCurrentDir[MAX_CMDLINE];
  55.  
  56.         GetCurrentDirectory(MAX_CMDLINE, &szCurrentDir);
  57.         printf("%s\n\n", szCurrentDir);
  58.         return TRUE;
  59.     }
  60.     else if(argc == 2)
  61.     {
  62.         SetCurrentDirectory(argv[1]);
  63.         return TRUE;
  64.     }
  65.     else
  66.     {
  67.         return FALSE;
  68.     }
  69. }
  70.  
  71.  
  72.