forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Open file and close it deleting its content

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support
View previous topic :: View next topic  
Author Message
DanRRight



Joined: 10 Mar 2008
Posts: 2816
Location: South Pole, Antarctica

PostPosted: Sat Aug 27, 2016 10:51 am    Post subject: Open file and close it deleting its content Reply with quote

Please remind how to open some file, erase its content if it exists and close with zero size?
Back to top
View user's profile Send private message
mecej4



Joined: 31 Oct 2006
Posts: 1886

PostPosted: Sat Aug 27, 2016 1:39 pm    Post subject: Reply with quote

This is one way (NOT SECURE!)
Code:

open(11,file='xx',status='replace')
rewind(11)
endfile(11)
close(11)

This way of truncating a file is not secure because most of the bytes that were originally on the file may still persist on the medium (disk drive, USB flash, etc.). If you are not worried about secrecy, etc., however, this is a simple solution.
Back to top
View user's profile Send private message
DanRRight



Joined: 10 Mar 2008
Posts: 2816
Location: South Pole, Antarctica

PostPosted: Sat Aug 27, 2016 10:35 pm    Post subject: Reply with quote

hollymolly...Good that I stopped and decided to ask the group. I'd easily lost the rest of the night trying to find this. Many thanks Mecej4
Back to top
View user's profile Send private message
davidb



Joined: 17 Jul 2009
Posts: 560
Location: UK

PostPosted: Thu Sep 08, 2016 7:48 am    Post subject: Reply with quote

To remove the file you can use

Code:

close(11,status='DELETE')

_________________
Programmer in: Fortran 77/95/2003/2008, C, C++ (& OpenMP), java, Python, Perl
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group