compression - How can i read/write Bytes/Bits to a new file in C++ -


my first post ill stick guide lines best can!

im trying make method of editing file on binary level. have way read bytes(unfortunatly not in large formats) im stuck how can write bytes new file. figured can convert bytes hex , write file way step id avoid. there method writing bytes file suggest? if possible allow write in large format 5gb.

here code im using converting file bytes:

#include "stdafx.h" #include <iostream>   #include <fstream> using namespace std;  //variables const unsigned long long size = 64ull * 1024ull * 1024ull; unsigned long long file[size];  class bytemanager {     char const* input; public:     void set_values(char const*);     char* converttobytes()     {         ifstream streamdata(input);         streamdata.seekg(0, ios::end);         size_t len = streamdata.tellg();         char* bytes = new char[len];         streamdata.seekg(0, ios::beg);         streamdata.read(bytes, len);         streamdata.close();          return bytes;         //return 0;          } };  void bytemanager::set_values(char const* a) {     input = a; }; 

note: can post hex class if in fact best method go down.

also in advance advice/feedback/code submitted! ~nobodyshome

  1. if going compression in-memory, , amount of available memory issue you, problem starts sooner when creating output file: need fit the input file in memory!
  2. just making copy of file easy , not memory-intensive: create loop read chunk of data (e.g. byte) input file, , write same chunk of data output file. memory footage can quite low if select small chunk.
  3. another issue, not mention speed of writing disk. writing in bigger chunks in general quicker (but not obvious (not linear, @ least) due various caching/buffering activities of operating system , storage device itself).

Comments

Popular posts from this blog

PySide and Qt Properties: Connecting signals from Python to QML -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

scala - 'wrong top statement declaration' when using slick in IntelliJ -