|
a/src/utils/smallut.cpp |
|
b/src/utils/smallut.cpp |
1 |
#ifndef lint
|
1 |
#ifndef lint
|
2 |
static char rcsid[] = "@(#$Id: smallut.cpp,v 1.2 2005-02-04 09:39:44 dockes Exp $ (C) 2004 J.F.Dockes";
|
2 |
static char rcsid[] = "@(#$Id: smallut.cpp,v 1.3 2005-02-09 12:07:30 dockes Exp $ (C) 2004 J.F.Dockes";
|
3 |
#endif
|
3 |
#endif
|
4 |
#ifndef TEST_SMALLUT
|
4 |
#ifndef TEST_SMALLUT
|
5 |
#include <string>
|
5 |
#include <string>
|
6 |
#include <ctype.h>
|
6 |
#include <ctype.h>
|
|
|
7 |
#include <unistd.h>
|
|
|
8 |
#include <sys/types.h>
|
|
|
9 |
#include <sys/stat.h>
|
7 |
|
10 |
|
8 |
#include "smallut.h"
|
11 |
#include "smallut.h"
|
|
|
12 |
#include "debuglog.h"
|
|
|
13 |
#include "pathut.h"
|
9 |
|
14 |
|
10 |
#define MIN(A,B) ((A)<(B)?(A):(B))
|
15 |
#define MIN(A,B) ((A)<(B)?(A):(B))
|
|
|
16 |
|
|
|
17 |
bool maketmpdir(string& tdir)
|
|
|
18 |
{
|
|
|
19 |
const char *tmpdir = getenv("RECOLL_TMPDIR");
|
|
|
20 |
if (!tmpdir)
|
|
|
21 |
tmpdir = getenv("TMPDIR");
|
|
|
22 |
if (!tmpdir)
|
|
|
23 |
tmpdir = "/tmp";
|
|
|
24 |
tdir = tmpdir;
|
|
|
25 |
path_cat(tdir, "rcltmpXXXXXX");
|
|
|
26 |
{
|
|
|
27 |
char *cp = strdup(tdir.c_str());
|
|
|
28 |
if (!cp) {
|
|
|
29 |
LOGERR(("maketmpdir: out of memory (for file name !)\n"));
|
|
|
30 |
tdir.erase();
|
|
|
31 |
return false;
|
|
|
32 |
}
|
|
|
33 |
if (!mktemp(cp)) {
|
|
|
34 |
free(cp);
|
|
|
35 |
LOGERR(("maketmpdir: mktemp failed\n"));
|
|
|
36 |
tdir.erase();
|
|
|
37 |
return false;
|
|
|
38 |
}
|
|
|
39 |
tdir = cp;
|
|
|
40 |
free(cp);
|
|
|
41 |
}
|
|
|
42 |
|
|
|
43 |
if (mkdir(tdir.c_str(), 0700) < 0) {
|
|
|
44 |
LOGERR(("maketmpdir: mkdir %s failed\n", tdir.c_str()));
|
|
|
45 |
tdir.erase();
|
|
|
46 |
return false;
|
|
|
47 |
}
|
|
|
48 |
return true;
|
|
|
49 |
}
|
11 |
|
50 |
|
12 |
int stringicmp(const string & s1, const string& s2)
|
51 |
int stringicmp(const string & s1, const string& s2)
|
13 |
{
|
52 |
{
|
14 |
string::const_iterator it1 = s1.begin();
|
53 |
string::const_iterator it1 = s1.begin();
|
15 |
string::const_iterator it2 = s2.begin();
|
54 |
string::const_iterator it2 = s2.begin();
|