FileName.cpp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // Windows/FileName.cpp
  2. #include "StdAfx.h"
  3. #include "Windows/FileName.h"
  4. #include "Common/Wildcard.h"
  5. namespace NWindows {
  6. namespace NFile {
  7. namespace NName {
  8. void NormalizeDirPathPrefix(CSysString &dirPath)
  9. {
  10. if (dirPath.IsEmpty())
  11. return;
  12. if (dirPath.ReverseFind(kDirDelimiter) != dirPath.Length() - 1)
  13. dirPath += kDirDelimiter;
  14. }
  15. #ifndef _UNICODE
  16. void NormalizeDirPathPrefix(UString &dirPath)
  17. {
  18. if (dirPath.IsEmpty())
  19. return;
  20. if (dirPath.ReverseFind(wchar_t(kDirDelimiter)) != dirPath.Length() - 1)
  21. dirPath += wchar_t(kDirDelimiter);
  22. }
  23. #endif
  24. #ifdef _WIN32
  25. const wchar_t kExtensionDelimiter = L'.';
  26. void SplitNameToPureNameAndExtension(const UString &fullName,
  27. UString &pureName, UString &extensionDelimiter, UString &extension)
  28. {
  29. int index = fullName.ReverseFind(kExtensionDelimiter);
  30. if (index < 0)
  31. {
  32. pureName = fullName;
  33. extensionDelimiter.Empty();
  34. extension.Empty();
  35. }
  36. else
  37. {
  38. pureName = fullName.Left(index);
  39. extensionDelimiter = kExtensionDelimiter;
  40. extension = fullName.Mid(index + 1);
  41. }
  42. }
  43. #endif
  44. }}}