Add source code for ctrtool

This commit is contained in:
jakcron
2022-03-12 16:00:33 +08:00
parent 6ad2f13c50
commit 800f5776bc
681 changed files with 219734 additions and 0 deletions
@@ -0,0 +1,22 @@
#include <tc/io/StreamUtil.h>
int64_t tc::io::StreamUtil::getSeekResult(int64_t offset, tc::io::SeekOrigin origin, int64_t current_position, int64_t stream_length)
{
int64_t new_pos = 0;
switch (origin)
{
case (SeekOrigin::Begin):
new_pos = offset;
break;
case (SeekOrigin::Current):
new_pos = current_position + offset;
break;
case (SeekOrigin::End):
new_pos = stream_length + offset;
break;
default:
throw tc::ArgumentOutOfRangeException("Illegal value for origin.");
}
return new_pos;
}