- Make dp0 give the directory the batch was run from instead of the current directory.

svn path=/trunk/; revision=32074
This commit is contained in:
Peter Ward 2008-02-01 14:15:41 +00:00
parent cf39f6646d
commit 4e8df678d2
3 changed files with 5 additions and 4 deletions

View file

@ -220,6 +220,7 @@ VOID ExitBatch (LPTSTR msg)
BOOL Batch (LPTSTR fullname, LPTSTR firstword, LPTSTR param)
{
HANDLE hFile;
LPTSTR tmp;
SetLastError(0);
hFile = CreateFile (fullname, GENERIC_READ, FILE_SHARE_WRITE | FILE_SHARE_READ | FILE_SHARE_DELETE, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL |
@ -269,6 +270,8 @@ BOOL Batch (LPTSTR fullname, LPTSTR firstword, LPTSTR param)
}
bc->hBatchFile = hFile;
tmp = _tcsrchr(fullname, '\\');
_tcsncpy(bc->BatchFilePath, fullname, ((_tcslen(fullname) - _tcslen(tmp)) + 1));
SetFilePointer (bc->hBatchFile, 0, NULL, FILE_BEGIN);
bc->bEcho = bEcho; /* Preserve echo across batch calls */
bc->shiftlevel = 0;

View file

@ -12,6 +12,7 @@ typedef struct tagBATCHCONTEXT
struct tagBATCHCONTEXT *prev;
LPWIN32_FIND_DATA ffind;
HANDLE hBatchFile;
TCHAR BatchFilePath[MAX_PATH];
LPTSTR forproto;
LPTSTR params;
LPTSTR raw_params; /* Holds the raw params given by the input */

View file

@ -1300,11 +1300,8 @@ GetParsedEnvVar ( LPCTSTR varName, UINT* varNameLen, BOOL ModeSetA )
if ( varNameLen )
*varNameLen = 4;
varName += 2;
if ( !GrowIfNecessary ( MAX_PATH, &ret, &retlen ) )
return NULL;
GetCurrentDirectory(MAX_PATH, ret);
return bc->BatchFilePath;
}
return ret;
case _T('0'):
case _T('1'):
case _T('2'):