本文整理汇总了C++中TFile::Open方法的典型用法代码示例。如果您正苦于以下问题:C++ TFile::Open方法的具体用法?C++ TFile::Open怎么用?C++ TFile::Open使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TFile
的用法示例。
在下文中一共展示了TFile::Open方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadMemBuffer
// Loads from the given memory buffer as if a file.
bool TessdataManager::LoadMemBuffer(const char *name, const char *data,
int size) {
Clear();
data_file_name_ = name;
TFile fp;
fp.Open(data, size);
uint32_t num_entries;
if (!fp.DeSerialize(&num_entries)) return false;
swap_ = num_entries > kMaxNumTessdataEntries;
fp.set_swap(swap_);
if (swap_) ReverseN(&num_entries, sizeof(num_entries));
if (num_entries > kMaxNumTessdataEntries) return false;
GenericVector<int64_t> offset_table;
offset_table.resize_no_init(num_entries);
if (!fp.DeSerialize(&offset_table[0], num_entries)) return false;
for (int i = 0; i < num_entries && i < TESSDATA_NUM_ENTRIES; ++i) {
if (offset_table[i] >= 0) {
int64_t entry_size = size - offset_table[i];
int j = i + 1;
while (j < num_entries && offset_table[j] == -1) ++j;
if (j < num_entries) entry_size = offset_table[j] - offset_table[i];
entries_[i].resize_no_init(entry_size);
if (!fp.DeSerialize(&entries_[i][0], entry_size)) return false;
}
}
if (entries_[TESSDATA_VERSION].empty()) {
SetVersionString("Pre-4.0.0");
}
is_loaded_ = true;
return true;
}
示例2: TDCacheFile
TFile *openRootFile(const std::string& rootfn, const std::string& option="")
{
TFile *rootfile = NULL;
// Now check to see if this file has already been opened...
map<string,TFile*>::const_iterator it = glmap_id2rootfile.find(rootfn);
if( it != glmap_id2rootfile.end() ) {
rootfile = it->second;
if (!rootfile->IsOpen())
rootfile->Open(rootfn.c_str(),option.c_str());
else
rootfile->cd();
} else {
if (strstr(rootfn.c_str(),"dcache") ||
strstr(rootfn.c_str(),"dcap") ) {
rootfile = new TDCacheFile(rootfn.c_str(),option.c_str());
} else
rootfile = new TFile(rootfn.c_str(),option.c_str());
if( rootfile->IsZombie() ) {
cerr << "File failed to open, " << rootfn << endl;
rootfile = NULL;
} else {
glmap_id2rootfile.insert(pair<string,TFile*>(rootfn,rootfile));
}
}
return rootfile;
}
示例3: LoadDomainsNacionales
//-----------------------------------------------------------------------------
void TAdministradora :: LoadDomainsNacionales(AnsiString pDomainNacional)
{
TFile* TreeFile = new TFile(pDomainNacional);
TreeFile->Open("rb+");
TreeFile->SeekTo(0);
if(TreeFile->IsOpen())
{
TSDomainInfo SDominio;
TreeFile->Read(&SDominio,sizeof(TSServerInfo));
while(!TreeFile->Eof())
{
TPreOrderNode* node = new TPreOrderNode();
TDomain* domain = new TDomain();
node->End(SDominio.End);
node->RightLink(SDominio.LinkedRight);
domain->NameDomain(SDominio.Name);
node->Info(domain);
aDomainsPreOrderList->Insert(node);
TreeFile->Read(&SDominio,sizeof(TSDomainInfo));
}
}
TreeFile->Close();
delete TreeFile;
}
示例4: SizeFileAdd
//-----------------------tamano del fichero adjunto--------------------------------
int TAdministradora :: SizeFileAdd( AnsiString pFileName)
{
TFile* fileadd = new TFile(pFileName);
fileadd->Open("rb");
int size = fileadd->FileSize();
fileadd->Close();
delete fileadd;
return size;
}
示例5: LoadFromFile
bool ParamsModel::LoadFromFile(
const char *lang,
const char *full_path) {
TFile fp;
if (!fp.Open(full_path, nullptr)) {
tprintf("Error opening file %s\n", full_path);
return false;
}
return LoadFromFp(lang, &fp);
}
示例6: SaveAdministradorCuenta
//-----------------------------------------------------------------------------
//::::::::::::::::::::::::::::::Administrador:::::::::::::::::::::::::::::::::::
//-----------------------------------------------------------------------------
void TAdministradora :: SaveAdministradorCuenta(AnsiString pNameFile)
{
TFile* administr = new TFile(pNameFile);
administr->Open("wb");
if(administr->IsOpen())
{
TSAdmin admin;
strcpy(admin.user,aUsuario.c_str());
strcpy(admin.pass,aPassWord.c_str());
administr->Write(&admin,sizeof(TSAdmin));
}
administr->Close();
delete administr;
}
示例7: LoadAdministradorCuenta
//-----------------------------------------------------------------------------
void TAdministradora :: LoadAdministradorCuenta(AnsiString pNameFile)
{
TFile* administr = new TFile(pNameFile);
administr->Open("rb");
if(administr->IsOpen())
{
TSAdmin admin;
administr->Read(&admin,sizeof(TSAdmin));
strcpy(aUsuario.c_str(),admin.user);
AnsiString User = aUsuario.c_str();
Usuario(User);
strcpy(aPassWord.c_str(),admin.pass);
AnsiString Pass = aPassWord.c_str();
PassWord(Pass);
}
administr->Close();
delete administr;
}
示例8: ReadParamsFile
bool ParamUtils::ReadParamsFile(const char *file,
SetParamConstraint constraint,
ParamsVectors *member_params) {
int16_t nameoffset; // offset for real name
if (*file == PLUS) {
nameoffset = 1;
} else if (*file == MINUS) {
nameoffset = 1;
} else {
nameoffset = 0;
}
TFile fp;
if (!fp.Open(file + nameoffset, nullptr)) {
tprintf("read_params_file: Can't open %s\n", file + nameoffset);
return true;
}
return ReadParamsFromFp(constraint, &fp, member_params);
}
示例9: ReCachePages
// Loads as many pages can fit in max_memory_ starting at index pages_offset_.
bool DocumentData::ReCachePages() {
// Read the file.
TFile fp;
if (!fp.Open(document_name_, reader_)) return false;
memory_used_ = 0;
if (!pages_.DeSerialize(false, &fp)) {
tprintf("Deserialize failed: %s\n", document_name_.string());
pages_.truncate(0);
return false;
}
total_pages_ = pages_.size();
pages_offset_ %= total_pages_;
// Delete pages before the first one we want, and relocate the rest.
int page;
for (page = 0; page < pages_.size(); ++page) {
if (page < pages_offset_) {
delete pages_[page];
pages_[page] = NULL;
} else {
ImageData* image_data = pages_[page];
if (max_memory_ > 0 && page > pages_offset_ &&
memory_used_ + image_data->MemoryUsed() > max_memory_)
break; // Don't go over memory quota unless the first image.
if (image_data->imagefilename().length() == 0) {
image_data->set_imagefilename(document_name_);
image_data->set_page_number(page);
}
image_data->set_language(lang_);
memory_used_ += image_data->MemoryUsed();
if (pages_offset_ != 0) {
pages_[page - pages_offset_] = image_data;
pages_[page] = NULL;
}
}
}
pages_.truncate(page - pages_offset_);
tprintf("Loaded %d/%d pages (%d-%d) of document %s\n",
pages_.size(), total_pages_, pages_offset_,
pages_offset_ + pages_.size(), document_name_.string());
return !pages_.empty();
}
示例10: SaveServersNacionales
//-----------------------------------------------------------------------------
//::::::::::::::::::::::::::::LOAD/SAVE SERVERS::::::::::::::::::::::::::::::::::::
//-----------------------------------------------------------------------------
//Nacionales Servers
void TAdministradora :: SaveServersNacionales(AnsiString pServerName)
{
TFile* serverFile = new TFile(pServerName);
serverFile->Open("wb");
serverFile->SeekTo(0);
if(serverFile->IsOpen())
{ FiltrarServerNacional();
TSServerInfo server;
for(int i = 0; i < aNacionalesServers->Length(); i++)
{
TServidor* servidor = (TServidor*)aNacionalesServers->ItemInfo(i);
server.Tope = servidor->Tope();
server.MaxMail = servidor->Max();
strcpy(server.Name,servidor->NameDomain().c_str());
serverFile->Write(&server,sizeof(TSServerInfo));
}
}
serverFile->Close();
delete serverFile;
}
示例11: SaveServersInternacional
//-----------------------------------------------------------------------------
//Internacionales Servers
void TAdministradora :: SaveServersInternacional(AnsiString pNameFile)
{
TFile* internacional = new TFile(pNameFile);
internacional->Open("wb");
internacional->SeekTo(0);
if(internacional->IsOpen())
{
TSServerInfo server;
for(int i = 0; i < aInternacionales->Length(); i++)
{
TServidor* servidor = (TServidor*)aInternacionales->ItemInfo(i);
server.Tope = servidor->Tope();
server.MaxMail = servidor->Max();
strcpy(server.Name,servidor->NameDomain().c_str());
internacional->Write(&server,sizeof(TSServerInfo));
}
}
internacional->Close();
delete internacional;
}
示例12: OnGoogleShowlocation
void CFrameLocs::OnGoogleShowlocation()
{
// TODO: Add your command handler code here
TString str;
int n;
CLocation * loc = NULL;
POSITION pos;
pos = m_wndLocs.GetFirstSelectedItemPosition();
if (pos != NULL && (n = m_wndLocs.GetNextSelectedItem(pos),n>=0))
{
loc = (CLocation *)m_wndLocs.GetItemData(n);
if (loc != NULL)
{
str.Format("<html><head><meta http-equiv=\"REFRESH\" content=\"0;url=http://maps.google.com/?ie=UTF8&ll=%f,%f&spn=0.774196,1.235962&z=10"
"\"></head><body></body><html>", loc->m_fLatitude, loc->m_fLongitude);
TFile file;
TString fileName;
fileName = GCalApp_GetFileName(GSTR_TEMFOLDER);
fileName += "temp.html";
if (file.Open(fileName, "w") == TRUE)
{
file.WriteString(str);
file.Close();
ShellExecute(this->m_hWnd, NULL, fileName, NULL, NULL, SW_SHOW);
}
/* str.Format("http://maps.google.com/?ie=UTF8&ll=%f,%f&spn=0.774196,1.235962&z=10", loc->m_fLatitude, loc->m_fLongitude);
if (p_wndWeb != NULL)
{
p_wndWeb->Navigate(str.c_str());
m_wndTab.SetCurSel(1);
ShowControlsForTab(1);
}*/
}
}
return;
}
示例13: LoadServersNacionales
//-----------------------------------------------------------------------------
void TAdministradora :: LoadServersNacionales(AnsiString pServerName)
{
TFile* serverFile = new TFile(pServerName);
serverFile->Open("rb+");
serverFile->SeekTo(0);
if(serverFile->IsOpen())
{
TSServerInfo server;
serverFile->Read(&server,sizeof(TSServerInfo));
while(!serverFile->Eof())
{
TServidor* Servidor = new TServidor();
Servidor->Tope(server.Tope);
Servidor->Max(server.MaxMail);
Servidor->NameDomain(server.Name);
aNacionalesServers->Insert(Servidor);
serverFile->Read(&server,sizeof(TSServerInfo));
}
}
serverFile->Close();
delete serverFile;
}
示例14: LoadServersInternacional
//-----------------------------------------------------------------------------
void TAdministradora::LoadServersInternacional(AnsiString pNameFile)
{
TFile* internacional = new TFile(pNameFile);
internacional->Open("rb+");
internacional->SeekTo(0);
if(internacional->IsOpen())
{
TSServerInfo server;
internacional->Read(&server,sizeof(TSServerInfo));
while(!internacional->Eof())
{
TServidor* Servidor = new TServidor();
Servidor->Tope(server.Tope);
Servidor->Max(server.MaxMail);
Servidor->NameDomain(server.Name);
aInternacionales->Insert(Servidor);
internacional->Read(&server,sizeof(TSServerInfo));
}
}
internacional->Close();
delete internacional;
}
示例15: SaveDominioTree
//-----------------------------------------------------------------------------
//:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
//::::::::::::::::::: METODOS DE GUARDAR/CARGAR EN FICHEROS:::::::::::::::::::
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
//-----------------------------------------------------------------------------
//Nacionales Domains
void TAdministradora :: SaveDominioTree(AnsiString pNameDomain)
{
TFile* TreeFile = new TFile(pNameDomain);
TreeFile->Open("wb");
TreeFile->SeekTo(0);
TSeqPreOrderTree* preorder = new TSeqPreOrderTree(aTree);
if(TreeFile->IsOpen())
{
TSDomainInfo SDominio;
for(int i = 0; i < preorder->Length(); i++)
{
TPreOrderNode* node = (TPreOrderNode*)preorder->ItemInfo(i);
SDominio.End = node->End();
SDominio.LinkedRight = node->RightLink();
TDomain* domain = (TDomain*)node->Info();
strcpy(SDominio.Name,domain->NameDomain().c_str());
TreeFile->Write(&SDominio,sizeof(TSDomainInfo));
}
}
TreeFile->Close();
delete TreeFile;
}