Upload 2.0.2
[physicsfs] / lzma / CPP / Windows / FileName.cpp
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
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
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 #ifdef _WIN32
31
32 const wchar_t kExtensionDelimiter = L'.';
33
34 void SplitNameToPureNameAndExtension(const UString &fullName, 
35     UString &pureName, UString &extensionDelimiter, UString &extension)
36 {
37   int index = fullName.ReverseFind(kExtensionDelimiter);
38   if (index < 0)
39   {
40     pureName = fullName;
41     extensionDelimiter.Empty();
42     extension.Empty();
43   }
44   else
45   {
46     pureName = fullName.Left(index);
47     extensionDelimiter = kExtensionDelimiter;
48     extension = fullName.Mid(index + 1);
49   }
50 }
51
52 #endif
53
54 }}}