| 2218 |
sbetterm |
1 |
//## begin module%1.7%.codegen_version preserve=yes
|
|
|
2 |
// Read the documentation to learn more about C++ code generator
|
|
|
3 |
// versioning.
|
|
|
4 |
//## end module%1.7%.codegen_version
|
|
|
5 |
|
|
|
6 |
//## begin module%4209BA4C03B8.cm preserve=no
|
|
|
7 |
//## end module%4209BA4C03B8.cm
|
|
|
8 |
|
|
|
9 |
//## begin module%4209BA4C03B8.cp preserve=no
|
|
|
10 |
// C O P Y R I G H T N O T I C E
|
|
|
11 |
// This material is confidential to ERG and may not be disclosed in whole
|
|
|
12 |
// or in part to any third party nor used in any manner whatsoever other
|
|
|
13 |
// than for the purposes expressly consented to by ERG in writing.
|
|
|
14 |
//
|
|
|
15 |
// This material is also copyright and may not be reproduced, stored in a
|
|
|
16 |
// retrieval system or transmitted in any form or by any means in whole or
|
|
|
17 |
// in part without the express written consent of ERG.
|
|
|
18 |
//## end module%4209BA4C03B8.cp
|
|
|
19 |
|
|
|
20 |
//## Module: UdFileManifest%4209BA4C03B8; Pseudo Package body
|
|
|
21 |
//## Subsystem: MASS::Dev::Tools::TxnTestManager::src%41F5A79001E4
|
|
|
22 |
//## Source file: Z:\MASS_Dev\Tools\TxnTestManager\src\UdFileManifest.cpp
|
|
|
23 |
|
|
|
24 |
//## begin module%4209BA4C03B8.additionalIncludes preserve=no
|
|
|
25 |
//## end module%4209BA4C03B8.additionalIncludes
|
|
|
26 |
|
|
|
27 |
//## begin module%4209BA4C03B8.includes preserve=yes
|
|
|
28 |
#pragma warn -com
|
|
|
29 |
#include <LoggingMacros.h>
|
|
|
30 |
#pragma warn +com
|
|
|
31 |
//## end module%4209BA4C03B8.includes
|
|
|
32 |
|
|
|
33 |
// TransactionStream
|
|
|
34 |
#include "TransactionStream.h"
|
|
|
35 |
// UdFileManifest
|
|
|
36 |
#include "UdFileManifest.h"
|
|
|
37 |
//## begin module%4209BA4C03B8.additionalDeclarations preserve=yes
|
|
|
38 |
|
| 2222 |
sbetterm |
39 |
#include <ctype>
|
| 2218 |
sbetterm |
40 |
/**
|
|
|
41 |
Example UD Manifest file. Lines starting with a # are comments and are
|
|
|
42 |
ignored.
|
| 2222 |
sbetterm |
43 |
|
| 2218 |
sbetterm |
44 |
#UD Manifest
|
|
|
45 |
#0000000101-SY1-903ECU-00000005
|
|
|
46 |
/afc/ergdce/var/DCE/ud/drained/CvXK71l0_903ECU.devud
|
|
|
47 |
/afc/ergdce/var/DCE/ud/drained/CvXLn1Y0_903ECU.devud
|
|
|
48 |
/afc/ergdce/var/DCE/ud/drained/CvXP49b0_903ECU.devud
|
|
|
49 |
/afc/ergdce/var/DCE/ud/drained/CvXtDCw0_903ECU.devud
|
|
|
50 |
/afc/ergdce/var/DCE/ud/drained/CvXtE0U0_903ECU.devud
|
|
|
51 |
/afc/ergdce/var/DCE/ud/drained/CvnNj8c0_903ECU.devud
|
|
|
52 |
/afc/ergdce/var/DCE/ud/drained/CvnRVA10_903ECU.devud
|
|
|
53 |
#total = 7
|
|
|
54 |
#end
|
|
|
55 |
*/
|
|
|
56 |
//## end module%4209BA4C03B8.additionalDeclarations
|
|
|
57 |
|
|
|
58 |
|
|
|
59 |
// Class UdFileManifest
|
|
|
60 |
|
|
|
61 |
//## Operation: UdFileManifest%4209BAA8031C
|
|
|
62 |
UdFileManifest::UdFileManifest (const std::string &folder, const std::string &prefix, const std::string &suffix)
|
|
|
63 |
//## begin UdFileManifest::UdFileManifest%4209BAA8031C.hasinit preserve=no
|
|
|
64 |
: m_count(0),
|
|
|
65 |
m_folder(folder),
|
|
|
66 |
m_prefix(prefix),
|
|
|
67 |
m_stream(0),
|
|
|
68 |
m_suffix(suffix)
|
|
|
69 |
//## end UdFileManifest::UdFileManifest%4209BAA8031C.hasinit
|
|
|
70 |
//## begin UdFileManifest::UdFileManifest%4209BAA8031C.initialization preserve=yes
|
|
|
71 |
//## end UdFileManifest::UdFileManifest%4209BAA8031C.initialization
|
|
|
72 |
{
|
|
|
73 |
//## begin UdFileManifest::UdFileManifest%4209BAA8031C.body preserve=yes
|
|
|
74 |
|
|
|
75 |
open();
|
|
|
76 |
|
|
|
77 |
//## end UdFileManifest::UdFileManifest%4209BAA8031C.body
|
|
|
78 |
}
|
|
|
79 |
|
|
|
80 |
|
|
|
81 |
UdFileManifest::~UdFileManifest()
|
|
|
82 |
{
|
|
|
83 |
//## begin UdFileManifest::~UdFileManifest%4209BA4C03B8_dest.body preserve=yes
|
|
|
84 |
|
|
|
85 |
close();
|
|
|
86 |
|
|
|
87 |
//## end UdFileManifest::~UdFileManifest%4209BA4C03B8_dest.body
|
|
|
88 |
}
|
|
|
89 |
|
|
|
90 |
|
|
|
91 |
|
|
|
92 |
//## Other Operations (implementation)
|
|
|
93 |
//## Operation: addUdFile%4209BAC703E7
|
|
|
94 |
void UdFileManifest::addUdFile (const std::string &file)
|
|
|
95 |
{
|
|
|
96 |
//## begin UdFileManifest::addUdFile%4209BAC703E7.body preserve=yes
|
|
|
97 |
|
| 2222 |
sbetterm |
98 |
// TODO: specify a pathmap to replace the filepath. For now, we just strip
|
|
|
99 |
// any drive specification an cannonise the path.
|
|
|
100 |
|
|
|
101 |
std::string cannonised;
|
|
|
102 |
char const * p = const_cast< char * >( file.c_str() );
|
|
|
103 |
|
|
|
104 |
// check if drive letter at start of filename
|
|
|
105 |
if ( file.length() >= 3
|
|
|
106 |
&& isalpha( file[ 0 ] ) != 0 // a-z or A-Z
|
|
|
107 |
&& file[ 1 ] == ':' ) // :
|
| 2218 |
sbetterm |
108 |
{
|
| 2222 |
sbetterm |
109 |
p += 2;
|
|
|
110 |
}
|
|
|
111 |
while ( *p )
|
|
|
112 |
{
|
|
|
113 |
if ( *p != '\\' )
|
|
|
114 |
{
|
|
|
115 |
cannonised += *p;
|
|
|
116 |
}
|
|
|
117 |
else
|
|
|
118 |
{
|
|
|
119 |
cannonised += '/';
|
|
|
120 |
}
|
|
|
121 |
++p;
|
|
|
122 |
}
|
|
|
123 |
|
|
|
124 |
if ( cannonised.length() )
|
|
|
125 |
{
|
|
|
126 |
(*m_stream) << cannonised << std::endl;
|
| 2218 |
sbetterm |
127 |
++m_count;
|
|
|
128 |
}
|
|
|
129 |
|
|
|
130 |
//## end UdFileManifest::addUdFile%4209BAC703E7.body
|
|
|
131 |
}
|
|
|
132 |
|
|
|
133 |
//## Operation: close%4209BAC10389
|
|
|
134 |
void UdFileManifest::close ()
|
|
|
135 |
{
|
|
|
136 |
//## begin UdFileManifest::close%4209BAC10389.body preserve=yes
|
|
|
137 |
|
|
|
138 |
if ( m_stream )
|
|
|
139 |
{
|
|
|
140 |
(*m_stream)
|
|
|
141 |
<< "#total = " << m_count << std::endl
|
|
|
142 |
<< "#end" << std::endl;
|
|
|
143 |
|
|
|
144 |
m_stream->close();
|
|
|
145 |
|
|
|
146 |
delete m_stream;
|
|
|
147 |
m_stream = 0;
|
|
|
148 |
}
|
|
|
149 |
|
|
|
150 |
//## end UdFileManifest::close%4209BAC10389.body
|
|
|
151 |
}
|
|
|
152 |
|
|
|
153 |
//## Operation: open%4209BAC10399
|
|
|
154 |
const bool UdFileManifest::open ()
|
|
|
155 |
{
|
|
|
156 |
//## begin UdFileManifest::open%4209BAC10399.body preserve=yes
|
|
|
157 |
|
|
|
158 |
close(); // Close the stream should it be open.
|
|
|
159 |
|
|
|
160 |
std::string filename;
|
|
|
161 |
TransactionStream::buildFileName(
|
|
|
162 |
filename,
|
|
|
163 |
m_folder,
|
|
|
164 |
m_prefix,
|
|
|
165 |
m_suffix,
|
|
|
166 |
"",
|
|
|
167 |
|
|
|
168 |
|
|
|
169 |
m_stream = new std::ofstream(
|
|
|
170 |
filename.c_str(),
|
|
|
171 |
std::ios_base::out );
|
|
|
172 |
if ( m_stream->is_open() )
|
|
|
173 |
{
|
|
|
174 |
(*m_stream)
|
|
|
175 |
<< "#UD Manifest" << std::endl
|
|
|
176 |
<< '#' << std::endl;
|
|
|
177 |
|
|
|
178 |
return ( true );
|
|
|
179 |
}
|
|
|
180 |
|
|
|
181 |
// When we can't open the file, then roll back.
|
|
|
182 |
delete m_stream;
|
|
|
183 |
m_stream = 0;
|
|
|
184 |
|
|
|
185 |
MERROR( "Cannot open \"" << filename << "\" for writing." );
|
|
|
186 |
return ( false );
|
|
|
187 |
|
|
|
188 |
//## end UdFileManifest::open%4209BAC10399.body
|
|
|
189 |
}
|
|
|
190 |
|
|
|
191 |
// Additional Declarations
|
|
|
192 |
//## begin UdFileManifest%4209BA4C03B8.declarations preserve=yes
|
|
|
193 |
//## end UdFileManifest%4209BA4C03B8.declarations
|
|
|
194 |
|
|
|
195 |
//## begin module%4209BA4C03B8.epilog preserve=yes
|
|
|
196 |
//## end module%4209BA4C03B8.epilog
|