468,457 Members | 1,581 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,457 developers. It's quick & easy.

reading from a file without actually writing into its hard disk copy

Hi,

I have an array of data (which I am getting from a socket connection).
I am working on a program which acts on this data but the program is
written to work on data from a file (not from an array). I cannot
change anything in the program but can add some features by which I
can convert this array of data into a file. The easiest thing would be
to write the data into a file (in hard disk) and use it. But I will be
working on thousands of such data, so this would be time consuming.

One more constraint is that, the data has to be written into a file in
binary format and read in ascii format (otherwise the data is not read
properly). Is there anyway I can achieve this (writing in binary
format and reading in ascii format) without actually writing the array
into harddisk (by just using RAM).

Thanks
Jeevan.
Nov 13 '05 #1
2 2782

"Jeevan" <kj***********@yahoo.com> wrote in message
The easiest thing would be to write the data into a file (in hard disk)
and use it. But I will be working on thousands of such data, so this
would be time consuming.
tmpfile() is your friend. This is almost always implemented as a RAM file.
One more constraint is that, the data has to be written into a file in
binary format and read in ascii format (otherwise the data is not read
properly). Is there anyway I can achieve this (writing in binary
format and reading in ascii format) without actually writing the array
into harddisk (by just using RAM).

Unfortunately now you're in trouble, since you can't open a temporary file
as binary for writing and text for reading. The real solution is to change
your program design so that this isn't necessary.
Nov 13 '05 #2
Well, if you're in Unix/Linux, maybe you can use function "mmap".
The system call mmap() establishes a mapping between your process's
address space and a file.
You could map your file into RAM, then place your array on that memory
address.
But, maybe your data should be formated as ascii .....

Scott
"Jeevan" <kj***********@yahoo.com> wrote in message
news:a6*************************@posting.google.co m...
Hi,

I have an array of data (which I am getting from a socket connection).
I am working on a program which acts on this data but the program is
written to work on data from a file (not from an array). I cannot
change anything in the program but can add some features by which I
can convert this array of data into a file. The easiest thing would be
to write the data into a file (in hard disk) and use it. But I will be
working on thousands of such data, so this would be time consuming.

One more constraint is that, the data has to be written into a file in
binary format and read in ascii format (otherwise the data is not read
properly). Is there anyway I can achieve this (writing in binary
format and reading in ascii format) without actually writing the array
into harddisk (by just using RAM).

Thanks
Jeevan.

Nov 13 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by ishekar | last post: by
9 posts views Thread by Jon LaBadie | last post: by
8 posts views Thread by Vijay | last post: by
3 posts views Thread by noridotjabi | last post: by
5 posts views Thread by thewritersclub | last post: by
7 posts views Thread by ianenis.tiryaki | last post: by
4 posts views Thread by ramyakrishnakumar | last post: by
12 posts views Thread by glennanthonyb | last post: by
1 post views Thread by subhajit12345 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.