All of lore.kernel.org
 help / color / mirror / Atom feed
From: "John T. Williams" <jtwilliams@vt.edu>
To: linux-c-programming@vger.kernel.org
Subject: mid file deletion
Date: Wed, 2 Jul 2003 16:45:42 -0700	[thread overview]
Message-ID: <000701c340f4$225660f0$ed64a8c0@descartes> (raw)
In-Reply-To: Pine.LNX.4.44.0307021454080.20193-100000@gpu.utcc





What is the best way to remove data from the middle of a file. Here is the
Scenario: I have a file that is 20MB in size, about ¼ th way through it is a
1 line I want to remove. I can use lseek to bring me to the beginning of the
section I want to remove, and then lseek again to bring me to the end of
that section. The only thing I can think to do is load everything from the
file after the point I want to delete into memory, remove the part I don't
want from what is stored in memory (or simply don't load it), truncate the
file at the point where the part I wanted to delete began, and re-write the
rest of the file. The alternative (since 20MB is rather big for loading into
memory on a multi-User multi-Media machine) is to load the bits I want to
keep into a temporary file, rather into memory. However, I was thinking that
for removing 20bytes of information, reading and writing 15MB to 30MB is a
lot of work. Is there a better way?




To give this more of a real world perspective. I'm downloading e-mails into
a mbox file and I'm trying to figure out how to delete 1 email from a mbox
file that could potentially store 1,000's of e-mails an any given time.







-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2003-07-02 23:45 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <S265125AbTGBQaA/20030702163000Z+15659@vger.kernel.org>
2003-07-02 16:48 ` quotactl Francis Lau
2003-07-02 17:37   ` quotactl Chris Nanakos
2003-07-02 18:04     ` quotactl Francis Lau
2003-07-02 18:20       ` quotactl Darío Mariani
2003-07-02 18:58         ` quotactl Francis Lau
2003-07-02 23:45           ` John T. Williams [this message]
2003-07-02 22:15             ` mid file deletion Glynn Clements
2003-07-02 21:45         ` quotactl Glynn Clements
2003-07-03 16:24           ` quotactl Francis Lau
2003-07-03 18:48             ` quotactl Glynn Clements

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='000701c340f4$225660f0$ed64a8c0@descartes' \
    --to=jtwilliams@vt.edu \
    --cc=linux-c-programming@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.