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: 06c91a2537fe574699b9e670627bdc34207f16b5 (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
/**
 * \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];
	char* ch;
	int result;

#if PLATFORM_WINDOWS
	result = (GetCurrentDirectory(0x4000, buffer) != 0);
#else
	result = (getcwd(buffer, 0x4000) != 0);
#endif

	if (!result)
		return 0;

	/* convert to platform-neutral directory separators */
	for (ch = buffer; *ch != '\0'; ++ch)
	{
		if (*ch == '\\') *ch = '/';
	}

	lua_pushstring(L, buffer);
	return 1;
}