diff options
author | 2021-09-06 06:34:42 +1000 | |
---|---|---|
committer | 2021-09-06 06:34:42 +1000 | |
commit | 4f495994c41cd2fbaf89c08f755e828ae3261828 (patch) | |
tree | 8ea2c8522b807e394ea942460687b66e3ec7e381 /src/lib/util/zippath.cpp | |
parent | 5e02ff231e2472e7e75a97b6e8758a070b227f8e (diff) |
-ui: Made zoom controls a bit more intuitive.
* The UI controls are described as zoom in/out, but they had the
opposite effect on the palette and tile viewers. That has been
changed to make them consistent with the tilemap viewer.
* Made the default zoom key not act as a toggle. People are familiar
with the function of Ctrl+0/=/- in web browsers, so making them behave
similarly in MAME should make it more approachable. Also added the
default zoom key to the relevant documentation page.
* Implemented the default zoom key for the palette and tile viewers.
* In the tilemap viewer, if the view is in default expand to fit mode,
zoom in/out starting from the actual zoom ratio. Once again, this
behaves more like the zoom controls in a web browser displaying an
image so it should be more intuitive.
* Made more messages from the tilemap viewer localisable.
-util/zippath.cpp: Fixed MT08074.
* There were multiple issues at play here. After #8443 was applied,
is_root was simply never returning true on Windows, as OSD_WINDOWS
isn't actually defined outside libosd and libocore. This caused
phantom parent items to appear in disk roots on Windows, but it meant
that the check in zippath_resolve would always fail so the trailing
backslash would be trimmed. Fixing the macro test in is_root meant
the trailing backslash from C:\ would no longer be trimmed, which
caused the stat in zippath_resolve to fail.
-bigbord2.cpp: Hooked up floppy DRQ that had somehow got lost.
-Reduced tag map lookups in several drivers and devices.
-util/coretmpl.h: Removed an overload of bitswap that can be avoided
using if constexpr.
-Added doxygen comments to some classes, and fixed several doxygen
warnings.
-util, osd: Test for _WIN32 rather than WIN32.
* In C++17 mode, WIN32 is no longer a predefined macro, although various
things in 3rdparty define it to maintain legacy support. We're better
off moving forward anyway for when WIN32 disappears entirely. (WIN32
is not a reserved name, while _WIN32 is, starting with an underscore
follwed by an uppercase letter.)
Diffstat (limited to 'src/lib/util/zippath.cpp')
-rw-r--r-- | src/lib/util/zippath.cpp | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/src/lib/util/zippath.cpp b/src/lib/util/zippath.cpp index 9d2e51a6833..6fad365d6fc 100644 --- a/src/lib/util/zippath.cpp +++ b/src/lib/util/zippath.cpp @@ -48,7 +48,7 @@ int is_path_separator(char c) bool is_root(std::string_view path) { -#if defined(WIN32) +#if defined(_WIN32) // FIXME: don't assume paths are DOS-like - UNC paths, \\?\ long path prefix, etc. complicate this // skip drive letter @@ -58,8 +58,7 @@ bool is_root(std::string_view path) // skip path separators return path.find_first_not_of(PATH_SEPARATOR) == std::string_view::npos; #else - // FIXME: handle multiple successive path separators, current directory references, parent directory references - return (path.length() == 1) && (path[0] == '/'); + return path.find_first_not_of(PATH_SEPARATOR) == std::string_view::npos; #endif } @@ -208,14 +207,11 @@ std::error_condition zippath_resolve(std::string_view path, osd::directory::entr bool went_up = false; do { - if (!is_root(apath)) - { - // trim the path of trailing path separators - auto i = apath.find_last_not_of(PATH_SEPARATOR); - if (i == std::string::npos) - break; - apath = apath.substr(0, i + 1); - } + // trim the path of trailing path separators + auto i = apath.find_last_not_of(PATH_SEPARATOR); + if (i == std::string::npos) + break; + apath = apath.erase(std::min<decltype(i)>(i + 1, 2)); apath_trimmed = apath; @@ -613,7 +609,7 @@ std::string &zippath_combine(std::string &dst, const std::string &path1, const s { dst.assign(path2); } - else if (!path1.empty() && !is_path_separator(*path1.rbegin())) + else if (!path1.empty() && !is_path_separator(path1.back())) { dst.assign(path1).append(PATH_SEPARATOR).append(path2); } |