2007-08-28 11:20:24 +00:00
|
|
|
/*
|
|
|
|
* Get path to config dir/file.
|
|
|
|
*
|
2015-04-13 07:36:54 +00:00
|
|
|
* This file is part of mpv.
|
2007-08-28 11:20:24 +00:00
|
|
|
*
|
2017-06-12 14:41:21 +00:00
|
|
|
* mpv is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
2007-08-28 11:20:24 +00:00
|
|
|
*
|
2015-04-13 07:36:54 +00:00
|
|
|
* mpv is distributed in the hope that it will be useful,
|
2007-08-28 11:20:24 +00:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2017-06-12 14:41:21 +00:00
|
|
|
* GNU Lesser General Public License for more details.
|
2007-08-28 11:20:24 +00:00
|
|
|
*
|
2017-06-12 14:41:21 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with mpv. If not, see <http://www.gnu.org/licenses/>.
|
2007-08-28 11:20:24 +00:00
|
|
|
*/
|
|
|
|
|
2010-03-20 23:38:27 +00:00
|
|
|
#ifndef MPLAYER_PATH_H
|
|
|
|
#define MPLAYER_PATH_H
|
2007-08-28 11:20:24 +00:00
|
|
|
|
2012-02-03 07:05:11 +00:00
|
|
|
#include <stdbool.h>
|
2014-08-29 10:09:04 +00:00
|
|
|
#include "misc/bstr.h"
|
2011-02-23 14:18:09 +00:00
|
|
|
|
2013-12-21 19:45:19 +00:00
|
|
|
struct mpv_global;
|
2018-05-21 13:49:19 +00:00
|
|
|
struct MPOpts;
|
|
|
|
|
|
|
|
void mp_init_paths(struct mpv_global *global, struct MPOpts *opts);
|
2012-12-09 14:05:21 +00:00
|
|
|
|
|
|
|
// Search for the input filename in several paths. These include user and global
|
|
|
|
// config locations by default. Some platforms may implement additional platform
|
|
|
|
// related lookups (i.e.: OSX inside an application bundle).
|
2013-12-21 19:45:19 +00:00
|
|
|
char *mp_find_config_file(void *talloc_ctx, struct mpv_global *global,
|
|
|
|
const char *filename);
|
2012-12-09 14:05:21 +00:00
|
|
|
|
2022-11-08 00:35:43 +00:00
|
|
|
// Search for local writable user files within a specific kind of user dir
|
|
|
|
// as documented in osdep/path.h. This returns a result even if the file does
|
|
|
|
// not exist. Calling it with filename="" is equivalent to retrieving the path
|
|
|
|
// to the dir.
|
|
|
|
char *mp_find_user_file(void *talloc_ctx, struct mpv_global *global,
|
|
|
|
const char *type, const char *filename);
|
2015-05-09 14:21:44 +00:00
|
|
|
|
2014-06-18 23:55:40 +00:00
|
|
|
// Find all instances of the given config file. Paths are returned in order
|
2015-02-15 13:28:49 +00:00
|
|
|
// from lowest to highest priority. filename can contain multiple names
|
|
|
|
// separated with '|', with the first having highest priority.
|
2014-06-18 23:55:40 +00:00
|
|
|
char **mp_find_all_config_files(void *talloc_ctx, struct mpv_global *global,
|
|
|
|
const char *filename);
|
2011-02-23 14:18:09 +00:00
|
|
|
|
2013-12-14 18:50:00 +00:00
|
|
|
// Normally returns a talloc_strdup'ed copy of the path, except for special
|
|
|
|
// paths starting with '~'. Used to allow the user explicitly reference a
|
|
|
|
// file from the user's home or mpv config directory.
|
2013-12-21 19:45:19 +00:00
|
|
|
char *mp_get_user_path(void *talloc_ctx, struct mpv_global *global,
|
|
|
|
const char *path);
|
2013-12-14 18:50:00 +00:00
|
|
|
|
2011-02-23 14:18:09 +00:00
|
|
|
// Return pointer to filename part of path
|
|
|
|
|
|
|
|
char *mp_basename(const char *path);
|
|
|
|
|
2013-12-22 22:04:19 +00:00
|
|
|
/* Return file extension, excluding the '.'. If root is not NULL, set it to the
|
|
|
|
* part of the path without extension. So: path == root + "." + extension
|
2013-07-08 18:34:26 +00:00
|
|
|
* Don't consider it a file extension if the only '.' is the first character.
|
2013-12-22 22:04:19 +00:00
|
|
|
* Return NULL if no extension and don't set *root in this case.
|
2013-07-08 18:34:26 +00:00
|
|
|
*/
|
|
|
|
char *mp_splitext(const char *path, bstr *root);
|
|
|
|
|
2011-02-23 14:18:09 +00:00
|
|
|
/* Return struct bstr referencing directory part of path, or if that
|
|
|
|
* would be empty, ".".
|
|
|
|
*/
|
|
|
|
struct bstr mp_dirname(const char *path);
|
|
|
|
|
2016-01-06 21:40:55 +00:00
|
|
|
void mp_path_strip_trailing_separator(char *path);
|
|
|
|
|
2011-02-23 14:18:09 +00:00
|
|
|
/* Join two path components and return a newly allocated string
|
|
|
|
* for the result. '/' is inserted between the components if needed.
|
|
|
|
* If p2 is an absolute path then the value of p1 is ignored.
|
|
|
|
*/
|
2015-05-09 13:26:47 +00:00
|
|
|
char *mp_path_join(void *talloc_ctx, const char *p1, const char *p2);
|
|
|
|
char *mp_path_join_bstr(void *talloc_ctx, struct bstr p1, struct bstr p2);
|
2007-08-28 11:20:24 +00:00
|
|
|
|
2020-02-06 13:14:35 +00:00
|
|
|
// Return whether the path is absolute.
|
|
|
|
bool mp_path_is_absolute(struct bstr path);
|
|
|
|
|
core: add playback resume feature (manual/opt-in)
A "watch later" command is now mapped to Shift+Q. This quits the player
and stores the playback state in a config file in ~/.mpv/watch_later/.
When calling the player with the same file again, playback is resumed
at that time position.
It's also possible to make mpv save playback state always on quit with
the --save-position-on-quit option. Likewise, resuming can be disabled
with the --no-resume-playback option.
This also attempts to save some playback parameters, like fullscreen
state or track selection. This will unconditionally override config
settings and command line options (which is probably not what you would
expect, but in general nobody will really care about this). Some things
are not backed up, because that would cause various problems. Additional
subtitle files, video filters, etc. are not stored because that would be
too hard and fragile. Volume/mute state are not stored because it would
mess up if the system mixer is used, or if the system mixer was
readjusted in the meantime.
Basically, the tradeoff between perfect state restoration and
complexity/fragility makes it not worth to attempt to implement
it perfectly, even if the result is a little bit inconsistent.
2013-05-05 17:37:29 +00:00
|
|
|
char *mp_getcwd(void *talloc_ctx);
|
|
|
|
|
player: always write redirect entries for resuming playback
35f43dfacbe added a system to write resume files for redirects, i.e.
directories and playlists that mpv expands.
It creates a resume file for each redirect, and for the first redirect
only, it writes a resume file for each segment of its path, without even
converting it to an absolute path if it's relative. This is incomplete:
mpv 'Iron Maiden/1982 The Number of the Beast/8 Hallowed Be Thy Name.mp3'
This doesn't save any redirect entry.
mpv --directory-mode=recursive 'Iron Maiden', then quit-watch-later on
Hallowed Be Thy Name
This saves a redirect entry for "Iron Maiden", but not for "1982 The
Number of the Beast". It doesn't save redirect entries for the
directories above "Iron Maiden" either because "Iron Maiden" isn't
converted to an absolute path.
In both of these cases mpv --directory-mode=lazy 'Iron Maiden' won't
resume from "Hallowed Be Thy Name" because "1982 The Number of the
Beast" isn't the first subdirectory and there is no redirect entry for
it.
503dada42f made mpv recursively expand subdirectories precisely to fix
this, and f266eadf1e added back an option not to expand them. But if we
fix how redirect entries are stored, we can make the superior
--directory-mode=lazy (because it's faster and doesn't result in massive
playlists) the default, and also ensure that mpv will resume playback
even when you quit-watch-later a file without redirects and then play
the directories above it.
Fix this by always creating redirect entries for all segments of the absolute
path of the file, so that both
mpv 'Iron Maiden/1982 The Number of the Beast/8 Hallowed Be Thy Name.mp3'
and
mpv --directory-mode=lazy 'Iron Maiden'
will create redirect entries for
/$USER
/$USER/music
/$USER/music/Iron Maiden
/$USER/music/Iron Maiden/1982 The Number of the Beast
making mpv --directory-mode=lazy "Iron Maiden" resume from
"Hallowed Be Thy Name".
This commit also makes mpv delete the redirect entries of parent
directories when resuming playback, because if for example you have a
playlist with all the songs in a discography:
1980 Iron Maiden/1 Prowler.mp3
1980 Iron Maiden/2 Remember Tomorrow.mp3
...
1981 Killers/1 The Ides of March.mp3
1981 Killers/2 Wrathchild.mp3
...
Now mpv will eventually create redirect entries for every album. If you
later decide to play the directories instead and there are 20 albums,
you would have to do mpv * 20 times to clear all the redirect entries.
2023-08-27 19:26:44 +00:00
|
|
|
char *mp_normalize_path(void *talloc_ctx, const char *path);
|
|
|
|
|
2012-02-03 07:05:11 +00:00
|
|
|
bool mp_path_exists(const char *path);
|
|
|
|
bool mp_path_isdir(const char *path);
|
|
|
|
|
2013-09-04 12:04:35 +00:00
|
|
|
bool mp_is_url(bstr path);
|
|
|
|
|
2013-12-22 22:05:37 +00:00
|
|
|
bstr mp_split_proto(bstr path, bstr *out_url);
|
|
|
|
|
2014-06-18 23:55:40 +00:00
|
|
|
void mp_mkdirp(const char *dir);
|
2022-11-08 00:35:43 +00:00
|
|
|
void mp_mk_user_dir(struct mpv_global *global, const char *type, char *subdir);
|
2013-10-29 21:38:29 +00:00
|
|
|
|
2010-03-20 23:38:27 +00:00
|
|
|
#endif /* MPLAYER_PATH_H */
|