Thread: Saving edited file

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Unregistered
    Guest

    Saving edited file

    Hi,
    I'm just writing a text editor. Now at the very beginning, I already have a design question: How should I deal with saving? Should I remove the edited file (I'm storing the entire content in RAM) and rewrite it from scratch after the user has made some changes, or only update it somehow? The first variant seems way too unefficient to me, but I wouldn't know how to realise the second one.
    I'd be glad to hear some opinions from the optimization specialists around here.
    Thanks in advance.

  2. #2
    Unleashed
    Join Date
    Sep 2001
    Posts
    1,765
    I would say the first, as it'll be much easier for you, and would work fine.
    The world is waiting. I must leave you now.

  3. #3
    Unregistered
    Guest
    I don't want it as easy as possible, but as efficient as possible. And I'm sure rewriting the file isn't the way to go, but I don't know how to update it otherwise- That's why I'm posting here.

  4. #4
    Unleashed
    Join Date
    Sep 2001
    Posts
    1,765
    Hmmm, I've never had the need for something like that, but it shouldn't be all too hard.
    Possibly Salem, or Prelude could give you some pointers from an expierenced joe.
    The world is waiting. I must leave you now.

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,666
    Personally, I'd go for renaming the current file to say file.bak, then rewrite the file in its entirety as a completely new file.

    You never know when the odd power cut / program bug could cause you to lose the file completely.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. sequential file program
    By needhelpbad in forum C Programming
    Replies: 80
    Last Post: 06-08-2008, 01:04 PM
  2. To find the memory leaks without using any tools
    By asadullah in forum C Programming
    Replies: 2
    Last Post: 05-12-2008, 07:54 AM
  3. Replies: 3
    Last Post: 03-04-2005, 02:46 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