]> cygwin.com Git - cygwin-apps/setup.git/blame - archive.h
2002-02-19 Robert Collins <rbtcollins@hotmail.com>
[cygwin-apps/setup.git] / archive.h
CommitLineData
b24c88b3
RC
1/*
2 * Copyright (c) 2001, Robert Collins.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * A copy of the GNU General Public License can be found at
10 * http://www.gnu.org/
11 *
12 * Written by Robert Collins <rbtcollins@hotmail.com>
13 *
14 */
15
16#ifndef _ARCHIVE_H_
17#define _ARCHIVE_H_
18
19/* this is the parent class for all archive IO operations.
20 * It
21 */
22
3c054baf
RC
23#include "String++.h"
24
b24c88b3
RC
25/* The read/write the archive stream to get the archive data is flawed.
26 * The problem is that you then need a *different* gzip etc class to be able
27 * to ungzip a gzip from within an archive.
28 * The correct way is to
29 * 1) retrieve the file name.
30 * 2) the user creates their own output object.
31 * 3) the user calls extract_file (output strea,).
32 */
33
34typedef enum
35{
36 ARCHIVE_FILE_INVALID,
37 ARCHIVE_FILE_REGULAR,
38 ARCHIVE_FILE_HARDLINK,
39 ARCHIVE_FILE_SYMLINK,
40 ARCHIVE_FILE_DIRECTORY
41}
42archive_file_t;
43
44
45class archive:public io_stream
46{
47public:
48 /* get an archive child class from an io_stream */
49 static archive *extract (io_stream *);
50 /* get an ouput stream for the next files from the archive.
51 * returns NULL on failure.
52 * The stream is not taken over - it will not be automatically deleted
53 */
54 virtual io_stream *extract_file () = NULL;
6dc75764 55 /* extract the next file to the given prefixURL+Path in one step, and name it with the
ad3c7385 56 * given suffix.
b24c88b3
RC
57 * returns 1 on failure.
58 */
3c054baf 59 static int extract_file (archive *, String const &, String const &, String const = String());
b24c88b3
RC
60
61 /*
62 * To create a stream that will be compressed, you should open the url, and then get a new stream
63 * from compress::compress.
64 */
65 /* read data - not valid for archives (duh!)
66 * Could be made valid via the read-child-directly model
67 */
68// virtual ssize_t read(void *buffer, size_t len) {return -1;};
69 /* provide data to (double duh!) */
70// virtual ssize_t write(void *buffer, size_t len) { return -1;};
71 /* read data without removing it from the class's internal buffer */
72// virtual ssize_t peek(void *buffer, size_t len);
73// virtual long tell ();
74 /* try guessing this one */
75// virtual int error ();
76 /* Find out the next stream name -
77 * ie for foo.tar.gz, at offset 0, next_file_name = foo.tar
78 * for foobar that is an compress, next_file_name is the next
79 * extractable filename.
80 * The way this works is that when read returns 0, you are at the end of *a* file.
81 * next_file_name will allow read to be called again, if it returns !NULL
82 */
3c054baf 83 virtual String const next_file_name () = NULL;
b24c88b3 84 virtual archive_file_t next_file_type () = ARCHIVE_FILE_INVALID;
3c054baf 85 virtual String const linktarget () = NULL;
b24c88b3
RC
86 virtual int skip_file () = 0;
87 /* if you are still needing these hints... give up now! */
88// virtual ~compress ();
cbfc4215
RC
89protected:
90 void operator= (const archive &);
91 archive () {};
92 archive (const archive &);
b24c88b3
RC
93private:
94// archive () {};
95};
96
97#endif /* _ARCHIVE_H_ */
This page took 0.033879 seconds and 5 git commands to generate.