Inserting/Deleting Data Within Large File :: Win32

This is a discussion on Inserting/Deleting Data Within Large File :: Win32 within the C++ Programming forums, part of the General Programming Boards category; Hi, I am working on a problem has to do with manipulating large files. Essentially, the program will open up ...

  1. #1
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348

    Inserting/Deleting Data Within Large File :: Win32

    Hi,

    I am working on a problem has to do with manipulating large files. Essentially, the program will open up any give files and append, insert, and delete data from the file at random position.

    What is the most efficient solution?

    I have tried memory mapping, but it does not work as expect. Memory mapping works only when the program change a byte in the file. It does not work for inserting and delete bytes from the file at random position.

    Thanks,
    Kuphryn

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,541
    You can't insert data into a file without rewriting the entire file.

    > What is the most efficient solution?
    Maintain a separate index file to track insert, append, delete operations. Manipulating the ordering of the index file will be much more efficient than manipulating the data files.

    From the point of view of the data file, insert and append are either
    - overwrite of any deleted record
    - append to file if there are no deleted record.

    Nothing immediately happens to the data file on deletion, it's simply a marker in the index file.

    If, at the end of all your operations, you want to rewrite a normalised data file (which can be accesses without the index), then that's easy to do as well.
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348
    Okay. Thanks.

    Kuphryn

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Inventory records
    By jsbeckton in forum C Programming
    Replies: 23
    Last Post: 06-28-2007, 04:14 AM
  2. File I/O in large data file
    By ryujinn in forum C Programming
    Replies: 24
    Last Post: 04-01-2007, 02:01 PM
  3. spell check in C using a dictionary file
    By goron350 in forum C Programming
    Replies: 10
    Last Post: 11-25-2004, 05:44 PM
  4. HUGE fps jump
    By DavidP in forum Game Programming
    Replies: 23
    Last Post: 07-01-2004, 10:36 AM
  5. File Database & Data Structure :: C++
    By kuphryn in forum C++ Programming
    Replies: 0
    Last Post: 02-24-2002, 10:47 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21