Thread: write file in ram

  1. #1
    Registered User
    Join Date
    Sep 2003
    Posts
    10

    write file in ram

    Hello, I want to do the following:

    Transfer some huge files (60MB) from pc a to pc c through pc b.
    (PC A)->(PC B)->(PC C)
    I want this to be done without that the files are written on the hard disk(of b), so they should stay in your ram (probably some hours, becouse a and c can't be connected simultaneously).
    It should work for all types of files binary/ascii/...
    How should I write/read to/from a "ramfile" ???
    How to tranfer it ???

    tia

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    > I want this to be done without that the files are written on the hard disk(of b),
    So what's so bad about the disk?
    At least you don't have to re-transmit the file a->b if b reboots / loses power

    > How should I write/read to/from a "ramfile" ???
    By configuring your OS to create a ramdisk of some suitable size. How you do that depends on your OS, but as far as some C++ code is concerned, it's just another file.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Sep 2003
    Posts
    10
    thanks for your replie, but it's mainly to find out how it COULD be done, in c++, because it interest's me. If it's not possible to do this, I'll write to the disk.

  4. #4
    Spaced Cadet
    Join Date
    Aug 2003
    Posts
    110
    look up file transfer, and on computer b have the files written to the ramdrive as Salem sugested, that is the onyway, ramdrives act just like Harddrives do.

  5. #5
    Registered User
    Join Date
    Sep 2003
    Posts
    10
    ok thanks.

  6. #6
    Registered User
    Join Date
    May 2003
    Posts
    1,619
    Do note this has downsides; it creates another drive letter, and however much space you devote to this RAMdrive is no longer available to any programs. Allocate too little space and it's useless to you, too much and you could destabilize the system by effectively removing RAM. Also any program could use your RAMdrive.

    And it typically requires a reboot to change RAMdrive parameters.

    You might be able to use WinAPI calls to allocate memory that you tell it cannot leave physical memory (can't go through the swapfile). Unless you have very sensitive data that cannot be swapped to disk, though, I would just allocate the memory and let Windows decide how much to put in RAM/how much on the disk.
    You ever try a pink golf ball, Wally? Why, the wind shear on a pink ball alone can take the head clean off a 90 pound midget at 300 yards.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Newbie homework help
    By fossage in forum C Programming
    Replies: 3
    Last Post: 04-30-2009, 04:27 PM
  2. Encryption program
    By zeiffelz in forum C Programming
    Replies: 1
    Last Post: 06-15-2005, 03:39 AM
  3. archive format
    By Nor in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 08-05-2003, 07:01 PM
  4. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 10:12 PM
  5. simulate Grep command in Unix using C
    By laxmi in forum C Programming
    Replies: 6
    Last Post: 05-10-2002, 04:10 PM