summaryrefslogtreecommitdiff
path: root/includes/cdreader.h
blob: 4be3344c17765cbafbfb4cd160b9916f496a3b8f (plain)
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
#ifndef __CDREADER_H__
#define __CDREADER_H__

#include <sys/types.h>
#include <time.h>
#include <BString.h>
#include <Handle.h>
#include "cdabstract.h"

class cdreader : public Handle {
  public:
      cdreader(const String &) throw (GeneralException);
      cdreader(const cdreader &);
      virtual ~cdreader();
    virtual bool CanWrite() const;
    virtual bool CanRead() const;
    virtual bool CanSeek() const;
#if defined (_MSC_VER) || defined (__MINGW32__)
    virtual void close() throw (GeneralException);
#endif
    virtual ssize_t read(void *buf, size_t count) throw (GeneralException);                                                     
    virtual off_t seek(off_t, int = SEEK_SET) throw (GeneralException);
    virtual String GetName() const;
    virtual ssize_t GetSize() const;
    void fetchsector(void *, int = -1);
    void getsector(void *, int = -1, int = 1) throw (GeneralException);
    void sectorseek(int);

  private:
    struct cachedsector {
        Byte sector[2352];
        cachedsector * next, * prev;
        int n;
    };
    String n;
    int sector;
    cachedsector * head, * tail, * sectors[400000];
    int nsectors;

    void removetail();
    void actualize(cachedsector * s);
    void introduce(Byte * datas, int n);
};

#endif