mirror of https://github.com/stella-emu/stella.git
C++ streams can now use a 'string' filename; it no longer has to be 'const char*'.
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@3167 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
a8a30a1746
commit
99f88719e5
|
@ -230,7 +230,7 @@ void CheatManager::enable(const string& code, bool enable)
|
|||
void CheatManager::loadCheatDatabase()
|
||||
{
|
||||
const string& cheatfile = myOSystem.cheatFile();
|
||||
ifstream in(cheatfile.c_str());
|
||||
ifstream in(cheatfile);
|
||||
if(!in)
|
||||
return;
|
||||
|
||||
|
@ -270,7 +270,7 @@ void CheatManager::saveCheatDatabase()
|
|||
return;
|
||||
|
||||
const string& cheatfile = myOSystem.cheatFile();
|
||||
ofstream out(cheatfile.c_str());
|
||||
ofstream out(cheatfile);
|
||||
if(!out)
|
||||
return;
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ void PNGLibrary::loadImage(const string& filename, FBSurface& surface)
|
|||
int bit_depth, color_type, interlace_type;
|
||||
const char* err_message = nullptr;
|
||||
|
||||
ifstream in(filename.c_str(), ios_base::binary);
|
||||
ifstream in(filename, ios_base::binary);
|
||||
if(!in.is_open())
|
||||
loadImageERROR("No image found");
|
||||
|
||||
|
@ -129,7 +129,7 @@ done:
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void PNGLibrary::saveImage(const string& filename, const VariantList& comments)
|
||||
{
|
||||
ofstream out(filename.c_str(), ios_base::binary);
|
||||
ofstream out(filename, ios_base::binary);
|
||||
if(!out.is_open())
|
||||
throw "ERROR: Couldn't create snapshot file";
|
||||
|
||||
|
@ -153,7 +153,7 @@ void PNGLibrary::saveImage(const string& filename, const VariantList& comments)
|
|||
void PNGLibrary::saveImage(const string& filename, const FBSurface& surface,
|
||||
const GUI::Rect& rect, const VariantList& comments)
|
||||
{
|
||||
ofstream out(filename.c_str(), ios_base::binary);
|
||||
ofstream out(filename, ios_base::binary);
|
||||
if(!out.is_open())
|
||||
throw "ERROR: Couldn't create snapshot file";
|
||||
|
||||
|
|
|
@ -689,7 +689,7 @@ string CartDebug::loadListFile()
|
|||
}
|
||||
|
||||
FilesystemNode node(myListFile);
|
||||
ifstream in(node.getPath().c_str());
|
||||
ifstream in(node.getPath());
|
||||
if(!in.is_open())
|
||||
return DebuggerParser::red("list file '" + node.getShortPath() + "' not readable");
|
||||
|
||||
|
@ -753,7 +753,7 @@ string CartDebug::loadSymbolFile()
|
|||
}
|
||||
|
||||
FilesystemNode node(mySymbolFile);
|
||||
ifstream in(node.getPath().c_str());
|
||||
ifstream in(node.getPath());
|
||||
if(!in.is_open())
|
||||
return DebuggerParser::red("symbol file '" + node.getShortPath() + "' not readable");
|
||||
|
||||
|
@ -818,7 +818,7 @@ string CartDebug::loadConfigFile()
|
|||
}
|
||||
|
||||
FilesystemNode node(myCfgFile);
|
||||
ifstream in(node.getPath().c_str());
|
||||
ifstream in(node.getPath());
|
||||
if(!in.is_open())
|
||||
return "Unable to load directives from " + node.getPath();
|
||||
|
||||
|
@ -924,7 +924,7 @@ string CartDebug::saveConfigFile()
|
|||
const string& name = myConsole.properties().get(Cartridge_Name);
|
||||
const string& md5 = myConsole.properties().get(Cartridge_MD5);
|
||||
|
||||
ofstream out(node.getPath().c_str());
|
||||
ofstream out(node.getPath());
|
||||
if(!out.is_open())
|
||||
return "Unable to save directives to " + node.getShortPath();
|
||||
|
||||
|
@ -964,7 +964,7 @@ string CartDebug::saveDisassembly()
|
|||
}
|
||||
|
||||
FilesystemNode node(myDisasmFile);
|
||||
ofstream out(node.getPath().c_str());
|
||||
ofstream out(node.getPath());
|
||||
if(!out.is_open())
|
||||
return "Unable to save disassembly to " + node.getShortPath();
|
||||
|
||||
|
@ -1154,7 +1154,7 @@ string CartDebug::saveRom()
|
|||
myConsole.properties().get(Cartridge_Name) + ".a26";
|
||||
|
||||
FilesystemNode node(path);
|
||||
ofstream out(node.getPath().c_str(), ios::binary);
|
||||
ofstream out(node.getPath(), ios::binary);
|
||||
if(out.is_open() && myConsole.cartridge().save(out))
|
||||
return "saved ROM as " + node.getShortPath();
|
||||
else
|
||||
|
|
|
@ -128,7 +128,7 @@ string DebuggerParser::exec(const FilesystemNode& file)
|
|||
{
|
||||
if(file.exists())
|
||||
{
|
||||
ifstream in(file.getPath().c_str());
|
||||
ifstream in(file.getPath());
|
||||
if(!in.is_open())
|
||||
return red("autoexec file \'" + file.getShortPath() + "\' not found");
|
||||
|
||||
|
@ -589,7 +589,7 @@ bool DebuggerParser::saveScriptFile(string file)
|
|||
file += ".stella";
|
||||
}
|
||||
|
||||
ofstream out(file.c_str());
|
||||
ofstream out(file);
|
||||
|
||||
FunctionDefMap funcs = debugger.getFunctionDefMap();
|
||||
for(const auto& i: funcs)
|
||||
|
|
|
@ -850,7 +850,7 @@ void PromptWidget::scrollToCurrent()
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool PromptWidget::saveBuffer(string& filename)
|
||||
{
|
||||
ofstream out(filename.c_str());
|
||||
ofstream out(filename);
|
||||
if(!out.is_open())
|
||||
return false;
|
||||
|
||||
|
|
|
@ -745,7 +745,7 @@ void Console::setControllers(const string& rommd5)
|
|||
void Console::loadUserPalette()
|
||||
{
|
||||
const string& palette = myOSystem.paletteFile();
|
||||
ifstream in(palette.c_str(), ios::binary);
|
||||
ifstream in(palette, ios::binary);
|
||||
if(!in)
|
||||
return;
|
||||
|
||||
|
|
|
@ -518,7 +518,7 @@ void EventHandler::handleKeyEvent(StellaKey key, StellaMod mod, bool state)
|
|||
{
|
||||
string filename = myOSystem.baseDir() +
|
||||
myOSystem.console().properties().get(Cartridge_Name) + ".pro";
|
||||
ofstream out(filename.c_str());
|
||||
ofstream out(filename);
|
||||
if(out)
|
||||
{
|
||||
out << myOSystem.console().properties();
|
||||
|
|
|
@ -73,8 +73,7 @@ MT24LC256::MT24LC256(const string& filename, const System& system)
|
|||
jpee_ad_known(0)
|
||||
{
|
||||
// Load the data from an external file (if it exists)
|
||||
ifstream in;
|
||||
in.open(myDataFile.c_str(), ios_base::binary);
|
||||
ifstream in(myDataFile, ios_base::binary);
|
||||
if(in.is_open())
|
||||
{
|
||||
// Get length of file; it must be 32768
|
||||
|
@ -99,7 +98,7 @@ MT24LC256::~MT24LC256()
|
|||
// Save EEPROM data to external file only when necessary
|
||||
if(!myDataFileExists || myDataChanged)
|
||||
{
|
||||
ofstream out(myDataFile.c_str(), ios_base::binary);
|
||||
ofstream out(myDataFile, ios_base::binary);
|
||||
if(out.is_open())
|
||||
out.write((char*)myData, 32768);
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ PropertiesSet::PropertiesSet(const string& propsfile)
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void PropertiesSet::load(const string& filename)
|
||||
{
|
||||
ifstream in(filename.c_str());
|
||||
ifstream in(filename);
|
||||
|
||||
// Loop reading properties
|
||||
for(;;)
|
||||
|
@ -59,7 +59,7 @@ void PropertiesSet::load(const string& filename)
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool PropertiesSet::save(const string& filename) const
|
||||
{
|
||||
ofstream out(filename.c_str());
|
||||
ofstream out(filename);
|
||||
if(!out)
|
||||
return false;
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ Serializer::Serializer(const string& filename, bool readonly)
|
|||
FilesystemNode node(filename);
|
||||
if(node.isFile() && node.isReadable())
|
||||
{
|
||||
unique_ptr<fstream> str = make_ptr<fstream>(filename.c_str(), ios::in | ios::binary);
|
||||
unique_ptr<fstream> str = make_ptr<fstream>(filename, ios::in | ios::binary);
|
||||
if(str && str->is_open())
|
||||
{
|
||||
myStream = std::move(str);
|
||||
|
@ -50,10 +50,10 @@ Serializer::Serializer(const string& filename, bool readonly)
|
|||
// So we open in write and append mode - the write creates the file
|
||||
// when necessary, and the append doesn't delete any data if it
|
||||
// already exists
|
||||
fstream temp(filename.c_str(), ios::out | ios::app);
|
||||
fstream temp(filename, ios::out | ios::app);
|
||||
temp.close();
|
||||
|
||||
unique_ptr<fstream> str = make_ptr<fstream>(filename.c_str(), ios::in | ios::out | ios::binary);
|
||||
unique_ptr<fstream> str = make_ptr<fstream>(filename, ios::in | ios::out | ios::binary);
|
||||
if(str && str->is_open())
|
||||
{
|
||||
myStream = std::move(str);
|
||||
|
|
|
@ -165,7 +165,7 @@ void Settings::loadConfig()
|
|||
string line, key, value;
|
||||
string::size_type equalPos, garbage;
|
||||
|
||||
ifstream in(myOSystem.configFile().c_str());
|
||||
ifstream in(myOSystem.configFile());
|
||||
if(!in || !in.is_open())
|
||||
{
|
||||
myOSystem.logMessage("ERROR: Couldn't load settings file", 0);
|
||||
|
@ -512,7 +512,7 @@ void Settings::saveConfig()
|
|||
if(!settingsChanged)
|
||||
return;
|
||||
|
||||
ofstream out(myOSystem.configFile().c_str());
|
||||
ofstream out(myOSystem.configFile());
|
||||
if(!out || !out.is_open())
|
||||
{
|
||||
myOSystem.logMessage("ERROR: Couldn't save settings file", 0);
|
||||
|
|
|
@ -119,7 +119,7 @@ void LoggerDialog::saveLogFile()
|
|||
path << "~" << BSPF_PATH_SEPARATOR << "stella.log";
|
||||
FilesystemNode node(path.str());
|
||||
|
||||
ofstream out(node.getPath().c_str());
|
||||
ofstream out(node.getPath());
|
||||
if(out.is_open())
|
||||
out << instance().logMessages();
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ OSystemWINDOWS::OSystemWINDOWS()
|
|||
FilesystemNode basedirfile("basedir.txt");
|
||||
if(basedirfile.exists())
|
||||
{
|
||||
ifstream in(basedirfile.getPath().c_str());
|
||||
ifstream in(basedirfile.getPath());
|
||||
if(in && in.is_open())
|
||||
{
|
||||
getline(in, basedir);
|
||||
|
|
Loading…
Reference in New Issue