summaryrefslogtreecommitdiffstats
path: root/options/path.c
Commit message (Collapse)AuthorAgeFilesLines
* path: cosmeticslzmths2015-12-021-3/+5
| | | | | | Avoiding conditional directives that split up parts of statements. Signed-off-by: wm4 <wm4@nowhere>
* player: prefer logical current directory pathwm42015-09-111-0/+4
| | | | | | | The "PWD" enviornment variable is described by POSIX. We don't go to length to verify its contents, but just trust it. This affects the logic for resuming playback.
* options: fix --no-configwm42015-09-051-1/+3
| | | | | | | | | | | | | | | | | | This was completely broken. It was checked manually in some config loading paths, so it appeared to work. But the intention was always to completely disable reading from the normal config dir. This logic was broken in commit 2263f37d. The manual checks are actually redundant, and are not needed if --no-config is implemented properly - remove them. Additionally, the change to load the libmpv defaults from an embedded profile also failed to set "config=no". The option is marked as not being settable by a config file, and the libmpv default profile is parsed as a config file, so this option was rejected. Fix it by removing the CONF_NOCFG flag. (Alternatively, m_config_set_profile() could be changed not to set the "config file" flag by default, but I'm not bothering with this.)
* path: improve verbose loggingwm42015-05-091-8/+8
|
* path: use mp_path_join in one more placewm42015-05-091-1/+1
|
* player: make resuming playlists less noisy in verbose modewm42015-05-091-8/+15
| | | | | | | | | | | | | | | | | | | mp_find_config_file() will print the filename lookup and its result in verbose mode. This is wanted, but gets inconvenient when it is done for every playlist entry (for resuming). Lookup the watch_later subdir only once and cache the result instead. This drops the logic for loading the resume file from other locations, which should generally be unnecessary, though might lead to confusion if the user has mixed old and new config paths (which the user shouldn't). Also add a mp_find_user_config_file() function for a more straightforward and reliable way to get actual local configpaths, instead of possibly global and unwritable locations. Also, for symmetry, check the resume option in mp_load_playback_resume() just like mp_check_playlist_resume() does.
* path: make mp_path_join accept normal C stringswm42015-05-091-3/+8
| | | | | Instead of bstr. Most callers of this function do not need bstr. The bstr version of this function is now mp_path_join_bstr().
* path: unify the two config file lookup functionswm42015-05-091-83/+60
| | | | | | | | | | | Share most of the implementation of config file lookup between mp_find_all_config_files() and mp_find_config_file(). Also move the check for config path overrides to mp_get_platform_path() directly. From the point of view of config file lookup, this is a bit stupid, but on the other hand increases consistency, as user path resolution exposes the mp_get_platform_path() functionality directly to the user.
* path: start special espansion with ~~name instead of ~namewm42015-05-031-1/+1
| | | | | | | Since commit 7381db60, strings like "~desktop/" were expanded as platform-specific paths by mpv. Apparently this similarity to standard Unix shell expansion caused confusion, so change it to "~~desktop/". The shell doesn't expand this, so it should be better.
* path: fix user path resolutionwm42015-05-011-2/+2
| | | | Forgot to add the remainder to the path.
* path: expose platform-specific path resolverswm42015-05-011-0/+5
|
* path: refactorwm42015-05-011-43/+40
| | | | | | | | | | | | | | Somewhat less ifdeffery, higher flexibility. Now there are 3 separate config file resolvers for 3 platforms (unix, win, osx), and they can still interact with each other somewhat. For example, OSX for now uses most of Unix, but adds the OSX bundle path. This can be extended to resolve very specific platform paths, such as location of the desktop. Most of the Unix specific code moves to path-unix.c. The behavior should be the same - if not, it is likely a bug.
* Update license headersMarcin Kurczewski2015-04-131-5/+4
| | | | Signed-off-by: wm4 <wm4@nowhere>
* win32: fix some more -Wparentheses warningswm42015-03-041-2/+2
| | | | | | | Stupid compiler. For decode_surrogate_pair(), I changed the order of evaluation; it shouldn't matter, but this order is more readable in my opinion.
* player: undeprecate 'config' fileswm42015-02-151-6/+9
| | | | | | | Actually, it's pretty simple to look for multiple filenames at once, since mp_find_all_config_files() is already a bit "special" anyway. See #1569. Reverts most of commit db167cd4 (keeps osx-bundle.conf).
* build: rename MPLAYER_CONFDIR definewm42015-01-021-1/+1
| | | | | | We certainly don't use the mplayer configuration dir. The name didn't matter, but now that it's in user-visible output (as part of config.h being dumped in verbose mode), it's a bit too strange.
* win32: silence some warningsJames Ross-Gowan2014-11-081-0/+2
| | | | Signed-off-by: wm4 <wm4@nowhere>
* win32: get rid of mp_stat in the normal source codewm42014-10-171-2/+2
| | | | | | | | | | | mp_stat() instead of stat() was used in the normal code (i.e. even on Unix), because MinGW-w64 has an unbelievable macro-mess in place, which prevents solving this elegantly. Add some dirty workarounds to hide mp_stat() from the normal code properly. This now requires replacing all functions that use the struct stat type. This includes fstat, lstat, fstatat, and possibly others. (mpv currently uses stat and fstat only.)
* path: remove XDG bullshitwm42014-09-031-23/+1
| | | | | | | | | | | | | Don't worry, your ~/.config/... paths are safe. This merely removes handling of $XDG_CONFIG_DIRS for global paths. Maybe there is a better solution for this, like still including the "traditional" config dir. But I will leave the fine reading of this (crappy) spec and fixing the code accordingly to someone else. So, if anyone has interest in getting this behavior back, you will have to write a patch. This patch should _also_ not break expected behavior. Fixes #1060.
* config: use the same signature for win32/OSX specific path functionswm42014-06-261-6/+7
| | | | | | | | Seems like a good idea, even if it's basically unused (yet). Also document requirements on the functions (they're not obvious). OSX changes untested.
* config: handle --no-config case directly in mp_config_dirs()wm42014-06-261-26/+23
| | | | | Requires less special-casing, and probably also avoids that starting mpv with --no-config creates a config dir (even if nothing is loaded).
* config, player: avoid some temporary talloc contextswm42014-06-261-13/+14
| | | | | IMO a semi-bad concept, that the mpv code unfortunately uses way too much.
* config: make passing talloc context optional for some functionswm42014-06-261-17/+21
| | | | | | | | | | | | | | | | Until now, the config functions added various allocations to the user- provided talloc context. Make it so that they're all under the returned allocation instead. This allows avoiding having to create an extra temporary context for some callers, and also avoids adding random memory leaks by accidentally passing a NULL context. mp_find_all_config_files() has to be changed not to return a pointer into the middle array for this to work. Make it add paths in order (instead of reverse), and then reverse the array entries after that. Also remove the declarations for the win-specific private functions. Remove STRNULL(); it's barely needed anymore and the functions are not called with NULL filenames anymore.
* player: create config dir if it doesn't existwm42014-06-261-4/+1
| | | | | | | This was dropped in the commit adding XDG support, probably accidentally. Also normalize some whitespace.
* config: prefer the old config dir if it exists, but XDG doesn'twm42014-06-261-6/+14
| | | | | | | | | | | This means normally the XDG config dir will be used. But if the old config dir (~/.mpv) exists and the XDG config dir does not, then don't create it. To simplify the code, also make mp_path_exists() accept NULL paths. In that case it's considered as not existing. (Funnily, on Linux this already worked, because the string is passed directly to the kernel, and the kernel will just return EFAULT on invalid memory.)
* Basic xdg directory implementationKenneth Zhou2014-06-261-71/+131
| | | | | | | | | | Search $XDG_CONFIG_HOME and $XDG_CONFIG_DIRS for config files. This also negates the need to have separate user and global variants of mp_find_config_file() Closes #864, #109. Signed-off-by: wm4 <wm4@nowhere>
* config: fix --config-dir logic for global config fileswm42014-02-281-1/+1
| | | | | Global config files should be loaded only when --no-config is missing _and_ --config-dir is not set.
* config: always print resolved config paths in verbose modewm42014-02-251-50/+63
| | | | | Restructure the code to make that easier. There should be no functional changes, other than the log call at the end of each function.
* config: add a --config-dir option to force config directorywm42014-02-251-0/+15
| | | | Useful for slave-mode like uses, and not as radical as --no-config.
* options: make --no-config block all auto-loaded configuration fileswm42014-02-141-0/+11
| | | | | | | | | | | | Until now, the --no-config was explicitly checked in multiple places to suppress loading of config files. Add such a check to the config path code itself, and refuse to resolve _any_ configuration file locations if the option is set. osc.lua needs a small fixup, because it didn't handle the situation when no path was returned. There may some of such cases in the C code too, but I didn't find any on a quick look.
* path: add function to split URL into prefix and pathwm42013-12-221-0/+11
| | | | Used in the following commit.
* path: don't accept empty protocol as validwm42013-12-221-1/+1
| | | | mp_is_url("://") returned true.
* path: change mp_splitext() semanticswm42013-12-221-4/+4
| | | | | | | | | Including the "." in the returned extension was too inconvenient. I think originally, the semantics were supposed to work like in Python, but screw this. Also, return NULL instead of "" on failure (which is what its only user actually seems to expect).
* path lookup functions: mp_msg conversionswm42013-12-211-17/+23
| | | | | | | | | | | | | | | | | There's a single mp_msg() in path.c, but all path lookup functions seem to depend on it, so we get a rat-tail of stuff we have to change. This is probably a good thing though, because we can have the path lookup functions also access options, so we could allow overriding the default config path, or ignore the MPV_HOME environment variable, and such things. Also take the chance to consistently add talloc_ctx parameters to the path lookup functions. Also, this change causes a big mess on configfiles.c. It's the same issue: everything suddenly needs a (different) context argument. Make it less wild by providing a mp_load_auto_profiles() function, which isolates most of it to configfiles.c.
* Split mpvcore/ into common/, misc/, bstr/wm42013-12-171-1/+1
|
* Move options/config related files from mpvcore/ to options/wm42013-12-171-0/+238
Since m_option.h and options.h are extremely often included, a lot of files have to be changed. Moving path.c/h to options/ is a bit questionable, but since this is mainly about access to config files (which are also handled in options/), it's probably ok.