summaryrefslogtreecommitdiff
path: root/src/dev
diff options
context:
space:
mode:
authorAli Saidi <saidi@eecs.umich.edu>2008-05-15 19:10:26 -0400
committerAli Saidi <saidi@eecs.umich.edu>2008-05-15 19:10:26 -0400
commite71a5270a2fe040e0542bc2c74a11a303688f6ae (patch)
treea4714028a2aabebeda1147d0c6a5a17cd75203fb /src/dev
parent4a4317ae18504226d298d42929b9882837ab1b44 (diff)
downloadgem5-e71a5270a2fe040e0542bc2c74a11a303688f6ae.tar.xz
Make sure that output files are always checked success before they're used.
Make OutputDirectory::resolve() private and change the functions using resolve() to instead use create(). --HG-- extra : convert_revision : 36d4be629764d0c4c708cec8aa712cd15f966453
Diffstat (limited to 'src/dev')
-rw-r--r--src/dev/etherdump.cc14
-rw-r--r--src/dev/etherdump.hh2
2 files changed, 8 insertions, 8 deletions
diff --git a/src/dev/etherdump.cc b/src/dev/etherdump.cc
index 471093521..07e52f36d 100644
--- a/src/dev/etherdump.cc
+++ b/src/dev/etherdump.cc
@@ -45,7 +45,7 @@
using std::string;
EtherDump::EtherDump(const Params *p)
- : SimObject(p), stream(simout.resolve(p->file).c_str()),
+ : SimObject(p), stream(simout.create(p->file, true)),
maxlen(p->maxlen)
{
}
@@ -86,7 +86,7 @@ EtherDump::init()
hdr.sigfigs = 0;
hdr.linktype = DLT_EN10MB;
- stream.write(reinterpret_cast<char *>(&hdr), sizeof(hdr));
+ stream->write(reinterpret_cast<char *>(&hdr), sizeof(hdr));
/*
* output an empty packet with the current time so that we know
@@ -98,9 +98,9 @@ EtherDump::init()
pkthdr.microseconds = 0;
pkthdr.caplen = 0;
pkthdr.len = 0;
- stream.write(reinterpret_cast<char *>(&pkthdr), sizeof(pkthdr));
+ stream->write(reinterpret_cast<char *>(&pkthdr), sizeof(pkthdr));
- stream.flush();
+ stream->flush();
}
void
@@ -111,9 +111,9 @@ EtherDump::dumpPacket(EthPacketPtr &packet)
pkthdr.microseconds = (curTick / Clock::Int::us) % ULL(1000000);
pkthdr.caplen = std::min(packet->length, maxlen);
pkthdr.len = packet->length;
- stream.write(reinterpret_cast<char *>(&pkthdr), sizeof(pkthdr));
- stream.write(reinterpret_cast<char *>(packet->data), pkthdr.caplen);
- stream.flush();
+ stream->write(reinterpret_cast<char *>(&pkthdr), sizeof(pkthdr));
+ stream->write(reinterpret_cast<char *>(packet->data), pkthdr.caplen);
+ stream->flush();
}
EtherDump *
diff --git a/src/dev/etherdump.hh b/src/dev/etherdump.hh
index 1027ce4d0..733e61c97 100644
--- a/src/dev/etherdump.hh
+++ b/src/dev/etherdump.hh
@@ -46,7 +46,7 @@
class EtherDump : public SimObject
{
private:
- std::ofstream stream;
+ std::ostream *stream;
const int maxlen;
void dumpPacket(EthPacketPtr &packet);
void init();