source: appstream-generator/src/asgen/backends/rpmmd/rpmpkg.d @ 4841

Last change on this file since 4841 was 4841, checked in by Juanma, 2 years ago

Initial release

File size: 2.4 KB
Line 
1/*
2 * Copyright (C) 2016 Matthias Klumpp <matthias@tenstral.net>
3 *
4 * Licensed under the GNU Lesser General Public License Version 3
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation, either version 3 of the license, or
9 * (at your option) any later version.
10 *
11 * This software is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this software.  If not, see <http://www.gnu.org/licenses/>.
18 */
19
20module asgen.backends.rpmmd.rpmpkg;
21
22import std.stdio;
23import std.string;
24import std.array : empty;
25
26import asgen.logging;
27import asgen.zarchive;
28import asgen.backends.interfaces;
29
30
31final class RPMPackage : Package
32{
33private:
34    string pkgname;
35    string pkgver;
36    string pkgarch;
37    string pkgmaintainer;
38    string[string] desc;
39    string pkgFname;
40
41    string[] contentsL;
42
43    ArchiveDecompressor archive;
44
45public:
46    override
47    @property string name () const { return pkgname; }
48    @property void   name (string val) { pkgname = val; }
49
50    override
51    @property string ver () const { return pkgver; }
52    @property void   ver (string val) { pkgver = val; }
53
54    override
55    @property string arch () const { return pkgarch; }
56    @property void   arch (string val) { pkgarch = val; }
57
58    override
59    @property const(string[string]) description () const { return desc; }
60
61    override
62    @property string filename () const { return pkgFname; }
63    @property void filename (string fname) { pkgFname = fname; }
64
65    override
66    @property string maintainer () const { return pkgmaintainer; }
67    @property void maintainer (string maint) { pkgmaintainer = maint; }
68
69    void setDescription (string text, string locale)
70    {
71        desc[locale] = text;
72    }
73
74    override
75    const(ubyte)[] getFileData (string fname)
76    {
77        if (!archive.isOpen)
78            archive.open (this.filename);
79
80        return archive.readData (fname);
81    }
82
83    @property override
84    string[] contents ()
85    {
86        return contentsL;
87    }
88
89    @property
90    void contents (string[] c)
91    {
92        contentsL = c;
93    }
94
95    override
96    void close ()
97    {
98    }
99}
Note: See TracBrowser for help on using the repository browser.