/** + * Path of a file that is possibly stored inside another file. + * The #fs_path points to a file at the file system. This can be either the file expressed by + * the #FilePath object, or a container file like a tar-file. In the latter case, the + * #contained_path is the lower-case path to the expressed file inside the container file. + */ +class FilePath { +public: + FilePath() : fs_path(""), contained_path("") { } + FilePath(const std::string &fs_path) : fs_path(fs_path), contained_path("") { } + FilePath(const std::string &fs_path, const std::string &contained_path) : fs_path(fs_path), contained_path(strlower(contained_path)) { } + + std::string fs_path; ///< Path to a file at the file system. + std::string contained_path; ///< If not empty, lower-case path inside the #fs_path file. diff --git a/src/newgrf_config.h b/src/newgrf_config.h --- a/src/newgrf_config.h +++ b/src/newgrf_config.h @@ -151,13 +151,15 @@ struct GRFTextWrapper : public SimpleCou /** Information about GRF, used in the game and (part of it) in savegames */ struct GRFConfig : ZeroedMemoryAllocator { - GRFConfig(const char *filename = NULL); + GRFConfig(); + GRFConfig(const FilePath &file_path); GRFConfig(const GRFConfig &config); ~GRFConfig(); GRFIdentifier ident; ///< grfid and md5sum to uniquely identify newgrfs uint8 original_md5sum[16]; ///< MD5 checksum of original file if only a 'compatible' file was loaded - char *filename; ///< Filename - either with or without full path +// char *filename; ///< Filename - either with or without full path + FilePath file_path; ////< Path to the file. GRFTextWrapper *name; ///< NOSAVE: GRF name (Action 0x08) GRFTextWrapper *info; ///< NOSAVE: GRF info (author, copyright, ...) (Action 0x08) GRFTextWrapper *url; ///< NOSAVE: URL belonging to this GRF.