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;
|
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
|
|
|
|
2015-05-09 14:21:44 +00:00
|
|
|
// Like mp_find_config_file(), but search only the local writable user config
|
|
|
|
// dir. Also, this returns a result even if the file does not exist. Calling
|
|
|
|
// it with filename="" is equivalent to retrieving the user config dir.
|
|
|
|
char *mp_find_user_config_file(void *talloc_ctx, struct mpv_global *global,
|
|
|
|
const char *filename);
|
|
|
|
|
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
|
|
|
|
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);
|
|
|
|
|
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);
|
2013-12-21 19:45:19 +00:00
|
|
|
void mp_mk_config_dir(struct mpv_global *global, char *subdir);
|
2013-10-29 21:38:29 +00:00
|
|
|
|
2010-03-20 23:38:27 +00:00
|
|
|
#endif /* MPLAYER_PATH_H */
|