diff options
author | Harry Jeffery <harry@exec64.co.uk> | 2019-01-29 22:18:38 +0000 |
---|---|---|
committer | Harry Jeffery <harry@exec64.co.uk> | 2019-01-29 22:26:22 +0000 |
commit | ef3fab3d2164dd61671e821ee6334fcaf7cd6de2 (patch) | |
tree | 246f8ac1584b03744fb518e035b140aa64c26e42 /src | |
parent | 453d70f9b7431e703e9c8e51e2bc16caf35b7382 (diff) | |
download | imv-ef3fab3d2164dd61671e821ee6334fcaf7cd6de2.tar.gz |
imv: Use open_memory for stdin
Diffstat (limited to 'src')
-rw-r--r-- | src/imv.c | 26 |
1 files changed, 20 insertions, 6 deletions
@@ -705,6 +705,8 @@ int imv_run(struct imv *imv) const char *current_path = imv_navigator_selection(imv->navigator); /* check we got a path back */ if(strcmp("", current_path)) { + + const bool path_is_stdin = !strcmp("-", current_path); struct imv_source *new_source; enum backend_result result = BACKEND_UNSUPPORTED; @@ -714,7 +716,24 @@ int imv_run(struct imv *imv) } for (struct backend_chain *chain = imv->backends; chain; chain = chain->next) { const struct imv_backend *backend = chain->backend; - result = backend->open_path(current_path, &new_source); + if (path_is_stdin) { + + if (!backend->open_memory) { + /* memory loading unsupported by backend */ + continue; + } + + result = backend->open_memory(imv->stdin_image_data, + imv->stdin_image_data_len, &new_source); + } else { + + if (!backend->open_path) { + /* path loading unsupported by backend */ + continue; + } + + result = backend->open_path(current_path, &new_source); + } if (result == BACKEND_UNSUPPORTED) { /* Try the next backend */ continue; @@ -742,11 +761,6 @@ int imv_run(struct imv *imv) /* Error loading path so remove it from the navigator */ imv_navigator_remove(imv->navigator, current_path); } - - // TODO stdin - /* imv_loader_load(imv->loader, current_path, */ - /* imv->stdin_image_data, imv->stdin_image_data_len); */ - } } |