diff options
author | Akihiko Odaki <akihiko.odaki@gmail.com> | 2022-06-18 20:57:44 +0900 |
---|---|---|
committer | Eli Schwartz <eschwartz93@gmail.com> | 2022-06-26 17:18:26 -0400 |
commit | c2c9359d466e545799aebaa2b6c6e353f5f5c833 (patch) | |
tree | fb99ff92a5a3599897427b8463b62d48152fd543 | |
parent | 4c706e961bcef8c2f4445eb4a24e3e6b2c86bbab (diff) | |
download | meson-c2c9359d466e545799aebaa2b6c6e353f5f5c833.zip meson-c2c9359d466e545799aebaa2b6c6e353f5f5c833.tar.gz meson-c2c9359d466e545799aebaa2b6c6e353f5f5c833.tar.bz2 |
Fix destdir_join
The old implementation assumed a path is of Windows iff the second
character is a colon. However, that is not always true.
First, a colon can be included in a non-Windows path. For example, it is
totally fine to have a directory named ':' on Linux 5.17.0 tmpfs.
Second, a Windows path may start with \\ for UNC or extended length.
Use pathlib to handle all of these cases.
-rw-r--r-- | mesonbuild/scripts/__init__.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/mesonbuild/scripts/__init__.py b/mesonbuild/scripts/__init__.py index 476a28a..7277771 100644 --- a/mesonbuild/scripts/__init__.py +++ b/mesonbuild/scripts/__init__.py @@ -12,10 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. +from pathlib import PurePath + def destdir_join(d1: str, d2: str) -> str: if not d1: return d2 # c:\destdir + c:\prefix must produce c:\destdir\prefix - if len(d2) > 1 and d2[1] == ':': - return d1 + d2[2:] - return d1 + d2 + return str(PurePath(d1, *PurePath(d2).parts[1:])) |