]> git.sesse.net Git - x264/commitdiff
Fix input support from named pipes in Windows
authorAnton Mitrofanov <BugMaster@narod.ru>
Fri, 3 Jan 2014 16:06:06 +0000 (20:06 +0400)
committerFiona Glaser <fiona@x264.com>
Wed, 8 Jan 2014 19:15:44 +0000 (11:15 -0800)
common/osdep.c
common/osdep.h

index 7564f654cb687a86a3e943aa3b57883d53a7c25d..bc3692a1b2d0a26d342d39bcb12e131cb327e22c 100644 (file)
@@ -199,4 +199,12 @@ int x264_vfprintf( FILE *stream, const char *format, va_list arg )
     }
     return vfprintf( stream, format, arg );
 }
+
+int x264_is_pipe( const char *path )
+{
+    wchar_t path_utf16[MAX_PATH];
+    if( utf8_to_utf16( path, path_utf16 ) )
+        return WaitNamedPipeW( path_utf16, 0 );
+    return 0;
+}
 #endif
index 054953d38fd8405ee6393ebc52ae04904fb8bfb9..ea6eb0859840f68873be696993b3924e0ffe6860 100644 (file)
@@ -78,6 +78,7 @@ int x264_rename( const char *oldname, const char *newname );
 #define x264_fstat _fstati64
 int x264_stat( const char *path, x264_struct_stat *buf );
 int x264_vfprintf( FILE *stream, const char *format, va_list arg );
+int x264_is_pipe( const char *path );
 #else
 #define x264_fopen       fopen
 #define x264_rename      rename
@@ -85,6 +86,7 @@ int x264_vfprintf( FILE *stream, const char *format, va_list arg );
 #define x264_fstat       fstat
 #define x264_stat        stat
 #define x264_vfprintf    vfprintf
+#define x264_is_pipe(x)  0
 #endif
 
 #ifdef __ICL
@@ -377,19 +379,19 @@ static ALWAYS_INLINE void x264_prefetch( void *p )
 #define x264_lower_thread_priority(p)
 #endif
 
-static inline uint8_t x264_is_regular_file( FILE *filehandle )
+static inline int x264_is_regular_file( FILE *filehandle )
 {
     x264_struct_stat file_stat;
     if( x264_fstat( fileno( filehandle ), &file_stat ) )
-        return -1;
+        return 1;
     return S_ISREG( file_stat.st_mode );
 }
 
-static inline uint8_t x264_is_regular_file_path( const char *filename )
+static inline int x264_is_regular_file_path( const char *filename )
 {
     x264_struct_stat file_stat;
     if( x264_stat( filename, &file_stat ) )
-        return -1;
+        return !x264_is_pipe( filename );
     return S_ISREG( file_stat.st_mode );
 }