Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

JoshG

Updating/Truncating Files

This topic is 6015 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Ok guys, thanks for all your help on my last problem... now I wish to update this file with all the nodes in it. I can change the passwords and names whenever I like. However, when I delete a user it does not work. When i delete a user I simply get all the info on the users After it, and overwrite it from the spot where the deleted user was. This works to an extent. But my file always stays the same size and I can't trunicate the end of it so that it REALLY deletes the data. Any help? or do I have to rewrite the file (delete it then write all the data again)? thanks --Josh Edited by - JoshG on December 29, 2001 3:15:53 AM

Share this post


Link to post
Share on other sites
Advertisement
mmm... I don''t have that include file "unistd.h"
and so it is not documented in my compiler. and by looking at the documentation on that website given, it is associated with the functions "open" and "close", not "fopen" and "fclose". for some strange reason.

is there any way that i can just move the EOF marker forward in the file? or is that not possible?

Share this post


Link to post
Share on other sites
quote:
Original post by JoshG
mmm... I don''t have that include file "unistd.h"
and so it is not documented in my compiler. and by looking at the documentation on that website given, it is associated with the functions "open" and "close", not "fopen" and "fclose". for some strange reason.

That header is only going to be found on in *nix (it''s probably in stdio.h or io.h in Windows). Also, of course it uses open and close, those are POSIX functions . I know the Windows compatibility layer has both open and close, but I''m not sure if it has ftruncate. It was just a suggestion. You can also use the Win32 API to do the truncation (in libHFS I did the Windows version with the Win32 API).

[Resist Windows XP''s Invasive Production Activation Technology!]

Share this post


Link to post
Share on other sites
Ok, thanks.
truncate and ftruncate arn't in stdio or io. But a function called "chsize" is. It is supposed to change the size of the file.

This works to an extent. It DOES change the file. but the data is lost from the start of the file and not the end! Can anyone help overcome that? or should I move everything in the file??

Edited by - JoshG on December 29, 2001 3:46:33 AM

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!