Improved removal of temp output file in case of errors.
committer: mfx <mfx> 975606039 +0000
This commit is contained in:
+18
-11
@@ -125,7 +125,7 @@ void do_one_file(const char *iname, char *oname)
|
|||||||
else
|
else
|
||||||
flags |= O_EXCL;
|
flags |= O_EXCL;
|
||||||
int shmode = SH_DENYWR;
|
int shmode = SH_DENYWR;
|
||||||
#if defined(__MFX_DOS) || defined(__MFX_WIN32)
|
#if defined(__DJGPP__) || defined(_MSC_VER)
|
||||||
// we can avoid the chmod() call below
|
// we can avoid the chmod() call below
|
||||||
int omode = st.st_mode;
|
int omode = st.st_mode;
|
||||||
fo.sopen(tname,flags,shmode,omode);
|
fo.sopen(tname,flags,shmode,omode);
|
||||||
@@ -227,6 +227,18 @@ void do_one_file(const char *iname, char *oname)
|
|||||||
|
|
||||||
#if !defined(WITH_GUI)
|
#if !defined(WITH_GUI)
|
||||||
|
|
||||||
|
static void unlink_ofile(const char *oname)
|
||||||
|
{
|
||||||
|
if (oname && oname[0])
|
||||||
|
{
|
||||||
|
#if defined(HAVE_CHMOD)
|
||||||
|
(void) ::chmod(oname, 0777);
|
||||||
|
#endif
|
||||||
|
(void) ::unlink(oname);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void do_files(int i, int argc, char *argv[])
|
void do_files(int i, int argc, char *argv[])
|
||||||
{
|
{
|
||||||
if (opt->verbose >= 1)
|
if (opt->verbose >= 1)
|
||||||
@@ -252,30 +264,25 @@ void do_files(int i, int argc, char *argv[])
|
|||||||
} catch (const Exception &e) {
|
} catch (const Exception &e) {
|
||||||
if (opt->verbose >= 2 || (opt->verbose >= 1 && !e.isWarning()))
|
if (opt->verbose >= 2 || (opt->verbose >= 1 && !e.isWarning()))
|
||||||
printErr(iname,&e);
|
printErr(iname,&e);
|
||||||
if (oname[0])
|
unlink_ofile(oname);
|
||||||
(void) ::unlink(oname);
|
|
||||||
} catch (const Error &e) {
|
} catch (const Error &e) {
|
||||||
printErr(iname,&e);
|
printErr(iname,&e);
|
||||||
if (oname[0])
|
unlink_ofile(oname);
|
||||||
(void) ::unlink(oname);
|
|
||||||
e_exit(EXIT_ERROR);
|
e_exit(EXIT_ERROR);
|
||||||
//throw;
|
//throw;
|
||||||
} catch (const exception &e) {
|
} catch (const exception &e) {
|
||||||
printUnhandledException(iname,&e);
|
printUnhandledException(iname,&e);
|
||||||
if (oname[0])
|
unlink_ofile(oname);
|
||||||
(void) ::unlink(oname);
|
|
||||||
e_exit(EXIT_ERROR);
|
e_exit(EXIT_ERROR);
|
||||||
//throw;
|
//throw;
|
||||||
} catch (const exception *e) {
|
} catch (const exception *e) {
|
||||||
printUnhandledException(iname,e);
|
printUnhandledException(iname,e);
|
||||||
if (oname[0])
|
unlink_ofile(oname);
|
||||||
(void) ::unlink(oname);
|
|
||||||
e_exit(EXIT_ERROR);
|
e_exit(EXIT_ERROR);
|
||||||
//throw;
|
//throw;
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
printUnhandledException(iname,NULL);
|
printUnhandledException(iname,NULL);
|
||||||
if (oname[0])
|
unlink_ofile(oname);
|
||||||
(void) ::unlink(oname);
|
|
||||||
e_exit(EXIT_ERROR);
|
e_exit(EXIT_ERROR);
|
||||||
//throw;
|
//throw;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user