blob: 46f2cee3e110a28aca5d4c14ca5eeacb9c6aafc5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
// Archive/Common/ItemNameUtils.cpp
#include "StdAfx.h"
#include "ItemNameUtils.h"
namespace NArchive {
namespace NItemName {
static const wchar_t kOSDirDelimiter = WCHAR_PATH_SEPARATOR;
static const wchar_t kDirDelimiter = L'/';
UString MakeLegalName(const UString &name)
{
UString zipName = name;
zipName.Replace(kOSDirDelimiter, kDirDelimiter);
return zipName;
}
UString GetOSName(const UString &name)
{
UString newName = name;
newName.Replace(kDirDelimiter, kOSDirDelimiter);
return newName;
}
UString GetOSName2(const UString &name)
{
if (name.IsEmpty())
return UString();
UString newName = GetOSName(name);
if (newName[newName.Length() - 1] == kOSDirDelimiter)
newName.Delete(newName.Length() - 1);
return newName;
}
bool HasTailSlash(const AString &name, UINT codePage)
{
if (name.IsEmpty())
return false;
LPCSTR prev =
#ifdef _WIN32
CharPrevExA(codePage, name, &name[name.Length()], 0);
#else
(LPCSTR)(name) + (name.Length() - 1);
#endif
return (*prev == '/');
}
#ifndef _WIN32
UString WinNameToOSName(const UString &name)
{
UString newName = name;
newName.Replace(L'\\', kOSDirDelimiter);
return newName;
}
#endif
}}
|