diff options
| author | Tom Limoncelli <tal@whatexit.org> | 2018-04-08 16:05:04 -0400 |
|---|---|---|
| committer | Brad Fitzpatrick <bradfitz@golang.org> | 2018-04-12 20:00:25 +0000 |
| commit | 191efbc419d7e5dec842c20841f6f716da4b561d (patch) | |
| tree | fc840d07b3c973c5aaf92b1afc779abd83084b9b /src/encoding | |
| parent | 9be1921042b6b81b7f16fa8640ddc5868af6d31e (diff) | |
| download | go-191efbc419d7e5dec842c20841f6f716da4b561d.tar.xz | |
io/ioutil: change TempFile prefix to a pattern
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/105675
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/encoding')
0 files changed, 0 insertions, 0 deletions
