本文整理汇总了C++中FileManager类的典型用法代码示例。如果您正苦于以下问题:C++ FileManager类的具体用法?C++ FileManager怎么用?C++ FileManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FileManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetLogFileName
//------------------------------------------------------------------------------
std::string ConsoleMessageReceiver::GetLogFileName()
{
FileManager *fm = FileManager::Instance();
std::string fname;
try
{
if (logFileName == "")
{
fname = fm->GetFullPathname("LOG_FILE");
}
else
{
std::string outputPath = fm->GetPathname(FileManager::LOG_FILE);
// add output path if there is no path
if (logFileName.find("/") == logFileName.npos &&
logFileName.find("\\") == logFileName.npos)
{
fname = outputPath + logFileName;
}
}
}
catch (BaseException &e)
{
ShowMessage
("**** ERROR **** " + e.GetFullMessage() +
"So setting log file name to GmatLog.txt");
fname = "GmatLog.txt";
}
return fname;
}
示例2: LoadFromFile
bool TextureAtlas::LoadFromFile(const std::string& filePath)
{
FileManager fr;
fr.OpenFile(filePath);
tinyxml2::XMLDocument doc;
if (doc.Parse(fr.ReadText().c_str()))
return false;
const tinyxml2::XMLElement* element = doc.FirstChildElement();
m_texture = uthRS.LoadTexture(element->FindAttribute("imagePath")->Value());
if (!m_texture)
return false;
for (const tinyxml2::XMLElement* child = element->FirstChildElement(); child != nullptr; child = child->NextSiblingElement())
{
std::string name(child->FindAttribute("name")->Value());
pmath::Rect rect;
float x = child->FindAttribute("x")->FloatValue(),
y = child->FindAttribute("y")->FloatValue();
rect.position.x = x / m_texture->GetSize().x;
rect.position.y = y / m_texture->GetSize().y;
rect.size.x = child->FindAttribute("width")->FloatValue() / m_texture->GetSize().x;
rect.size.y = child->FindAttribute("height")->FloatValue() / m_texture->GetSize().y;
m_textureRects.insert(std::make_pair(name, rect));
}
return true;
}
示例3: InitializeSourceManager
bool CompilerInstance::InitializeSourceManager(llvm::StringRef InputFile,
Diagnostic &Diags,
FileManager &FileMgr,
SourceManager &SourceMgr,
const FrontendOptions &Opts) {
// Figure out where to get and map in the main file, unless it's already
// been created (e.g., by a precompiled preamble).
if (!SourceMgr.getMainFileID().isInvalid()) {
// Do nothing: the main file has already been set.
} else if (InputFile != "-") {
const FileEntry *File = FileMgr.getFile(InputFile);
if (!File) {
Diags.Report(diag::err_fe_error_reading) << InputFile;
return false;
}
SourceMgr.createMainFileID(File);
} else {
llvm::OwningPtr<llvm::MemoryBuffer> SB;
if (llvm::MemoryBuffer::getSTDIN(SB)) {
// FIXME: Give ec.message() in this diag.
Diags.Report(diag::err_fe_error_reading_stdin);
return false;
}
const FileEntry *File = FileMgr.getVirtualFile(SB->getBufferIdentifier(),
SB->getBufferSize(), 0);
SourceMgr.createMainFileID(File);
SourceMgr.overrideFileContents(File, SB.take());
}
assert(!SourceMgr.getMainFileID().isInvalid() &&
"Couldn't establish MainFileID!");
return true;
}
示例4: callbackSendChunk
int callbackSendChunk(Packet& p)
{
PacketSendChunk pp (p);
//cout << "callbackSendChunk";
// récupérer singleton serveur
ClientData* cd = PolypeerClient::getInstance()->getClientData();
Chunk* tmp = pp.getChunk();
if(tmp->isIntegrate())
{
FileManager* fm = cd->getFileManager(tmp->getIdFile());
fm->saveChunk(*tmp);
cd->getConnectionManager()->sendTo(cd->getAddressServ(), PacketChunkReceived(tmp->getIdFile(), fm->getCurrentNumberChunk()));
}
else
{
//cout << "erreur du Chunk reçu :";
//cout << tmp->getNumber()<<endl;
cd->getConnectionManager()->sendTo(cd->getAddressServ(), PacketMd5Error(tmp->getIdFile(), tmp->getNumber()));
}
delete tmp;
return 1;
}
示例5: main
int main()
{
llvm::raw_stdout_ostream ost;
//DiagnosticOptions dops;
TextDiagnosticPrinter tdp(ost);//, dops);
Diagnostic diag(&tdp);
LangOptions lang;
//lang.GNUMode = 1;
SourceManager sm;
FileManager fm;
HeaderSearch headers(fm);
InitHeaderSearch init(headers);
init.AddDefaultSystemIncludePaths(lang);
init.Realize();
TargetInfo *ti = TargetInfo::CreateTargetInfo(LLVM_HOSTTRIPLE);
Preprocessor pp(diag, lang, *ti, sm, headers);
PreprocessorInitOptions ppio;
InitializePreprocessor(pp, ppio);
const FileEntry *file = fm.getFile("foo.c");
sm.createMainFileID(file, SourceLocation());
pp.EnterMainSourceFile();
IdentifierTable tab(lang);
MyAction action(pp);
Parser p(pp, action);
p.ParseTranslationUnit();
return 0;
}
示例6: while
bool LnkProperties::copyFile( DocLnk &newdoc )
{
const char *linkExtn = ".desktop";
QString fileExtn;
int extnPos = lnk->file().findRev( '.' );
if ( extnPos > 0 )
fileExtn = lnk->file().mid( extnPos );
QString safename = newdoc.name();
safename.replace(QRegExp("/"),"_");
QString fn = locations[ d->locationCombo->currentItem() ]
+ "/Documents/" + newdoc.type();
if (!createMimedir(locations[ d->locationCombo->currentItem() ],newdoc.type())) {
return FALSE;
}
fn+="/"+safename;
if ( QFile::exists(fn + fileExtn) || QFile::exists(fn + linkExtn) ) {
int n=1;
QString nn = fn + "_" + QString::number(n);
while ( QFile::exists(nn+fileExtn) || QFile::exists(nn+linkExtn) ) {
n++;
nn = fn + "_" + QString::number(n);
}
fn = nn;
}
newdoc.setFile( fn + fileExtn );
newdoc.setLinkFile( fn + linkExtn );
// Copy file
FileManager fm;
if ( !fm.copyFile( *lnk, newdoc ) )
return FALSE;
return TRUE;
}
示例7:
std::unique_ptr<Project> JsonImporter::ImportProject(FileManager& fileManager, const filesystem::path& projectFile)
{
auto json = internal::ParseJsonFile(fileManager.GetFileSystem(), projectFile);
if (internal::IsValidProject(json))
{
auto project = std::make_unique<Project>();
project->SetName(json["project"]);
project->SetFile(projectFile);
for (auto& config : json["configs"])
{
project->AddConfiguration(internal::ImportConfig(config));
}
for (auto& filePath : json["files"])
{
project->AddFile(fileManager.GetOrCreateFile(filePath));
}
return project;
}
return nullptr;
}
示例8: progress
bool MainWindow2::saveObject( QString strSavedFileName )
{
QProgressDialog progress( tr( "Saving document..." ), tr( "Abort" ), 0, 100, this );
progress.setWindowModality( Qt::WindowModal );
progress.show();
FileManager* fm = new FileManager( this );
Status st = fm->save( mEditor->object(), strSavedFileName );
progress.setValue( 100 );
if ( !st.ok() )
{
return false;
}
QSettings settings( PENCIL2D, PENCIL2D );
settings.setValue( LAST_FILE_PATH, strSavedFileName );
mRecentFileMenu->addRecentFile( strSavedFileName );
mRecentFileMenu->saveToDisk();
mTimeLine->updateContent();
setWindowTitle( strSavedFileName );
return true;
}
示例9: InitializeSourceManager
bool CompilerInstance::InitializeSourceManager(StringRef InputFile,
SrcMgr::CharacteristicKind Kind,
DiagnosticsEngine &Diags,
FileManager &FileMgr,
SourceManager &SourceMgr,
const FrontendOptions &Opts) {
// Figure out where to get and map in the main file.
if (InputFile != "-") {
const FileEntry *File = FileMgr.getFile(InputFile);
if (!File) {
Diags.Report(diag::err_fe_error_reading) << InputFile;
return false;
}
SourceMgr.createMainFileID(File, Kind);
} else {
OwningPtr<llvm::MemoryBuffer> SB;
if (llvm::MemoryBuffer::getSTDIN(SB)) {
// FIXME: Give ec.message() in this diag.
Diags.Report(diag::err_fe_error_reading_stdin);
return false;
}
const FileEntry *File = FileMgr.getVirtualFile(SB->getBufferIdentifier(),
SB->getBufferSize(), 0);
SourceMgr.createMainFileID(File, Kind);
SourceMgr.overrideFileContents(File, SB.take());
}
assert(!SourceMgr.getMainFileID().isInvalid() &&
"Couldn't establish MainFileID!");
return true;
}
示例10: updateList
void ContactList::updateList(QStringList nameList)
{
FileManager file;
listWidget->clear();
listWidget->addItems(nameList);
file.updateContacts(nameList);
}
示例11: getResourcePath
char* ReplayBuilder::getResourcePath(const char *resourcePath) {
if (templateDir_ == 0) {
return 0;
}
FileManager fileManager;
return fileManager.getFilePath(templateDir_, resourcePath);
}
示例12:
//------------------------------------------------------------------------------
HarmonicField::HarmonicField(const std::string &name, const std::string &typeName,
Integer maxDeg, Integer maxOrd) :
GravityBase (typeName, name),
hMinitialized (false),
maxDegree (maxDeg),
maxOrder (maxOrd),
degree (4),
order (4),
filename (""),
filenameFullPath (""),
fileRead (false),
usingDefaultFile (false),
isFirstTimeDefault (true),
inputCSName ("EarthMJ2000Eq"),
fixedCSName ("EarthFixed"),
targetCSName ("EarthMJ2000Eq"),
potPath (""),
inputCS (NULL),
fixedCS (NULL),
targetCS (NULL),
eop (NULL)
{
objectTypeNames.push_back("HarmonicField");
parameterCount = HarmonicFieldParamCount;
r = s = t = u = 0.0;
FileManager *fm = FileManager::Instance();
potPath = fm->GetAbsPathname(bodyName + "_POT_PATH");
#ifdef DEBUG_EOP_FILE
MessageInterface::ShowMessage
("HarmonicField() constructor, this=<%p>, name='%s'\n", this, name.c_str());
#endif
}
示例13: test_delete_record
void test_delete_record() {
int fileID;
FileManager* fm = new FileManager();
fm->openFile("testfile.txt", fileID); //打开文件,fileID是返回的文件id
RecordManager* test = new RecordManager(fm);
test->load_table_info(fileID);
vector<string> newRecord, newRecord2, newRecord3;
newRecord.push_back("106001");
newRecord.push_back("'CHAD CABELLO'");
newRecord.push_back("'F'");
newRecord2.push_back("106002");
newRecord2.push_back("'CHAD CABELLO'");
newRecord2.push_back("'M'");
newRecord3.push_back("106003");
newRecord3.push_back("'CHAD CABELLO'");
newRecord3.push_back("'F'");
vector<int> nulls;
nulls.push_back(1);
nulls.push_back(1);
nulls.push_back(1);
test->insert_record(fileID, newRecord, nulls);
test->insert_record(fileID, newRecord2, nulls);
test->insert_record(fileID, newRecord3, nulls);
test->print_all_record(fileID);
test->delete_record(fileID, 2);
test->insert_record(fileID, newRecord, nulls);
test->print_all_record(fileID);
// for (int i = 0; i < 9000; i++) {
// test->insert_record(fileID, newRecord);
// }
// test->print_all_record();
}
示例14: main
int main() {
cout << "!!!DataTeam project start!!!" << endl;
// int totalTrainRecords = 878049;
int totalTrainRecords = 100000;
int totalTestRecords = 884261;
string predictFieldName = "Category";
string trainFileName = string("../DataTeam/files/train.csv");
string testFileName = string("../DataTeam/files/test.csv");
string trainNewFileName = string("../DataTeam/files/trainNew.csv");
string submissionFileName = string("../DataTeam/files/submission.csv");
// Preparar el archivo para que funcione al pasarlo al NaiveBayes
FileManager fileManager = FileManager(totalTrainRecords, trainFileName, trainNewFileName);
fileManager.process();
// Pasarle el archivo con los datos de los registros como numericos
// NaiveBayes naiveBayes = NaiveBayes(predictFieldName, fileManager.getSetterData());
// naiveBayes.train(totalTrainRecords, trainNewFileName);
// naiveBayes.test(totalTestRecords, testFileName, submissionFileName);
KNN knn = KNN(50, fileManager.getSetterData());
knn.aplicarKNN(trainNewFileName,testFileName,submissionFileName);
cout << "Finish run app" << endl;
return 0;
}
示例15:
//------------------------------------------------------------------------------
HarmonicField::HarmonicField(const std::string &name, const std::string &typeName,
Integer maxDeg, Integer maxOrd) :
GravityBase (typeName, name),
hMinitialized (false),
maxDegree (maxDeg),
maxOrder (maxOrd),
degree (4),
order (4),
filename (""),
fileRead (false),
usingDefaultFile (false),
isFirstTimeDefault (true),
inputCSName ("EarthMJ2000Eq"),
fixedCSName ("EarthFixed"),
targetCSName ("EarthMJ2000Eq"),
potPath (""),
inputCS (NULL),
fixedCS (NULL),
targetCS (NULL),
eop (NULL)
{
objectTypeNames.push_back("HarmonicField");
parameterCount = HarmonicFieldParamCount;
r = s = t = u = 0.0;
FileManager *fm = FileManager::Instance();
potPath = fm->GetAbsPathname(bodyName + "_POT_PATH");
}