feisty meow concerns codebase 2.140
common_bundle.h
Go to the documentation of this file.
1#ifndef COMMON_BUNDLER_DEFS
2#define COMMON_BUNDLER_DEFS
3
4/*****************************************************************************\
5* *
6* Name : common bundler definitions *
7* Author : Chris Koeritz *
8* *
9*******************************************************************************
10* Copyright (c) 2007-$now By Author. This program is free software; you can *
11* redistribute it and/or modify it under the terms of the GNU General Public *
12* License as published by the Free Software Foundation; either version 2 of *
13* the License or (at your option) any later version. This is online at: *
14* http://www.fsf.org/copyleft/gpl.html *
15* Please send any updates to: fred@gruntose.com *
16\*****************************************************************************/
17
19
24#include <basis/astring.h>
25#include <basis/contracts.h>
27#include <structures/set.h>
28
30
44
46
48
54{
61
62 // note: when flags has SET_VARIABLE, the _payload is the variable
63 // name to be set and the _parms is the value to use.
64
65 static int packed_filetime_size();
66
68 manifest_chunk(int size, const basis::astring &target, int flags,
69 const basis::astring &parms, const structures::string_set &keywords)
70 : _size(size), _payload(target), _flags(flags), _parms(parms),
72 for (int i = 0; i < packed_filetime_size(); i++) c_filetime[i] = 0;
73 }
74
77 for (int i = 0; i < packed_filetime_size(); i++) c_filetime[i] = 0;
78 }
79
80 virtual ~manifest_chunk();
81
82 virtual void text_form(basis::base_string &state_fill) const {
83 state_fill.assign(basis::astring(class_name())
84 + basis::a_sprintf(": size=%d payload=%s flags=%x parms=%s",
85 _size, _payload.s(), _flags, _parms.s()));
86 }
87
88 DEFINE_CLASS_NAME("manifest_chunk");
89
90 void pack(basis::byte_array &target) const;
91 bool unpack(basis::byte_array &source);
92
93 static bool read_manifest(filesystem::byte_filer &bundle, manifest_chunk &to_fill);
95
99
100 static bool read_an_int(filesystem::byte_filer &bundle, basis::un_int &found);
102
103 static bool read_an_obscured_int(filesystem::byte_filer &bundle, basis::un_int &found);
105
106 static bool read_a_filetime(filesystem::byte_filer &bundle, basis::byte_array &found);
108};
109
111
112#endif
113
a_sprintf is a specialization of astring that provides printf style support.
Definition astring.h:440
Provides a dynamically resizable ASCII character string.
Definition astring.h:35
const char * s() const
synonym for observe. the 's' stands for "string", if that helps.
Definition astring.h:113
Defines the base class for all string processing objects in hoople.
Definition base_string.h:28
virtual base_string & assign(const base_string &s)=0
Sets the contents of this string to "s".
A very common template for a dynamic array of bytes.
Definition byte_array.h:36
A base class for objects that can provide a synopsis of their current state.
Definition contracts.h:142
virtual const char * class_name() const =0
Returns the bare name of this class as a constant character pointer.
Provides file managment services using the standard I/O support.
Definition byte_filer.h:32
A simple object that wraps a templated set of strings.
Definition set.h:168
special_bundling_flags
Contains some definitions used by both the bundle creator and unpacker.
@ TEST_VARIABLE_DEFINED
check for required variable's presence.
@ OMIT_PACKING
for a source side exe, do not pack the file.
@ SET_VARIABLE
this item just has a variable assignment.
@ RECURSIVE_SRC
source is a recursive folder.
@ SOURCE_EXECUTE
the file should be executed before bundling.
@ QUIET_FAILURE
when errors happen, no popup message happens.
@ IGNORE_ERRORS
if set, errors in an item will not stop program.
@ TARGET_EXECUTE
the file should be executed on unbundling.
@ MAKE_BACKUP_FILE
save a copy if original file already exists.
@ NO_OVERWRITE
target file will not be overwritten if exists.
unsigned int un_int
Abbreviated name for unsigned integers.
Definition definitions.h:62
we will read the manifest pieces out of our own exe image.
basis::un_int _flags
uses the special_bundling_flags.
basis::astring _parms
the parameters to pass on the command line.
static basis::astring read_a_string(filesystem::byte_filer &bundle)
reads a string from the "bundle" file, one byte at a time.
basis::astring _payload
guts of the chunk, such as location for file on target or a variable definition.
void pack(basis::byte_array &target) const
streams out into the "target".
static bool read_an_obscured_int(filesystem::byte_filer &bundle, basis::un_int &found)
reads in our obscured packing format for an int, which takes 8 bytes.
static bool read_manifest(filesystem::byte_filer &bundle, manifest_chunk &to_fill)
reads a chunk out of the "bundle" and stores it in "to_fill".
virtual ~manifest_chunk()
static bool read_a_filetime(filesystem::byte_filer &bundle, basis::byte_array &found)
retrieves packed_filetime_size() byte timestamp from the "bundle".
static bool read_an_int(filesystem::byte_filer &bundle, basis::un_int &found)
reads an integer (4 bytes) from the file into "found".
basis::un_int _size
the size of the packed file.
virtual void text_form(basis::base_string &state_fill) const
Provides a text view of all the important info owned by this object.
bool unpack(basis::byte_array &source)
streams in from the "source".
static int packed_filetime_size()
manifest_chunk(int size, const basis::astring &target, int flags, const basis::astring &parms, const structures::string_set &keywords)
the chunk is the unit found in the packing manifest in the bundle.
basis::byte_array c_filetime
more than enough room for unix file time.
DEFINE_CLASS_NAME("manifest_chunk")
structures::string_set _keywords
keywords applicable to this item.