mirror of
https://github.com/reactos/reactos.git
synced 2024-11-20 06:15:26 +00:00
45 lines
872 B
C
45 lines
872 B
C
/*
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
* PROJECT: ReactOS system libraries
|
|
* FILE: lib/sdk/crt/direct/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;
|
|
}
|