|
a/src/utils/pathut.cpp |
|
b/src/utils/pathut.cpp |
1 |
#ifndef lint
|
1 |
#ifndef lint
|
2 |
static char rcsid[] = "@(#$Id: pathut.cpp,v 1.13 2006-12-16 15:31:51 dockes Exp $ (C) 2004 J.F.Dockes";
|
2 |
static char rcsid[] = "@(#$Id: pathut.cpp,v 1.14 2006-12-23 13:07:21 dockes Exp $ (C) 2004 J.F.Dockes";
|
3 |
#endif
|
3 |
#endif
|
4 |
/*
|
4 |
/*
|
5 |
* This program is free software; you can redistribute it and/or modify
|
5 |
* This program is free software; you can redistribute it and/or modify
|
6 |
* it under the terms of the GNU General Public License as published by
|
6 |
* it under the terms of the GNU General Public License as published by
|
7 |
* the Free Software Foundation; either version 2 of the License, or
|
7 |
* the Free Software Foundation; either version 2 of the License, or
|
|
... |
|
... |
89 |
if (!cp) {
|
89 |
if (!cp) {
|
90 |
m_reason = "Out of memory (for file name !)\n";
|
90 |
m_reason = "Out of memory (for file name !)\n";
|
91 |
return;
|
91 |
return;
|
92 |
}
|
92 |
}
|
93 |
|
93 |
|
|
|
94 |
// Yes using mkstemp this way is awful (bot the suffix adding and
|
|
|
95 |
// using mkstemp() just to avoid the warnings)
|
|
|
96 |
int fd;
|
94 |
if (!mktemp(cp)) {
|
97 |
if ((fd = mkstemp(cp)) < 0) {
|
95 |
free(cp);
|
98 |
free(cp);
|
96 |
m_reason = "maketmpdir: mktemp failed\n";
|
99 |
m_reason = "maketmpdir: mkstemp failed\n";
|
97 |
return;
|
100 |
return;
|
98 |
}
|
101 |
}
|
|
|
102 |
close(fd);
|
|
|
103 |
unlink(cp);
|
|
|
104 |
|
99 |
filename = cp;
|
105 |
filename = cp;
|
100 |
free(cp);
|
106 |
free(cp);
|
101 |
|
107 |
|
102 |
// Yea not right
|
|
|
103 |
m_filename = filename + suffix;
|
108 |
m_filename = filename + suffix;
|
104 |
if (close(open(m_filename.c_str(), O_CREAT|O_EXCL, 0600)) != 0) {
|
109 |
if (close(open(m_filename.c_str(), O_CREAT|O_EXCL, 0600)) != 0) {
|
105 |
m_reason = string("Could not open/create") + m_filename;
|
110 |
m_reason = string("Could not open/create") + m_filename;
|
106 |
m_filename.erase();
|
111 |
m_filename.erase();
|
107 |
}
|
112 |
}
|