]> git.sesse.net Git - vlc/blobdiff - modules/access_output/file.c
Add includes guards to cdrom.h
[vlc] / modules / access_output / file.c
index 07ecaafe1f4517fd0a4f8e280d03b1079a7255c2..846a0b3fe5e6eb8a6313c504146dcf0695e73131 100644 (file)
@@ -1,25 +1,25 @@
 /*****************************************************************************
  * file.c
  *****************************************************************************
- * Copyright (C) 2001, 2002 the VideoLAN team
+ * Copyright (C) 2001, 2002 VLC authors and VideoLAN
  * $Id$
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *          Eric Petit <titer@videolan.org>
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
  * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
 /*****************************************************************************
@@ -34,6 +34,9 @@
 #include <time.h>
 #include <fcntl.h>
 #include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
 
 #include <vlc_common.h>
 #include <vlc_plugin.h>
 #include <vlc_strings.h>
 #include <vlc_dialog.h>
 
-#if defined( WIN32 ) || defined( __OS2__ )
+#if defined( _WIN32 ) || defined( __OS2__ )
 #   include <io.h>
 #endif
 
-#ifndef WIN32
+#ifndef _WIN32
 #   include <unistd.h>
 #endif
 
@@ -146,20 +149,22 @@ static int Open( vlc_object_t *p_this )
         fd = vlc_dup (fd);
         if (fd == -1)
         {
-            msg_Err (p_access, "cannot use file descriptor: %m");
+            msg_Err (p_access, "cannot use file descriptor: %s",
+                     vlc_strerror_c(errno));
             return VLC_EGENERIC;
         }
     }
     else
     if( !strcmp( p_access->psz_path, "-" ) )
     {
-#if defined( WIN32 ) || defined( __OS2__ )
+#if defined( _WIN32 ) || defined( __OS2__ )
         setmode (STDOUT_FILENO, O_BINARY);
 #endif
         fd = vlc_dup (STDOUT_FILENO);
         if (fd == -1)
         {
-            msg_Err (p_access, "cannot use standard output: %m");
+            msg_Err (p_access, "cannot use standard output: %s",
+                     vlc_strerror_c(errno));
             return VLC_EGENERIC;
         }
         msg_Dbg( p_access, "using stdout" );
@@ -191,7 +196,8 @@ static int Open( vlc_object_t *p_this )
             if (fd != -1)
                 break;
             if (fd == -1)
-                msg_Err (p_access, "cannot create %s: %m", path);
+                msg_Err (p_access, "cannot create %s: %s", path,
+                         vlc_strerror_c(errno));
             if (overwrite || errno != EEXIST)
                 break;
             flags &= ~O_EXCL;
@@ -243,6 +249,17 @@ static int Control( sout_access_out_t *p_access, int i_query, va_list args )
             break;
         }
 
+        case ACCESS_OUT_CAN_SEEK:
+        {
+            bool *pb = va_arg( args, bool * );
+            struct stat st;
+            if( fstat( (intptr_t)p_access->p_sys, &st ) == -1 )
+                *pb = false;
+            else
+                *pb = S_ISREG( st.st_mode ) || S_ISBLK( st.st_mode );
+            break;
+        }
+
         default:
             return VLC_EGENERIC;
     }
@@ -279,7 +296,7 @@ static ssize_t Write( sout_access_out_t *p_access, block_t *p_buffer )
             if (errno == EINTR)
                 continue;
             block_ChainRelease (p_buffer);
-            msg_Err( p_access, "cannot write: %m" );
+            msg_Err( p_access, "cannot write: %s", vlc_strerror_c(errno) );
             return -1;
         }