Renamed FSNode::openForReading / openForWriting to createReadStream / createWriteStream, again to make ownership of the returned stream clear

svn-id: r36014
This commit is contained in:
Max Horn 2009-01-23 03:41:36 +00:00
parent e4b013f616
commit 8f16458e9b
30 changed files with 85 additions and 85 deletions

View File

@ -52,7 +52,7 @@ protected:
* When called with a name not matching any of the files/dirs contained in this
* directory, a valid node shold be returned, which returns 'false' upon calling
* the exists() method. The idea is that this node can then still can be used to
* create a new file via the openForWriting() method.
* create a new file via the createWriteStream() method.
*
* Example:
* Calling getChild() for a node with path "/foo/bar" using name="file.txt",
@ -169,7 +169,7 @@ public:
*
* @return pointer to the stream object, 0 in case of a failure
*/
virtual Common::SeekableReadStream *openForReading() = 0;
virtual Common::SeekableReadStream *createReadStream() = 0;
/**
* Creates a WriteStream instance corresponding to the file
@ -178,7 +178,7 @@ public:
*
* @return pointer to the stream object, 0 in case of a failure
*/
virtual Common::WriteStream *openForWriting() = 0;
virtual Common::WriteStream *createWriteStream() = 0;
};

View File

@ -107,8 +107,8 @@ public:
virtual bool getChildren(AbstractFSList &list, ListMode mode, bool hidden) const;
virtual AbstractFSNode *getParent() const;
virtual Common::SeekableReadStream *openForReading();
virtual Common::WriteStream *openForWriting();
virtual Common::SeekableReadStream *createReadStream();
virtual Common::WriteStream *createWriteStream();
/**
* Creates a list with all the volumes present in the root node.
@ -569,11 +569,11 @@ AbstractFSList AmigaOSFilesystemNode::listVolumes() const {
return myList;
}
Common::SeekableReadStream *AmigaOSFilesystemNode::openForReading() {
Common::SeekableReadStream *AmigaOSFilesystemNode::createReadStream() {
return StdioStream::makeFromPath(getPath().c_str(), false);
}
Common::WriteStream *AmigaOSFilesystemNode::openForWriting() {
Common::WriteStream *AmigaOSFilesystemNode::createWriteStream() {
return StdioStream::makeFromPath(getPath().c_str(), true);
}

View File

@ -196,11 +196,11 @@ AbstractFSNode* DSFileSystemNode::getParent() const {
return p;
}
Common::SeekableReadStream *DSFileSystemNode::openForReading() {
Common::SeekableReadStream *DSFileSystemNode::createReadStream() {
return StdioStream::makeFromPath(getPath().c_str(), false);
}
Common::WriteStream *DSFileSystemNode::openForWriting() {
Common::WriteStream *DSFileSystemNode::createWriteStream() {
return StdioStream::makeFromPath(getPath().c_str(), true);
}
@ -372,7 +372,7 @@ AbstractFSNode* GBAMPFileSystemNode::getParent() const {
return p;
}
Common::SeekableReadStream *GBAMPFileSystemNode::openForReading() {
Common::SeekableReadStream *GBAMPFileSystemNode::createReadStream() {
// consolePrintf("Opening: %s\n", getPath().c_str());
if (!strncmp(getPath().c_str(), "mp:/", 4)) {
@ -382,7 +382,7 @@ Common::SeekableReadStream *GBAMPFileSystemNode::openForReading() {
}
}
Common::WriteStream *GBAMPFileSystemNode::openForWriting() {
Common::WriteStream *GBAMPFileSystemNode::createWriteStream() {
return StdioStream::makeFromPath(getPath().c_str(), true);
}

View File

@ -90,8 +90,8 @@ public:
virtual bool getChildren(AbstractFSList &list, ListMode mode, bool hidden) const;
virtual AbstractFSNode *getParent() const;
virtual Common::SeekableReadStream *openForReading();
virtual Common::WriteStream *openForWriting();
virtual Common::SeekableReadStream *createReadStream();
virtual Common::WriteStream *createWriteStream();
/**
* Returns the zip file this node points to.
@ -155,8 +155,8 @@ public:
virtual bool getChildren(AbstractFSList &list, ListMode mode, bool hidden) const;
virtual AbstractFSNode *getParent() const;
virtual Common::SeekableReadStream *openForReading();
virtual Common::WriteStream *openForWriting();
virtual Common::SeekableReadStream *createReadStream();
virtual Common::WriteStream *createWriteStream();
};
struct fileHandle {

View File

@ -68,8 +68,8 @@ public:
virtual bool getChildren(AbstractFSList &list, ListMode mode, bool hidden) const;
virtual AbstractFSNode *getParent() const;
virtual Common::SeekableReadStream *openForReading();
virtual Common::WriteStream *openForWriting();
virtual Common::SeekableReadStream *createReadStream();
virtual Common::WriteStream *createWriteStream();
private:
/**
@ -208,11 +208,11 @@ AbstractFSNode *PalmOSFilesystemNode::getParent() const {
return p;
}
Common::SeekableReadStream *PalmOSFilesystemNode::openForReading() {
Common::SeekableReadStream *PalmOSFilesystemNode::createReadStream() {
return StdioStream::makeFromPath(getPath().c_str(), false);
}
Common::WriteStream *PalmOSFilesystemNode::openForWriting() {
Common::WriteStream *PalmOSFilesystemNode::createWriteStream() {
return StdioStream::makeFromPath(getPath().c_str(), true);
}

View File

@ -237,11 +237,11 @@ AbstractFSNode *POSIXFilesystemNode::getParent() const {
return makeNode(Common::String(start, end));
}
Common::SeekableReadStream *POSIXFilesystemNode::openForReading() {
Common::SeekableReadStream *POSIXFilesystemNode::createReadStream() {
return StdioStream::makeFromPath(getPath().c_str(), false);
}
Common::WriteStream *POSIXFilesystemNode::openForWriting() {
Common::WriteStream *POSIXFilesystemNode::createWriteStream() {
return StdioStream::makeFromPath(getPath().c_str(), true);
}

View File

@ -73,8 +73,8 @@ public:
virtual bool getChildren(AbstractFSList &list, ListMode mode, bool hidden) const;
virtual AbstractFSNode *getParent() const;
virtual Common::SeekableReadStream *openForReading();
virtual Common::WriteStream *openForWriting();
virtual Common::SeekableReadStream *createReadStream();
virtual Common::WriteStream *createWriteStream();
private:
/**

View File

@ -100,8 +100,8 @@ public:
virtual bool getChildren(AbstractFSList &list, ListMode mode, bool hidden) const;
virtual AbstractFSNode *getParent() const;
virtual Common::SeekableReadStream *openForReading();
virtual Common::WriteStream *openForWriting();
virtual Common::SeekableReadStream *createReadStream();
virtual Common::WriteStream *createWriteStream();
};
Ps2FilesystemNode::Ps2FilesystemNode() {
@ -341,10 +341,10 @@ char *Ps2FilesystemNode::getDeviceDescription(const char *path) const {
return "Harddisk";
}
Common::SeekableReadStream *Ps2FilesystemNode::openForReading() {
Common::SeekableReadStream *Ps2FilesystemNode::createReadStream() {
return StdioStream::makeFromPath(getPath().c_str(), false);
}
Common::WriteStream *Ps2FilesystemNode::openForWriting() {
Common::WriteStream *Ps2FilesystemNode::createWriteStream() {
return StdioStream::makeFromPath(getPath().c_str(), true);
}

View File

@ -71,8 +71,8 @@ public:
virtual bool getChildren(AbstractFSList &list, ListMode mode, bool hidden) const;
virtual AbstractFSNode *getParent() const;
virtual Common::SeekableReadStream *openForReading();
virtual Common::WriteStream *openForWriting();
virtual Common::SeekableReadStream *createReadStream();
virtual Common::WriteStream *createWriteStream();
};
PSPFilesystemNode::PSPFilesystemNode() {
@ -161,11 +161,11 @@ AbstractFSNode *PSPFilesystemNode::getParent() const {
return new PSPFilesystemNode(Common::String(start, end - start), false);
}
Common::SeekableReadStream *PSPFilesystemNode::openForReading() {
Common::SeekableReadStream *PSPFilesystemNode::createReadStream() {
return StdioStream::makeFromPath(getPath().c_str(), false);
}
Common::WriteStream *PSPFilesystemNode::openForWriting() {
Common::WriteStream *PSPFilesystemNode::createWriteStream() {
return StdioStream::makeFromPath(getPath().c_str(), true);
}

View File

@ -79,8 +79,8 @@ public:
virtual bool getChildren(AbstractFSList &list, ListMode mode, bool hidden) const;
virtual AbstractFSNode *getParent() const;
virtual Common::SeekableReadStream *openForReading();
virtual Common::WriteStream *openForWriting();
virtual Common::SeekableReadStream *createReadStream();
virtual Common::WriteStream *createWriteStream();
};
/**
@ -252,11 +252,11 @@ AbstractFSNode *SymbianFilesystemNode::getParent() const {
return p;
}
Common::SeekableReadStream *SymbianFilesystemNode::openForReading() {
Common::SeekableReadStream *SymbianFilesystemNode::createReadStream() {
return SymbianStdioStream::makeFromPath(getPath().c_str(), false);
}
Common::WriteStream *SymbianFilesystemNode::openForWriting() {
Common::WriteStream *SymbianFilesystemNode::createWriteStream() {
return SymbianStdioStream::makeFromPath(getPath().c_str(), true);
}
#endif //#if defined (__SYMBIAN32__)

View File

@ -79,8 +79,8 @@ public:
virtual bool getChildren(AbstractFSList &list, ListMode mode, bool hidden) const;
virtual AbstractFSNode *getParent() const;
virtual Common::SeekableReadStream *openForReading();
virtual Common::WriteStream *openForWriting();
virtual Common::SeekableReadStream *createReadStream();
virtual Common::WriteStream *createWriteStream();
static void asyncHandler(bool umount, const Common::String *path);
};
@ -290,11 +290,11 @@ AbstractFSNode *WiiFilesystemNode::getParent() const {
return new WiiFilesystemNode(Common::String(start, end - start));
}
Common::SeekableReadStream *WiiFilesystemNode::openForReading() {
Common::SeekableReadStream *WiiFilesystemNode::createReadStream() {
return StdioStream::makeFromPath(getPath().c_str(), false);
}
Common::WriteStream *WiiFilesystemNode::openForWriting() {
Common::WriteStream *WiiFilesystemNode::createWriteStream() {
return StdioStream::makeFromPath(getPath().c_str(), true);
}

View File

@ -102,8 +102,8 @@ public:
virtual bool getChildren(AbstractFSList &list, ListMode mode, bool hidden) const;
virtual AbstractFSNode *getParent() const;
virtual Common::SeekableReadStream *openForReading();
virtual Common::WriteStream *openForWriting();
virtual Common::SeekableReadStream *createReadStream();
virtual Common::WriteStream *createWriteStream();
private:
/**
@ -313,11 +313,11 @@ AbstractFSNode *WindowsFilesystemNode::getParent() const {
return p;
}
Common::SeekableReadStream *WindowsFilesystemNode::openForReading() {
Common::SeekableReadStream *WindowsFilesystemNode::createReadStream() {
return StdioStream::makeFromPath(getPath().c_str(), false);
}
Common::WriteStream *WindowsFilesystemNode::openForWriting() {
Common::WriteStream *WindowsFilesystemNode::createWriteStream() {
return StdioStream::makeFromPath(getPath().c_str(), true);
}

View File

@ -183,10 +183,10 @@ Common::TimerManager *OSystem_PalmBase::getTimerManager() {
Common::SeekableReadStream *OSystem_PalmBase::createConfigReadStream() {
Common::FSNode file(PALMOS_CONFIG_FILE);
return file.openForReading();
return file.createReadStream();
}
Common::WriteStream *OSystem_PalmBase::createConfigWriteStream() {
Common::FSNode file(PALMOS_CONFIG_FILE);
return file.openForWriting();
return file.createWriteStream();
}

View File

@ -53,8 +53,8 @@ public:
virtual bool getChildren(AbstractFSList &list, ListMode mode, bool hidden) const { return false; }
virtual AbstractFSNode *getParent() const;
virtual Common::SeekableReadStream *openForReading();
virtual Common::WriteStream *openForWriting() { return 0; }
virtual Common::SeekableReadStream *createReadStream();
virtual Common::WriteStream *createWriteStream() { return 0; }
static AbstractFSNode *makeFileNodePath(const Common::String &path);
};
@ -67,7 +67,7 @@ public:
virtual bool isDirectory() const { return true; }
virtual AbstractFSNode *getChild(const Common::String &n) const;
virtual bool getChildren(AbstractFSList &list, ListMode mode, bool hidden) const;
virtual Common::SeekableReadStream *openForReading() { return 0; }
virtual Common::SeekableReadStream *createReadStream() { return 0; }
};
/* A file/directory which does not exist */
@ -77,7 +77,7 @@ public:
virtual bool exists() const { return false; }
virtual bool isReadable() const { return false; }
virtual Common::SeekableReadStream *openForReading() { return 0; }
virtual Common::SeekableReadStream *createReadStream() { return 0; }
};
AbstractFSNode *RoninCDFileNode::makeFileNodePath(const Common::String &path) {
@ -150,7 +150,7 @@ AbstractFSNode *RoninCDFileNode::getParent() const {
}
Common::SeekableReadStream *RoninCDFileNode::openForReading() {
Common::SeekableReadStream *RoninCDFileNode::createReadStream() {
return StdioStream::makeFromPath(getPath().c_str(), false);
}

View File

@ -1314,12 +1314,12 @@ OSystem *OSystem_IPHONE_create() {
Common::SeekableReadStream *OSystem_IPHONE::createConfigReadStream() {
Common::FSNode file(SCUMMVM_PREFS_PATH);
return file.openForReading();
return file.createReadStream();
}
Common::WriteStream *OSystem_IPHONE::createConfigWriteStream() {
Common::FSNode file(SCUMMVM_PREFS_PATH);
return file.openForWriting();
return file.createWriteStream();
}
void iphone_main(int argc, char *argv[]) {

View File

@ -776,14 +776,14 @@ Common::SeekableReadStream *OSystem_PS2::createConfigReadStream() {
char configFile[MAXPATHLEN];
makeConfigPath(configFile);
Common::FSNode file(configFile);
return file.openForReading();
return file.createReadStream();
}
Common::WriteStream *OSystem_PS2::createConfigWriteStream() {
char configFile[MAXPATHLEN];
makeConfigPath(configFile);
Common::FSNode file(configFile);
return file.openForWriting();
return file.createWriteStream();
}
bool OSystem_PS2::runningFromHost(void) {

View File

@ -645,10 +645,10 @@ void OSystem_PSP::displayMessageOnOSD(const char *msg) {
Common::SeekableReadStream *OSystem_PSP::createConfigReadStream() {
Common::FSNode file(PSP_CONFIG_FILE);
return file.openForReading();
return file.createReadStream();
}
Common::WriteStream *OSystem_PSP::createConfigWriteStream() {
Common::FSNode file(PSP_CONFIG_FILE);
return file.openForWriting();
return file.createWriteStream();
}

View File

@ -386,12 +386,12 @@ static Common::String getDefaultConfigFileName() {
Common::SeekableReadStream *OSystem_SDL::createConfigReadStream() {
Common::FSNode file(getDefaultConfigFileName());
return file.openForReading();
return file.createReadStream();
}
Common::WriteStream *OSystem_SDL::createConfigWriteStream() {
Common::FSNode file(getDefaultConfigFileName());
return file.openForWriting();
return file.createWriteStream();
}
void OSystem_SDL::setWindowCaption(const char *caption) {

View File

@ -125,12 +125,12 @@ static Common::String getDefaultConfigFileName() {
Common::SeekableReadStream *OSystem_SDL_Symbian::createConfigReadStream() {
Common::FSNode file(getDefaultConfigFileName());
return file.openForReading();
return file.createReadStream();
}
Common::WriteStream *OSystem_SDL_Symbian::createConfigWriteStream() {
Common::FSNode file(getDefaultConfigFileName());
return file.openForWriting();
return file.createWriteStream();
}
OSystem_SDL_Symbian::zoneDesc OSystem_SDL_Symbian::_zones[TOTAL_ZONES] = {

View File

@ -465,12 +465,12 @@ static Common::String getDefaultConfigFileName() {
Common::SeekableReadStream *OSystem_WINCE3::createConfigReadStream() {
Common::FSNode file(getDefaultConfigFileName());
return file.openForReading();
return file.createReadStream();
}
Common::WriteStream *OSystem_WINCE3::createConfigWriteStream() {
Common::FSNode file(getDefaultConfigFileName());
return file.openForWriting();
return file.createWriteStream();
}
// ********************************************************************************************

View File

@ -84,7 +84,7 @@ Common::InSaveFile *DefaultSaveFileManager::openForLoading(const char *filename)
Common::FSNode file = savePath.getChild(filename);
// Open the file for reading
Common::SeekableReadStream *sf = file.openForReading();
Common::SeekableReadStream *sf = file.createReadStream();
return Common::wrapCompressedReadStream(sf);
}
@ -99,7 +99,7 @@ Common::OutSaveFile *DefaultSaveFileManager::openForSaving(const char *filename)
Common::FSNode file = savePath.getChild(filename);
// Open the file for saving
Common::WriteStream *sf = file.openForWriting();
Common::WriteStream *sf = file.createWriteStream();
return Common::wrapCompressedWriteStream(sf);
}

View File

@ -150,7 +150,7 @@ SeekableReadStream *FSDirectory::openFile(const String &name) {
return 0;
}
SeekableReadStream *stream = node.openForReading();
SeekableReadStream *stream = node.createReadStream();
if (!stream)
warning("FSDirectory::openFile: Can't create stream for file '%s'", name.c_str());

View File

@ -84,7 +84,7 @@ bool File::open(const FSNode &node) {
return false;
}
SeekableReadStream *stream = node.openForReading();
SeekableReadStream *stream = node.createReadStream();
return open(stream, node.getPath());
}
@ -192,7 +192,7 @@ bool DumpFile::open(const FSNode &node) {
return false;
}
_handle = node.openForWriting();
_handle = node.createWriteStream();
if (_handle == NULL)
debug(2, "File %s not found", node.getName().c_str());

View File

@ -135,31 +135,31 @@ bool FSNode::isWritable() const {
return _realNode->isWritable();
}
Common::SeekableReadStream *FSNode::openForReading() const {
Common::SeekableReadStream *FSNode::createReadStream() const {
if (_realNode == 0)
return 0;
if (!_realNode->exists()) {
warning("FSNode::openForReading: FSNode does not exist");
warning("FSNode::createReadStream: FSNode does not exist");
return false;
} else if (_realNode->isDirectory()) {
warning("FSNode::openForReading: FSNode is a directory");
warning("FSNode::createReadStream: FSNode is a directory");
return false;
}
return _realNode->openForReading();
return _realNode->createReadStream();
}
Common::WriteStream *FSNode::openForWriting() const {
Common::WriteStream *FSNode::createWriteStream() const {
if (_realNode == 0)
return 0;
if (_realNode->isDirectory()) {
warning("FSNode::openForWriting: FSNode is a directory");
warning("FSNode::createWriteStream: FSNode is a directory");
return 0;
}
return _realNode->openForWriting();
return _realNode->createWriteStream();
}
} // End of namespace Common

View File

@ -109,9 +109,9 @@ public:
* If a child matching the name exists, a normal node for it is returned.
* If no child with the name exists, a node for it is still returned,
* but exists() will return 'false' for it. This node can however be used
* to create a new file using the openForWriting() method.
* to create a new file using the createWriteStream() method.
*
* @todo If openForWriting() (or a hypothetical future mkdir() method) is used,
* @todo If createWriteStream() (or a hypothetical future mkdir() method) is used,
* this should affect what exists/isDirectory/isReadable/isWritable return
* for existing nodes. However, this is not the case for many existing
* FSNode implementations. Either fix those, or document that FSNodes
@ -213,7 +213,7 @@ public:
*
* @return pointer to the stream object, 0 in case of a failure
*/
virtual SeekableReadStream *openForReading() const;
virtual SeekableReadStream *createReadStream() const;
/**
* Creates a WriteStream instance corresponding to the file
@ -222,11 +222,11 @@ public:
*
* @return pointer to the stream object, 0 in case of a failure
*/
virtual WriteStream *openForWriting() const;
virtual WriteStream *createWriteStream() const;
// Compatibility with ArchiveMember API.
SeekableReadStream *open() {
return openForReading();
return createReadStream();
}
};

View File

@ -258,7 +258,7 @@ bool md5_file(const FSNode &file, uint8 digest[16], uint32 length) {
return false;
}
ReadStream *stream = file.openForReading();
ReadStream *stream = file.createReadStream();
if (!stream) {
warning("md5_file: failed to open '%s'", file.getPath().c_str());
return false;

View File

@ -116,7 +116,7 @@ void OSystem::clearScreen() {
Common::SeekableReadStream *OSystem::createConfigReadStream() {
Common::FSNode file(DEFAULT_CONFIG_FILE);
return file.openForReading();
return file.createReadStream();
}
Common::WriteStream *OSystem::createConfigWriteStream() {
@ -124,6 +124,6 @@ Common::WriteStream *OSystem::createConfigWriteStream() {
return 0;
#else
Common::FSNode file(DEFAULT_CONFIG_FILE);
return file.openForWriting();
return file.createWriteStream();
#endif
}

View File

@ -1381,7 +1381,7 @@ ZipArchive::ZipArchive(const Common::String &name) {
}
ZipArchive::ZipArchive(const Common::FSNode &node) {
SeekableReadStream *stream = node.openForReading();
SeekableReadStream *stream = node.createReadStream();
_zipFile = unzOpen(stream);
}

View File

@ -40,7 +40,7 @@ bool XMLParser::loadFile(const Common::String &filename) {
}
bool XMLParser::loadFile(const FSNode &node) {
_stream = node.openForReading();
_stream = node.createReadStream();
if (!_stream)
return false;

View File

@ -180,7 +180,7 @@ bool WagFileParser::parse(const Common::FSNode &node) {
_parsedOk = false; // We haven't parsed the file yet
stream = node.openForReading(); // Open the file
stream = node.createReadStream(); // Open the file
if (stream) { // Check that opening the file was succesful
if (checkWagVersion(*stream)) { // Check that WinAGI version string is valid
// It seems we've got a valid *.wag file so let's parse its properties from the start.