The Pedigree Project  0.1
Archive.h
1 /*
2  * Copyright (c) 2008-2014, Pedigree Developers
3  *
4  * Please see the CONTRIB file in the root of the source tree for a full
5  * list of contributors.
6  *
7  * Permission to use, copy, modify, and distribute this software for any
8  * purpose with or without fee is hereby granted, provided that the above
9  * copyright notice and this permission notice appear in all copies.
10  *
11  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 #ifndef ARCHIVE_H
21 #define ARCHIVE_H
22 
23 #include "pedigree/kernel/processor/MemoryRegion.h"
24 #include "pedigree/kernel/processor/types.h"
25 
30 class Archive
31 {
32  public:
34  Archive(uint8_t *pPhys, size_t sSize);
37  ~Archive();
38 
40  size_t getNumFiles();
41 
44  size_t getFileSize(size_t n);
45 
48  char *getFileName(size_t n);
49 
52  uintptr_t *getFile(size_t n);
53 
54  private:
55  struct ArchiveFile
56  {
57  char name[100]; // Filename.
58  char mode[8]; // Permissions.
59  char uid[8]; // User ID.
60  char gid[8]; // Group ID.
61  char size[12]; // Size, in bytes (octal)
62  char mtime[12]; // Modification time.
63  char chksum[8]; // Header checksum.
64  char link; // Link type: 0 = regular file, 1 = hard link, 2 = symlink.
65  char linkname[100]; // Linked-to file name.
66  };
67 
68  ArchiveFile *getFirst();
69  ArchiveFile *getNext(ArchiveFile *pFile);
70  ArchiveFile *get(size_t n);
71 
72 #ifdef HOSTED
73  uint8_t *m_pBase;
74 #else
75  MemoryRegion m_Region;
76 #endif
77 };
78 
79 #endif
uintptr_t * getFile(size_t n)
Definition: Archive.cc:84
~Archive()
Definition: Archive.cc:53
char * getFileName(size_t n)
Definition: Archive.cc:79
size_t getNumFiles()
Definition: Archive.cc:60
Special memory entity in the kernel's virtual address space.
Definition: MemoryRegion.h:35
Archive(uint8_t *pPhys, size_t sSize)
Definition: Archive.cc:28
size_t getFileSize(size_t n)
Definition: Archive.cc:72