mirror of https://github.com/aria2/aria2
2010-01-24 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Fixed compile error with i586-mingw32msvc-g++. Always Cut console readout by 80 characters in mingw32 build. Catch exception in DHTMessageReceiver::receiveMessage(). * src/AbstractDiskWriter.cc * src/ConsoleStatCalc.cc * src/DHTMessageReceiver.cc * src/File.cc * src/RequestGroupMan.cc * src/a2io.h * test/FileTest.ccpull/1/head
parent
46605f66c3
commit
b39ede01a7
13
ChangeLog
13
ChangeLog
|
@ -1,3 +1,16 @@
|
||||||
|
2010-01-24 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
|
Fixed compile error with i586-mingw32msvc-g++. Always Cut console
|
||||||
|
readout by 80 characters in mingw32 build. Catch exception in
|
||||||
|
DHTMessageReceiver::receiveMessage().
|
||||||
|
* src/AbstractDiskWriter.cc
|
||||||
|
* src/ConsoleStatCalc.cc
|
||||||
|
* src/DHTMessageReceiver.cc
|
||||||
|
* src/File.cc
|
||||||
|
* src/RequestGroupMan.cc
|
||||||
|
* src/a2io.h
|
||||||
|
* test/FileTest.cc
|
||||||
|
|
||||||
2010-01-24 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
2010-01-24 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
Fixed compile error with intel compiler
|
Fixed compile error with intel compiler
|
||||||
|
|
|
@ -139,7 +139,7 @@ ssize_t AbstractDiskWriter::readDataInternal(unsigned char* data, size_t len)
|
||||||
|
|
||||||
void AbstractDiskWriter::seek(off_t offset)
|
void AbstractDiskWriter::seek(off_t offset)
|
||||||
{
|
{
|
||||||
if(lseek(fd, offset, SEEK_SET) == (off_t)-1) {
|
if(a2lseek(fd, offset, SEEK_SET) == (off_t)-1) {
|
||||||
throw DL_ABORT_EX
|
throw DL_ABORT_EX
|
||||||
(StringFormat(EX_FILE_SEEK, _filename.c_str(), strerror(errno)).str());
|
(StringFormat(EX_FILE_SEEK, _filename.c_str(), strerror(errno)).str());
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,7 @@
|
||||||
#endif // HAVE_SYS_IOCTL_H
|
#endif // HAVE_SYS_IOCTL_H
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <cstdio>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
@ -218,25 +219,25 @@ ConsoleStatCalc::calculateStat(const DownloadEngine* e)
|
||||||
}
|
}
|
||||||
_cp.reset();
|
_cp.reset();
|
||||||
const SizeFormatter& sizeFormatter = *_sizeFormatter.get();
|
const SizeFormatter& sizeFormatter = *_sizeFormatter.get();
|
||||||
|
|
||||||
|
#ifdef __MINGW32__
|
||||||
|
bool isTTY = true;
|
||||||
|
// Windows terminal cannot handle at the end of line properly.
|
||||||
|
unsigned short int cols = 79;
|
||||||
|
#else // !__MINGW32__
|
||||||
bool isTTY = isatty(STDOUT_FILENO) == 1;
|
bool isTTY = isatty(STDOUT_FILENO) == 1;
|
||||||
unsigned short int cols = 80;
|
unsigned short int cols = 80;
|
||||||
#ifdef __MINGW32__
|
#endif // !__MINGW32__
|
||||||
// Windows terminal cannot handle at the end of line properly.
|
|
||||||
--cols;
|
|
||||||
#endif // __MINGW32__
|
|
||||||
if(isTTY) {
|
if(isTTY) {
|
||||||
|
#ifndef __MINGW32__
|
||||||
#ifdef HAVE_TERMIOS_H
|
#ifdef HAVE_TERMIOS_H
|
||||||
struct winsize size;
|
struct winsize size;
|
||||||
if(ioctl(STDOUT_FILENO, TIOCGWINSZ, &size) == 0) {
|
if(ioctl(STDOUT_FILENO, TIOCGWINSZ, &size) == 0) {
|
||||||
cols = size.ws_col;
|
cols = size.ws_col;
|
||||||
#ifdef __MINGW32__
|
|
||||||
if(cols > 0) {
|
|
||||||
// Windows terminal cannot handle at the end of line properly.
|
|
||||||
--cols;
|
|
||||||
}
|
|
||||||
#endif // __MINGW32__
|
|
||||||
}
|
}
|
||||||
#endif // HAVE_TERMIOS_H
|
#endif // HAVE_TERMIOS_H
|
||||||
|
#endif // !__MINGW32__
|
||||||
std::cout << '\r' << std::setfill(' ') << std::setw(cols) << ' ' << '\r';
|
std::cout << '\r' << std::setfill(' ') << std::setw(cols) << ' ' << '\r';
|
||||||
}
|
}
|
||||||
std::ostringstream o;
|
std::ostringstream o;
|
||||||
|
|
|
@ -66,13 +66,13 @@ SharedHandle<DHTMessage> DHTMessageReceiver::receiveMessage()
|
||||||
std::string remoteAddr;
|
std::string remoteAddr;
|
||||||
uint16_t remotePort;
|
uint16_t remotePort;
|
||||||
unsigned char data[64*1024];
|
unsigned char data[64*1024];
|
||||||
ssize_t length = _connection->receiveMessage(data, sizeof(data),
|
|
||||||
remoteAddr,
|
|
||||||
remotePort);
|
|
||||||
if(length <= 0) {
|
|
||||||
return SharedHandle<DHTMessage>();
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
|
ssize_t length = _connection->receiveMessage(data, sizeof(data),
|
||||||
|
remoteAddr,
|
||||||
|
remotePort);
|
||||||
|
if(length <= 0) {
|
||||||
|
return SharedHandle<DHTMessage>();
|
||||||
|
}
|
||||||
bool isReply = false;
|
bool isReply = false;
|
||||||
const BDE dict = bencode::decode(data, length);
|
const BDE dict = bencode::decode(data, length);
|
||||||
if(dict.isDict()) {
|
if(dict.isDict()) {
|
||||||
|
|
|
@ -59,7 +59,7 @@ File::File(const std::string& name):name(name) {}
|
||||||
File::~File() {}
|
File::~File() {}
|
||||||
|
|
||||||
int File::fillStat(a2_struct_stat& fstat) {
|
int File::fillStat(a2_struct_stat& fstat) {
|
||||||
return stat(name.c_str(), &fstat);
|
return a2stat(name.c_str(), &fstat);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool File::exists() {
|
bool File::exists() {
|
||||||
|
|
|
@ -577,8 +577,13 @@ void RequestGroupMan::showDownloadResults(std::ostream& o) const
|
||||||
o << "\n"
|
o << "\n"
|
||||||
<<_("Download Results:") << "\n"
|
<<_("Download Results:") << "\n"
|
||||||
<< "gid|stat|avg speed |path/URI" << "\n"
|
<< "gid|stat|avg speed |path/URI" << "\n"
|
||||||
<< "===+====+===========+===========================================================" << "\n";
|
<< "===+====+===========+";
|
||||||
|
#ifdef __MINGW32__
|
||||||
|
int pathRowSize = 58;
|
||||||
|
#else // !__MINGW32__
|
||||||
|
int pathRowSize = 59;
|
||||||
|
#endif // !__MINGW32__
|
||||||
|
o << std::setfill('=') << std::setw(pathRowSize) << '=' << "\n";
|
||||||
int ok = 0;
|
int ok = 0;
|
||||||
int err = 0;
|
int err = 0;
|
||||||
int inpr = 0;
|
int inpr = 0;
|
||||||
|
|
23
src/a2io.h
23
src/a2io.h
|
@ -113,22 +113,27 @@
|
||||||
#endif // HAVE_WINSOCK2_H
|
#endif // HAVE_WINSOCK2_H
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
#ifdef __MINGW32__
|
||||||
# define lseek(fd, offset, origin) _lseeki64(fd, offset, origin)
|
# define a2lseek(fd, offset, origin) _lseeki64(fd, offset, origin)
|
||||||
# define fseek(fd, offset, origin) _fseeki64(fd, offset, origin)
|
# define a2fseek(fd, offset, origin) _fseeki64(fd, offset, origin)
|
||||||
# define fstat(fd, buf) _fstati64(fd, buf)
|
# define a2fstat(fd, buf) _fstati64(fd, buf)
|
||||||
# define ftell(fd) _ftelli64(fd)
|
# define a2ftell(fd) _ftelli64(fd)
|
||||||
# define wstat(path, buf) _wstati64(path, buf)
|
# define a2wstat(path, buf) _wstati64(path, buf)
|
||||||
# ifdef stat
|
# ifdef stat
|
||||||
# undef stat
|
# undef stat
|
||||||
# endif // stat
|
# endif // stat
|
||||||
# define a2_struct_stat struct _stati64
|
# define a2_struct_stat struct _stati64
|
||||||
# define stat(path, buf) _stati64(path, buf)
|
# define a2stat(path, buf) _stati64(path, buf)
|
||||||
# define tell(handle) _telli64(handle)
|
# define a2tell(handle) _telli64(handle)
|
||||||
# define a2mkdir(path, openMode) mkdir(path)
|
# define a2mkdir(path, openMode) mkdir(path)
|
||||||
#else
|
#else // !__MINGW32__
|
||||||
|
# define a2lseek(fd, offset, origin) lseek(fd, offset, origin)
|
||||||
|
# define a2fseek(fp, offset, origin) fseek(fp, offset, origin)
|
||||||
|
# define a2fstat(fp, buf) fstat(fp, buf)
|
||||||
|
# define a2ftell(fp) ftell(fp)
|
||||||
# define a2_struct_stat struct stat
|
# define a2_struct_stat struct stat
|
||||||
|
# define a2stat(path, buf) stat(path, buf)
|
||||||
# define a2mkdir(path, openMode) mkdir(path, openMode)
|
# define a2mkdir(path, openMode) mkdir(path, openMode)
|
||||||
#endif // __MINGW32__
|
#endif // !__MINGW32__
|
||||||
|
|
||||||
#if defined HAVE_POSIX_MEMALIGN && defined O_DIRECT
|
#if defined HAVE_POSIX_MEMALIGN && defined O_DIRECT
|
||||||
# define ENABLE_DIRECT_IO 1
|
# define ENABLE_DIRECT_IO 1
|
||||||
|
|
|
@ -222,7 +222,7 @@ void FileTest::testUtime()
|
||||||
CPPUNIT_ASSERT(f.utime(Time(atime), Time(mtime)));
|
CPPUNIT_ASSERT(f.utime(Time(atime), Time(mtime)));
|
||||||
|
|
||||||
a2_struct_stat buf;
|
a2_struct_stat buf;
|
||||||
CPPUNIT_ASSERT(0 == stat(f.getPath().c_str(), &buf));
|
CPPUNIT_ASSERT(0 == a2stat(f.getPath().c_str(), &buf));
|
||||||
CPPUNIT_ASSERT_EQUAL((time_t)atime, buf.st_atime);
|
CPPUNIT_ASSERT_EQUAL((time_t)atime, buf.st_atime);
|
||||||
CPPUNIT_ASSERT_EQUAL((time_t)mtime, f.getModifiedTime().getTime());
|
CPPUNIT_ASSERT_EQUAL((time_t)mtime, f.getModifiedTime().getTime());
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue