1
mirror of https://github.com/rapid7/metasploit-payloads synced 2025-04-30 13:07:22 +02:00
HD Moore 088a92fa13 Use _WIN32 instead of __WIN32__ to be consistent
git-svn-id: file:///home/svn/framework3/trunk@7290 4d416f70-5f16-0410-b530-b9f4589650da
2009-10-27 01:13:35 +00:00

41 lines
856 B
C

#include "precomp.h"
/*
* Returns an expanded file path that must be freed
*/
LPSTR fs_expand_path(LPCSTR regular)
{
#ifdef _WIN32
DWORD expandedFilePathSize = 32768;
LPSTR expandedFilePath = NULL;
do
{
// Expand the file path
if (!(expandedFilePath = (LPSTR)malloc(expandedFilePathSize)))
break;
// Expand the file path being accessed
if (!ExpandEnvironmentStrings(regular, expandedFilePath,
expandedFilePathSize - 1))
{
free(expandedFilePath);
expandedFilePath = 0;
break;
}
expandedFilePath[expandedFilePathSize - 1] = 0;
} while (0);
return expandedFilePath;
#else /* Hack to make it work with existing code under *nix */
char *expandedFilePath;
expandedFilePath = malloc(strlen(regular)+1);
strcpy(expandedFilePath, regular);
return expandedFilePath;
#endif
}