Switch to unified view

a/src/query/recollq.cpp b/src/query/recollq.cpp
...
...
44
#include "internfile.h"
44
#include "internfile.h"
45
#include "wipedir.h"
45
#include "wipedir.h"
46
#include "transcode.h"
46
#include "transcode.h"
47
#include "textsplit.h"
47
#include "textsplit.h"
48
48
49
bool dump_contents(RclConfig *rclconfig, string& tmpdir, Rcl::Doc& idoc)
49
bool dump_contents(RclConfig *rclconfig, TempDir& tmpdir, Rcl::Doc& idoc)
50
{
50
{
51
    if (tmpdir.empty() || access(tmpdir.c_str(), 0) < 0) {
52
  string reason;
53
  if (!maketmpdir(tmpdir, reason)) {
54
      cerr << "Cannot create temporary directory: "
55
       << reason << endl;
56
      return false;
57
  }
58
    }
59
    wipedir(tmpdir);
60
    FileInterner interner(idoc, rclconfig, tmpdir, 
51
    FileInterner interner(idoc, rclconfig, tmpdir,
61
                          FileInterner::FIF_forPreview);
52
                          FileInterner::FIF_forPreview);
62
    Rcl::Doc fdoc;
53
    Rcl::Doc fdoc;
63
    string ipath = idoc.ipath;
54
    string ipath = idoc.ipath;
64
    if (interner.internfile(fdoc, ipath)) {
55
    if (interner.internfile(fdoc, ipath)) {
65
    cout << fdoc.text << endl;
56
    cout << fdoc.text << endl;
...
...
261
        cout << cnt << " results" << endl;
252
        cout << cnt << " results" << endl;
262
    else
253
    else
263
        cout << cnt << " results (printing  " << limit << " max):" << endl;
254
        cout << cnt << " results (printing  " << limit << " max):" << endl;
264
    }
255
    }
265
256
266
    string tmpdir;
257
    TempDir tmpdir;
258
    if (!tmpdir.ok()) {
259
  cerr << "Can't create temporary directory: " << 
260
      tmpdir.getreason() << endl;
261
  exit(1);
262
    }
267
    for (int i = 0; i < limit; i++) {
263
    for (int i = 0; i < limit; i++) {
268
    Rcl::Doc doc;
264
    Rcl::Doc doc;
269
    if (!query.getDoc(i, doc))
265
    if (!query.getDoc(i, doc))
270
        break;
266
        break;
271
267
...
...
298
        if (op_flags & OPT_d) {
294
        if (op_flags & OPT_d) {
299
            dump_contents(rclconfig, tmpdir, doc);
295
            dump_contents(rclconfig, tmpdir, doc);
300
        }   
296
        }   
301
    }
297
    }
302
298
303
    // Maybe clean up temporary directory
304
    if (tmpdir.length()) {
305
  wipedir(tmpdir);
306
  if (rmdir(tmpdir.c_str()) < 0) {
307
      cerr << "Cannot clear temp dir " << tmpdir << endl;
308
  }
309
    }
310
311
    return 0;
299
    return 0;
312
}
300
}
313
301
314
#else // TEST_RECOLLQ The test driver is actually the useful program...
302
#else // TEST_RECOLLQ The test driver is actually the useful program...
315
#include <stdlib.h>
303
#include <stdlib.h>