/* getcwd.c (rsxnt) -- Copyright (c) 1996-1997 Rainer Schnitker */

#include "rsxnt.h"

/* DOS 0x47 have no path nor initial backslash */

int __getcwd(char *name, char drive)
{
    char path[260];

    if (drive == 0) {
	if (GetCurrentDirectory(260, (LPTSTR)path) == 0)
	    return _rsxnt_get_last_errno();
	if (path[1] == ':')
	    lstrcpy(name, path+3);
	else
	    lstrcpy(name, path);
    }
    else {
	static char letter[] = "C:";
	LPTSTR filepos;

	letter[0] = drive;
	GetFullPathName(letter, 260, path, &filepos);
	lstrcpy(name, path+3);
    }

    if (_rsxnt_get_process_ptr()->bConsoleApp)
	CharToOem(name, name);
    return 0;
}
