linuxdcpp-team team mailing list archive
-
linuxdcpp-team team
-
Mailing list archive
-
Message #02315
[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2281: Revert revision 2280
------------------------------------------------------------
revno: 2281
committer: Steven Sheehy <steven.sheehy@xxxxxxxxx>
branch nick: trunk
timestamp: Sun 2010-10-31 20:50:21 -0500
message:
Revert revision 2280
removed:
dcpp/Streams.cpp
modified:
dcpp/Streams.h
--
lp:dcplusplus
https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk
Your team Dcplusplus-team is subscribed to branch lp:dcplusplus.
To unsubscribe from this branch go to https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk/+edit-subscription
=== removed file 'dcpp/Streams.cpp'
--- dcpp/Streams.cpp 2010-10-31 22:54:47 +0000
+++ dcpp/Streams.cpp 1970-01-01 00:00:00 +0000
@@ -1,31 +0,0 @@
-/*
- * Copyright (C) 2010 Jacek Sieka, arnetheduck on gmail point com
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#include "stdinc.h"
-#include "DCPlusPlus.h"
-#include "Streams.h"
-
-template<bool managed>
-size_t dcpp::LimitedOutputStream<managed>::write(const void* buf, size_t len) throw(Exception) {
- if(maxBytes < len) {
- throw FileException(_("More bytes written than requested"));
- }
- maxBytes -= len;
- return s->write(buf, len);
-}
-
=== modified file 'dcpp/Streams.h'
--- dcpp/Streams.h 2010-10-31 22:54:47 +0000
+++ dcpp/Streams.h 2010-11-01 01:50:21 +0000
@@ -108,13 +108,13 @@
template<bool managed>
class LimitedInputStream : public InputStream {
public:
- LimitedInputStream(InputStream* is, uint64_t aMaxBytes) : s(is), maxBytes(aMaxBytes) {
+ LimitedInputStream(InputStream* is, int64_t aMaxBytes) : s(is), maxBytes(aMaxBytes) {
}
virtual ~LimitedInputStream() throw() { if(managed) delete s; }
size_t read(void* buf, size_t& len) throw(FileException) {
dcassert(maxBytes >= 0);
- len = (size_t)min(maxBytes, (uint64_t)len);
+ len = (size_t)min(maxBytes, (int64_t)len);
if(len == 0)
return 0;
size_t x = s->read(buf, len);
@@ -124,18 +124,24 @@
private:
InputStream* s;
- uint64_t maxBytes;
+ int64_t maxBytes;
};
/** Limits the number of bytes that are requested to be written (not the number actually written!) */
template<bool managed>
class LimitedOutputStream : public OutputStream {
public:
- LimitedOutputStream(OutputStream* os, uint64_t aMaxBytes) : s(os), maxBytes(aMaxBytes) {
+ LimitedOutputStream(OutputStream* os, int64_t aMaxBytes) : s(os), maxBytes(aMaxBytes) {
}
virtual ~LimitedOutputStream() throw() { if(managed) delete s; }
- virtual size_t write(const void* buf, size_t len) throw(Exception);
+ virtual size_t write(const void* buf, size_t len) throw(Exception) {
+ if(maxBytes < len) {
+ throw FileException(_("More bytes written than requested"));
+ }
+ maxBytes -= len;
+ return s->write(buf, len);
+ }
virtual size_t flush() throw(Exception) {
return s->flush();
@@ -144,7 +150,7 @@
virtual bool eof() { return maxBytes == 0; }
private:
OutputStream* s;
- uint64_t maxBytes;
+ int64_t maxBytes;
};
template<bool managed>