copy_stream
This commit is contained in:
parent
6f42852497
commit
b027447c0f
|
|
@ -14,6 +14,7 @@
|
|||
circBuffer.h \
|
||||
config_express.h \
|
||||
compress_string.h \
|
||||
copy_stream.h \
|
||||
datagram.I datagram.h datagramGenerator.I \
|
||||
datagramGenerator.h \
|
||||
datagramIterator.I datagramIterator.h datagramSink.I datagramSink.h \
|
||||
|
|
@ -74,6 +75,7 @@
|
|||
buffer.cxx checksumHashGenerator.cxx \
|
||||
config_express.cxx \
|
||||
compress_string.cxx \
|
||||
copy_stream.cxx \
|
||||
datagram.cxx datagramGenerator.cxx \
|
||||
datagramIterator.cxx \
|
||||
datagramSink.cxx dcast.cxx \
|
||||
|
|
@ -125,6 +127,7 @@
|
|||
circBuffer.h \
|
||||
config_express.h \
|
||||
compress_string.h \
|
||||
copy_stream.h \
|
||||
datagram.I datagram.h datagramGenerator.I \
|
||||
datagramGenerator.h \
|
||||
datagramIterator.I datagramIterator.h datagramSink.I datagramSink.h \
|
||||
|
|
|
|||
|
|
@ -0,0 +1,39 @@
|
|||
// Filename: copy_stream.cxx
|
||||
// Created by: drose (27Aug09)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) Carnegie Mellon University. All rights reserved.
|
||||
//
|
||||
// All use of this software is subject to the terms of the revised BSD
|
||||
// license. You should have received a copy of this license along
|
||||
// with this source code in a file named "LICENSE."
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "copy_stream.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: copy_stream
|
||||
// Access: Published
|
||||
// Description: Reads the source stream from its current position to
|
||||
// the end of the stream, and writes that data to the
|
||||
// dest stream at its current position. Returns true on
|
||||
// success, false on failure.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool
|
||||
copy_stream(istream &source, ostream &dest) {
|
||||
static const size_t buffer_size = 4096;
|
||||
char buffer[buffer_size];
|
||||
|
||||
source.read(buffer, buffer_size);
|
||||
size_t count = source.gcount();
|
||||
while (count != 0) {
|
||||
dest.write(buffer, count);
|
||||
source.read(buffer, buffer_size);
|
||||
count = source.gcount();
|
||||
}
|
||||
|
||||
return (!source.fail() || source.eof()) && (!dest.fail());
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
// Filename: copy_stream.h
|
||||
// Created by: drose (27Aug09)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) Carnegie Mellon University. All rights reserved.
|
||||
//
|
||||
// All use of this software is subject to the terms of the revised BSD
|
||||
// license. You should have received a copy of this license along
|
||||
// with this source code in a file named "LICENSE."
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef COPY_STREAM_H
|
||||
#define COPY_STREAM_H
|
||||
|
||||
#include "pandabase.h"
|
||||
|
||||
BEGIN_PUBLISH
|
||||
EXPCL_PANDAEXPRESS bool
|
||||
copy_stream(istream &source, ostream &dest);
|
||||
END_PUBLISH
|
||||
|
||||
#endif
|
||||
|
|
@ -2,6 +2,7 @@
|
|||
#include "checksumHashGenerator.cxx"
|
||||
#include "config_express.cxx"
|
||||
#include "compress_string.cxx"
|
||||
#include "copy_stream.cxx"
|
||||
#include "datagram.cxx"
|
||||
#include "datagramGenerator.cxx"
|
||||
#include "datagramIterator.cxx"
|
||||
|
|
|
|||
Loading…
Reference in New Issue