mirror of https://github.com/tongzx/nt5src
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.9 KiB
56 lines
1.9 KiB
#include <pch.h>
|
|
#include <windows.h>
|
|
|
|
//***************************************************************************
|
|
//* *
|
|
//* NAME: AddPath *
|
|
//* *
|
|
//* SYNOPSIS: *
|
|
//* *
|
|
//* REQUIRES: *
|
|
//* *
|
|
//* RETURNS: *
|
|
//* *
|
|
//***************************************************************************
|
|
VOID AddPath(LPTSTR szPath, LPCTSTR szName )
|
|
{
|
|
LPTSTR szTmp;
|
|
|
|
// Find end of the string
|
|
szTmp = szPath + lstrlen(szPath);
|
|
|
|
// If no trailing backslash then add one
|
|
if ( szTmp > szPath && *(CharPrev( szPath, szTmp )) != TEXT('\\') )
|
|
*(szTmp++) = TEXT('\\');
|
|
|
|
// Add new name to existing path string
|
|
while ( *szName == TEXT(' ') ) szName++;
|
|
lstrcpy( szTmp, szName );
|
|
}
|
|
|
|
// function will upated the given buffer to parent dir
|
|
//
|
|
BOOL GetParentDir( LPTSTR szFolder )
|
|
{
|
|
LPTSTR lpTmp;
|
|
BOOL bRet = FALSE;
|
|
|
|
// remove the trailing '\\'
|
|
lpTmp = CharPrev( szFolder, (szFolder + lstrlen(szFolder)) );
|
|
lpTmp = CharPrev( szFolder, lpTmp );
|
|
|
|
while ( (lpTmp > szFolder) && (*lpTmp != TEXT('\\')) )
|
|
{
|
|
lpTmp = CharPrev( szFolder, lpTmp );
|
|
}
|
|
|
|
if ( *lpTmp == TEXT('\\') )
|
|
{
|
|
if ( (lpTmp == szFolder) || (*CharPrev(szFolder, lpTmp) == TEXT(':')) )
|
|
lpTmp = CharNext( lpTmp );
|
|
*lpTmp = TEXT('\0');
|
|
bRet = TRUE;
|
|
}
|
|
|
|
return bRet;
|
|
}
|