home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / DMAKE38C.ZIP / OS2 / _CHDIR.C next >
C/C++ Source or Header  |  1992-01-23  |  2KB  |  60 lines

  1. /* RCS      -- $Header: /u2/dvadura/src/generic/dmake/src/os2/_chdir.c,v 1.1 1992/01/24 03:29:24 dvadura Exp $
  2. -- SYNOPSIS -- Change directory.
  3. -- 
  4. -- DESCRIPTION
  5. --    Under DOS change the current drive as well as the current directory.
  6. --
  7. -- AUTHOR
  8. --      Dennis Vadura, dvadura@watdragon.uwaterloo.ca
  9. --      CS DEPT, University of Waterloo, Waterloo, Ont., Canada
  10. --
  11. -- COPYRIGHT
  12. --      Copyright (c) 1990 by Dennis Vadura.  All rights reserved.
  13. -- 
  14. --      This program is free software; you can redistribute it and/or
  15. --      modify it under the terms of the GNU General Public License
  16. --      (version 1), as published by the Free Software Foundation, and
  17. --      found in the file 'LICENSE' included with this distribution.
  18. -- 
  19. --      This program is distributed in the hope that it will be useful,
  20. --      but WITHOUT ANY WARRANTY; without even the implied warrant of
  21. --      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  22. --      GNU General Public License for more details.
  23. -- 
  24. --      You should have received a copy of the GNU General Public License
  25. --      along with this program;  if not, write to the Free Software
  26. --      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  27. --
  28. -- LOG
  29. --     $Log: _chdir.c,v $
  30.  * Revision 1.1  1992/01/24  03:29:24  dvadura
  31.  * dmake Version 3.8, Initial revision
  32.  *
  33. */
  34.  
  35. #include <dos.h>
  36. #include <os2.h>
  37. #include "extern.h"
  38.  
  39. PUBLIC int
  40. _chdir(path)
  41. char *path;
  42. {
  43.    int res;
  44.  
  45.    res = chdir(path);
  46.  
  47.    if (res == 0 && path[1] == ':')
  48. #ifdef OS2
  49.       DosSelectDisk((*path & ~0x20) - '@');
  50. #else
  51.       unsigned new_drive;
  52.       unsigned max_drives;
  53.  
  54.       new_drive = (*path & ~0x20) - 'A' + 1;
  55.       _dos_setdrive(new_drive, &max_drives);
  56. #endif
  57.  
  58.    return (res);
  59. }
  60.