Skip to content
Snippets Groups Projects
Commit fcd7a80f authored by Steven Murray's avatar Steven Murray
Browse files

Simplified CTACopyCmd::formatCommandPath()

parent f74ddaad
No related branches found
No related tags found
No related merge requests found
......@@ -86,18 +86,9 @@ int CTACopyCmd::sendCommand(const int argc, const char **argv) const {
//------------------------------------------------------------------------------
std::string CTACopyCmd::formatCommandPath(const int argc, const char **argv) const {
std::string cmdPath = "root://localhost:10955//";
std::string arg = encode(std::string(argv[0]));
replaceAll(arg, "/", "_");
//need to add this because xroot removes consecutive slashes, and the
//cryptopp base64 algorithm may produce consecutive slashes. This is solved
//in cryptopp-5.6.3 (using Base64URLEncoder instead of Base64Encoder) but we
//currently have cryptopp-5.6.2. To be changed in the future...
cmdPath += arg;
for(int i=1; i<argc; i++) {
std::string arg = encode(std::string(argv[i]));
replaceAll(arg, "/", "_");
cmdPath += "&";
cmdPath += arg;
for(int i=0; i<argc; i++) {
if(i) cmdPath += "&";
cmdPath += encode(std::string(argv[i]));
}
return cmdPath;
}
......@@ -122,5 +113,13 @@ std::string CTACopyCmd::encode(const std::string msg) const {
std::string ret;
const bool noNewLineInBase64Output = false;
CryptoPP::StringSource ss1(msg, true, new CryptoPP::Base64Encoder(new CryptoPP::StringSink(ret), noNewLineInBase64Output));
// need to replace slashes ('/') with underscores ('_') because xroot removes
// consecutive slashes, and the cryptopp base64 algorithm may produce
// consecutive slashes. This is solved in cryptopp-5.6.3 (using
// Base64URLEncoder instead of Base64Encoder) but we currently have
// cryptopp-5.6.2. To be changed in the future...
replaceAll(ret, "/", "_");
return ret;
}
......@@ -38,7 +38,7 @@ public:
*/
int main(const int argc, const char **argv) const throw();
protected:
private:
/**
* Sends the command and waits for the reply
......@@ -68,7 +68,14 @@ protected:
void replaceAll(std::string& str, const std::string& from, const std::string& to) const;
/**
* Encodes a string in base 64
* Encodes a string in base 64 and replaces slatches ('/') in the result
* with underscores ('_').
*
* Need to replace slashes ('/') with underscores ('_') because xroot removes
* consecutive slashes, and the cryptopp base64 algorithm may produce
* consecutive slashes. This is solved in cryptopp-5.6.3 (using
* Base64URLEncoder instead of Base64Encoder) but we currently have
* cryptopp-5.6.2. To be changed in the future...
*
* @param msg string to encode
* @return encoded string
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment