Both.
So I have a file of data. A lot of data. The data itself (not the array, but the data IN the array) can be broken down into a bunch of smaller objects.
I read it in:
1 2 3 4
|
int fd = open(filename, blahblahblah);
while(bytesRead >0) {
bytesRead = read(fd, buffer, blahblahblah);
}
| |
So there I have my char array, buffer. Let's say it looks like this:
ABCDEFGABCDEFGABCDEFGABCDEFGABCDEFGABCDEFGABCDEFGABCDEFGABCDEFGABCDEFGABCDEFGABCDEFGABCDEFGABCDEFGABCDEFGABCDEFGABCDEFG
I then pass it into a container that we can call ContainerBig(), which is of type Container().
So what I do is call this:
1 2
|
ContainerBig bc;
bc->process(buffer);
| |
ContainerBig then processes all of the data and starts to deinterleave it. It then puts all of the new stuff into a handful of smaller containers, called ContainerMedium() (also of type Container);
So ContainerBig() can have data enough for 4 ContainerMedium()s. In order to put the data into them, it would do something like this:
1 2 3 4 5 6 7 8 9
|
Container * medium[4];
for(int i = 0; i<4, i++) {
medium[i]->copy(placeInBuffer, bytesToRead);
}
for(int i = 0; i<4, i++) {
medium[i]->checkContainer();
}
| |
What this does is use the Container() method called "copy()" to copy a certain number of bytes from the buffer, starting at "placeInBuffer" into medium[i]. It is far more complex than this, but just giving you the idea.
Then, checkContainer() will go into the ContainerMedium() object and begin processing the data in it. When it processes the data, it breaks it down further into ContainerSmall() objects (also of type Container). ContainerMedium() can have enough data for 4 ContainerSmalls().
ContainerSmall then does all of the processing it needs to find the bytes that I want to modify. It successfully does this, as I can get it to display exactly what I want it to. The problem is that I want to be able to modify this data and write it back into the correct place in the file that I got it from.
So...
ABCDEFGABCDEFGABCDEFGABCDEFGABCDEFGABCDEFGABCDEFGABCDEFGABCDEFGABCDEFGABCDEFGABCDEFGABCDEFGABCDEFGABCDEFGABCDEFGABCDEFG
Given this data, the first ContainerMedium object might contain:
ABCABCABCABCABCABC
And then the first ContainerSmall within the ContainerMedium might contain:
CCCCCC
So what I want to do is be able to take these CCCCCC bytes and change them to XXXXXX and write them back up into the file so that the original data that I pulled in would look like this:
ABXDEFGABXDEFGABXDEFGABXDEFGABXDEFGABXDEFGABCDEFGABCDEFGABCDEFGABCDEFGABCDEFGABCDEFGABCDEFGABCDEFGABCDEFGABCDEFGABCDEFG
(I bolded the content that got changed...)
I really think I am doing a terrible job of explaining what this is doing, but the code that they wrote is so ridiculous that I don't know how to explain it any better. Does this clear anything up at all about what I am trying to do and how I am currently doing it?