diff options
| author | Xavier Del Campo Romero <xavi92@disroot.org> | 2025-12-19 00:01:17 +0100 |
|---|---|---|
| committer | Xavier Del Campo Romero <xavi92@disroot.org> | 2025-12-22 12:47:40 +0100 |
| commit | c736e13c7dd04bfa6c0580a4db3d6501dc28eed1 (patch) | |
| tree | 04d1b490f710b0ed956e8f43d620ed6f846b8cf2 /src/rez/rez.cpp | |
| parent | e2f9ee3f8cd319e952e4f5d5ec466f0ea9e6e77f (diff) | |
| download | globalops-irrlicht.tar.gz | |
Irrlichtirrlicht
Diffstat (limited to 'src/rez/rez.cpp')
| -rw-r--r-- | src/rez/rez.cpp | 51 |
1 files changed, 27 insertions, 24 deletions
diff --git a/src/rez/rez.cpp b/src/rez/rez.cpp index 2351c05..b8c22ce 100644 --- a/src/rez/rez.cpp +++ b/src/rez/rez.cpp @@ -18,12 +18,17 @@ std::string rez::ball::toupper(const std::string &s) const return ret; } -std::unique_ptr<rez::file> rez::ball::open(const char *path) +const rez::dir &rez::ball::root() const +{ + return root_dir; +} + +const rez::dir::direntry *rez::ball::access(const char *path) const { std::istringstream stream(path); std::string token; const rez::dir *dir = &root_dir; - const rez::resource *resource = nullptr; + const rez::dir::direntry *de = nullptr; while (std::getline(stream, token, '/')) { @@ -34,38 +39,41 @@ std::unique_ptr<rez::file> rez::ball::open(const char *path) if (it == map.end()) return nullptr; - const rez::dir::direntry &de = it->second; + de = &it->second; - if (std::holds_alternative<rez::dir>(de)) - dir = &std::get<rez::dir>(de); - else if (std::holds_alternative<rez::resource>(de)) - { + if (std::holds_alternative<rez::dir>(*de)) + dir = &std::get<rez::dir>(*de); + else if (std::holds_alternative<rez::resource>(*de)) dir = nullptr; - resource = &std::get<rez::resource>(de); - } } - if (dir) + return de; +} + +std::unique_ptr<rez::file> rez::ball::open(const char *path) +{ + const rez::dir::direntry *entry = access(path); + + if (!entry) { - std::cerr << path << " is a directory\n"; + std::cerr << io.path() << ": could not find " << path << '\n'; return nullptr; } - else if (!resource) + else if (std::holds_alternative<rez::dir>(*entry)) { - std::cerr << io.path() << ": could not find " << path << '\n'; + std::cerr << path << " is a directory\n"; return nullptr; } - return std::make_unique<rez::file>(*resource, io); + return std::make_unique<rez::file>(std::get<rez::resource>(*entry), io); } +const char rez::ball::title[127] = + "\r\nRezMgr Version 1 Copyright (C) 1995 MONOLITH INC. " + "\r\nLithTech Resource File \r\n"; + int rez::ball::parse() { - static const char title[63] = - "\r\nRezMgr Version 1 Copyright (C) 1995 MONOLITH INC. ", - subtitle[65] = - "\r\nLithTech Resource File \r\n"; - if (io.open()) return -1; else if (io.check(title)) @@ -73,11 +81,6 @@ int rez::ball::parse() std::cerr << path << ": wrong title\n"; return -1; } - else if (io.check(subtitle)) - { - std::cerr << path << ": wrong subtitle\n"; - return -1; - } else if (io.check(0x1a)) { std::cerr << path << ": wrong EOF\n"; |
