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
pull/1/head
Tatsuhiro Tsujikawa 2009-09-09 12:50:42 +00:00
parent 6399f6dcf9
commit 9f54011349
3 changed files with 36 additions and 0 deletions

View File

@ -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.

View File

@ -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_

View File

@ -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.")