Leaked source code of windows server 2003
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.

55 lines
1.9 KiB

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