mirror of https://github.com/aria2/aria2
[Config] Added support for ENABLE_CONTROL_FILE
parent
b408409f13
commit
9f27580f14
|
@ -256,7 +256,7 @@ std::array<unsigned char, INFO_HASH_LENGTH> DefaultBtProgressInfoFile::getInfoHa
|
||||||
throw DL_ABORT_EX(fmt(EX_SEGMENT_FILE_READ, control_file.c_str()));
|
throw DL_ABORT_EX(fmt(EX_SEGMENT_FILE_READ, control_file.c_str()));
|
||||||
}
|
}
|
||||||
|
|
||||||
auto version = getControlFileVersion(fp, control_file);
|
const auto version = getControlFileVersion(fp, control_file);
|
||||||
|
|
||||||
unsigned char extension[4];
|
unsigned char extension[4];
|
||||||
READ_CHECK_STATIC(fp, extension, sizeof(extension), control_file);
|
READ_CHECK_STATIC(fp, extension, sizeof(extension), control_file);
|
||||||
|
@ -289,7 +289,7 @@ void DefaultBtProgressInfoFile::load()
|
||||||
throw DL_ABORT_EX(fmt(EX_SEGMENT_FILE_READ, filename_.c_str()));
|
throw DL_ABORT_EX(fmt(EX_SEGMENT_FILE_READ, filename_.c_str()));
|
||||||
}
|
}
|
||||||
|
|
||||||
auto version = getControlFileVersion(fp, filename_);
|
const auto version = getControlFileVersion(fp, filename_);
|
||||||
|
|
||||||
unsigned char extension[4];
|
unsigned char extension[4];
|
||||||
READ_CHECK(fp, extension, sizeof(extension));
|
READ_CHECK(fp, extension, sizeof(extension));
|
||||||
|
|
|
@ -46,7 +46,9 @@
|
||||||
#ifdef ENABLE_BITTORRENT
|
#ifdef ENABLE_BITTORRENT
|
||||||
# include "bittorrent_helper.h"
|
# include "bittorrent_helper.h"
|
||||||
#endif // ENABLE_BITTORRENT
|
#endif // ENABLE_BITTORRENT
|
||||||
|
#ifdef ENABLE_CONTROL_FILE
|
||||||
# include "DefaultBtProgressInfoFile.h"
|
# include "DefaultBtProgressInfoFile.h"
|
||||||
|
#endif // ENABLE_CONTROL_FILE
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -91,6 +93,22 @@ bool ProtocolDetector::guessTorrentMagnet(const std::string& uri) const
|
||||||
#endif // !ENABLE_BITTORRENT
|
#endif // !ENABLE_BITTORRENT
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ProtocolDetector::guessAria2ControlFile(const std::string& uri) const
|
||||||
|
{
|
||||||
|
#ifdef ENABLE_CONTROL_FILE
|
||||||
|
File control_file(uri);
|
||||||
|
|
||||||
|
if(!control_file.isFile())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return control_file.getExtension() == DefaultBtProgressInfoFile::getSuffix();
|
||||||
|
#else // !ENABLE_CONTROL_FILE
|
||||||
|
return false;
|
||||||
|
#endif // !ENABLE_CONTROL_FILE
|
||||||
|
}
|
||||||
|
|
||||||
bool ProtocolDetector::guessMetalinkFile(const std::string& uri) const
|
bool ProtocolDetector::guessMetalinkFile(const std::string& uri) const
|
||||||
{
|
{
|
||||||
BufferedFile fp(uri.c_str(), BufferedFile::READ);
|
BufferedFile fp(uri.c_str(), BufferedFile::READ);
|
||||||
|
@ -108,17 +126,4 @@ bool ProtocolDetector::guessMetalinkFile(const std::string& uri) const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ProtocolDetector::guessAria2ControlFile(const std::string& uri) const
|
|
||||||
{
|
|
||||||
File control_file(uri);
|
|
||||||
|
|
||||||
if(!control_file.isFile())
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto control_file_suffix = DefaultBtProgressInfoFile::getSuffix();
|
|
||||||
return control_file.getExtension() == control_file_suffix;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
||||||
|
|
|
@ -67,10 +67,11 @@
|
||||||
# include "BtConstants.h"
|
# include "BtConstants.h"
|
||||||
# include "ValueBaseBencodeParser.h"
|
# include "ValueBaseBencodeParser.h"
|
||||||
#endif // ENABLE_BITTORRENT
|
#endif // ENABLE_BITTORRENT
|
||||||
// TODO ENABLE CONTROLFILE
|
#ifdef ENABLE_CONTROL_FILE
|
||||||
# include "TorrentAttribute.h"
|
# include "TorrentAttribute.h"
|
||||||
# include "bittorrent_helper.h"
|
# include "bittorrent_helper.h"
|
||||||
# include "DefaultBtProgressInfoFile.h"
|
# include "DefaultBtProgressInfoFile.h"
|
||||||
|
#endif // ENABLE_CONTROL_FILE
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -450,7 +451,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // ENABLE_METALINK
|
#endif // ENABLE_METALINK
|
||||||
//TOOD: ifdef of ENABLE aria2
|
#ifdef ENABLE_CONTROL_FILE
|
||||||
else if (!ignoreLocalPath_ && detector_.guessAria2ControlFile(uri))
|
else if (!ignoreLocalPath_ && detector_.guessAria2ControlFile(uri))
|
||||||
{
|
{
|
||||||
// Extract hash and construct a magnet to feed into createBtMagentRequestGroup
|
// Extract hash and construct a magnet to feed into createBtMagentRequestGroup
|
||||||
|
@ -471,6 +472,7 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif // ENABLE_CONTROL_FILE
|
||||||
};
|
};
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue