diff --git a/skeleton/Program/Build/RaspberryCloud.sdf b/skeleton/Program/Build/RaspberryCloud.sdf index 8100dc9b2991eaff0d53997c9f9c864df8bf2876..7e537595bf9173b3c215908b8b98d4705a09450e 100644 Binary files a/skeleton/Program/Build/RaspberryCloud.sdf and b/skeleton/Program/Build/RaspberryCloud.sdf differ diff --git a/skeleton/Program/Build/RaspberryCloud.v12.suo b/skeleton/Program/Build/RaspberryCloud.v12.suo index a69890abbff9840099e5624b91d606cd94785df8..66e186584c19db2fa5faf16320e24e06491fa22f 100644 Binary files a/skeleton/Program/Build/RaspberryCloud.v12.suo and b/skeleton/Program/Build/RaspberryCloud.v12.suo differ diff --git a/skeleton/Program/Build/RaspberryCloud/RaspberryCloud.vcxproj b/skeleton/Program/Build/RaspberryCloud/RaspberryCloud.vcxproj index d54b0383b9335540f43c76ca0ceeeb628dc507ce..f1382ae2a8aec920161e0dff8606622c965d58fa 100644 --- a/skeleton/Program/Build/RaspberryCloud/RaspberryCloud.vcxproj +++ b/skeleton/Program/Build/RaspberryCloud/RaspberryCloud.vcxproj @@ -42,6 +42,7 @@ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <LinkIncremental>true</LinkIncremental> <IncludePath>C:\KodoDependencies;$(IncludePath)</IncludePath> + <LibraryPath>c:\KodoDependencies\DependencyLIBS\;$(LibraryPath)</LibraryPath> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <LinkIncremental>false</LinkIncremental> @@ -54,10 +55,12 @@ <Optimization>Disabled</Optimization> <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> <AdditionalIncludeDirectories>$(SolutionDir)..\Source\</AdditionalIncludeDirectories> + <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> </ClCompile> <Link> <SubSystem>Console</SubSystem> <GenerateDebugInformation>true</GenerateDebugInformation> + <AdditionalDependencies>c:\KodoDependencies\DependencyLIBS\*.lib;%(AdditionalDependencies)</AdditionalDependencies> </Link> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> diff --git a/skeleton/Program/Source/dataAccess/Encoder.cpp b/skeleton/Program/Source/dataAccess/Encoder.cpp index d4c6362adeef5717e2d0e0a2eb710064cd699184..1d27d5362e987b0badc0279b2b200c47c41cacec 100644 --- a/skeleton/Program/Source/dataAccess/Encoder.cpp +++ b/skeleton/Program/Source/dataAccess/Encoder.cpp @@ -2,22 +2,39 @@ #include "logger\Logger.h" #include "cloud\CloudException.h" #include <fstream> + +#include <kodo/object/file_encoder.hpp> +#include <kodo/object/file_decoder.hpp> +#include <kodo/rlnc/full_rlnc_codes.hpp> + +#include <boost/format.hpp> + /** * Encoder implementation */ +std::ifstream::pos_type filesize(std::string filename) +{ + std::ifstream in(filename, std::ifstream::ate | std::ifstream::binary); + return in.tellg(); +} + FileDescriptor* Encoder::encode(string localFileID, string destinationFileID) { LOG_ENTER_EXIT; string dataFolder = "C:\\Users\\krisz\\raspberrycloud\\skeleton\\Program\\data\\"; string fragFolder = "C:\\Users\\krisz\\raspberrycloud\\skeleton\\Program\\temp\\"; + /*uint32_t max_symbols = 10; + uint32_t max_symbol_size = 5000;*/ + + std::string encode_filename = dataFolder + localFileID; + //check if file exists - if (!exists(dataFolder + localFileID)){ + if (!exists(encode_filename)){ throw CloudException("No such file exists"); return NULL; } - ifstream src(dataFolder + localFileID, std::ios::binary); ofstream dst(fragFolder + destinationFileID, std::ios::binary); dst << src.rdbuf(); @@ -26,8 +43,40 @@ FileDescriptor* Encoder::encode(string localFileID, string destinationFileID) { dst.close(); FileDescriptor* encoded = new FileDescriptor(localFileID); - encoded->addFragment(*(new Fragment("unset", destinationFileID))); + + + /*using file_encoder = kodo::object::file_encoder< + kodo::shallow_full_rlnc_encoder<fifi::binary >> ; + + file_encoder::factory encoder_factory(max_symbols, max_symbol_size); + encoder_factory.set_filename(encode_filename); + + auto encoder = encoder_factory.build(); + + for (uint32_t i = 0; i < encoder->blocks(); ++i) + { + auto e = encoder->build(i); + + std::vector<uint8_t> payload(e->payload_size()); + + for (uint32_t j = 0; j < max_symbols; j++) + { + e->encode(payload.data()); + + std::string filename = (boost::format("frag_%1$02d_%2$02d.frg") % i % j).str(); + + std::ofstream fragFile( + fragFolder + filename, + std::ios::out | std::ios::binary); + std::copy(payload.begin(), payload.end(), std::ostreambuf_iterator<char>(fragFile)); + fragFile.close(); + + encoded->addFragment(*(new Fragment("unset", filename))); + } + }*/ + + encoded->addFragment(*(new Fragment("unset", destinationFileID))); return encoded; }