mirror of https://github.com/aria2/aria2
make string type argument const string& where possible
parent
1457d7f660
commit
b1d46227d4
|
@ -59,7 +59,7 @@ void AbstractDiskWriter::closeFile() {
|
|||
}
|
||||
}
|
||||
|
||||
void AbstractDiskWriter::openExistingFile(string filename) {
|
||||
void AbstractDiskWriter::openExistingFile(const string& filename) {
|
||||
File f(filename);
|
||||
if(!f.isFile()) {
|
||||
throw new DlAbortEx(EX_FILE_OPEN, filename.c_str(), "file not found");
|
||||
|
@ -70,7 +70,7 @@ void AbstractDiskWriter::openExistingFile(string filename) {
|
|||
}
|
||||
}
|
||||
|
||||
void AbstractDiskWriter::createFile(string filename, int addFlags) {
|
||||
void AbstractDiskWriter::createFile(const string& filename, int addFlags) {
|
||||
// TODO proper filename handling needed
|
||||
assert(filename.size());
|
||||
// if(filename.empty()) {
|
||||
|
|
|
@ -35,7 +35,7 @@ protected:
|
|||
MessageDigestContext ctx;
|
||||
#endif // ENABLE_SHA1DIGEST
|
||||
|
||||
void createFile(string filename, int addFlags = 0);
|
||||
void createFile(const string& filename, int addFlags = 0);
|
||||
|
||||
void writeDataInternal(const char* data, int len);
|
||||
int readDataInternal(char* data, int len);
|
||||
|
@ -50,7 +50,7 @@ public:
|
|||
|
||||
void closeFile();
|
||||
|
||||
void openExistingFile(string filename);
|
||||
void openExistingFile(const string& filename);
|
||||
|
||||
string sha1Sum(long long int offset, long long int length);
|
||||
|
||||
|
|
|
@ -60,8 +60,9 @@ string Base64::part_encode(const string& subplain)
|
|||
return crypted;
|
||||
}
|
||||
|
||||
string Base64::encode(string plain)
|
||||
string Base64::encode(const string& plainSrc)
|
||||
{
|
||||
string plain = plainSrc;
|
||||
int remainder = plain.size() % 3;
|
||||
if( remainder ) remainder = 3-remainder;
|
||||
for(int i = 0; i < remainder; ++i) plain += (char)0;
|
||||
|
@ -112,7 +113,7 @@ string Base64::part_decode(const string& subCrypted)
|
|||
return plain;
|
||||
}
|
||||
|
||||
string Base64::decode(string crypted)
|
||||
string Base64::decode(const string& crypted)
|
||||
{
|
||||
string plain;
|
||||
int sIndex = 0;
|
||||
|
|
|
@ -32,8 +32,8 @@ private:
|
|||
static string part_decode(const string& subCrypted);
|
||||
static char getValue(char ch);
|
||||
public:
|
||||
static string encode(string plain);
|
||||
static string decode(string crypted);
|
||||
static string encode(const string& plain);
|
||||
static string decode(const string& crypted);
|
||||
};
|
||||
|
||||
#endif // _BASE64_H_
|
||||
|
|
|
@ -42,12 +42,7 @@ void ByteArrayDiskWriter::init() {
|
|||
bufLength = 0;
|
||||
}
|
||||
|
||||
void ByteArrayDiskWriter::reset() {
|
||||
clear();
|
||||
init();
|
||||
}
|
||||
|
||||
void ByteArrayDiskWriter::initAndOpenFile(string filename) {
|
||||
void ByteArrayDiskWriter::initAndOpenFile(const string& filename) {
|
||||
openFile(filename);
|
||||
}
|
||||
|
||||
|
@ -60,7 +55,7 @@ void ByteArrayDiskWriter::closeFile() {
|
|||
clear();
|
||||
}
|
||||
|
||||
void ByteArrayDiskWriter::openExistingFile(string filename) {
|
||||
void ByteArrayDiskWriter::openExistingFile(const string& filename) {
|
||||
openFile(filename);
|
||||
}
|
||||
|
||||
|
|
|
@ -36,13 +36,13 @@ public:
|
|||
ByteArrayDiskWriter();
|
||||
virtual ~ByteArrayDiskWriter();
|
||||
|
||||
virtual void initAndOpenFile(string filename);
|
||||
virtual void initAndOpenFile(const string& filename);
|
||||
|
||||
virtual void openFile(const string& filename);
|
||||
|
||||
virtual void closeFile();
|
||||
|
||||
virtual void openExistingFile(string filename);
|
||||
virtual void openExistingFile(const string& filename);
|
||||
|
||||
// position is ignored
|
||||
virtual void writeData(const char* data, int len, long long int position = 0);
|
||||
|
@ -56,7 +56,6 @@ public:
|
|||
int getByteArrayLength() const {
|
||||
return bufLength;
|
||||
}
|
||||
void reset();
|
||||
};
|
||||
|
||||
#endif // _D_BYTE_ARRAY_DISK_WRITER_H_
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
class ConnectionException:public DlAbortEx {
|
||||
public:
|
||||
ConnectionException():DlAbortEx() {}
|
||||
ConnectionException(string msg):DlAbortEx() {}
|
||||
ConnectionException(const string& msg):DlAbortEx() {}
|
||||
};
|
||||
|
||||
#endif // _D_CONNECTION_EXCEPTION_H_
|
||||
|
|
|
@ -29,7 +29,7 @@ DefaultDiskWriter::DefaultDiskWriter(long long int totalLength):AbstractDiskWrit
|
|||
|
||||
DefaultDiskWriter::~DefaultDiskWriter() {}
|
||||
|
||||
void DefaultDiskWriter::initAndOpenFile(string filename) {
|
||||
void DefaultDiskWriter::initAndOpenFile(const string& filename) {
|
||||
createFile(filename);
|
||||
if(totalLength > 0) {
|
||||
ftruncate(fd, totalLength);
|
||||
|
|
|
@ -32,7 +32,7 @@ public:
|
|||
DefaultDiskWriter(long long int totalLength);
|
||||
~DefaultDiskWriter();
|
||||
|
||||
void initAndOpenFile(string filename);
|
||||
void initAndOpenFile(const string& filename);
|
||||
};
|
||||
|
||||
#endif // _D_DEFAULT_DISK_WRITER_H_
|
||||
|
|
|
@ -34,7 +34,7 @@ void Dictionary::clearTable() {
|
|||
}
|
||||
}
|
||||
|
||||
const MetaEntry* Dictionary::get(string name) const {
|
||||
const MetaEntry* Dictionary::get(const string& name) const {
|
||||
MetaTable::const_iterator itr = table.find(name);
|
||||
if(itr == table.end()) {
|
||||
return NULL;
|
||||
|
@ -43,7 +43,7 @@ const MetaEntry* Dictionary::get(string name) const {
|
|||
}
|
||||
}
|
||||
|
||||
void Dictionary::put(string name, MetaEntry* entry) {
|
||||
void Dictionary::put(const string& name, MetaEntry* entry) {
|
||||
table[name] = entry;
|
||||
order.push_back(name);
|
||||
}
|
||||
|
|
|
@ -41,8 +41,8 @@ public:
|
|||
Dictionary();
|
||||
~Dictionary();
|
||||
|
||||
const MetaEntry* get(string name) const;
|
||||
void put(string name, MetaEntry* entry);
|
||||
const MetaEntry* get(const string& name) const;
|
||||
void put(const string& name, MetaEntry* entry);
|
||||
|
||||
void accept(MetaEntryVisitor* v) const;
|
||||
const Order& getOrder() const;
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
Directory::Directory(string name):name(name) {}
|
||||
Directory::Directory(const string& name):name(name) {}
|
||||
|
||||
Directory::~Directory() {
|
||||
for(Files::iterator itr = files.begin(); itr != files.end(); itr++) {
|
||||
|
@ -34,7 +34,7 @@ Directory::~Directory() {
|
|||
}
|
||||
}
|
||||
|
||||
void Directory::createDir(string parentDir, bool recursive) const {
|
||||
void Directory::createDir(const string& parentDir, bool recursive) const {
|
||||
string path = parentDir+"/"+name;
|
||||
File f(path);
|
||||
if(f.exists()) {
|
||||
|
|
|
@ -34,10 +34,10 @@ private:
|
|||
string name;
|
||||
Files files;
|
||||
public:
|
||||
Directory(string name);
|
||||
Directory(const string& name);
|
||||
~Directory();
|
||||
|
||||
void createDir(string parentDir, bool recursive) const;
|
||||
void createDir(const string& parentDir, bool recursive) const;
|
||||
void addFile(Directory* directory);
|
||||
};
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ public:
|
|||
* If the file exists, then it is truncated to 0 length.
|
||||
* @param filename the file name to be opened.
|
||||
*/
|
||||
virtual void initAndOpenFile(string filename) = 0;
|
||||
virtual void initAndOpenFile(const string& filename) = 0;
|
||||
|
||||
virtual void openFile(const string& filename) = 0;
|
||||
|
||||
|
@ -54,7 +54,7 @@ public:
|
|||
*
|
||||
* @param filename the file name to be opened.
|
||||
*/
|
||||
virtual void openExistingFile(string filename) = 0;
|
||||
virtual void openExistingFile(const string& filename) = 0;
|
||||
|
||||
/*
|
||||
* Writes len bytes from data to this binary stream at offset position.
|
||||
|
|
|
@ -42,7 +42,7 @@ public:
|
|||
DownloadCommand(int cuid, Request* req, DownloadEngine* e, const Socket* s);
|
||||
virtual ~DownloadCommand();
|
||||
|
||||
virtual TransferEncoding* getTransferEncoding(string transferEncoding) = 0;
|
||||
virtual TransferEncoding* getTransferEncoding(const string& transferEncoding) = 0;
|
||||
|
||||
string transferEncoding;
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ class Exception {
|
|||
private:
|
||||
string msg;
|
||||
protected:
|
||||
void setMsg(string msgsrc, va_list ap) {
|
||||
void setMsg(const string& msgsrc, va_list ap) {
|
||||
char buf[256];
|
||||
vsnprintf(buf, sizeof(buf), msgsrc.c_str(), ap);
|
||||
msg = buf;
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
File::File(string name):name(name) {}
|
||||
File::File(const string& name):name(name) {}
|
||||
|
||||
File::~File() {}
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ private:
|
|||
string name;
|
||||
int fillStat(struct stat& fstat);
|
||||
public:
|
||||
File(string name);
|
||||
File(const string& name);
|
||||
~File();
|
||||
|
||||
/**
|
||||
|
|
|
@ -31,7 +31,7 @@ public:
|
|||
long long int offset;
|
||||
bool extracted;
|
||||
bool requested;
|
||||
FileEntry(string path, long long int length, long long int offset):
|
||||
FileEntry(const string& path, long long int length, long long int offset):
|
||||
path(path), length(length), offset(offset),
|
||||
extracted(false), requested(true) {}
|
||||
~FileEntry() {}
|
||||
|
|
|
@ -33,6 +33,6 @@ FtpDownloadCommand::~FtpDownloadCommand() {
|
|||
}
|
||||
}
|
||||
|
||||
TransferEncoding* FtpDownloadCommand::getTransferEncoding(string name) {
|
||||
TransferEncoding* FtpDownloadCommand::getTransferEncoding(const string& name) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ public:
|
|||
FtpDownloadCommand(int cuid, Request* req, DownloadEngine* e, const Socket* dataSocket, const Socket* ctrlSocket);
|
||||
~FtpDownloadCommand();
|
||||
|
||||
TransferEncoding* getTransferEncoding(string name);
|
||||
TransferEncoding* getTransferEncoding(const string& name);
|
||||
};
|
||||
|
||||
#endif // _D_FTP_DOWNLOAD_COMMAND_H_
|
||||
|
|
|
@ -46,6 +46,6 @@ HttpDownloadCommand::~HttpDownloadCommand() {
|
|||
}
|
||||
}
|
||||
|
||||
TransferEncoding* HttpDownloadCommand::getTransferEncoding(string name) {
|
||||
TransferEncoding* HttpDownloadCommand::getTransferEncoding(const string& name) {
|
||||
return transferEncodings[name];
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ public:
|
|||
HttpDownloadCommand(int cuid, Request* req, DownloadEngine* e, const Socket* s);
|
||||
~HttpDownloadCommand();
|
||||
|
||||
TransferEncoding* getTransferEncoding(string transferEncoding);
|
||||
TransferEncoding* getTransferEncoding(const string& transferEncoding);
|
||||
};
|
||||
|
||||
#endif // _D_HTTP_DOWNLOAD_COMMAND_H_
|
||||
|
|
|
@ -84,7 +84,7 @@ void HttpResponseCommand::checkResponse(int status, const Segment& segment) {
|
|||
}
|
||||
}
|
||||
|
||||
bool HttpResponseCommand::handleRedirect(string url, const HttpHeader& headers) {
|
||||
bool HttpResponseCommand::handleRedirect(const string& url, const HttpHeader& headers) {
|
||||
req->redirectUrl(url);
|
||||
logger->info(MSG_REDIRECT, cuid, url.c_str());
|
||||
e->noWait = true;
|
||||
|
@ -126,7 +126,7 @@ bool HttpResponseCommand::handleDefaultEncoding(const HttpHeader& headers) {
|
|||
}
|
||||
}
|
||||
|
||||
bool HttpResponseCommand::handleOtherEncoding(string transferEncoding, const HttpHeader& headers) {
|
||||
bool HttpResponseCommand::handleOtherEncoding(const string& transferEncoding, const HttpHeader& headers) {
|
||||
// we ignore content-length when transfer-encoding is set
|
||||
e->segmentMan->downloadStarted = true;
|
||||
e->segmentMan->isSplittable = false;
|
||||
|
@ -139,7 +139,7 @@ bool HttpResponseCommand::handleOtherEncoding(string transferEncoding, const Htt
|
|||
return true;
|
||||
}
|
||||
|
||||
void HttpResponseCommand::createHttpDownloadCommand(string transferEncoding) {
|
||||
void HttpResponseCommand::createHttpDownloadCommand(const string& transferEncoding) {
|
||||
|
||||
HttpDownloadCommand* command = new HttpDownloadCommand(cuid, req, e, socket);
|
||||
TransferEncoding* enc = NULL;
|
||||
|
|
|
@ -28,10 +28,10 @@
|
|||
class HttpResponseCommand : public AbstractCommand {
|
||||
private:
|
||||
void checkResponse(int status, const Segment& segment);
|
||||
bool handleRedirect(string url, const HttpHeader& headers);
|
||||
bool handleRedirect(const string& url, const HttpHeader& headers);
|
||||
bool handleDefaultEncoding(const HttpHeader& headers);
|
||||
bool handleOtherEncoding(string transferEncoding, const HttpHeader& headers);
|
||||
void createHttpDownloadCommand(string transferEncoding = "");
|
||||
bool handleOtherEncoding(const string& transferEncoding, const HttpHeader& headers);
|
||||
void createHttpDownloadCommand(const string& transferEncoding = "");
|
||||
void retrieveCookie(const HttpHeader& headers);
|
||||
HttpConnection* http;
|
||||
protected:
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
MetaEntry* MetaFileUtil::parseMetaFile(string file) {
|
||||
MetaEntry* MetaFileUtil::parseMetaFile(const string& file) {
|
||||
File f(file);
|
||||
int len = f.size();
|
||||
char* buf = new char[len];
|
||||
|
|
|
@ -43,7 +43,7 @@ private:
|
|||
static string decodeWordAsString(const char** pp, const char* end);
|
||||
|
||||
public:
|
||||
static MetaEntry* parseMetaFile(string file);
|
||||
static MetaEntry* parseMetaFile(const string& file);
|
||||
static MetaEntry* bdecoding(const char* buf, int len);
|
||||
};
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ void MultiDiskWriter::openFile(const string& filename) {
|
|||
}
|
||||
|
||||
// filename is a directory which is specified by the user in the option.
|
||||
void MultiDiskWriter::initAndOpenFile(string filename) {
|
||||
void MultiDiskWriter::initAndOpenFile(const string& filename) {
|
||||
for(DiskWriterEntries::iterator itr = diskWriterEntries.begin();
|
||||
itr != diskWriterEntries.end(); itr++) {
|
||||
(*itr)->diskWriter->initAndOpenFile(filename+"/"+(*itr)->fileEntry.path);
|
||||
|
@ -75,7 +75,7 @@ void MultiDiskWriter::closeFile() {
|
|||
}
|
||||
}
|
||||
|
||||
void MultiDiskWriter::openExistingFile(string filename) {
|
||||
void MultiDiskWriter::openExistingFile(const string& filename) {
|
||||
for(DiskWriterEntries::iterator itr = diskWriterEntries.begin();
|
||||
itr != diskWriterEntries.end(); itr++) {
|
||||
(*itr)->diskWriter->openExistingFile(filename+"/"+(*itr)->fileEntry.path);
|
||||
|
|
|
@ -60,9 +60,9 @@ public:
|
|||
void setFileEntries(const FileEntries& fileEntries);
|
||||
|
||||
virtual void openFile(const string& filename);
|
||||
virtual void initAndOpenFile(string filename);
|
||||
virtual void initAndOpenFile(const string& filename);
|
||||
virtual void closeFile();
|
||||
virtual void openExistingFile(string filename);
|
||||
virtual void openExistingFile(const string& filename);
|
||||
virtual void writeData(const char* data, int len, long long int position = 0);
|
||||
virtual int readData(char* data, int len, long long int position);
|
||||
virtual string sha1Sum(long long int offset, long long int length);
|
||||
|
|
|
@ -33,7 +33,7 @@ PreAllocationDiskWriter::PreAllocationDiskWriter(long long int totalLength)
|
|||
|
||||
PreAllocationDiskWriter::~PreAllocationDiskWriter() {}
|
||||
|
||||
void PreAllocationDiskWriter::initAndOpenFile(string filename) {
|
||||
void PreAllocationDiskWriter::initAndOpenFile(const string& filename) {
|
||||
createFile(filename);
|
||||
int bufSize = 4096;
|
||||
char buf[4096];
|
||||
|
|
|
@ -31,7 +31,7 @@ public:
|
|||
PreAllocationDiskWriter(long long int totalLength);
|
||||
~PreAllocationDiskWriter();
|
||||
|
||||
void initAndOpenFile(string filename);
|
||||
void initAndOpenFile(const string& filename);
|
||||
};
|
||||
|
||||
#endif // _D_PRE_ALLOCATION_DISK_WRITER_H_
|
||||
|
|
|
@ -40,7 +40,7 @@ Request::~Request() {
|
|||
delete cookieBox;
|
||||
}
|
||||
|
||||
bool Request::setUrl(string url) {
|
||||
bool Request::setUrl(const string& url) {
|
||||
this->url = url;
|
||||
return parseUrl(url);
|
||||
}
|
||||
|
@ -50,12 +50,12 @@ bool Request::resetUrl() {
|
|||
return setUrl(url);
|
||||
}
|
||||
|
||||
bool Request::redirectUrl(string url) {
|
||||
bool Request::redirectUrl(const string& url) {
|
||||
previousUrl = currentUrl;
|
||||
return parseUrl(url);
|
||||
}
|
||||
|
||||
bool Request::parseUrl(string url) {
|
||||
bool Request::parseUrl(const string& url) {
|
||||
currentUrl = url;
|
||||
host = "";
|
||||
port = 0;
|
||||
|
|
|
@ -57,7 +57,7 @@ private:
|
|||
map<string, int> defaultPorts;
|
||||
int tryCount;
|
||||
int trackerEvent;
|
||||
bool parseUrl(string url);
|
||||
bool parseUrl(const string& url);
|
||||
public:
|
||||
Segment seg;
|
||||
CookieBox* cookieBox;
|
||||
|
@ -68,11 +68,11 @@ public:
|
|||
|
||||
// Parses URL and sets url, host, port, dir, file fields.
|
||||
// Returns true if parsing goes successful, otherwise returns false.
|
||||
bool setUrl(string url);
|
||||
bool setUrl(const string& url);
|
||||
// Parses URL and sets host, port, dir, file fields.
|
||||
// url field are not altered by this method.
|
||||
// Returns true if parsing goes successful, otherwise returns false.
|
||||
bool redirectUrl(string url);
|
||||
bool redirectUrl(const string& url);
|
||||
bool resetUrl();
|
||||
void resetTryCount() { tryCount = 0; }
|
||||
void addTryCount() { tryCount++; }
|
||||
|
@ -83,7 +83,7 @@ public:
|
|||
string getCurrentUrl() const { return currentUrl; }
|
||||
string getPreviousUrl() const { return previousUrl; }
|
||||
string getReferer() const { return referer; }
|
||||
void setReferer(string url) { referer = previousUrl = url; }
|
||||
void setReferer(const string& url) { referer = previousUrl = url; }
|
||||
string getProtocol() const { return protocol; }
|
||||
string getHost() const { return host; }
|
||||
int getPort() const { return port; }
|
||||
|
|
|
@ -150,7 +150,7 @@ void SegmentMan::save() const {
|
|||
logger->info(MSG_SAVED_SEGMENT_FILE);
|
||||
}
|
||||
|
||||
FILE* SegmentMan::openSegFile(string segFilename, string mode) const {
|
||||
FILE* SegmentMan::openSegFile(const string& segFilename, const string& mode) const {
|
||||
FILE* segFile = fopen(segFilename.c_str(), mode.c_str());
|
||||
if(segFile == NULL) {
|
||||
throw new DlAbortEx(strerror(errno));
|
||||
|
|
|
@ -41,7 +41,7 @@ private:
|
|||
const Logger* logger;
|
||||
|
||||
void read(FILE* file);
|
||||
FILE* openSegFile(string segFilename, string mode) const;
|
||||
FILE* openSegFile(const string& segFilename, const string& mode) const;
|
||||
public:
|
||||
/**
|
||||
* The total number of bytes to download.
|
||||
|
|
|
@ -69,7 +69,7 @@ Socket* Socket::acceptConnection() const {
|
|||
return new Socket(core->acceptConnection());
|
||||
}
|
||||
|
||||
void Socket::establishConnection(string host, int port) const {
|
||||
void Socket::establishConnection(const string& host, int port) const {
|
||||
core->establishConnection(host, port);
|
||||
}
|
||||
|
||||
|
@ -93,7 +93,7 @@ void Socket::writeData(const char* data, int len, int timeout) const {
|
|||
core->writeData(data, len, timeout);
|
||||
}
|
||||
|
||||
void Socket::writeData(string str, int timeout) const {
|
||||
void Socket::writeData(const string& str, int timeout) const {
|
||||
core->writeData(str.c_str(), str.size(), timeout);
|
||||
}
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ public:
|
|||
/**
|
||||
* @see SocketCore::establishConnection()
|
||||
*/
|
||||
void establishConnection(string host, int port) const;
|
||||
void establishConnection(const string& host, int port) const;
|
||||
|
||||
/**
|
||||
* @see SocketCore::setBlockingMode()
|
||||
|
@ -101,7 +101,7 @@ public:
|
|||
* A covenient function that can take string class parameter and
|
||||
* internally calls SocketCore::writeData().
|
||||
*/
|
||||
void writeData(string str, int timeout = 5) const;
|
||||
void writeData(const string& str, int timeout = 5) const;
|
||||
|
||||
/**
|
||||
* @see SocketCore::readData()
|
||||
|
|
|
@ -130,7 +130,7 @@ void SocketCore::getPeerInfo(pair<string, int>& peerinfo) const {
|
|||
peerinfo.second = ntohs(peerin.sin_port);
|
||||
}
|
||||
|
||||
void SocketCore::establishConnection(string host, int port) {
|
||||
void SocketCore::establishConnection(const string& host, int port) {
|
||||
closeConnection();
|
||||
sockfd = socket(AF_INET, SOCK_STREAM, 0);
|
||||
if(sockfd == -1) {
|
||||
|
|
|
@ -102,7 +102,7 @@ public:
|
|||
* @param host hostname or ip address to connect to
|
||||
* @param port service port number to connect to
|
||||
*/
|
||||
void establishConnection(string host, int port);
|
||||
void establishConnection(const string& host, int port);
|
||||
|
||||
/**
|
||||
* Makes this socket blocking mode.
|
||||
|
|
|
@ -350,7 +350,7 @@ void TorrentMan::readFileEntry(FileEntries& fileEntries, Directory** pTopDir, co
|
|||
}
|
||||
}
|
||||
|
||||
void TorrentMan::setup(string metaInfoFile, const Strings& targetFilePaths) {
|
||||
void TorrentMan::setup(const string& metaInfoFile, const Strings& targetFilePaths) {
|
||||
peerId = "-A2****-";
|
||||
for(int i = 0; i < 12; i++) {
|
||||
peerId += Util::itos((int)(((double)10)*random()/(RAND_MAX+1.0)));
|
||||
|
@ -466,7 +466,7 @@ bool TorrentMan::segmentFileExists() const {
|
|||
}
|
||||
}
|
||||
|
||||
FILE* TorrentMan::openSegFile(string segFilename, string mode) const {
|
||||
FILE* TorrentMan::openSegFile(const string& segFilename, const string& mode) const {
|
||||
FILE* segFile = fopen(segFilename.c_str(), mode.c_str());
|
||||
if(segFile == NULL) {
|
||||
throw new DlAbortEx(strerror(errno));
|
||||
|
|
|
@ -76,7 +76,7 @@ private:
|
|||
bool setupComplete;
|
||||
const Logger* logger;
|
||||
|
||||
FILE* openSegFile(string segFilename, string mode) const;
|
||||
FILE* openSegFile(const string& segFilename, const string& mode) const;
|
||||
void read(FILE* file);
|
||||
|
||||
Piece findUsedPiece(int index) const;
|
||||
|
@ -141,7 +141,7 @@ public:
|
|||
return infoHash;
|
||||
}
|
||||
|
||||
void setup(string metaInfoFile, const Strings& targetFilePaths);
|
||||
void setup(const string& metaInfoFile, const Strings& targetFilePaths);
|
||||
|
||||
string getPieceHash(int index) const;
|
||||
|
||||
|
@ -201,7 +201,7 @@ public:
|
|||
}
|
||||
|
||||
string getStoreDir() const { return storeDir; }
|
||||
void setStoreDir(string dir) { storeDir = dir; }
|
||||
void setStoreDir(const string& dir) { storeDir = dir; }
|
||||
|
||||
string getSegmentFilePath() const;
|
||||
|
||||
|
|
Loading…
Reference in New Issue