mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-11 20:07:19 -06:00
17.00
This commit is contained in:
@@ -7,58 +7,57 @@
|
||||
namespace NArchive {
|
||||
namespace NItemName {
|
||||
|
||||
static const wchar_t kOSDirDelimiter = WCHAR_PATH_SEPARATOR;
|
||||
static const wchar_t kDirDelimiter = L'/';
|
||||
static const wchar_t kOsPathSepar = WCHAR_PATH_SEPARATOR;
|
||||
static const wchar_t kUnixPathSepar = L'/';
|
||||
|
||||
void ReplaceToOsPathSeparator(wchar_t *s)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
for (;;)
|
||||
void ReplaceSlashes_OsToUnix
|
||||
#if WCHAR_PATH_SEPARATOR != L'/'
|
||||
(UString &name)
|
||||
{
|
||||
wchar_t c = *s;
|
||||
if (c == 0)
|
||||
break;
|
||||
if (c == kDirDelimiter)
|
||||
*s = kOSDirDelimiter;
|
||||
s++;
|
||||
name.Replace(kOsPathSepar, kUnixPathSepar);
|
||||
}
|
||||
#else
|
||||
(UString &) {}
|
||||
#endif
|
||||
|
||||
|
||||
UString GetOsPath(const UString &name)
|
||||
{
|
||||
#if WCHAR_PATH_SEPARATOR != L'/'
|
||||
UString newName = name;
|
||||
newName.Replace(kUnixPathSepar, kOsPathSepar);
|
||||
return newName;
|
||||
#else
|
||||
return name;
|
||||
#endif
|
||||
}
|
||||
|
||||
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)
|
||||
UString GetOsPath_Remove_TailSlash(const UString &name)
|
||||
{
|
||||
if (name.IsEmpty())
|
||||
return UString();
|
||||
UString newName = GetOSName(name);
|
||||
if (newName.Back() == kOSDirDelimiter)
|
||||
UString newName = GetOsPath(name);
|
||||
if (newName.Back() == kOsPathSepar)
|
||||
newName.DeleteBack();
|
||||
return newName;
|
||||
}
|
||||
|
||||
void ConvertToOSName2(UString &name)
|
||||
|
||||
void ReplaceToOsSlashes_Remove_TailSlash(UString &name)
|
||||
{
|
||||
if (!name.IsEmpty())
|
||||
{
|
||||
name.Replace(kDirDelimiter, kOSDirDelimiter);
|
||||
if (name.Back() == kOSDirDelimiter)
|
||||
#if WCHAR_PATH_SEPARATOR != L'/'
|
||||
name.Replace(kUnixPathSepar, kOsPathSepar);
|
||||
#endif
|
||||
|
||||
if (name.Back() == kOsPathSepar)
|
||||
name.DeleteBack();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool HasTailSlash(const AString &name, UINT
|
||||
#if defined(_WIN32) && !defined(UNDER_CE)
|
||||
codePage
|
||||
@@ -67,20 +66,21 @@ bool HasTailSlash(const AString &name, UINT
|
||||
{
|
||||
if (name.IsEmpty())
|
||||
return false;
|
||||
LPCSTR prev =
|
||||
#if defined(_WIN32) && !defined(UNDER_CE)
|
||||
CharPrevExA((WORD)codePage, name, &name[name.Len()], 0);
|
||||
#else
|
||||
(LPCSTR)(name) + (name.Len() - 1);
|
||||
#endif
|
||||
return (*prev == '/');
|
||||
char c =
|
||||
#if defined(_WIN32) && !defined(UNDER_CE)
|
||||
*CharPrevExA((WORD)codePage, name, name.Ptr(name.Len()), 0);
|
||||
#else
|
||||
name.Back();
|
||||
#endif
|
||||
return (c == '/');
|
||||
}
|
||||
|
||||
|
||||
#ifndef _WIN32
|
||||
UString WinNameToOSName(const UString &name)
|
||||
UString WinPathToOsPath(const UString &name)
|
||||
{
|
||||
UString newName = name;
|
||||
newName.Replace(L'\\', kOSDirDelimiter);
|
||||
newName.Replace(L'\\', WCHAR_PATH_SEPARATOR);
|
||||
return newName;
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user