1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
/* $Id: file.H,v 1.3 2004/06/14 00:18:42 mrsam Exp $
**
** Copyright 2002, Double Precision Inc.
**
** See COPYING for distribution information.
*/
#ifndef libmail_file_H
#define libmail_file_H
#include "libmail_config.h"
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <vector>
#include <string>
#include "namespace.H"
#include "mail.H"
///////////////////////////////////////////////////////////////////////////
// A wrapper for a stdio FILE object, that mail::mbox finds very useful
//
// The constructor accepts a file descriptor, and a file access mode.
// The original file descriptor is not touched, the object dupes it, and
// attaches the dupe to a FILE object.
//
// The FILE object is cleaned up by the destructor.
#include "mail.H"
LIBMAIL_START
class file {
int fd;
FILE *fp;
off_t pos;
std::vector<char> buffer;
public:
file(int fdArg, const char *mode);
~file();
operator FILE *() const { return fp; }
bool operator !() const { return fp == NULL; }
std::string getline(); // Read a line of text
void seeked(); // The caller seeked in the file, update pos.
off_t tell() const { return pos; }
void genericMessageRead(mail::account *account,
size_t messageNumber,
mail::readMode readType,
mail::callback::message &callback);
};
LIBMAIL_END
#endif
|