reactos/lib/sdk/crt/direct/chdrive.c
Cameron Gutman 29fa274d6d - Create another branch for networking fixes
- TSVN choked repeatedly when attempting to merge ~9000 revs into the branch (tried 3 times on 2 different computers)
 - If someone wants to delete aicom-network-fixes, they are welcome to
 - Lesson learned: Letting a branch get thousands of revs out of date is a horrible idea

svn path=/branches/aicom-network-branch/; revision=44353
2009-12-02 03:23:19 +00:00

45 lines
862 B
C

/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/crt/chdrive.c
* PURPOSE: Change the current drive.
* PROGRAMER: WINE
* UPDATE HISTORY:
* 25/11/05: Added license header
*/
#include <precomp.h>
/*
* @implemented
*
* _chdrive (MSVCRT.@)
*
* Change the current drive.
*
* PARAMS
* newdrive [I] Drive number to change to (1 = 'A', 2 = 'B', ...)
*
* RETURNS
* Success: 0. The current drive is set to newdrive.
* Failure: -1. errno indicates the error.
*
* NOTES
* See SetCurrentDirectoryA.
*/
int _chdrive(int newdrive)
{
WCHAR buffer[] = L"A:";
buffer[0] += newdrive - 1;
if (!SetCurrentDirectoryW( buffer ))
{
_dosmaperr(GetLastError());
if (newdrive <= 0)
{
__set_errno(EACCES);
}
return -1;
}
return 0;
}