Source code of Windows XP (NT5)
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

  1. #include <pch.h>
  2. #include <windows.h>
  3. //***************************************************************************
  4. //* *
  5. //* NAME: AddPath *
  6. //* *
  7. //* SYNOPSIS: *
  8. //* *
  9. //* REQUIRES: *
  10. //* *
  11. //* RETURNS: *
  12. //* *
  13. //***************************************************************************
  14. VOID AddPath(LPTSTR szPath, LPCTSTR szName )
  15. {
  16. LPTSTR szTmp;
  17. // Find end of the string
  18. szTmp = szPath + lstrlen(szPath);
  19. // If no trailing backslash then add one
  20. if ( szTmp > szPath && *(CharPrev( szPath, szTmp )) != TEXT('\\') )
  21. *(szTmp++) = TEXT('\\');
  22. // Add new name to existing path string
  23. while ( *szName == TEXT(' ') ) szName++;
  24. lstrcpy( szTmp, szName );
  25. }
  26. // function will upated the given buffer to parent dir
  27. //
  28. BOOL GetParentDir( LPTSTR szFolder )
  29. {
  30. LPTSTR lpTmp;
  31. BOOL bRet = FALSE;
  32. // remove the trailing '\\'
  33. lpTmp = CharPrev( szFolder, (szFolder + lstrlen(szFolder)) );
  34. lpTmp = CharPrev( szFolder, lpTmp );
  35. while ( (lpTmp > szFolder) && (*lpTmp != TEXT('\\')) )
  36. {
  37. lpTmp = CharPrev( szFolder, lpTmp );
  38. }
  39. if ( *lpTmp == TEXT('\\') )
  40. {
  41. if ( (lpTmp == szFolder) || (*CharPrev(szFolder, lpTmp) == TEXT(':')) )
  42. lpTmp = CharNext( lpTmp );
  43. *lpTmp = TEXT('\0');
  44. bRet = TRUE;
  45. }
  46. return bRet;
  47. }