本文整理汇总了C++中UString类的典型用法代码示例。如果您正苦于以下问题:C++ UString类的具体用法?C++ UString怎么用?C++ UString使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了UString类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: AddNewLineString
static void AddNewLineString(UString &s, const UString &m)
{
s += m;
s.Add_LF();
}
开发者ID:670232921,项目名称:pfm_archive,代码行数:5,代码来源:ExtractCallback.cpp
示例2: InitName
bool InitName(const UString &name, bool newStyle)
{
_first = true;
_newStyle = newStyle;
int dotPos = name.ReverseFind('.');
UString basePart = name;
if (dotPos >= 0)
{
UString ext = name.Mid(dotPos + 1);
if (ext.CompareNoCase(L"rar") == 0)
{
_afterPart = name.Mid(dotPos);
basePart = name.Left(dotPos);
}
else if (ext.CompareNoCase(L"exe") == 0)
{
_afterPart = L".rar";
basePart = name.Left(dotPos);
}
else if (!_newStyle)
{
if (ext.CompareNoCase(L"000") == 0 ||
ext.CompareNoCase(L"001") == 0 ||
ext.CompareNoCase(L"r00") == 0 ||
ext.CompareNoCase(L"r01") == 0)
{
_afterPart.Empty();
_first = false;
_changedPart = ext;
_unchangedPart = name.Left(dotPos + 1);
return true;
}
}
}
if (!_newStyle)
{
_afterPart.Empty();
_unchangedPart = basePart + UString(L".");
_changedPart = L"r00";
return true;
}
int numLetters = 1;
if (basePart.Right(numLetters) == L"1" || basePart.Right(numLetters) == L"0")
{
while (numLetters < basePart.Length())
{
if (basePart[basePart.Length() - numLetters - 1] != '0')
break;
numLetters++;
}
}
else
return false;
_unchangedPart = basePart.Left(basePart.Length() - numLetters);
_changedPart = basePart.Right(numLetters);
return true;
}
开发者ID:Dabil,项目名称:puNES,代码行数:59,代码来源:RarHandler.cpp
示例3: msg_Dbg
CtrlGeneric *TopWindow::findHitControl( int xPos, int yPos )
{
if( m_pActiveLayout == NULL )
{
return NULL;
}
// Get the controls in the active layout
const list<LayeredControl> &ctrlList = m_pActiveLayout->getControlList();
list<LayeredControl>::const_reverse_iterator iter;
// New control hit by the mouse
CtrlGeneric *pNewHitControl = NULL;
// Loop on the control list to find the uppest hit control
for( iter = ctrlList.rbegin(); iter != ctrlList.rend(); ++iter )
{
// Get the position of the control in the layout
const Position *pos = (*iter).m_pControl->getPosition();
if( pos != NULL )
{
// Compute the coordinates of the mouse relative to the control
int xRel = xPos - pos->getLeft();
int yRel = yPos - pos->getTop();
CtrlGeneric *pCtrl = (*iter).m_pControl;
// Control hit ?
if( pCtrl->isVisible() && pCtrl->mouseOver( xRel, yRel ) )
{
pNewHitControl = (*iter).m_pControl;
break;
}
}
else
{
msg_Dbg( getIntf(), "control at NULL position" );
}
}
// If the hit control has just been entered, send it an enter event
if( pNewHitControl && (pNewHitControl != m_pLastHitControl) )
{
// Don't send the event if another control captured the mouse
if( !m_pCapturingControl || (m_pCapturingControl == pNewHitControl ) )
{
EvtEnter evt( getIntf() );
pNewHitControl->handleEvent( evt );
if( !m_pCapturingControl )
{
// Show the tooltip
m_rWindowManager.hideTooltip();
UString tipText = pNewHitControl->getTooltipText();
if( tipText.length() > 0 )
{
// Set the tooltip text variable
VarManager *pVarManager = VarManager::instance( getIntf() );
pVarManager->getTooltipText().set( tipText );
m_rWindowManager.showTooltip();
}
}
}
}
return pNewHitControl;
}
开发者ID:12307,项目名称:VLC-for-VS2010,代码行数:66,代码来源:top_window.cpp
示例4: isDirectory
bool FilePath::isDirectory(const UString &p) {
return (exists(p.c_str()) && is_directory(p.c_str()));
}
开发者ID:mclark4386,项目名称:xoreos,代码行数:3,代码来源:filepath.cpp
示例5: getExtension
UString FilePath::getExtension(const UString &p) {
path file(p.c_str());
return file.extension();
}
开发者ID:mclark4386,项目名称:xoreos,代码行数:5,代码来源:filepath.cpp
示例6: escapeStringLiteral
UString FilePath::escapeStringLiteral(const UString &str) {
const boost::regex esc("[\\^\\.\\$\\|\\(\\)\\[\\]\\*\\+\\?\\/\\\\]");
const std::string rep("\\\\\\1&");
return boost::regex_replace(std::string(str.c_str()), esc, rep, boost::match_default | boost::format_sed);
}
开发者ID:mclark4386,项目名称:xoreos,代码行数:6,代码来源:filepath.cpp
示例7: LangString
HRESULT CPanel::CopyTo(CCopyToOptions &options, const CRecordVector<UInt32> &indices,
UStringVector *messages,
bool &usePassword, UString &password)
{
CMyComPtr<IFolderOperations> folderOperations;
if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK)
{
UString errorMessage = LangString(IDS_OPERATION_IS_NOT_SUPPORTED);
if (options.showErrorMessages)
MessageBox(errorMessage);
else if (messages != 0)
messages->Add(errorMessage);
return E_FAIL;
}
HRESULT res;
{
CPanelCopyThread extracter;
extracter.ExtractCallbackSpec = new CExtractCallbackImp;
extracter.ExtractCallback = extracter.ExtractCallbackSpec;
extracter.options = &options;
extracter.ExtractCallbackSpec->ProgressDialog = &extracter.ProgressDialog;
extracter.ProgressDialog.CompressingMode = false;
extracter.ExtractCallbackSpec->StreamMode = options.streamMode;
#ifdef EXTERNAL_CODECS
CExternalCodecs __externalCodecs;
#else
CMyComPtr<IUnknown> compressCodecsInfo;
#endif
if (indices.Size() == 1)
extracter.FirstFilePath = GetItemRelPath(indices[0]);
if (options.VirtFileSystem)
{
extracter.ExtractCallbackSpec->VirtFileSystem = options.VirtFileSystem;
extracter.ExtractCallbackSpec->VirtFileSystemSpec = options.VirtFileSystemSpec;
}
extracter.ExtractCallbackSpec->ProcessAltStreams = options.includeAltStreams;
if (!options.hashMethods.IsEmpty())
{
{
CCodecs *codecs = new CCodecs;
ThrowException_if_Error(codecs->Load());
#ifdef EXTERNAL_CODECS
__externalCodecs.GetCodecs = codecs;
__externalCodecs.GetHashers = codecs;
ThrowException_if_Error(__externalCodecs.LoadCodecs());
#else
compressCodecsInfo = codecs;
#endif
}
extracter.Hash.SetMethods(EXTERNAL_CODECS_VARS options.hashMethods);
extracter.ExtractCallbackSpec->SetHashMethods(&extracter.Hash);
}
else if (options.testMode)
{
extracter.ExtractCallbackSpec->SetHashCalc(&extracter.Hash);
}
extracter.Hash.Init();
UString title;
{
UInt32 titleID = IDS_COPYING;
if (options.moveMode)
titleID = IDS_MOVING;
else if (!options.hashMethods.IsEmpty() && options.streamMode)
{
titleID = IDS_CHECKSUM_CALCULATING;
if (options.hashMethods.Size() == 1)
{
const UString &s = options.hashMethods[0];
if (s != L"*")
title = s;
}
}
else if (options.testMode)
titleID = IDS_PROGRESS_TESTING;
if (title.IsEmpty())
title = LangString(titleID);
}
UString progressWindowTitle = L"7-Zip"; // LangString(IDS_APP_TITLE);
extracter.ProgressDialog.MainWindow = GetParent();
extracter.ProgressDialog.MainTitle = progressWindowTitle;
extracter.ProgressDialog.MainAddTitle = title + L' ';
extracter.ExtractCallbackSpec->OverwriteMode = NExtract::NOverwriteMode::kAsk;
extracter.ExtractCallbackSpec->Init();
extracter.Indices = indices;
//.........这里部分代码省略.........
开发者ID:OwenTan,项目名称:AndroidP7zip,代码行数:101,代码来源:PanelCopy.cpp
示例8: str
//------------------------------------------------------------------------
void AGainSimple::setDefaultMessageText (String128 text)
{
UString str (defaultMessageText, 128);
str.assign (text, -1);
}
开发者ID:mchowdhury,项目名称:VST-Compressor,代码行数:6,代码来源:againsimple.cpp
示例9: AmendString
UString HawkSqlite::AmendString(const UString& sValue)
{
AString sRet = AmendString((Char*)sValue.c_str());
return (Utf8*)sRet.c_str();
}
开发者ID:pop9006,项目名称:hawkcocos2d,代码行数:5,代码来源:HawkSqlite.cpp
示例10: while
OtpAuthToken::OtpAuthToken(CryptEngine* eng_, const UString& buf)
{
U_TRACE_REGISTER_OBJECT(5, OtpAuthToken, "%p,%.*S", eng_, U_STRING_TO_TRACE(buf))
eng = eng_;
U_STR_RESERVE(buffer, 1000);
long pos;
unsigned char ptr[1000];
#ifdef U_PROXY_UNIT
Base64engine eng1;
pos = eng1.decode((unsigned char*)buf.data(), (long)buf.size(), ptr);
pos = eng->decrypt(ptr, pos, (unsigned char*)buffer.data());
#else
pos = u_base64_decode(U_STRING_TO_PARAM(buf), ptr);
# ifdef USE_LIBSSL
pos = u_des3_decode(ptr, pos, (unsigned char*)buffer.data());
# endif
#endif
U_STR_SIZE_ADJUST_FORCE(buffer, pos);
migrate = false;
valid = (memcmp(buffer.data(), U_CONSTANT_TO_PARAM("TID=")) == 0);
timestamp = 0;
if (valid)
{
unsigned n = U_VEC_SPLIT(vec, buffer, "=; \r\n"), i = 10;
if (n < i)
{
valid = false;
return;
}
U_INTERNAL_ASSERT(vec[0] == U_STRING_FROM_CONSTANT("TID"))
tid = vec[1];
U_INTERNAL_ASSERT(vec[2] == U_STRING_FROM_CONSTANT("UID"))
uid = vec[3];
U_INTERNAL_ASSERT(vec[4] == U_STRING_FROM_CONSTANT("SID"))
sid = vec[5];
U_INTERNAL_ASSERT(vec[6] == U_STRING_FROM_CONSTANT("TS"))
ts = vec[7];
U_INTERNAL_ASSERT(vec[8] == U_STRING_FROM_CONSTANT("CF"))
cf = vec[9];
while (i < n)
{
if (vec[i] == U_STRING_FROM_CONSTANT("MIGRATE"))
{
migrate = true;
++i;
}
else
{
hp.push_back(vec[i]);
++i;
if (i >= n)
{
valid = false;
return;
}
hp.push_back(vec[i]);
++i;
}
}
# ifdef U_STD_STRING
char* _ptr = (char*) ts.c_str();
# else
char* _ptr = ts.data();
# endif
static struct tm tm;
(void) strptime(_ptr, "%Y%m%d%H%M%S", &tm);
timestamp = mktime(&tm);
}
}
开发者ID:fast01,项目名称:ULib,代码行数:90,代码来源:OtpAuthToken.cpp
示例11: UnicodeStringToMultiByte2
static void UnicodeStringToMultiByte2(AString &dest, const UString &src, UINT codePage, char defaultChar, bool &defaultCharWasUsed)
{
dest.Empty();
defaultCharWasUsed = false;
if (src.IsEmpty())
return;
{
/*
unsigned numRequiredBytes = src.Len() * 2;
char *d = dest.GetBuf(numRequiredBytes);
const wchar_t *s = (const wchar_t *)src;
unsigned i;
for (i = 0;;)
{
wchar_t c = s[i];
if (c >= 0x80 || c == 0)
break;
d[i++] = (char)c;
}
if (i != src.Len())
{
BOOL defUsed = FALSE;
defaultChar = defaultChar;
bool isUtf = (codePage == CP_UTF8 || codePage == CP_UTF7);
unsigned len = WideCharToMultiByte(codePage, 0, s + i, src.Len() - i,
d + i, numRequiredBytes + 1 - i,
(isUtf ? NULL : &defaultChar),
(isUtf ? NULL : &defUsed));
defaultCharWasUsed = (defUsed != FALSE);
if (len == 0)
throw 282229;
i += len;
}
d[i] = 0;
dest.ReleaseBuf_SetLen(i);
*/
/*
if (codePage != CP_UTF7)
{
const wchar_t *s = (const wchar_t *)src;
unsigned i;
for (i = 0;; i++)
{
wchar_t c = s[i];
if (c >= 0x80 || c == 0)
break;
}
if (s[i] == 0)
{
char *d = dest.GetBuf(src.Len());
for (i = 0;;)
{
wchar_t c = s[i];
if (c == 0)
break;
d[i++] = (char)c;
}
d[i] = 0;
dest.ReleaseBuf_SetLen(i);
return;
}
}
*/
unsigned len = WideCharToMultiByte(codePage, 0, src, src.Len(), NULL, 0, NULL, NULL);
if (len == 0)
{
if (GetLastError() != 0)
throw 282228;
}
else
{
BOOL defUsed = FALSE;
bool isUtf = (codePage == CP_UTF8 || codePage == CP_UTF7);
// defaultChar = defaultChar;
len = WideCharToMultiByte(codePage, 0, src, src.Len(),
dest.GetBuf(len), len,
(isUtf ? NULL : &defaultChar),
(isUtf ? NULL : &defUsed)
);
if (!isUtf)
defaultCharWasUsed = (defUsed != FALSE);
if (len == 0)
throw 282228;
dest.ReleaseBuf_SetEnd(len);
}
}
}
开发者ID:ming-hai,项目名称:soui,代码行数:94,代码来源:StringConvert.cpp
示例12:
String::String(const UString& str)
{
if (str.isNull())
return;
m_impl = StringImpl::create(str);
}
开发者ID:Akheon23,项目名称:chromecast-mirrored-source.vendor,代码行数:6,代码来源:String.cpp
示例13: LoadFullPathAndShow
HRESULT CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool selectFocused,
const UStringVector &selectedNames)
{
_dontShowMode = false;
LoadFullPathAndShow();
// OutputDebugStringA("=======\n");
// OutputDebugStringA("s1 \n");
CDisableTimerProcessing timerProcessing(*this);
CDisableNotify disableNotify(*this);
if (focusedPos < 0)
focusedPos = 0;
_listView.SetRedraw(false);
// m_RedrawEnabled = false;
LVITEMW item;
ZeroMemory(&item, sizeof(item));
// DWORD tickCount0 = GetTickCount();
_enableItemChangeNotify = false;
_listView.DeleteAllItems();
_enableItemChangeNotify = true;
int listViewItemCount = 0;
_selectedStatusVector.Clear();
// _realIndices.Clear();
_startGroupSelect = 0;
_selectionIsDefined = false;
// m_Files.Clear();
if (!_folder)
{
// throw 1;
SetToRootFolder();
}
_headerToolBar.EnableButton(kParentFolderID, !IsRootFolder());
{
CMyComPtr<IFolderSetFlatMode> folderSetFlatMode;
_folder.QueryInterface(IID_IFolderSetFlatMode, &folderSetFlatMode);
if (folderSetFlatMode)
folderSetFlatMode->SetFlatMode(BoolToInt(_flatMode));
}
/*
{
CMyComPtr<IFolderSetShowNtfsStreamsMode> setShow;
_folder.QueryInterface(IID_IFolderSetShowNtfsStreamsMode, &setShow);
if (setShow)
setShow->SetShowNtfsStreamsMode(BoolToInt(_showNtfsStrems_Mode));
}
*/
// DWORD tickCount1 = GetTickCount();
RINOK(_folder->LoadItems());
// DWORD tickCount2 = GetTickCount();
RINOK(InitColumns());
// OutputDebugString(TEXT("Start Dir\n"));
UInt32 numItems;
_folder->GetNumberOfItems(&numItems);
bool showDots = _showDots && !IsRootFolder();
_listView.SetItemCount(numItems + (showDots ? 1 : 0));
_selectedStatusVector.ClearAndReserve(numItems);
int cursorIndex = -1;
CMyComPtr<IFolderGetSystemIconIndex> folderGetSystemIconIndex;
if (!Is_Slow_Icon_Folder() || _showRealFileIcons)
_folder.QueryInterface(IID_IFolderGetSystemIconIndex, &folderGetSystemIconIndex);
if (!IsFSFolder())
{
CMyComPtr<IGetFolderArcProps> getFolderArcProps;
_folder.QueryInterface(IID_IGetFolderArcProps, &getFolderArcProps);
_thereAreDeletedItems = false;
if (getFolderArcProps)
{
CMyComPtr<IFolderArcProps> arcProps;
getFolderArcProps->GetFolderArcProps(&arcProps);
if (arcProps)
{
UInt32 numLevels;
if (arcProps->GetArcNumLevels(&numLevels) != S_OK)
numLevels = 0;
NCOM::CPropVariant prop;
if (arcProps->GetArcProp(numLevels - 1, kpidIsDeleted, &prop) == S_OK)
if (prop.vt == VT_BOOL && VARIANT_BOOLToBool(prop.boolVal))
_thereAreDeletedItems = true;
}
}
}
//.........这里部分代码省略.........
开发者ID:wyrover,项目名称:7-Zip-Pro,代码行数:101,代码来源:PanelItems.cpp
示例14: disableTimerProcessing1
void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
{
int destPanelIndex = (NumPanels <= 1) ? srcPanelIndex : (1 - srcPanelIndex);
CPanel &srcPanel = Panels[srcPanelIndex];
CPanel &destPanel = Panels[destPanelIndex];
CPanel::CDisableTimerProcessing disableTimerProcessing1(destPanel);
CPanel::CDisableTimerProcessing disableTimerProcessing2(srcPanel);
if (!srcPanel.DoesItSupportOperations())
{
srcPanel.MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
return;
}
CRecordVector<UInt32> indices;
UString destPath;
bool useDestPanel = false;
{
if (copyToSame)
{
int focusedItem = srcPanel._listView.GetFocusedItem();
if (focusedItem < 0)
return;
int realIndex = srcPanel.GetRealItemIndex(focusedItem);
if (realIndex == kParentIndex)
return;
indices.Add(realIndex);
destPath = srcPanel.GetItemName(realIndex);
}
else
{
srcPanel.GetOperatedItemIndices(indices);
if (indices.Size() == 0)
return;
destPath = destPanel._currentFolderPrefix;
if (NumPanels == 1)
ReducePathToRealFileSystemPath(destPath);
}
CCopyDialog copyDialog;
UStringVector copyFolders;
ReadCopyHistory(copyFolders);
copyDialog.Strings = copyFolders;
copyDialog.Value = destPath;
copyDialog.Title = move ?
LangString(IDS_MOVE, 0x03020202):
LangString(IDS_COPY, 0x03020201);
copyDialog.Static = move ?
LangString(IDS_MOVE_TO, 0x03020204):
LangString(IDS_COPY_TO, 0x03020203);
if (copyDialog.Create(srcPanel.GetParent()) == IDCANCEL)
return;
destPath = copyDialog.Value;
if (!IsPathAbsolute(destPath))
{
if (!srcPanel.IsFSFolder())
{
srcPanel.MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
return;
}
destPath = srcPanel._currentFolderPrefix + destPath;
}
if (indices.Size() > 1 || (destPath.Length() > 0 && destPath.ReverseFind('\\') == destPath.Length() - 1) ||
IsThereFolderOfPath(destPath))
{
NDirectory::CreateComplexDirectory(destPath);
NName::NormalizeDirPathPrefix(destPath);
if (!CheckFolderPath(destPath))
{
if (NumPanels < 2 || destPath != destPanel._currentFolderPrefix || !destPanel.DoesItSupportOperations())
{
srcPanel.MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
return;
}
useDestPanel = true;
}
}
else
{
int pos = destPath.ReverseFind('\\');
if (pos >= 0)
{
UString prefix = destPath.Left(pos + 1);
NDirectory::CreateComplexDirectory(prefix);
if (!CheckFolderPath(prefix))
{
srcPanel.MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
return;
}
}
}
//.........这里部分代码省略.........
开发者ID:Ando02,项目名称:wubiuefi,代码行数:101,代码来源:App.cpp
示例15: update
void TextView::update(const UString& _text, IFont* _font, int _height, Align _align, VertexColourType _format, int _maxWidth)
{
mFontHeight = _height;
// массив для быстрой конвертации цветов
static const char convert_colour[64] =
{
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0,
0, 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
mViewSize.clear();
RollBackPoint roll_back;
IntSize result;
float width = 0.0f;
size_t count = 0;
mLength = 0;
mLineInfo.clear();
LineInfo line_info;
int font_height = _font->getDefaultHeight();
UString::const_iterator end = _text.end();
UString::const_iterator index = _text.begin();
/*if (index == end)
return;*/
result.height += _height;
for (; index != end; ++index)
{
Char character = *index;
// новая строка
if (character == FontCodeType::CR
|| character == FontCodeType::NEL
|| character == FontCodeType::LF)
{
if (character == FontCodeType::CR)
{
UString::const_iterator peeki = index;
++peeki;
if ((peeki != end) && (*peeki == FontCodeType::LF))
index = peeki; // skip both as one newline
}
line_info.width = (int)ceil(width);
line_info.count = count;
mLength += line_info.count + 1;
result.height += _height;
setMax(result.width, line_info.width);
width = 0;
count = 0;
mLineInfo.push_back(line_info);
line_info.clear();
// отменяем откат
roll_back.clear();
continue;
}
// тег
else if (character == L'#')
{
// берем следующий символ
++ index;
if (index == end)
{
--index; // это защита
continue;
}
character = *index;
// если два подряд, то рисуем один шарп, если нет то меняем цвет
if (character != L'#')
{
// парсим первый символ
uint32 colour = convert_colour[(character - 48) & 0x3F];
// и еще пять символов после шарпа
for (char i = 0; i < 5; i++)
{
++ index;
if (index == end)
{
--index; // это защита
continue;
}
colour <<= 4;
colour += convert_colour[ ((*index) - 48) & 0x3F ];
}
// если нужно, то меняем красный и синий компоненты
texture_utility::convertColour(colour, _format);
//.........这里部分代码省略.........
开发者ID:Anomalous-Software,项目名称:mygui,代码行数:101,代码来源:MyGUI_TextView.cpp
示例16: adoptRef
PassRefPtr<OpaqueJSString> OpaqueJSString::create(const UString& ustring)
{
if (!ustring.isNull())
return adoptRef(new OpaqueJSString(ustring.data(), ustring.size()));
return 0;
}
开发者ID:325116067,项目名称:semc-qsd8x50,代码行数:6,代码来源:OpaqueJSString.cpp
示例17: UFile
ULog::ULog(const UString& path, uint32_t _size, const char* dir_log_gz) : UFile(path, 0)
{
U_TRACE_REGISTER_OBJECT(0, ULog, "%V,%u,%S", path.rep, _size, dir_log_gz)
lock = 0;
ptr_log_data = 0;
log_file_sz =
log_gzip_sz = 0;
U_Log_start_stop_msg(this) = false;
#ifdef USE_LIBZ
buf_path_compress = 0;
index_path_compress = 0;
#endif
if (UFile::getPath().equal(U_CONSTANT_TO_PARAM("syslog")))
{
U_Log_syslog(this) = true;
# ifndef _MSWINDOWS_
openlog(u_progname, LOG_PID, LOG_LOCAL0);
# endif
return;
}
if (UFile::creat(O_RDWR | O_APPEND, 0664) == false)
{
# ifndef U_COVERITY_FALSE_POSITIVE
U_ERROR("cannot creat log file %.*S", U_FILE_TO_TRACE(*this));
# endif
return;
}
/**
* typedef struct log_data {
* uint32_t file_ptr;
* uint32_t file_page;
* uint32_t gzip_len;
* sem_t lock_shared;
* char spinlock_shared[1];
* // --------------> maybe unnamed array of char for gzip compression...
* } log_data;
*/
ptr_log_data = U_MALLOC_TYPE(log_data);
ptr_log_data->file_ptr = 0;
if (_size)
{
uint32_t file_size = UFile::size();
bool bsize = (file_size != _size);
if ((bsize && UFile::ftruncate(_size) == false) ||
UFile::memmap(PROT_READ | PROT_WRITE) == false)
{
U_ERROR("cannot init log file %.*S", U_FILE_TO_TRACE(*this));
return;
}
if (bsize) ptr_log_data->file_ptr = file_size; // append mode
else
{
// NB: we can have a previous crash without resizing the file or we are an other process (apache like log)...
char* ptr = (char*) u_find(UFile::map, file_size, U_CONSTANT_TO_PARAM(U_MARK_END));
if (ptr)
{
ptr_log_data->file_ptr = ptr - UFile::map;
// NB: we can be an other process that manage this file (apache like log)...
u_put_unalignedp64(ptr, U_MULTICHAR_CONSTANT64('\n','\n','\n','\n','\n','\n','\n','\n'));
u_put_unalignedp64(ptr+8, U_MULTICHAR_CONSTANT64('\n','\n','\n','\n','\n','\n','\n','\n'));
u_put_unalignedp64(ptr+16, U_MULTICHAR_CONSTANT64('\n','\n','\n','\n','\n','\n','\n','\n'));
UFile::msync(ptr + U_CONSTANT_SIZE(U_MARK_END), UFile::map, MS_SYNC);
}
U_INTERNAL_ASSERT_MINOR(ptr_log_data->file_ptr, UFile::st_size)
}
log_file_sz = UFile::st_size;
}
U_INTERNAL_ASSERT(ptr_log_data->file_ptr <= UFile::st_size)
lock = U_NEW(ULock);
U_Log_syslog(this) = false;
ptr_log_data->gzip_len = 0;
ptr_log_data->file_page = ptr_log_data->file_ptr;
#ifdef USE_LIBZ
char suffix[32];
//.........这里部分代码省略.........
开发者ID:shensurong,项目名称:ULib,代码行数:101,代码来源:log.cpp
示例18: ExtractFileNameFromPath
HRESULT CArc::OpenStream(
CCodecs *codecs,
int formatIndex,
IInStream *stream,
ISequentialInStream *seqStream,
IArchiveOpenCallback *callback)
{
Archive.Release();
ErrorMessage.Empty();
const UString fileName = ExtractFileNameFromPath(Path);
UString extension;
{
int dotPos = fileName.ReverseFind(L'.');
if (dotPos >= 0)
extension = fileName.Mid(dotPos + 1);
}
CIntVector orderIndices;
if (formatIndex >= 0)
orderIndices.Add(formatIndex);
else
{
int i;
int numFinded = 0;
for (i = 0; i < codecs->Formats.Size(); i++)
if (codecs->Formats[i].FindExtension(extension) >= 0)
orderIndices.Insert(numFinded++, i);
else
orderIndices.Add(i);
if (!stream)
{
if (numFinded != 1)
return E_NOTIMPL;
orderIndices.DeleteFrom(1);
}
#ifndef _SFX
if (orderIndices.Size() >= 2 && (numFinded == 0 || extension.CompareNoCase(L"exe") == 0))
{
CIntVector orderIndices2;
CByteBuffer byteBuffer;
const size_t kBufferSize = (1 << 21);
byteBuffer.SetCapacity(kBufferSize);
RINOK(stream->Seek(0, STREAM_SEEK_SET, NULL));
size_t processedSize = kBufferSize;
RINOK(ReadStream(stream, byteBuffer, &processedSize));
if (processedSize == 0)
return S_FALSE;
const Byte *buf = byteBuffer;
CByteBuffer hashBuffer;
const UInt32 kNumVals = 1 << (kNumHashBytes * 8);
hashBuffer.SetCapacity(kNumVals);
Byte *hash = hashBuffer;
memset(hash, 0xFF, kNumVals);
Byte prevs[256];
if (orderIndices.Size() >= 256)
return S_FALSE;
int i;
for (i = 0; i < orderIndices.Size(); i++)
{
const CArcInfoEx &ai = codecs->Formats[orderIndices[i]];
const CByteBuffer &sig = ai.StartSignature;
if (sig.GetCapacity() < kNumHashBytes)
continue;
UInt32 v = HASH_VAL(sig, 0);
prevs[i] = hash[v];
hash[v] = (Byte)i;
}
processedSize -= (kNumHashBytes - 1);
for (UInt32 pos = 0; pos < processedSize; pos++)
{
for (; pos < processedSize && hash[HASH_VAL(buf, pos)] == 0xFF; pos++);
if (pos == processedSize)
break;
UInt32 v = HASH_VAL(buf, pos);
Byte *ptr = &hash[v];
int i = *ptr;
do
{
int index = orderIndices[i];
const CArcInfoEx &ai = codecs->Formats[index];
const CByteBuffer &sig = ai.StartSignature;
if (sig.GetCapacity() != 0 && pos + sig.GetCapacity() <= processedSize + (kNumHashBytes - 1) &&
TestSignature(buf + pos, sig, sig.GetCapacity()))
{
orderIndices2.Add(index);
orderIndices[i] = 0xFF;
*ptr = prevs[i];
}
else
ptr = &prevs[i];
i = *ptr;
}
while (i != 0xFF);
}
for (i = 0; i < orderIndices.Size(); i++)
//.........这里部分代码省略.........
开发者ID:0vermind,项目名称:NeoLoader,代码行数:101,代码来源:OpenArchive.cpp
示例19: documentWrite
static inline void documentWrite(ExecState* exec, HTMLDocument* document, NewlineRequirement addNewline)
{
// DOM only specifies single string argument, but browsers allow multiple or no arguments.
size_t size = exec->argumentCount();
UString firstString = exec->argument(0).toString(exec);
#if defined(JSC_TAINTED)
unsigned int tainted = 0;
if (firstString.isTainted()) {
TaintedStructure trace_struct;
trace_struct.taintedno = firstString.isTainted();
trace_struct.internalfunc = "documentWrite";
trace_struct.jsfunc = "document.write/writeln";
trace_struct.action = "sink";
trace_struct.value = TaintedUtils::UString2string(firstString);
TaintedTrace* trace = TaintedTrace::getInstance();
trace->addTaintedTrace(trace_struct);
tainted = firstString.isTainted();
}
#endif
SegmentedString segmentedString = ustringToString(firstString);
if (size != 1) {
if (!size)
segmentedString.clear();
else {
for (size_t i = 1; i < size; ++i) {
UString subsequentString = exec->argument(i).toString(exec);
#if defined(JSC_TAINTED)
unsigned int c_tainted = 0;
if (subsequentString.isTainted()) {
c_tainted = subsequentString.isTainted();
}
if (c_tainted) {
TaintedStructure trace_struct;
trace_struct.taintedno = c_tainted;
trace_struct.internalfunc = "documentWrite";
trace_struct.jsfunc = "document.write/writeln";
trace_struct.action = "sink";
trace_struct.value = TaintedUtils::UString2string(subsequentString);
TaintedTrace* trace = TaintedTrace::getInstance();
trace->addTaintedTrace(trace_struct);
tainted = c_tainted;
}
#endif
segmentedString.append(SegmentedString(ustringToString(subsequentString)));
}
}
}
if (addNewline)
segmentedString.append(SegmentedString(String(&newlineCharacter, 1)));
Document* activeDocument = asJSDOMWindow(exec->lexicalGlobalObject())->impl()->document();
document->write(segmentedString, activeDocument);
#if defined(JSC_TAINTED)
if (tainted) {
activeDocument->setTainted(tainted);
}
#endif
}
开发者ID:dpnishant,项目名称:tpjs,代码行数:63,代码来源:JSHTMLDocumentCustom.cpp
示例20: isRegularFile
bool FilePath::isRegularFile(const UString &p) {
return (exists(p.c_str()) && is_regular_file(p.c_str()));
}
开发者ID:mclark4386,项目名称:xoreos,代码行数:3,代码来源:filepath.cpp
注:本文中的UString类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论