void THierarchicalStorage::WriteBinaryDataAsString(const UnicodeString & Name, const RawByteString & Value) { // This should be exactly the same operation as calling WriteString in // C++Builder 6 (non-Unicode) on Unicode-based OS // (conversion is done by Ansi layer of the OS) WriteString(Name, AnsiToString(Value)); }
RawByteString THierarchicalStorage::ReadStringAsBinaryData(const UnicodeString & Name, const RawByteString & Default) const { UnicodeString UnicodeDefault = AnsiToString(Default); // This should be exactly the same operation as calling ReadString in // C++Builder 6 (non-Unicode) on Unicode-based OS // (conversion is done by Ansi layer of the OS) UnicodeString String = ReadString(Name, UnicodeDefault); AnsiString Ansi = AnsiString(String); RawByteString Result = RawByteString(Ansi.c_str(), Ansi.Length()); return Result; }
extern "C" int WINAPI WinMain (HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR pszCmdLineA, int nCmdShow) { LPTSTR pszCmdLine = AnsiToString (pszCmdLineA); if (InitApplication (hInst, pszCmdLine, nCmdShow)) { AfsAppLib_MainPump(); } ExitApplication(); FreeString (pszCmdLine, pszCmdLineA); return g.rc; }
UnicodeString UnMungeStr(const UnicodeString & Str) { // Str should contain ASCII characters only RawByteString Source = Str; RawByteString Dest; char * Buffer = Dest.SetLength(Source.GetLength()); putty_unmungestr(Source.c_str(), Buffer, static_cast<int>(Source.GetLength())); // Cut the string at null character PackStr(Dest); UnicodeString Result; const std::string Bom(CONST_BOM); if (Dest.Pos(Bom.c_str()) == 1) { Dest.Delete(1, Bom.size()); Result = UTF8ToString(Dest); } else { Result = AnsiToString(Dest); } return Result; }
BOOL SERVER::RefreshAggregates (BOOL fNotify, ULONG *pStatus) { BOOL rc = TRUE; DWORD status = 0; if (m_fAggregatesOutOfDate) { m_fAggregatesOutOfDate = FALSE; if (fIsMonitored()) { if (fNotify) NOTIFYCALLBACK::SendNotificationToAll (evtRefreshAggregatesBegin, GetIdentifier()); // First thing is to forget about what aggregates we think we have // now. // LPENUM pEnum; for (pEnum = m_lAggregates->FindLast(); pEnum; pEnum = pEnum->FindPrevious()) { LPAGGREGATE lpAggregate = (LPAGGREGATE)(pEnum->GetObject()); lpAggregate->SendDeleteNotifications(); m_lAggregates->Remove (lpAggregate); Delete (lpAggregate); } // Next, the harder part: look through the server to find a list // of aggregates. // PVOID hCell; PVOID hVOS; if ((hVOS = OpenVosObject (&hCell, &status)) == NULL) rc = FALSE; else { WORKERPACKET wpBegin; wpBegin.wpVosPartitionGetBegin.hCell = hCell; wpBegin.wpVosPartitionGetBegin.hServer = hVOS; if (!Worker_DoTask (wtaskVosPartitionGetBegin, &wpBegin, &status)) rc = FALSE; else { for (;;) { WORKERPACKET wpNext; wpNext.wpVosPartitionGetNext.hEnum = wpBegin.wpVosPartitionGetBegin.hEnum; if (!Worker_DoTask (wtaskVosPartitionGetNext, &wpNext, &status)) { if (status == ADMITERATORDONE) status = 0; else rc = FALSE; break; } vos_partitionEntry_p pData = &wpNext.wpVosPartitionGetNext.Data; LPTSTR pszName = AnsiToString (pData->name); LPTSTR pszDevice = AnsiToString (pData->deviceName); LPAGGREGATE lpAggregate = New2 (AGGREGATE,(this, pszName, pszDevice)); lpAggregate->m_as.dwID = lpAggregate->GetID(); FreeString (pszDevice, pData->deviceName); FreeString (pszName, pData->name); lpAggregate->m_wGhost |= GHOST_HAS_SERVER_ENTRY; lpAggregate->m_as.ckStorageTotal = pData->totalSpace; lpAggregate->m_as.ckStorageFree = pData->totalFreeSpace; m_lAggregates->Add (lpAggregate); NOTIFYCALLBACK::SendNotificationToAll (evtCreate, lpAggregate->GetIdentifier()); } WORKERPACKET wpDone; wpDone.wpVosPartitionGetDone.hEnum = wpBegin.wpVosPartitionGetBegin.hEnum; Worker_DoTask (wtaskVosPartitionGetDone, &wpDone); } CloseVosObject(); } if (fNotify) NOTIFYCALLBACK::SendNotificationToAll (evtRefreshAggregatesEnd, GetIdentifier(), ((rc) ? 0 : status)); } } if (pStatus && !rc) *pStatus = status; return TRUE; }