]> cygwin.com Git - cygwin-apps/setup.git/blob - package_source.h
2006-04-17 Max Bowsher <maxb1@ukf.net>
[cygwin-apps/setup.git] / package_source.h
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 SETUP_PACKAGE_SOURCE_H
17 #define SETUP_PACKAGE_SOURCE_H
18
19 /* this is the parent class for all package source (not source code - installation
20 * source as in http/ftp/disk file) operations.
21 */
22
23 /* required to parse this file */
24 #include "strings.h"
25 #include "String++.h"
26 #include "csu_util/MD5Sum.h"
27 #include <vector>
28
29 /* standard binary package metadata:
30 * Name (ie mutt
31 * Vendor Version (ie 2.5.1)
32 * Package Version (ie 16)
33 * Stability
34 * Files
35 */
36
37 /* For non installed files, this class can be populated via information about
38 * what is available on the net, or by parsing a specific package file.
39 * for installed packages, this class should represent what is currently installed,
40 * - updated by what net metadata has about it.
41 * i.e. the stability of this version will change simply because the net mirrors
42 * now consider it old.
43 */
44
45 class site
46 {
47 public:
48 site (const std::string& newkey);
49 ~site () {}
50 std::string key;
51 bool operator == (site const &rhs)
52 {
53 return casecompare(key, rhs.key) == 0;
54 }
55 };
56
57 class packagesource
58 {
59 public:
60 packagesource ():size (0), canonical (0), base (0), filename (0), cached (),
61 _installedSize (0)
62 {
63 };
64 /* how big is the source file */
65 size_t size;
66 /* how much space do we need to install this ? */
67 virtual unsigned long installedSize () const
68 {
69 return _installedSize;
70 }
71 virtual void setInstalledSize (unsigned long size)
72 {
73 _installedSize = size;
74 }
75 /* The canonical name - the complete path to the source file
76 * i.e. foo/bar/package-1.tar.bz2
77 */
78 virtual const char *Canonical () const
79 {
80 return canonical;
81 };
82 /* The basename - without extention
83 * i.e. package-1
84 */
85 virtual const char *Base () const
86 {
87 return base;
88 };
89 /* The basename - with extention
90 * i.e. package-1.tar.bz2
91 */
92 virtual const char *Filename () const
93 {
94 return filename;
95 };
96 /* what is the cached filename, to prevent directory scanning during install */
97 virtual char const *Cached () const
98 {
99 /* Pointer-coerce-to-boolean is used by many callers. */
100 if (cached.empty())
101 return NULL;
102 return cached.c_str();
103 };
104 /* sets the canonical path, and parses and creates base and filename */
105 virtual void set_canonical (char const *);
106 virtual void set_cached (const std::string& );
107 MD5Sum md5;
108 typedef std::vector <site> sitestype;
109 sitestype sites;
110
111 virtual ~ packagesource ()
112 {
113 if (canonical)
114 delete []canonical;
115 if (base)
116 delete []base;
117 if (filename)
118 delete []filename;
119 };
120
121 private:
122 char *canonical;
123 char *base;
124 char *filename;
125 std::string cached;
126 unsigned long _installedSize;
127 };
128
129 #endif /* SETUP_PACKAGE_SOURCE_H */
This page took 0.044044 seconds and 6 git commands to generate.