File: //usr/share/ri/3.0.0/system/Tempfile/unlink-i.ri
U:RDoc::AnyMethod[iI"unlink:ETI"Tempfile#unlink;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"NUnlinks (deletes) the file from the filesystem. One should always unlink ;TI"Kthe file after using it, as is explained in the "Explicit close" good ;TI"/practice section in the Tempfile overview:;To:RDoc::Markup::BlankLine o:RDoc::Markup::Verbatim; [I" file = Tempfile.new('foo')
;TI"begin
;TI"' # ...do something with file...
;TI"ensure
;TI" file.close
;TI". file.unlink # deletes the temp file
;TI" end
;T:@format0S:RDoc::Markup::Heading:
leveli: textI"Unlink-before-close;T@o;
; [I"MOn POSIX systems it's possible to unlink a file before closing it. This ;TI"Gpractice is explained in detail in the Tempfile overview (section ;TI"G"Unlink after creation"); please refer there for more information.;T@o;
; [
I"NHowever, unlink-before-close may not be supported on non-POSIX operating ;TI"Qsystems. Microsoft Windows is the most notable case: unlinking a non-closed ;TI"Nfile will result in an error, which this method will silently ignore. If ;TI"Qyou want to practice unlink-before-close whenever possible, then you should ;TI"write code like this:;T@o;; [I" file = Tempfile.new('foo')
;TI"5file.unlink # On Windows this silently fails.
;TI"begin
;TI") # ... do something with file ...
;TI"ensure
;TI"L file.close! # Closes the file handle. If the file wasn't unlinked
;TI"N # because #unlink failed, then this method will attempt
;TI"( # to do so again.
;TI"end;T;
0:
@fileI"lib/tempfile.rb;T:0@omit_headings_from_table_of_contents_below000[[I"delete;To;; [ ;@3;0I"();T@3FI"
Tempfile;TcRDoc::NormalClass00