summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGoran Mekić <meka@tilda.center>2017-04-17 02:19:43 +0200
committerGoran Mekić <meka@tilda.center>2017-04-17 14:24:22 +0200
commitd091b7db11fc0fa3e19912d03c11d511218608e3 (patch)
tree317b132246bed7aa8ae430b78fc814f2d872e168 /src
parent20c62f8cc12c86734d63c654d2fceb80d762e010 (diff)
CLI diskstreaming options
Diffstat (limited to 'src')
-rw-r--r--src/bytesizeparser.cc17
1 files changed, 6 insertions, 11 deletions
diff --git a/src/bytesizeparser.cc b/src/bytesizeparser.cc
index 329407d..ef63f7d 100644
--- a/src/bytesizeparser.cc
+++ b/src/bytesizeparser.cc
@@ -54,7 +54,7 @@ static std::size_t suffixToSize(const char& suffix)
std::size_t byteSizeParser(const std::string& argument)
{
std::string::size_type suffix_index;
- std::size_t stream_size;
+ std::size_t size;
std::string suffix;
bool error = false;
@@ -65,7 +65,7 @@ std::size_t byteSizeParser(const std::string& argument)
try
{
- stream_size = std::stoi(argument, &suffix_index);
+ size = std::stoi(argument, &suffix_index);
}
catch(std::invalid_argument)
{
@@ -85,19 +85,14 @@ std::size_t byteSizeParser(const std::string& argument)
error = true;
}
}
- if(!error)
+ if(!error && suffix.size() > 0)
{
- std::size_t suffix_size = 1;
- if(suffix_index <= suffix.length())
- {
- suffix_size = suffixToSize(suffix[0]);
-
- }
- stream_size *= suffix_size;
+ std::size_t suffix_size = suffixToSize(suffix[0]);
+ size *= suffix_size;
}
if(error)
{
return 0;
}
- return stream_size;
+ return size;
}