wxDatabaseConfig::wxDatabaseConfig ( const wxString& appName, const wxString& vendorName, const wxString& viewName, const wxString& settingsConf, long WXUNUSED(style), const wxMBConv& WXUNUSED(conv) ) : wxConfigBase(appName, vendorName), m_viewName(viewName), m_pDatabase(NULL), m_self(wx_const_cast(wxDatabaseConfig*, this)) { wxStringInputStream inStream(settingsConf); wxString err; if (!LoadStream(inStream, &err)) { wxLogWarning(wxString::Format("%s in configuration settings '%s'", err, settingsConf)); } } #ifdef wxUSE_STREAMS wxDatabaseConfig::wxDatabaseConfig ( wxInputStream& inStream, const wxString& viewName, const wxMBConv& WXUNUSED(conv) ) : wxConfigBase(), m_viewName(viewName), m_pDatabase(NULL), m_self(wx_const_cast(wxDatabaseConfig*, this)) { wxString warning(" configuration stream"); wxString err; if (!LoadStream(inStream, &err)) { wxLogWarning(wxString::Format("%s in configuration stream", err)); } } #endif wxDatabaseConfig::~wxDatabaseConfig() { Flush(); CleanUp(); } void wxDatabaseConfig::SetRootPath(dbentry& entry) { entry.id = 0; entry.name = ""; entry.value = ""; entry.path = ""; entry.isgroup = true; }
CDib::CDib(IStream *pStream) { m_fileName[0] = '\0'; m_pRGB = NULL; m_pData = NULL; m_pBitmapFileHeader = NULL; m_pBitmapInfoHeader = NULL; m_pBitmapInfo = NULL; LoadStream(pStream); }
NAMESPACE_UPP static void sLoadBom(Stream& in, String *t, WString *wt, byte def_charset) { if(in.IsOpen()) { String s; if(in.GetLeft() > 3) { word header = in.Get16le(); if(header == 0xfffe || header == 0xfeff) { int n = (int)in.GetLeft() / 2; WStringBuffer ws(n); ws.SetLength(in.Get(~ws, 2 * n) / 2); if(header == 0xfffe) EndianSwap((word *)~ws, ws.GetCount()); if(wt) *wt = ws; else *t = FromUnicode(ws); return; } int c = in.Get(); if(c < 0) return; byte *h = (byte *)&header; if(h[0] == 0xef && h[1] == 0xbb && c == 0xbf) { if(wt) *wt = FromUtf8(LoadStream(in)); else *t = ToCharset(CHARSET_DEFAULT, LoadStream(in), CHARSET_UTF8); return; } s.Cat(h, 2); s.Cat(c); } s.Cat(LoadStream(in)); if(wt) *wt = ToUnicode(s, def_charset); else *t = ToCharset(CHARSET_DEFAULT, s, def_charset); return; } return; }
String FollowCygwinSymlink(const String& file) { for(String fn = file;;) { if(fn.IsEmpty()) return fn; FileIn fi(fn); if(!fi.IsOpen()) return fn; char buffer[10]; if(!fi.GetAll(buffer, 10) || memcmp(buffer, "!<symlink>", 10)) return fn; fn = NormalizePath(LoadStream(fi), GetFileDirectory(fn)); } }
bool WinMetaFile::Load(const char* path) { Clear(); FileIn file(path); if(!file.Open(path) || file.GetSize() <= sizeof(ENHMETAHEADER)) return false; int first = file.Get32le(); file.Seek(0); HENHMETAFILE hemf; HMETAFILE hMF; Size sz(1000, 1000); if(first == 0x9AC6CDD7) { PLACEABLE_METAFILEHEADER mfh; file.Get(&mfh, 22); String bits = LoadStream(file); if((hMF = ::SetMetaFileBitsEx(bits.GetLength(), bits)) == NULL) return false; sz = Size(mfh.right - mfh.left, mfh.bottom - mfh.top); } else if((hemf = ::GetEnhMetaFile(path)) != NULL) { Attach(hemf); return true; } else if((LOWORD(first) == 1 || LOWORD(first) == 2) && HIWORD(first) >= sizeof(METAHEADER) / 2) { METAHEADER mh; if(!file.GetAll(&mh, sizeof(mh))) return false; if(mh.mtVersion != 0x100 && mh.mtVersion != 0x300) return false; if((hMF = ::GetMetaFile(path)) == NULL) return false; } else return false; dword len = ::GetMetaFileBitsEx(hMF, 0, NULL); Buffer<byte> bits(len); ::GetMetaFileBitsEx(hMF, len, bits); Attach(::SetWinMetaFileBits(len, bits, NULL, NULL)); ::DeleteMetaFile(hMF); size = sz; return true; }
bool ESceneAIMapTool::LoadSelection(IReader& F) { Clear(); return LoadStream(F); }
void StreamTest() { FileIn in("d:/chips.cpp"); FileOut out("d:/chips1.cpp"); for(;;) { int c = in.Get(); if(c < 0) break; out.Put(c); } in.Seek(300); out.Seek(300); for(int i = 0; i < 5000; i++) out.Put(in.Get()); out.SetBufferSize(8); out.Seek(0); LOG("================================================"); StringStream ss(LoadFile("d:/chips.cpp")); int nn = 0; dword style = 0; for(;;) { if(++nn % 1000 == 0) Cout() << "ops: " << nn << ", len: " << ss.GetSize() << ", buffersize: " << out.GetBufferSize() << "\n"; if(ss.GetSize() > 256*1024) { int sz = (rand() % 1000) * 100; ss.SetSize(sz); out.SetSize(sz); LOG("Adjusted size: " << ss.GetSize()); } if(ss.GetSize() != out.GetSize()) { Panic("SIZE MISMATCH!"); return; } if((rand() & 255) == 0) { int64 p = out.GetPos(); out.Seek(0); if(ss.GetResult() != LoadStream(out)) { out.Seek(0); SaveFile("d:/f1.txt", LoadStream(out)); SaveFile("d:/f2.txt", ss.GetResult()); Panic("CONTENT INEQUAL!"); return; } out.Seek(p); } int spos = rand() % (int)ss.GetSize(); int ssize = rand() % (out.GetBufferSize() * 7); int tpos = MAKELONG(rand(), rand()) % (int)ss.GetSize(); if((rand() & 3) == 0) tpos = minmax<int>(spos - (rand() & 63) + 32, 0, (int)out.GetSize()); if((rand() & 3) == 0) ssize = rand() % (3 * out.GetBufferSize()); if((rand() & 4091) == 0) { style++; Cout() << "MODE: " << style << "\n"; } LOG("---------------------"); LOG("spos: " << spos << " ssize: " << ssize << " tpos: " << tpos << " style: " << style); // DUMP(ss.GetSize()); // DUMP(out.GetSize()); String a = Copy(out, spos, ssize, tpos, style); String b = Copy(ss, spos, ssize, tpos, style); // DUMP(ss.GetSize()); // DUMP(out.GetSize()); if((rand() & 1023) == 0) out.SetBufferSize((rand() & 127) + 2); if(a != b) { SaveFile("d:/f1c.txt", a); SaveFile("d:/f2c.txt", b); out.Seek(0); SaveFile("d:/f1.txt", LoadStream(out)); SaveFile("d:/f2.txt", ss.GetResult()); DUMP(ss.GetSize()); Panic("INEQUAL READ IN COPY!"); return; } } }
bool CGroupObject::UpdateReference(bool bForceReload) { if (!m_ReferenceName_.size()) { ELog.Msg (mtError,"ERROR: '%s' - has empty reference.",Name); return false; } xr_string fn = m_ReferenceName_.c_str(); fn = EFS.ChangeFileExt(fn,".group"); IReader* R = FS.r_open(_groups_, fn.c_str()); bool bres = false; if (R) { bForceInitListBox = TRUE; ObjectsInGroup ObjectsInGroupBk = m_ObjectsInGroup; if(bForceReload) ClearInternal (ObjectsInGroupBk); m_ObjectsInGroup.clear(); xr_string nm = Name; shared_str old_refs = m_ReferenceName_; UpdateTransform (true); Fvector old_pos = PPosition; Fvector old_rot = PRotation; Fvector old_sc = PScale; if(LoadStream(*R)) { Name = nm.c_str(); bres = true; UpdateTransform (true); } FS.r_close (R); SetRefName(old_refs.c_str()); NumSetPosition (old_pos); NumSetRotation (old_rot); NumSetScale (old_sc); UpdateTransform (true); if(m_ObjectsInGroup.size()==ObjectsInGroupBk.size()) { ObjectsInGroup::iterator it = m_ObjectsInGroup.begin(); ObjectsInGroup::iterator itBk = ObjectsInGroupBk.begin(); for(; it!=m_ObjectsInGroup.end(); ++it, ++itBk) { it->pObject->m_CO_Flags.set(flObjectInGroupUnique, FALSE); if(itBk->pObject->m_CO_Flags.test(flObjectInGroupUnique) ) { std::swap(*itBk, *it); }else it->pObject->Name = itBk->pObject->Name; } }else { if(ObjectsInGroupBk.size()) { ELog.Msg (mtError, "Not all objects synchronised correctly", Name); for (ObjectsInGroup::iterator it=m_ObjectsInGroup.begin(); it!=m_ObjectsInGroup.end(); ++it) it->pObject->m_CO_Flags.set(flObjectInGroupUnique, FALSE); }else { // first setup for (ObjectsInGroup::iterator it=m_ObjectsInGroup.begin(); it!=m_ObjectsInGroup.end(); ++it) it->pObject->m_CO_Flags.set(flObjectInGroupUnique, FALSE); } } ClearInternal (ObjectsInGroupBk); }else { ELog.Msg (mtError,"ERROR: Can't open group file: '%s'.",fn.c_str()); } return bres; }
bool EDetailManager::LoadSelection(IReader& F) { Clear(); return LoadStream (F); }
cOAL_Stream* cOAL_Device::LoadStream(const string& asFilename) { return LoadStream(String2WString(asFilename)); }