473,396 Members | 1,879 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to create a file in memory ?

Hi all,

i want to create a file in memory and access the memory block like a
file(i/o function) in windows 2000. Any hlep are appreciated.

Regards,
Zheng
Jul 22 '05 #1
4 7358
"Lokicer" <lo*****@163.com> wrote...
i want to create a file in memory and access the memory block like a
file(i/o function) in windows 2000. Any hlep are appreciated.


The simplest way I know is to use std::stringstream.

Victor
Jul 22 '05 #2

"Lokicer" <lo*****@163.com> wrote in message news:cg***********@mail.cn99.com...
Hi all,

i want to create a file in memory and access the memory block like a
file(i/o function) in windows 2000. Any hlep are appreciated.

Try a Microsoft newsgroup or read the documentation of "CreateFile" in
the MSDN documentations.
Jul 22 '05 #3
"Lokicer" <lo*****@163.com> wrote in message news:<cg***********@mail.cn99.com>...
Hi all,

i want to create a file in memory and access the memory block like a
file(i/o function) in windows 2000. Any hlep are appreciated.


Sounds a lot like a stringstream.

--
Later,
Jerry.

The universe is a figment of its own imagination.
Jul 22 '05 #4

"Victor Bazarov" <v.********@comAcast.net> wrote in message
news:swJVc.49191$mD.15134@attbi_s02...
"Lokicer" <lo*****@163.com> wrote...
i want to create a file in memory and access the memory block like a file(i/o function) in windows 2000. Any hlep are appreciated.


The simplest way I know is to use std::stringstream.


stringstream is useful a lot of the time, but it has the following
limitations (both reasonable, in context):

1. You can't specify that the stream access a pre-existing block of
memory,
2. When you're done performing i/o you can't get direct access to the
underlying memory -- you have to settle for a copy.

A library up for review at boost (by Darlye Walker) offers a
collection of streams and stream buffers for accessing arrays
directly, with this usage:

char buf[1000];
boost::io::pointerstream ps(buf, buf + 1000);

Here buf need not be on the stack -- it could just as well be
dynamically allocated. Of course, unlike with a std::stringstream, the
user has to be careful not to write past the end of the array.

I've submitted a slightly more general iostreams libray which allows
the creation of a pointerstream as follows:

typedef boost::io::stream_facade<array_resource>
pointerstream;
char buf[1000];
pointerstream ps(buf, buf + 1000);

You can also access mmap'd files as follows:

typedef boost::io::stream_facade<mapped_file_resource>
mapped_fstream;
mapped_fstream ms("hello.txt");

Docs are here:

more_io (Daryle Walker) http://tinyurl.com/5d9xt
iostreams (Jonathan Turkanis) http://tinyurl.com/4zfmt

Jonathan
Jul 22 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Justin | last post by:
Hi, I am continualy receiving the following type of error in my browser from programs using php/mysql Warning: mysql_connect(): Can't create a new thread (errno 11). If you are not out of...
4
by: Frank Millman | last post by:
Hi all I need to generate potentially large reports from a database, and I want to offer the option of print preview before actually printing (using wxPython). I figure that the best way to...
4
by: Nicholas Then | last post by:
I am writing an ASP.NET application and I have a class that I have written to create a vCard...it just returns a string with all the necessarry info... Anyway...is there a way that I can create a...
1
by: John | last post by:
Greetings microsoft.public.dotnet.general, Here is my problem: my boss wants to create a PDF file for our clients that they can open (without entering a password) that cannot be viewed or...
1
by: Amy L. | last post by:
I am working on creating a web service that will create a signed xml file. I would like to create this file in memory and than somehow email it to the user that requested it to be generated. I...
13
by: Daniel Walzenbach | last post by:
Hi, Imagine the following situation: I have an asp.net application which allows uploading files to a SQL Server 2000 database (Files are stored as type "images"). As a next step I would like to...
34
by: Tom | last post by:
I'd greatly appreciate advice and code snippets on how to create a ram disk within a C/C++ program. I also need to be able to determine the free space. Thanks in advance for any help.
23
by: sandy | last post by:
I need (okay, I want) to make a dynamic array of my class 'Directory', within my class Directory (Can you already smell disaster?) Each Directory can have subdirectories so I thought to put these...
5
by: Nitin Mahajan | last post by:
Guys Is there a way in C# to create a word object directly from a memory stream without passing that to hard disk (file stream). I think it doesn't makes sense to create a file just to read it...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.