954,483 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

MFC CFile Stream Question

Hello guys, this is my first post, so don't be harsh if I do something stupid.

Well, the reason why I'm posting here is because I need to find a method to alter the stream itself, not just the buffer I send to a variable with "file.Read(".

For example, lets say i have a file whose bytes are as follows:
05 FF 3E 23 80 BD

As I'm using MFC I'd use 'file.Open' to open the file, and 'file.Read' to send the stream above to a buffer (char *) variable.

What I want to do is to change the stream to something else before I use the Read function so that it will be something different when I read the stream whilst still keeping the file untouched.

The reason I need this is for encryption purposes, and because I dont want to create a temporary file on the computer.

By the way, I don't want just to send the stream to the buffer and then process it, I want to change the stream itself.

Any help is appreciated.
Regards, Gabriel.

0dark
Newbie Poster
4 posts since Oct 2010
Reputation Points: 10
Solved Threads: 0
 

What do you mean you want to change the stream to something else? What do you want to change it to?

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

Lets say we had the above file "05 FF 3E 23 80 BD"

I wanted to use my decription algorythm that would change it to something like:
BF 46 E6 AF 08 99

Before I used the Read function however not changing the actual file. (I already have the decryption algorythm)

0dark
Newbie Poster
4 posts since Oct 2010
Reputation Points: 10
Solved Threads: 0
 

Now how in the world do you expect to decrypt a file without reading it?? Just read the file, decrypt it and save it in memory. I don't see why you need a temp file to do that.

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

Because the .read function is used several times later (more than 100) and I didn't want to change that because I would have to convert char[4] to int for exemple.. something that the function does by itself.

0dark
Newbie Poster
4 posts since Oct 2010
Reputation Points: 10
Solved Threads: 0
 

converting char[4] to int is simple assignment int x = *(int *)buffer; , assuming that buffer contains the binary representation of the int.

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: