summaryrefslogtreecommitdiffstats
path: root/wince/direct.c
blob: bf0d7cd2248e2e9ced3c37cc6c683b53243ba5f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/***************************************************************
  direct.c
***************************************************************/

#include <windows.h>
#include <tchar.h>
#include <direct.h>
#include "wince.h" /* for wce_mbtowc */

/* global for chdir, getcwd */
char _currentdir[MAX_PATH+1];


char *getcwd(char* buffer, int maxlen)
{
	strcpy( buffer, _currentdir );
	return buffer;
}

int _chdir(const char * dirname)
{
	if( MAX_PATH < strlen(dirname) )
		return -1;

	strcpy( _currentdir, dirname );
	return 0;
}

int _rmdir(const char * dir)
{
	wchar_t *wdir;
	BOOL rc;

	/* replace with RemoveDirectory. */
	wdir = wce_mbtowc(dir);
	rc = RemoveDirectoryW(wdir);
	free(wdir);

	return rc==TRUE ? 0 : -1;
}

int _mkdir(const char * dir)
{
	wchar_t* wdir;
	BOOL rc;

	/* replace with CreateDirectory. */
	wdir = wce_mbtowc(dir);
	rc = CreateDirectoryW(wdir, NULL);
	free(wdir);

	return rc==TRUE ? 0 : -1;
}