Welcome to mirror list, hosted at ThFree Co, Russian Federation.

os_getcwd.c « host « src - github.com/windirstat/premake-4.x.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: de8bfbde285bbc385864d62429c87b7388d48641 (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
/**
 * \file   os_getcwd.c
 * \brief  Retrieve the current working directory.
 * \author Copyright (c) 2002-2008 Jason Perkins and the Premake project
 */

#include "premake.h"

int os_getcwd(lua_State* L)
{
	char buffer[0x4000];
	if (do_getcwd(buffer, 0x4000)) {
		lua_pushstring(L, buffer);
		return 1;
	}
	else {
		return 0;
	}
}


int do_getcwd(char* buffer, size_t size)
{
	int result;

#if PLATFORM_WINDOWS
	result = (GetCurrentDirectory(size, buffer) != 0);
	if (result) {
		do_translate(buffer, '/');
	}
#else
	result = (getcwd(buffer, size) != 0);
#endif

	return result;
}