mirror of https://github.com/aria2/aria2
2009-09-09 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Added LocalFilePathOptionHandler which check whether the specified file path does exist or not. * src/OptionHandlerImpl.cc * src/message.hpull/1/head
parent
6399f6dcf9
commit
9f54011349
|
@ -1,3 +1,10 @@
|
|||
2009-09-09 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||
|
||||
Added LocalFilePathOptionHandler which check whether the specified
|
||||
file path does exist or not.
|
||||
* src/OptionHandlerImpl.cc
|
||||
* src/message.h
|
||||
|
||||
2009-09-07 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||
|
||||
Updated wiki page URI.
|
||||
|
|
|
@ -53,6 +53,8 @@
|
|||
#include "A2STR.h"
|
||||
#include "Request.h"
|
||||
#include "a2functional.h"
|
||||
#include "message.h"
|
||||
#include "File.h"
|
||||
|
||||
namespace aria2 {
|
||||
|
||||
|
@ -572,6 +574,32 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
class LocalFilePathOptionHandler : public NameMatchOptionHandler {
|
||||
public:
|
||||
LocalFilePathOptionHandler
|
||||
(const std::string& optName,
|
||||
const std::string& description = NO_DESCRIPTION,
|
||||
const std::string& defaultValue = NO_DEFAULT_VALUE,
|
||||
char shortName = 0):
|
||||
NameMatchOptionHandler(optName, description, defaultValue,
|
||||
OptionHandler::REQ_ARG,
|
||||
shortName) {}
|
||||
|
||||
virtual void parseArg(Option& option, const std::string& optarg)
|
||||
{
|
||||
if(!File(optarg).exists()) {
|
||||
throw DL_ABORT_EX
|
||||
(StringFormat(MSG_FILE_NOT_EXIST, optarg.c_str()).str());
|
||||
}
|
||||
option.put(_optName, optarg);
|
||||
}
|
||||
|
||||
virtual std::string createPossibleValuesString() const
|
||||
{
|
||||
return "/path/to/file";
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace aria2
|
||||
|
||||
#endif // _D_OPTION_HANDLER_IMPL_H_
|
||||
|
|
|
@ -174,6 +174,7 @@
|
|||
#define MSG_GID_NOT_PROVIDED "GID is not provided."
|
||||
#define MSG_CANNOT_PARSE_XML_RPC_REQUEST "Failed to parse xml-rpc request."
|
||||
#define MSG_GOOD_BYE_SEEDER "Client is in seed state: Good Bye Seeder;)"
|
||||
#define MSG_FILE_NOT_EXIST "File %s was not found."
|
||||
|
||||
#define EX_TIME_OUT _("Timeout.")
|
||||
#define EX_INVALID_CHUNK_SIZE _("Invalid chunk size.")
|
||||
|
|
Loading…
Reference in New Issue