Fri, 16 Jan 2015 18:13:44 +0100
Integrate suggestion from review to improve consistency with existing code.
1 // DefaultName.cpp
3 #include "StdAfx.h"
5 #include "DefaultName.h"
7 static const wchar_t *kEmptyFileAlias = L"[Content]";
9 UString GetDefaultName2(const UString &fileName,
10 const UString &extension, const UString &addSubExtension)
11 {
12 int extLength = extension.Length();
13 int fileNameLength = fileName.Length();
14 if (fileNameLength > extLength + 1)
15 {
16 int dotPos = fileNameLength - (extLength + 1);
17 if (fileName[dotPos] == '.')
18 if (extension.CompareNoCase(fileName.Mid(dotPos + 1)) == 0)
19 return fileName.Left(dotPos) + addSubExtension;
20 }
21 return kEmptyFileAlias;
22 }