# HG changeset patch # User arpi # Date 1023410528 0 # Node ID 12136df07dbdc06cb35ed8de760b370db0fb1091 # Parent 76baa05a63abf26848270c55e149aeee03e99883 common code to handle file/stdin/fifo opening, allows using named pipes and seeking with direct file redirection (mplayer < file.avi) based on patch by Eric Lammerts diff -r 76baa05a63ab -r 12136df07dbd libmpdemux/open.c --- a/libmpdemux/open.c Fri Jun 07 00:30:32 2002 +0000 +++ b/libmpdemux/open.c Fri Jun 07 00:42:08 2002 +0000 @@ -417,15 +417,6 @@ return(stream); } - -//============ Open STDIN ============ - if(!strcmp(filename,"-")){ - // read from stdin - mp_msg(MSGT_OPEN,MSGL_INFO,MSGTR_ReadSTDIN); - f=0; // 0=stdin - stream=new_stream(f,STREAMTYPE_STREAM); - return stream; - } #ifdef STREAMING url = url_new(filename); @@ -442,13 +433,20 @@ } #endif -//============ Open plain FILE ============ +//============ Open STDIN or plain FILE ============ + if(!strcmp(filename,"-")){ + // read from stdin + mp_msg(MSGT_OPEN,MSGL_INFO,MSGTR_ReadSTDIN); + f=0; // 0=stdin + } else { f=open(filename,O_RDONLY); if(f<0){ mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_FileNotFound,filename);return NULL; } + } + len=lseek(f,0,SEEK_END); lseek(f,0,SEEK_SET); if (len == -1) - perror("Error: lseek failed to obtain video file size"); - else + return new_stream(f,STREAMTYPE_STREAM); // open as stream + #ifdef _LARGEFILE_SOURCE mp_msg(MSGT_OPEN,MSGL_V,"File size is %lld bytes\n", (long long)len); #else @@ -457,7 +455,6 @@ stream=new_stream(f,STREAMTYPE_FILE); stream->end_pos=len; return stream; - } int dvd_parse_chapter_range(struct config *conf, const char *range){