[vlc-commits] file out: ask for confirmation to overwrite file
Rémi Denis-Courmont
git at videolan.org
Tue Sep 4 11:15:17 CEST 2012
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue Sep 4 12:14:44 2012 +0300| [4dfda7ce68f29dad72da61188abf162c80aa3f65] | committer: Rémi Denis-Courmont
file out: ask for confirmation to overwrite file
To avoid disrupting existing workflows, the dialog is only shown when
overwrite is disabled. If there is no UI, then it will be assumed that
the file is not overwritten.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=4dfda7ce68f29dad72da61188abf162c80aa3f65
---
modules/access_output/file.c | 21 ++++++++++++++++++---
1 file changed, 18 insertions(+), 3 deletions(-)
diff --git a/modules/access_output/file.c b/modules/access_output/file.c
index ec874ec..99ebb89 100644
--- a/modules/access_output/file.c
+++ b/modules/access_output/file.c
@@ -41,6 +41,7 @@
#include <vlc_block.h>
#include <vlc_fs.h>
#include <vlc_strings.h>
+#include <vlc_dialog.h>
#if defined( WIN32 ) || defined( __OS2__ )
# include <io.h>
@@ -171,9 +172,23 @@ static int Open( vlc_object_t *p_this )
if (var_GetBool (p_access, SOUT_CFG_PREFIX"sync"))
flags |= O_SYNC;
#endif
- fd = vlc_open (path, flags, 0666);
- if (fd == -1)
- msg_Err (p_access, "cannot create %s: %m", path);
+ do
+ {
+ fd = vlc_open (path, flags, 0666);
+ if (fd != -1)
+ break;
+ if (fd == -1)
+ msg_Err (p_access, "cannot create %s: %m", path);
+ if (overwrite || errno != EEXIST)
+ break;
+ flags &= ~O_EXCL;
+ }
+ while (dialog_Question (p_access, path,
+ N_("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);
if (fd == -1)
return VLC_EGENERIC;
More information about the vlc-commits
mailing list