• Tom Limoncelli's avatar
    io/ioutil: change TempFile prefix to a pattern · 191efbc4
    Tom Limoncelli authored
    Users of TempFile need to be able to supply the suffix, especially
    when using operating systems that give semantic meaning to the
    filename extension such as Windows.  Renaming the file to include
    an extension after the fact is insufficient as it could lead to
    race conditions.
    
    If the string given to TempFile includes a "*", the random string
    replaces the "*". For example "myname.*.bat" will result in a random
    filename such as "myname.123456.bat".  If no "*' is included the
    old behavior is retained, and the random digits are appended to the
    end.
    
    If multiple "*" are included, the final one is replaced, thus
    permitting a pathological programmer to create filenames such as
    "foo*.123456.bat" but not "foo.123456.*.bat"
    
    Fixes #4896
    
    Change-Id: Iae7f0980b4de6d7d31b87c8c3c3d40767b283c1f
    Reviewed-on: https://go-review.googlesource.com/105675Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
    Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    191efbc4
Name
Last commit
Last update
.github Loading commit data...
api Loading commit data...
doc Loading commit data...
lib/time Loading commit data...
misc Loading commit data...
src Loading commit data...
test Loading commit data...
.gitattributes Loading commit data...
.gitignore Loading commit data...
AUTHORS Loading commit data...
CONTRIBUTING.md Loading commit data...
CONTRIBUTORS Loading commit data...
LICENSE Loading commit data...
PATENTS Loading commit data...
README.md Loading commit data...
favicon.ico Loading commit data...
robots.txt Loading commit data...