Commit 41439afe authored by Segher Boessenkool's avatar Segher Boessenkool

When using a temporary file, set the mode of the old file on the new file.

Closes #136.

svn path=/trunk/vorbis-tools/; revision=2982
parent 2aa4f66e
......@@ -12,6 +12,9 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <locale.h>
#include "getopt.h"
#include "utf8.h"
......@@ -478,6 +481,12 @@ void close_files(param_t *p)
if (p->out != NULL && p->out != stdout) fclose(p->out);
if (p->com != NULL && p->com != stdout && p->com != stdin) fclose(p->com);
if(p->tempoutfile)
if(p->tempoutfile) {
/* this is not portable to non-posix systems */
struct stat st;
stat(p->infilename, &st);
rename(p->outfilename, p->infilename);
chmod(p->infilename, st.st_mode);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment