/* * Baltisot * Copyright (C) 1999-2003 Nicolas "Pixel" Noble * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* $Id: Input.h,v 1.21 2004-11-27 21:46:02 pixel Exp $ */ #ifndef __INPUT_H__ #define __INPUT_H__ #include #include #include #include enum ArchiveType { ARCHIVE_BUILTIN = 0, ARCHIVE_EXECUTABLE }; 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: 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 = ARCHIVE_BUILTIN); Archive(Handle *, int = ARCHIVE_BUILTIN); virtual ~Archive(); protected: static Archive * inarchive(const String &); Handle * GetHandle(); int open(const String &, Input::openresults_t *); private: void create() throw (GeneralException); 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; Handle * archive; int type; Archive * next, * prev; static Archive * header; friend class Input; }; #endif