michael@0: // Archive/Common/ItemNameUtils.cpp michael@0: michael@0: #include "StdAfx.h" michael@0: michael@0: #include "ItemNameUtils.h" michael@0: michael@0: namespace NArchive { michael@0: namespace NItemName { michael@0: michael@0: static const wchar_t kOSDirDelimiter = WCHAR_PATH_SEPARATOR; michael@0: static const wchar_t kDirDelimiter = L'/'; michael@0: michael@0: UString MakeLegalName(const UString &name) michael@0: { michael@0: UString zipName = name; michael@0: zipName.Replace(kOSDirDelimiter, kDirDelimiter); michael@0: return zipName; michael@0: } michael@0: michael@0: UString GetOSName(const UString &name) michael@0: { michael@0: UString newName = name; michael@0: newName.Replace(kDirDelimiter, kOSDirDelimiter); michael@0: return newName; michael@0: } michael@0: michael@0: UString GetOSName2(const UString &name) michael@0: { michael@0: if (name.IsEmpty()) michael@0: return UString(); michael@0: UString newName = GetOSName(name); michael@0: if (newName[newName.Length() - 1] == kOSDirDelimiter) michael@0: newName.Delete(newName.Length() - 1); michael@0: return newName; michael@0: } michael@0: michael@0: bool HasTailSlash(const AString &name, UINT codePage) michael@0: { michael@0: if (name.IsEmpty()) michael@0: return false; michael@0: LPCSTR prev = michael@0: #ifdef _WIN32 michael@0: CharPrevExA(codePage, name, &name[name.Length()], 0); michael@0: #else michael@0: (LPCSTR)(name) + (name.Length() - 1); michael@0: #endif michael@0: return (*prev == '/'); michael@0: } michael@0: michael@0: #ifndef _WIN32 michael@0: UString WinNameToOSName(const UString &name) michael@0: { michael@0: UString newName = name; michael@0: newName.Replace(L'\\', kOSDirDelimiter); michael@0: return newName; michael@0: } michael@0: #endif michael@0: michael@0: }}