Revert "various: expand paths for all file/directory related options"
Since the option system now handles all the path expansion
automatically, these recent changes can be reverted for simplicity.
This reverts commit be15be3a83.
This commit is contained in:
1 parent
afbd3abb20
commit
43fda5442f
13 files changed
+27
-49
No files matched your search
+1
-2
@@ -28,7 +28,6 @@
|
||||
#include "mpv_talloc.h"
|
||||
|
||||
#include "options/m_option.h"
|
||||
#include "options/path.h"
|
||||
#include "audio/format.h"
|
||||
#include "ao.h"
|
||||
#include "internal.h"
|
||||
@@ -110,7 +109,7 @@ static int init(struct ao *ao)
|
||||
{
|
||||
struct priv *priv = ao->priv;
|
||||
|
||||
char *outputfilename = mp_get_user_path(priv, ao->global, priv->outputfilename);
|
||||
char *outputfilename = priv->outputfilename;
|
||||
if (!outputfilename) {
|
||||
outputfilename = talloc_strdup(priv, priv->waveheader ? "audiodump.wav"
|
||||
: "audiodump.pcm");
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
#include "options/m_config.h"
|
||||
#include "options/m_option.h"
|
||||
#include "options/options.h"
|
||||
#include "options/path.h"
|
||||
#include "osdep/timer.h"
|
||||
#include "video/out/vo.h"
|
||||
#include "mpv_talloc.h"
|
||||
@@ -134,9 +133,7 @@ struct encode_lavc_context *encode_lavc_init(struct mpv_global *global)
|
||||
|
||||
p->muxer->oformat = ctx->oformat;
|
||||
|
||||
char *path = mp_get_user_path(NULL, global, filename);
|
||||
p->muxer->url = av_strdup(path);
|
||||
talloc_free(path);
|
||||
p->muxer->url = av_strdup(filename);
|
||||
MP_HANDLE_OOM(p->muxer->url);
|
||||
|
||||
return ctx;
|
||||
|
||||
+1
-3
@@ -404,12 +404,11 @@ struct playlist *playlist_parse_file(const char *file, struct mp_cancel *cancel,
|
||||
struct mp_log *log = mp_log_new(NULL, global->log, "!playlist_parser");
|
||||
mp_verbose(log, "Parsing playlist file %s...\n", file);
|
||||
|
||||
char *path = mp_get_user_path(NULL, global, file);
|
||||
struct demuxer_params p = {
|
||||
.force_format = "playlist",
|
||||
.stream_flags = STREAM_ORIGIN_DIRECT,
|
||||
};
|
||||
struct demuxer *d = demux_open_url(path, &p, cancel, global);
|
||||
struct demuxer *d = demux_open_url(file, &p, cancel, global);
|
||||
struct playlist *ret = NULL;
|
||||
if (!d)
|
||||
goto done;
|
||||
@@ -436,7 +435,6 @@ struct playlist *playlist_parse_file(const char *file, struct mp_cancel *cancel,
|
||||
|
||||
done:
|
||||
talloc_free(log);
|
||||
talloc_free(path);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -115,7 +115,7 @@ void mp_init_paths(struct mpv_global *global, struct MPOpts *opts)
|
||||
if (!opts->load_config)
|
||||
force_configdir = "";
|
||||
|
||||
global->configdir = mp_get_user_path(global, global, force_configdir);
|
||||
global->configdir = talloc_strdup(global, force_configdir);
|
||||
}
|
||||
|
||||
char *mp_find_user_file(void *talloc_ctx, struct mpv_global *global,
|
||||
|
||||
+2
-5
@@ -857,11 +857,8 @@ int mp_add_external_file(struct MPContext *mpctx, char *filename,
|
||||
|
||||
mp_core_unlock(mpctx);
|
||||
|
||||
char *path = mp_get_user_path(NULL, mpctx->global, filename);
|
||||
struct demuxer *demuxer =
|
||||
demux_open_url(path, ¶ms, cancel, mpctx->global);
|
||||
talloc_free(path);
|
||||
|
||||
demux_open_url(filename, ¶ms, cancel, mpctx->global);
|
||||
if (demuxer)
|
||||
enable_demux_thread(mpctx, demuxer);
|
||||
|
||||
@@ -1079,7 +1076,7 @@ static void load_chapters(struct MPContext *mpctx)
|
||||
bool free_src = false;
|
||||
char *chapter_file = mpctx->opts->chapter_file;
|
||||
if (chapter_file && chapter_file[0]) {
|
||||
chapter_file = mp_get_user_path(NULL, mpctx->global, chapter_file);
|
||||
chapter_file = talloc_strdup(NULL, chapter_file);
|
||||
mp_core_unlock(mpctx);
|
||||
struct demuxer_params p = {
|
||||
.stream_flags = STREAM_ORIGIN_DIRECT,
|
||||
|
||||
+1
-4
@@ -31,7 +31,6 @@
|
||||
#include "options/options.h"
|
||||
#include "options/m_property.h"
|
||||
#include "options/m_config.h"
|
||||
#include "options/path.h"
|
||||
#include "common/common.h"
|
||||
#include "common/encode.h"
|
||||
#include "common/playlist.h"
|
||||
@@ -270,7 +269,6 @@ int stream_dump(struct MPContext *mpctx, const char *source_filename)
|
||||
struct MPOpts *opts = mpctx->opts;
|
||||
bool ok = false;
|
||||
|
||||
char *filename = mp_get_user_path(NULL, mpctx->global, opts->stream_dump);
|
||||
stream_t *stream = stream_create(source_filename,
|
||||
STREAM_ORIGIN_DIRECT | STREAM_READ,
|
||||
mpctx->playback_abort, mpctx->global);
|
||||
@@ -279,7 +277,7 @@ int stream_dump(struct MPContext *mpctx, const char *source_filename)
|
||||
|
||||
int64_t size = stream_get_size(stream);
|
||||
|
||||
FILE *dest = fopen(filename, "wb");
|
||||
FILE *dest = fopen(opts->stream_dump, "wb");
|
||||
if (!dest) {
|
||||
MP_ERR(mpctx, "Error opening dump file: %s\n", mp_strerror(errno));
|
||||
goto done;
|
||||
@@ -307,7 +305,6 @@ int stream_dump(struct MPContext *mpctx, const char *source_filename)
|
||||
ok &= fclose(dest) == 0;
|
||||
done:
|
||||
free_stream(stream);
|
||||
talloc_free(filename);
|
||||
return ok ? 0 : -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -431,9 +431,7 @@ static int bluray_stream_open_internal(stream_t *s)
|
||||
bd_set_debug_mask(0);
|
||||
|
||||
/* open device */
|
||||
char *device_tmp = mp_get_user_path(NULL, s->global, device);
|
||||
BLURAY *bd = bd_open(device_tmp, NULL);
|
||||
talloc_free(device_tmp);
|
||||
BLURAY *bd = bd_open(device, NULL);
|
||||
if (!bd) {
|
||||
MP_ERR(s, "Couldn't open Blu-ray device: %s\n", device);
|
||||
ret = STREAM_UNSUPPORTED;
|
||||
|
||||
@@ -38,7 +38,6 @@
|
||||
#include "options/m_option.h"
|
||||
#include "options/m_config.h"
|
||||
#include "options/options.h"
|
||||
#include "options/path.h"
|
||||
|
||||
#if !HAVE_GPL
|
||||
#error GPL only
|
||||
@@ -254,11 +253,11 @@ static int open_cdda(stream_t *st)
|
||||
int last_track;
|
||||
|
||||
if (st->path[0]) {
|
||||
p->device = talloc_strdup(priv, st->path);
|
||||
p->device = st->path;
|
||||
} else if (p->cdda_device && p->cdda_device[0]) {
|
||||
p->device = mp_get_user_path(priv, st->global, p->cdda_device);
|
||||
p->device = p->cdda_device;
|
||||
} else {
|
||||
p->device = talloc_strdup(priv, DEFAULT_OPTICAL_DEVICE);
|
||||
p->device = DEFAULT_OPTICAL_DEVICE;
|
||||
}
|
||||
|
||||
#if defined(__NetBSD__)
|
||||
|
||||
+3
-2
@@ -1118,11 +1118,12 @@ dvb_state_t *dvb_get_state(stream_t *stream)
|
||||
continue;
|
||||
}
|
||||
|
||||
void *talloc_ctx = talloc_new(NULL);
|
||||
void *talloc_ctx = NULL;
|
||||
char *conf_file;
|
||||
if (priv->opts->cfg_file && priv->opts->cfg_file[0]) {
|
||||
conf_file = mp_get_user_path(talloc_ctx, global, priv->opts->cfg_file);
|
||||
conf_file = priv->opts->cfg_file;
|
||||
} else {
|
||||
talloc_ctx = talloc_new(NULL);
|
||||
conf_file = mp_find_config_file(talloc_ctx, global, conf_file_name);
|
||||
if (conf_file) {
|
||||
mp_verbose(log, "Ignoring other channels.conf files.\n");
|
||||
|
||||
@@ -552,7 +552,7 @@ static struct priv *new_dvdnav_stream(stream_t *stream, char *filename)
|
||||
if (!filename)
|
||||
return NULL;
|
||||
|
||||
if (!(priv->filename = mp_get_user_path(priv, stream->global, filename)))
|
||||
if (!(priv->filename = talloc_strdup(priv, filename)))
|
||||
return NULL;
|
||||
|
||||
priv->dvd_speed = priv->opts->speed;
|
||||
|
||||
+7
-11
@@ -29,7 +29,6 @@
|
||||
#include "config.h"
|
||||
#include "options/m_config.h"
|
||||
#include "options/options.h"
|
||||
#include "options/path.h"
|
||||
#include "common/common.h"
|
||||
#include "common/msg.h"
|
||||
#include "demux/demux.h"
|
||||
@@ -109,14 +108,11 @@ static const struct sd_filter_functions *const filters[] = {
|
||||
|
||||
// Add default styles, if the track does not have any styles yet.
|
||||
// Apply style overrides if the user provides any.
|
||||
static void mp_ass_add_default_styles(struct sd *sd, ASS_Track *track, struct mp_subtitle_opts *opts,
|
||||
struct mp_subtitle_shared_opts *shared_opts)
|
||||
static void mp_ass_add_default_styles(ASS_Track *track, struct mp_subtitle_opts *opts,
|
||||
struct mp_subtitle_shared_opts *shared_opts, int order)
|
||||
{
|
||||
if (opts->ass_styles_file && shared_opts->ass_style_override[sd->order]) {
|
||||
char *file = mp_get_user_path(NULL, sd->global, opts->ass_styles_file);
|
||||
ass_read_styles(track, file, NULL);
|
||||
talloc_free(file);
|
||||
}
|
||||
if (opts->ass_styles_file && shared_opts->ass_style_override[order])
|
||||
ass_read_styles(track, opts->ass_styles_file, NULL);
|
||||
|
||||
if (track->n_styles == 0) {
|
||||
if (!track->PlayResY) {
|
||||
@@ -131,7 +127,7 @@ static void mp_ass_add_default_styles(struct sd *sd, ASS_Track *track, struct mp
|
||||
mp_ass_set_style(style, track->PlayResY, opts->sub_style);
|
||||
}
|
||||
|
||||
if (shared_opts->ass_style_override[sd->order])
|
||||
if (shared_opts->ass_style_override[order])
|
||||
ass_process_force_style(track);
|
||||
}
|
||||
|
||||
@@ -260,7 +256,7 @@ static void assobjects_init(struct sd *sd)
|
||||
ctx->shadow_track = ass_new_track(ctx->ass_library);
|
||||
ctx->shadow_track->PlayResX = MP_ASS_FONT_PLAYRESX;
|
||||
ctx->shadow_track->PlayResY = MP_ASS_FONT_PLAYRESY;
|
||||
mp_ass_add_default_styles(sd, ctx->shadow_track, opts, shared_opts);
|
||||
mp_ass_add_default_styles(ctx->shadow_track, opts, shared_opts, sd->order);
|
||||
|
||||
char *extradata = sd->codec->extradata;
|
||||
int extradata_size = sd->codec->extradata_size;
|
||||
@@ -271,7 +267,7 @@ static void assobjects_init(struct sd *sd)
|
||||
if (extradata)
|
||||
ass_process_codec_private(ctx->ass_track, extradata, extradata_size);
|
||||
|
||||
mp_ass_add_default_styles(sd, ctx->ass_track, opts, shared_opts);
|
||||
mp_ass_add_default_styles(ctx->ass_track, opts, shared_opts, sd->order);
|
||||
|
||||
#if LIBASS_VERSION >= 0x01302000
|
||||
ass_set_check_readorder(ctx->ass_track, sd->opts->sub_clear_on_seek ? 0 : 1);
|
||||
|
||||
@@ -44,7 +44,6 @@
|
||||
#include "common/msg.h"
|
||||
#include "misc/ctype.h"
|
||||
#include "options/m_config.h"
|
||||
#include "options/path.h"
|
||||
#include "osdep/io.h"
|
||||
#include "osdep/poll_wrapper.h"
|
||||
#include "osdep/timer.h"
|
||||
@@ -944,7 +943,7 @@ static bool card_has_connection(const char *path)
|
||||
static void get_primary_device_path(struct vo_drm_state *drm)
|
||||
{
|
||||
if (drm->opts->device_path) {
|
||||
drm->card_path = mp_get_user_path(drm, drm->vo->global, drm->opts->device_path);
|
||||
drm->card_path = talloc_strdup(drm, drm->opts->device_path);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -66,16 +66,13 @@ struct priv {
|
||||
struct vo_image_opts *opts;
|
||||
|
||||
struct mp_image *current;
|
||||
char *dir;
|
||||
int frame;
|
||||
};
|
||||
|
||||
static bool checked_mkdir(struct vo *vo, const char *buf)
|
||||
{
|
||||
struct priv *p = vo->priv;
|
||||
p->dir = mp_get_user_path(vo, vo->global, buf);
|
||||
MP_INFO(vo, "Creating output directory '%s'...\n", p->dir);
|
||||
if (mkdir(p->dir, 0755) < 0) {
|
||||
MP_INFO(vo, "Creating output directory '%s'...\n", buf);
|
||||
if (mkdir(buf, 0755) < 0) {
|
||||
char *errstr = mp_strerror(errno);
|
||||
if (errno == EEXIST) {
|
||||
struct stat stat_p;
|
||||
@@ -120,8 +117,8 @@ static void flip_page(struct vo *vo)
|
||||
char *filename = talloc_asprintf(t, "%08d.%s", p->frame,
|
||||
image_writer_file_ext(p->opts->opts));
|
||||
|
||||
if (p->dir && strlen(p->dir))
|
||||
filename = mp_path_join(t, p->dir, filename);
|
||||
if (p->opts->outdir && strlen(p->opts->outdir))
|
||||
filename = mp_path_join(t, p->opts->outdir, filename);
|
||||
|
||||
MP_INFO(vo, "Saving %s\n", filename);
|
||||
write_image(p->current, p->opts->opts, filename, vo->global, vo->log, true);
|
||||
|
||||
Reference in new issue
Block a user