Commit Graph

7 Commits

Author SHA1 Message Date
Kacper Michajłow 053d971507 misc/path_utils: normalize win32 paths 2024-05-05 19:37:57 +02:00
Guido Cella 1d640c9887 player: normalize paths for resuming playback
Paths like foo.mkv, ./foo.mkv .//foo.mkv, ../"$(basename
"$PWD")"/foo.mkv, and C:\foo.mkv and C:/foo.mkv on Windows, use
different config files for resuming playback, so if you quit-watch-later
and later play the same file with a different path, mpv does not resume
playback. This commit normalizes the paths on Unix to fix this.
2024-05-05 19:37:57 +02:00
Guido Cella 1128989885 test: fflush between printf and abort
This is necessary to show the output with meson test. Followup to
06edb04692.
2024-05-05 17:51:34 +02:00
Dudemanguy 9db818279a test: integrate unittests with meson
This reworks all of mpv's unit tests so they are compiled as separate
executables (optional) and run via meson test. Because most of the tests
are dependant on mpv's internals, existing compiled objects are
leveraged to create static libs and used when necessary. As an aside, a
function was moved into video/out/gpu/utils for sanity's sake (otherwise
most of vo would have been needed). As a plus, meson multithreads
running tests automatically and also the output no longer pollutes the
source directory. There are tests that can break due to ffmpeg changes,
so they require a specific minimum libavutil version to be built.
2023-03-02 15:45:27 +00:00
wm4 1dc3507474 path: add mp_path_is_absolute()
Just move it from mp_path_join_bstr() to this new function.
2020-02-06 14:14:35 +01:00
wm4 31acec5438 path: change win32 semantics for joining drive-relative paths
win32 is a cursed abomination which has "drive letters" at the root of
the filesystem namespace for no reason. This requires special handling
beyond tolerating the idiotic "\" path separator.

Even more cursed is the fact that a path starting with a drive letter
can be a relative path. For example, "c:billsucks" is actually a
relative path to the current working directory of the C drive. So for
example if the current working directory is "c:/windowsphone", then
"c:billsucks" would reference "c:/windowsphone/billsucks".

You should realize that win32 is a ridiculous satanic trash fire by the
point you realize that win32 has at least 26 current working
directories, one for each drive letter.

Anyway, the actual problem is that mpv's mp_path_join() function would
return a relative path if an absolute relative path is joined with a
drive-relative path. This should never happen; I bet it breaks a lot of
assumptions (maybe even some security or safety relevant ones, but
probably not).

Since relative drive paths are such a fucked up shit idea, don't try to
support them "properly", and just solve the problem at hand. The
solution produces a path that should be invalid on win32.

Joining two relative paths still behaves the same; this is probably OK
(maybe).

The change isn't very minimal due to me rewriting parts of it without
strict need, but I don't care.

Note that the Python os.path.join() function (after which the mpv
function was apparently modeled) has the same problem.
2020-02-06 14:10:40 +01:00
wm4 1293c40623 test: add some path handling tests
Exhaustive tests would be nice, but I'm only adding a test for a
function I'm going to change.
2020-02-06 13:50:41 +01:00