My Project  + 80db3
directory.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2011-2019 Daniel Scharrer
3  *
4  * This software is provided 'as-is', without any express or implied
5  * warranty. In no event will the author(s) be held liable for any damages
6  * arising from the use of this software.
7  *
8  * Permission is granted to anyone to use this software for any purpose,
9  * including commercial applications, and to alter it and redistribute it
10  * freely, subject to the following restrictions:
11  *
12  * 1. The origin of this software must not be misrepresented; you must not
13  * claim that you wrote the original software. If you use this software
14  * in a product, an acknowledgment in the product documentation would be
15  * appreciated but is not required.
16  * 2. Altered source versions must be plainly marked as such, and must not be
17  * misrepresented as being the original software.
18  * 3. This notice may not be removed or altered from any source distribution.
19  */
20 
21 #include "setup/directory.hpp"
22 
23 #include "setup/info.hpp"
24 #include "setup/version.hpp"
25 #include "util/load.hpp"
26 #include "util/storedenum.hpp"
27 
28 namespace setup {
29 
30 namespace {
31 
32 STORED_FLAGS_MAP(stored_inno_directory_options_0,
33  directory_entry::NeverUninstall,
34  directory_entry::DeleteAfterInstall,
35  directory_entry::AlwaysUninstall,
36 );
37 
38 // starting with version 5.2.0
39 STORED_FLAGS_MAP(stored_inno_directory_options_1,
40  directory_entry::NeverUninstall,
41  directory_entry::DeleteAfterInstall,
42  directory_entry::AlwaysUninstall,
43  directory_entry::SetNtfsCompression,
44  directory_entry::UnsetNtfsCompression,
45 );
46 
47 } // anonymous namespace
48 
49 void directory_entry::load(std::istream & is, const info & i) {
50 
51  if(i.version < INNO_VERSION(1, 3, 0)) {
52  (void)util::load<boost::uint32_t>(is); // uncompressed size of the entry
53  }
54 
56 
57  load_condition_data(is, i);
58 
59  if(i.version >= INNO_VERSION(4, 0, 11) && i.version < INNO_VERSION(4, 1, 0)) {
61  } else {
62  permissions.clear();
63  }
64 
65  if(i.version >= INNO_VERSION(2, 0, 11)) {
66  attributes = util::load<boost::uint32_t>(is);
67  } else {
68  attributes = 0;
69  }
70 
72 
73  if(i.version >= INNO_VERSION(4, 1, 0)) {
74  permission = util::load<boost::int16_t>(is);
75  } else {
76  permission = boost::int16_t(-1);
77  }
78 
79  if(i.version >= INNO_VERSION(5, 2, 0)) {
81  } else if(i.version.bits() != 16) {
83  } else {
85  }
86 
87 }
88 
89 } // namespace setup
90 
91 NAMES(setup::directory_entry::flags, "Directory Option",
92  "never uninstall",
93  "delete after install",
94  "always uninstall",
95  "set NTFS compression",
96  "unset NTFS compression",
97 )
void load(std::istream &is, const info &i)
Definition: directory.cpp:49
void load_condition_data(std::istream &is, const info &i)
Definition: item.cpp:29
flag_type get()
Definition: storedenum.hpp:168
Definition: gog.hpp:34
#define NAMES(Enum, Name,...)
Definition: enum.hpp:70
boost::uint16_t bits() const
Definition: version.hpp:80
Utility function to load stored data while properly handling encodings and endianness.
Central point to load all the different headers in the correct order.
Class used to hold and load the various setup headers.
Definition: info.hpp:57
#define STORED_FLAGS_MAP(MapName, Flag0,...)
Declare a mapping from bits to flag enum elements to be used for stored_flags.
Definition: storedenum.hpp:62
Load a flag set where the possible flags are known at compile-time.
Definition: storedenum.hpp:157
util::codepage_id codepage
Definition: info.hpp:89
#define INNO_VERSION(a, b, c)
Definition: version.hpp:47
std::string name
Definition: directory.hpp:52
boost::uint32_t attributes
Definition: directory.hpp:55
Wrapper to load a length-prefixed string with a specified encoding from an input stream into a UTF-8 ...
Definition: load.hpp:88
void load_version_data(std::istream &is, const version &version)
Definition: item.hpp:55
boost::int16_t permission
index into the permission entry list
Definition: directory.hpp:57
setup::version version
Definition: info.hpp:87
Structures for directory entries stored in Inno Setup files.
std::string permissions
Definition: directory.hpp:53
flags options
Definition: directory.hpp:59
Utilities for decoding stored enum values into run-time values.
Wrapper to load a length-prefixed string from an input stream into a std::string.
Definition: load.hpp:50
Inno Setup version number utilities.