unlimited-storage

YouTube filesystem tool for uploading arbitrary data to the service
git clone git://git.laack.co/unlimited-storage.git
Log | Files | Refs | README

encode.cpp (1184B)


      1 #include "../include/chunk.h"
      2 #include "iostream"
      3 #include "../include/debug.h"
      4 #include "filesystem"
      5 
      6 
      7 int main(int argc, char* argv[]) {
      8 
      9     if (argc < 5) {
     10         std::cout << "usage: [source] [destination] [x-dimension] [y-dimension]" << std::endl;
     11         return 10;
     12     }
     13 
     14     std::string source = argv[1];
     15     std::string destination = argv[2];
     16     std::string xDim = argv[3];
     17     std::string yDim = argv[4];
     18 
     19     int x = std::stoi(xDim);
     20     int y = std::stoi(yDim);
     21 
     22     // how much space should we reserve for the header section
     23     // of the image?
     24     
     25     uint start = 0;
     26     uint itr = 0;
     27 
     28     std::string destinationWithoutExtension = destination.replace(destination.size() - 4, 4, "");
     29 
     30     while (start < std::filesystem::file_size(source)){
     31         LOG("READING CHUNK # " + std::to_string(itr))
     32         LOG("STARTING AT BYTE " + std::to_string(start))
     33         Chunk chunk = Chunk(source, start, x, y);
     34         std::string fname = destinationWithoutExtension + std::to_string(itr) + ".pbm";
     35         chunk.writeImage(fname, itr, source, x, y);
     36         start += chunk.written;
     37 
     38         LOG("START: " + std::to_string(start))
     39 
     40         itr += 1;
     41     }
     42 
     43     return 0;
     44 }