本文整理汇总了C++中UString::Back方法的典型用法代码示例。如果您正苦于以下问题:C++ UString::Back方法的具体用法?C++ UString::Back怎么用?C++ UString::Back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UString
的用法示例。
在下文中一共展示了UString::Back方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetMyDocsPath
UString GetMyDocsPath()
{
UString us;
WCHAR s[MAX_PATH + 1];
SHGetSpecialFolderPathWp getW = (SHGetSpecialFolderPathWp)
#ifdef UNDER_CE
My_GetProcAddress(GetModuleHandle(TEXT("coredll.dll")), "SHGetSpecialFolderPath");
#else
My_GetProcAddress(GetModuleHandle(TEXT("shell32.dll")), "SHGetSpecialFolderPathW");
#endif
if (getW && getW(0, s, CSIDL_PERSONAL, FALSE))
us = s;
#ifndef _UNICODE
else
{
SHGetSpecialFolderPathAp getA = (SHGetSpecialFolderPathAp)
::GetProcAddress(::GetModuleHandleA("shell32.dll"), "SHGetSpecialFolderPathA");
CHAR s2[MAX_PATH + 1];
if (getA && getA(0, s2, CSIDL_PERSONAL, FALSE))
us = GetUnicodeString(s2);
}
#endif
if (us.Length() > 0 && us.Back() != WCHAR_PATH_SEPARATOR)
us += WCHAR_PATH_SEPARATOR;
return us;
}
示例2: NormalizeDirPathPrefix
void NormalizeDirPathPrefix(UString &dirPath)
{
if (dirPath.IsEmpty())
return;
if (dirPath.Back() != WCHAR_PATH_SEPARATOR)
dirPath += WCHAR_PATH_SEPARATOR;
}
示例3: GetOSName2
UString GetOSName2(const UString &name)
{
if (name.IsEmpty())
return UString();
UString newName = GetOSName(name);
if (newName.Back() == kOSDirDelimiter)
newName.DeleteBack();
return newName;
}
示例4: ConvertToOSName2
void ConvertToOSName2(UString &name)
{
if (!name.IsEmpty())
{
name.Replace(kDirDelimiter, kOSDirDelimiter);
if (name.Back() == kOSDirDelimiter)
name.DeleteBack();
}
}
示例5: AddName
static void AddName(UStringVector &strings, UString &s)
{
s.Trim();
if (s.Len() >= 2 && s[0] == kQuoteChar && s.Back() == kQuoteChar)
{
s.DeleteBack();
s.Delete(0);
}
if (!s.IsEmpty())
strings.Add(s);
}
示例6: GetParentPath
bool CBrowseDialog::GetParentPath(const UString &path, UString &parentPrefix, UString &name)
{
parentPrefix.Empty();
name.Empty();
if (path.IsEmpty())
return false;
if (_topDirPrefix == path)
return false;
UString s = path;
if (s.Back() == WCHAR_PATH_SEPARATOR)
s.DeleteBack();
if (s.IsEmpty())
return false;
if (s.Back() == WCHAR_PATH_SEPARATOR)
return false;
int pos = s.ReverseFind_PathSepar();
parentPrefix.SetFrom(s, pos + 1);
name = s.Ptr(pos + 1);
return true;
}
示例7: CopyTo
STDMETHODIMP CFSFolder::CopyTo(const UInt32 *indices, UInt32 numItems,
const wchar_t *path, IFolderOperationsExtractCallback *callback)
{
if (numItems == 0)
return S_OK;
UInt64 numFolders, numFiles, totalSize;
GetItemsFullSize(indices, numItems, numFolders, numFiles, totalSize, callback);
RINOK(callback->SetTotal(totalSize));
RINOK(callback->SetNumFiles(numFiles));
UString destPath = path;
if (destPath.IsEmpty())
return E_INVALIDARG;
bool directName = (destPath.Back() != WCHAR_PATH_SEPARATOR);
if (directName)
{
if (numItems > 1)
return E_INVALIDARG;
}
/*
// doesn't work in network
else
if (!NDirectory::CreateComplexDirectory(destPath)))
{
DWORD lastError = ::GetLastError();
UString message = UString(L"can not create folder ") +
destPath;
RINOK(callback->ShowMessage(message));
return E_ABORT;
}
*/
UInt64 completedSize = 0;
RINOK(callback->SetCompleted(&completedSize));
for (UInt32 i = 0; i < numItems; i++)
{
const CDirItem &fi = *_refs[indices[i]];
FString destPath2 = us2fs(destPath);
if (!directName)
destPath2 += fi.Name;
FString srcPath = _path + GetPrefix(fi) + fi.Name;
if (fi.IsDir())
{
RINOK(CopyFolder(srcPath, destPath2, callback, completedSize));
}
else
{
RINOK(MyCopyFile(srcPath, fi, destPath2, callback, completedSize));
}
}
return S_OK;
}
示例8: ParseName
bool ParseName(const UString &name)
{
if (name.Len() < 2)
return false;
if (name.Back() != L'1' || name[name.Len() - 2] != L'0')
return false;
unsigned pos = name.Len() - 2;
for (; pos > 0 && name[pos - 1] == '0'; pos--);
UnchangedPart.SetFrom(name, pos);
ChangedPart = name.Ptr(pos);
return true;
}
示例9: SetProperties
HRESULT SetProperties(IUnknown *unknown, const CObjectVector<CProperty> &properties)
{
if (properties.IsEmpty())
return S_OK;
CMyComPtr<ISetProperties> setProperties;
unknown->QueryInterface(IID_ISetProperties, (void **)&setProperties);
if (!setProperties)
return S_OK;
UStringVector realNames;
CPropVariant *values = new CPropVariant[properties.Size()];
try
{
int i;
for(i = 0; i < properties.Size(); i++)
{
const CProperty &property = properties[i];
NCOM::CPropVariant propVariant;
UString name = property.Name;
if (property.Value.IsEmpty())
{
if (!name.IsEmpty())
{
wchar_t c = name.Back();
if (c == L'-')
propVariant = false;
else if (c == L'+')
propVariant = true;
if (propVariant.vt != VT_EMPTY)
name.DeleteBack();
}
}
else
ParseNumberString(property.Value, propVariant);
realNames.Add(name);
values[i] = propVariant;
}
CRecordVector<const wchar_t *> names;
for(i = 0; i < realNames.Size(); i++)
names.Add((const wchar_t *)realNames[i]);
RINOK(setProperties->SetProperties(&names.Front(), values, names.Size()));
}
catch(...)
{
delete []values;
throw;
}
delete []values;
return S_OK;
}
示例10: LoadFullPathAndShow
void CPanel::LoadFullPathAndShow()
{
LoadFullPath();
_appState->FolderHistory.AddString(_currentFolderPrefix);
_headerComboBox.SetText(_currentFolderPrefix);
#ifndef UNDER_CE
COMBOBOXEXITEM item;
item.mask = 0;
UString path = _currentFolderPrefix;
if (path.Len() >
#ifdef _WIN32
3
#else
1
#endif
&& path.Back() == WCHAR_PATH_SEPARATOR)
path.DeleteBack();
DWORD attrib = FILE_ATTRIBUTE_DIRECTORY;
// GetRealIconIndex is slow for direct DVD/UDF path. So we use dummy path
if (path.IsPrefixedBy(L"\\\\.\\"))
path = L"_TestFolder_";
else
{
CFileInfo fi;
if (fi.Find(us2fs(path)))
attrib = fi.Attrib;
}
item.iImage = GetRealIconIndex(us2fs(path), attrib);
if (item.iImage >= 0)
{
item.iSelectedImage = item.iImage;
item.mask |= (CBEIF_IMAGE | CBEIF_SELECTEDIMAGE);
}
item.iItem = -1;
_headerComboBox.SetItem(&item);
#endif
RefreshTitle();
}
示例11: OpenAltStreams
void CPanel::OpenAltStreams()
{
CRecordVector<UInt32> indices;
GetOperatedItemIndices(indices);
Int32 realIndex = -1;
if (indices.Size() > 1)
return;
if (indices.Size() == 1)
realIndex = indices[0];
if (_folderAltStreams)
{
CMyComPtr<IFolderFolder> newFolder;
_folderAltStreams->BindToAltStreams(realIndex, &newFolder);
if (newFolder)
{
CDisableTimerProcessing disableTimerProcessing(*this);
CDisableNotify disableNotify(*this);
SetNewFolder(newFolder);
RefreshListCtrl(UString(), -1, true, UStringVector());
return;
}
return;
}
#if defined(_WIN32) && !defined(UNDER_CE)
UString path;
if (realIndex >= 0)
path = GetItemFullPath(realIndex);
else
{
path = GetFsPath();
if (!NName::IsDriveRootPath_SuperAllowed(us2fs(path)))
if (!path.IsEmpty() && IS_PATH_SEPAR(path.Back()))
path.DeleteBack();
}
path += L':';
BindToPathAndRefresh(path);
#endif
}
示例12: ParseName
void CHandler::ParseName(Byte replaceByte, IArchiveOpenCallback *callback)
{
if (!callback)
return;
CMyComPtr<IArchiveOpenVolumeCallback> volumeCallback;
callback->QueryInterface(IID_IArchiveOpenVolumeCallback, (void **)&volumeCallback);
if (!volumeCallback)
return;
NWindows::NCOM::CPropVariant prop;
if (volumeCallback->GetProperty(kpidName, &prop) != S_OK || prop.vt != VT_BSTR)
return;
UString s = prop.bstrVal;
if (s.IsEmpty() ||
s.Back() != L'_')
return;
s.DeleteBack();
_name = s;
if (replaceByte == 0)
{
if (s.Len() < 3 || s[s.Len() - 3] != '.')
return;
for (unsigned i = 0; i < ARRAY_SIZE(g_Exts); i++)
{
const char *ext = g_Exts[i];
if (s[s.Len() - 2] == (Byte)ext[0] &&
s[s.Len() - 1] == (Byte)ext[1])
{
replaceByte = ext[2];
break;
}
}
}
if (replaceByte >= 0x20 && replaceByte < 0x80)
_name += (wchar_t)replaceByte;
}
示例13: GetFullPath
bool GetFullPath(CFSTR dirPrefix, CFSTR s, FString &res)
{
res = s;
#ifdef UNDER_CE
if (s[0] != CHAR_PATH_SEPARATOR)
{
if (!dirPrefix)
return false;
res = dirPrefix;
res += s;
}
#else
unsigned prefixSize = GetRootPrefixSize(s);
if (prefixSize != 0)
{
if (!AreThereDotsFolders(s + prefixSize))
return true;
UString rem = fs2us(s + prefixSize);
if (!ResolveDotsFolders(rem))
return true; // maybe false;
res.DeleteFrom(prefixSize);
res += us2fs(rem);
return true;
}
/*
FChar c = s[0];
if (c == 0)
return true;
if (c == '.' && (s[1] == 0 || (s[1] == '.' && s[2] == 0)))
return true;
if (c == CHAR_PATH_SEPARATOR && s[1] == CHAR_PATH_SEPARATOR)
return true;
if (IsDrivePath(s))
return true;
*/
UString curDir;
if (dirPrefix)
curDir = fs2us(dirPrefix);
else
{
if (!GetCurDir(curDir))
return false;
}
if (!curDir.IsEmpty() && curDir.Back() != WCHAR_PATH_SEPARATOR)
curDir += WCHAR_PATH_SEPARATOR;
unsigned fixedSize = 0;
if (IsDrivePath(curDir))
fixedSize = kDrivePrefixSize;
UString temp;
if (s[0] == CHAR_PATH_SEPARATOR)
{
temp = fs2us(s + 1);
}
else
{
temp += curDir.Ptr(fixedSize);
temp += fs2us(s);
}
if (!ResolveDotsFolders(temp))
return false;
curDir.DeleteFrom(fixedSize);
res = us2fs(curDir);
res += us2fs(temp);
#endif // UNDER_CE
return true;
}
示例14: GetSuperPathBase
static bool GetSuperPathBase(CFSTR s, UString &res)
{
res.Empty();
FChar c = s[0];
if (c == 0)
return true;
if (c == '.' && (s[1] == 0 || (s[1] == '.' && s[2] == 0)))
return true;
if (IsSuperOrDevicePath(s))
{
#ifdef LONG_PATH_DOTS_FOLDERS_PARSING
if ((s)[2] == '.')
return true;
// we will return true here, so we will try to use these problem paths.
if (!AreThereDotsFolders(s + kSuperPathPrefixSize))
return true;
UString temp = fs2us(s);
unsigned fixedSize = GetRootPrefixSize_Of_SuperPath(temp);
if (fixedSize == 0)
return true;
UString rem = &temp[fixedSize];
if (!ResolveDotsFolders(rem))
return true;
temp.DeleteFrom(fixedSize);
res += temp;
res += rem;
#endif
return true;
}
if (c == CHAR_PATH_SEPARATOR)
{
if (s[1] == CHAR_PATH_SEPARATOR)
{
UString temp = fs2us(s + 2);
unsigned fixedSize = GetRootPrefixSize_Of_NetworkPath(temp);
if (fixedSize == 0) // maybe we must ignore that error to allow short network paths?
return false;
UString rem = &temp[fixedSize];
if (!ResolveDotsFolders(rem))
return false;
res += kSuperUncPrefix;
temp.DeleteFrom(fixedSize);
res += temp;
res += rem;
return true;
}
}
else
{
if (IsDrivePath(s))
{
UString temp = fs2us(s);
UString rem = &temp[kDrivePrefixSize];
if (!ResolveDotsFolders(rem))
return true;
res += kSuperPathPrefix;
temp.DeleteFrom(kDrivePrefixSize);
res += temp;
res += rem;
return true;
}
}
UString curDir;
if (!GetCurDir(curDir))
return false;
if (curDir.Back() != WCHAR_PATH_SEPARATOR)
curDir += WCHAR_PATH_SEPARATOR;
unsigned fixedSizeStart = 0;
unsigned fixedSize = 0;
const wchar_t *superMarker = NULL;
if (IsSuperPath(curDir))
{
fixedSize = GetRootPrefixSize_Of_SuperPath(curDir);
if (fixedSize == 0)
return false;
}
else
{
if (IsDrivePath(curDir))
{
superMarker = kSuperPathPrefix;
fixedSize = kDrivePrefixSize;
}
else
{
if (curDir[0] != CHAR_PATH_SEPARATOR || curDir[1] != CHAR_PATH_SEPARATOR)
return false;
//.........这里部分代码省略.........
示例15: GetProperty
STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
{
COM_TRY_BEGIN
NCOM::CPropVariant prop;
if (index >= (UInt32)_archive.Refs.Size())
{
index -= _archive.Refs.Size();
const CBootInitialEntry &be = _archive.BootEntries[index];
switch (propID)
{
case kpidPath:
{
AString s = "[BOOT]" STRING_PATH_SEPARATOR;
if (_archive.BootEntries.Size() != 1)
{
char temp[16];
ConvertUInt32ToString(index + 1, temp);
s += temp;
s += '-';
}
s += be.GetName();
prop = s;
break;
}
case kpidIsDir: prop = false; break;
case kpidSize:
case kpidPackSize:
prop = (UInt64)_archive.GetBootItemSize(index);
break;
}
}
else
{
const CRef &ref = _archive.Refs[index];
const CDir &item = ref.Dir->_subItems[ref.Index];
switch (propID)
{
case kpidPath:
// if (item.FileId.GetCapacity() >= 0)
{
UString s;
if (_archive.IsJoliet())
item.GetPathU(s);
else
s = MultiByteToUnicodeString(item.GetPath(_archive.IsSusp, _archive.SuspSkipSize), CP_OEMCP);
if (s.Len() >= 2 && s[s.Len() - 2] == ';' && s.Back() == '1')
s.DeleteFrom(s.Len() - 2);
if (!s.IsEmpty() && s.Back() == L'.')
s.DeleteBack();
NItemName::ConvertToOSName2(s);
prop = s;
}
break;
case kpidIsDir: prop = item.IsDir(); break;
case kpidSize:
case kpidPackSize:
if (!item.IsDir())
prop = (UInt64)ref.TotalSize;
break;
case kpidMTime:
{
FILETIME utc;
if (item.DateTime.GetFileTime(utc))
prop = utc;
break;
}
}
}
prop.Detach(value);
return S_OK;
COM_TRY_END
}