other-licenses/7zstub/src/7zip/Archive/Common/ItemNameUtils.cpp

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial