text
stringlengths
0
2.2M
#endif
bdlsb::FixedMemOutStreamBuf sb(tmpWorkingDir, sizeof(tmpWorkingDir));
bsl::ostream os(&sb);
os << "tmp.workingDir.baltzo_defaultzoneinfocache." << test << '.' <<
host << '.' << bdls::ProcessUtil::getProcessId() << ends;
}
if (veryVerbose) P(tmpWorkingDir);
if (FUtil::exists(tmpWorkingDir)) {
// Sometimes the cleanup at the end of this program is unable to clean
// up files, so we might encounter leftovers from a previous run, but
// these can usually be deleted if sufficient time has elapsed. If
// we're not able to clean it up now, old files may prevent the test
// case we're running this time from working. So we want this assert
// to fail to give the tester a 'heads-up' as to what went wrong.
ASSERTV(tmpWorkingDir, 0 == FUtil::remove(tmpWorkingDir, true));
}
ASSERT(0 == FUtil::createDirectories( tmpWorkingDir, true));
ASSERT(0 == FUtil::setWorkingDirectory(tmpWorkingDir));
if (!bdls::FilesystemUtil::exists(TEST_DIRECTORY)) {
bdls::FilesystemUtil::createDirectories(TEST_DIRECTORY, true);
}
if (!bdls::FilesystemUtil::exists(TEST_GMT_FILE)) {
bsl::ofstream outputFile(TEST_GMT_FILE, bsl::ofstream::binary);
ASSERT(outputFile.is_open());
outputFile.close();
}
if (!bdls::FilesystemUtil::exists(AMERICA_NEW_YORK_FILE)) {
writeData(AMERICA_NEW_YORK_FILE,
reinterpret_cast<const char *>(AMERICA_NEW_YORK_DATA),
sizeof(AMERICA_NEW_YORK_DATA));
}
switch (test) { case 0:
case 7: {
// --------------------------------------------------------------------
// TESTING USAGE EXAMPLE
//
// Concerns:
// The usage example provided in the component header file must
// compile, link, and run on all platforms as shown.
//
// Plan:
// Incorporate usage example from header into driver, remove leading
// comment characters, and replace 'assert' with 'ASSERT'.
//
// Testing:
// USAGE EXAMPLE
// --------------------------------------------------------------------
if (verbose) cout << "\nTesting Usage Example"
<< "\n=====================" << endl;
///Usage
///-----
// The following example illustrates how to use a 'baltzo::DataFileLoader' to
// load the Zoneinfo time zone data for a time zone.
//
///Prologue: Create a Example Data File
/// - - - - - - - - - - - - - - - - - -
// We need to create one time zone data file on which to operate in the
// remainder of the example. In practice, clients should *not* generate data
// files in this manner. Data files are typically created using the 'zic'
// compiler -- a publicly available tool provided as part of the standard
// Zoneinfo distribution (see 'http://www.twinsun.com/tz/tz-link.htm') -- and
// deployed in a standard directory location (see
// 'baltzo_defaultzoneinfocache').
//
// First we define static binary data for "Asia/Bangkok" (chosen because it is
// relatively small):
//..
const unsigned char ASIA_BANGKOK_DATA[] = {
0x54, 0x5a, 0x69, 0x66, 0x32, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x08, 0xa2, 0x6a, 0x67, 0xc4,
0x01, 0x00, 0x00, 0x5e, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x62, 0x70, 0x00,
0x04, 0x42, 0x4d, 0x54, 0x00, 0x49, 0x43, 0x54, 0x00, 0x00, 0x00, 0x00,
0x00, 0x54, 0x5a, 0x69, 0x66, 0x32, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x0c, 0xff, 0xff, 0xff,
0xff, 0x56, 0xb6, 0x85, 0xc4, 0xff, 0xff, 0xff, 0xff, 0xa2, 0x6a, 0x67,
0xc4, 0x01, 0x02, 0x00, 0x00, 0x5e, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x5e,
0x3c, 0x00, 0x04, 0x00, 0x00, 0x62, 0x70, 0x00, 0x08, 0x4c, 0x4d, 0x54,
0x00, 0x42, 0x4d, 0x54, 0x00, 0x49, 0x43, 0x54, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x0a, 0x49, 0x43, 0x54, 0x2d, 0x37, 0x0a
};
//..
// Then we create a testing sub-directory "test/Asia" that will hold the
// data file for Bangkok. Note that "Asia/Bangkok" is the Olson time zone
// identifier for Bangkok and "Asia/Bangkok" also serves as a path (relative
// to our "./test" sub-directory) to that data file.
//..