Skip to content
This repository has been archived by the owner on Apr 14, 2020. It is now read-only.

Commit

Permalink
Fix incorrect behavior of file_exists checkup
Browse files Browse the repository at this point in the history
when working with docker volumes.

Avoid misleading "Input file not found" error message when file actually exists.
  • Loading branch information
Piotr authored and Ullaakut committed Jun 22, 2018
1 parent dee16f0 commit c125921
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/file_input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
#include <gst/app/gstappsrc.h>
#include <iostream>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>


typedef struct _App App;
struct _App {
Expand Down Expand Up @@ -82,6 +85,12 @@ gboolean bus_callback(GstBus *bus, GstMessage *msg, gpointer data) {
return TRUE;
}

inline bool file_exists (const std::string& name) {
struct stat buffer;
std::string corrected_name = name.substr(5);
return (stat (corrected_name.c_str(), &buffer) == 0);
}

bool configure_file_input(t_server *serv) {
// Setup and configuration
App *app = &s_app;
Expand All @@ -100,8 +109,11 @@ bool configure_file_input(t_server *serv) {
g_signal_connect(serv->factory, "media-configure", (GCallback)media_configure,
app);

if (access(input_path.c_str(), F_OK) != -1) {
if (file_exists(input_path)) {
return true;
}
else {
std::cerr << "Can't access " << input_path.c_str() << std::endl;
}
return false;
}

0 comments on commit c125921

Please sign in to comment.