From d091b7db11fc0fa3e19912d03c11d511218608e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Goran=20Meki=C4=87?= Date: Mon, 17 Apr 2017 02:19:43 +0200 Subject: CLI diskstreaming options --- src/bytesizeparser.cc | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'src') 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; } -- cgit v1.2.3