bool File::open(const FilesystemNode &node, AccessMode mode) { assert(mode == kFileReadMode || mode == kFileWriteMode); String filename(node.displayName()); if (_handle) { error("File::open: This file object already is opened (%s), won't open '%s'", _name.c_str(), filename.c_str()); } clearIOFailed(); _name.clear(); const char *modeStr = (mode == kFileReadMode) ? "rb" : "wb"; _handle = fopen(node.path().c_str(), modeStr); if (_handle == NULL) { if (mode == kFileReadMode) debug(2, "File %s not found", filename.c_str()); else debug(2, "File %s not opened", filename.c_str()); return false; } _name = filename; #ifdef DEBUG_FILE_REFCOUNT warning("File::open on file '%s'", _name.c_str()); #endif return true; }
bool FilesystemNode::operator< (const FilesystemNode& node) const { if (isDirectory() && !node.isDirectory()) return true; if (!isDirectory() && node.isDirectory()) return false; return scumm_stricmp(displayName().c_str(), node.displayName().c_str()) < 0; }