All pastes #728366 Raw Edit

Mine

public text v1 · immutable
·published 2007-10-06 22:20 UTC
rendered paste body
bool File::exists(const String &filename) {
	FilesystemNode* file;
	String fname = filename;
	
	//See if the file is already mapped
	if (_filesMap && _filesMap->contains(fname)) {
		fname = (*_filesMap)[fname];
		file = new FilesystemNode(fname);
		
		if (file->exists())
			return !file->isDirectory();
	}
	
	if (_defaultDirectories) {
		// Try all default directories
		StringIntMap::const_iterator i(_defaultDirectories->begin());
		for (; i != _defaultDirectories->end(); ++i) {
			fname = i->_key+fname;
			file = new FilesystemNode(fname);
			
			if(file->exists())
				return !file->isDirectory();
		}
	}

	if (file->exists())
		return !file->isDirectory();
	
	File tmp;
	return tmp.open(filename, kFileReadMode);
}