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