]> git.sesse.net Git - vlc/blobdiff - modules/access_output/file.c
msi: cleaning and cosmetics
[vlc] / modules / access_output / file.c
index 99ebb8969c5fb787bc286aaa3ecc4758cd441ecd..07ecaafe1f4517fd0a4f8e280d03b1079a7255c2 100644 (file)
@@ -68,6 +68,9 @@ static void Close( vlc_object_t * );
 #define APPEND_TEXT N_("Append to file")
 #define APPEND_LONGTEXT N_( "Append to file if it exists instead " \
                             "of replacing it.")
+#define FORMAT_TEXT N_("Format time and date")
+#define FORMAT_LONGTEXT N_("Perform ISO C time and date formatting " \
+    "on the file path")
 #define SYNC_TEXT N_("Synchronous writing")
 #define SYNC_LONGTEXT N_( "Open the file with synchronous writing.")
 
@@ -82,6 +85,8 @@ vlc_module_begin ()
               OVERWRITE_LONGTEXT, true )
     add_bool( SOUT_CFG_PREFIX "append", false, APPEND_TEXT,APPEND_LONGTEXT,
               true )
+    add_bool( SOUT_CFG_PREFIX "format", false, FORMAT_TEXT, FORMAT_LONGTEXT,
+              true )
 #ifdef O_SYNC
     add_bool( SOUT_CFG_PREFIX "sync", false, SYNC_TEXT,SYNC_LONGTEXT,
               false )
@@ -95,6 +100,7 @@ vlc_module_end ()
  *****************************************************************************/
 static const char *const ppsz_sout_options[] = {
     "append",
+    "format",
     "overwrite",
 #ifdef O_SYNC
     "sync",
@@ -160,8 +166,15 @@ static int Open( vlc_object_t *p_this )
     }
     else
     {
-        char *path = str_format_time (p_access->psz_path);
-        path_sanitize (path);
+        const char *path = p_access->psz_path;
+        char *buf = NULL;
+
+        if (var_InheritBool (p_access, SOUT_CFG_PREFIX"format"))
+        {
+            buf = str_format_time (path);
+            path_sanitize (buf);
+            path = buf;
+        }
 
         int flags = O_RDWR | O_CREAT | O_LARGEFILE;
         if (!overwrite)
@@ -184,12 +197,12 @@ static int Open( vlc_object_t *p_this )
             flags &= ~O_EXCL;
         }
         while (dialog_Question (p_access, path,
-                                N_("The output file already exists. "
+                                _("The output file already exists. "
                                 "If recording continues, the file will be "
-                                "overriden and its content will be lost."),
-                                N_("Keep existing file"),
-                                N_("Overwrite"), NULL) == 2);
-        free (path);
+                                "overridden and its content will be lost."),
+                                _("Keep existing file"),
+                                _("Overwrite"), NULL) == 2);
+        free (buf);
         if (fd == -1)
             return VLC_EGENERIC;
     }
@@ -261,11 +274,12 @@ static ssize_t Write( sout_access_out_t *p_access, block_t *p_buffer )
     {
         ssize_t val = write ((intptr_t)p_access->p_sys,
                              p_buffer->p_buffer, p_buffer->i_buffer);
-        if (val == -1)
+        if (val <= 0)
         {
             if (errno == EINTR)
                 continue;
             block_ChainRelease (p_buffer);
+            msg_Err( p_access, "cannot write: %m" );
             return -1;
         }