summaryrefslogtreecommitdiff
path: root/include/Input.h
blob: 0b074b2a5f137c15299af2026135385c8a5b1bd1 (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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#ifndef __INPUT_H__
#define __INPUT_H__

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

enum ArchiveType {
    ARCHIVE_BUILTIN = 0
};

class Input : public Handle {
  public:
      Input(const String & = "") throw (GeneralException);
      Input(const Input &);
      virtual ~Input() {}
    virtual bool CanWrite() const;
    virtual bool CanRead() const;
    virtual bool CanSeek() const;
    virtual off_t seek(off_t, int = SEEK_SET) throw (GeneralException);
    virtual String GetName() const;
    virtual ssize_t GetSize() const;
    virtual time_t GetModif() const;
    virtual void SetZ(int = 9) throw (GeneralException);

    struct openresults_t {
	String name;
	int type;
	size_t size;
	size_t ptr;
    };

  protected:
    String n;
    off_t size;
    time_t date_modif;
    openresults_t results;
    bool fromarchive;

  private:
    static int wrapopen(const String &, openresults_t *);
};

class Stdin_t : public Input {
  public:
      Stdin_t();
      virtual ~Stdin_t() {}
    virtual bool CanSeek() const;
    virtual String GetName() const;
};

extern Stdin_t Stdin;

class Archive : public Base {
  public:
      Archive(const String &, int = 0) throw (GeneralException);
      virtual ~Archive();
  protected:
    static bool inarchive(const String &);
    static int open(const String &, Input::openresults_t *) throw (GeneralException);
  private:
    bool inarchivein(const String &);
    int openin(const String &, Input::openresults_t *) throw (GeneralException);
    class FileTree : public Base {
      public:
          FileTree(const String & = "", size_t = 0, int = 0, FileTree * = 0);
	  virtual ~FileTree();
	int compute_ptrs(size_t = 0);
	FileTree * Father();
	FileTree * Child();
	FileTree * Next();
	FileTree * Prev();
    	String name;
    	int type;
	size_t size;
	size_t ptr;
      private:
    	void touched();
	FileTree * next, * prev, * father, * child;
    } filetree;
    String name;
    Input archive;
    int type;
    Archive * next, * prev;
    static Archive * header;
    
    friend class Input;
};

#endif