z4none
10/27/2016 - 2:07 AM

boost get file path in exe directory

boost get file path in exe directory

inline string exe_directory(const string & filename)
{
	char directory[MAX_PATH] = { 0 };
	GetModuleFileNameA(NULL, directory, MAX_PATH);
	strrchr(directory, '\\')[0] = '\0';

	return filesystem::absolute(
		filesystem::path(filename),
		filesystem::path(directory)
	).string();
}

// win32 get exe dir
char Path[MAX_PATH] = { 0 };
GetModuleFileNameA(NULL, Path, MAX_PATH);
strrchr(Path, '\\')[1] = 0;
strcat_s(Path, "foo.txt");