2016 Update

This commit is contained in:
Tina Müller 2016-12-05 22:15:40 +01:00
parent 948b86eafa
commit dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions

View file

@ -1 +1,7 @@
Create a temporary file, '''securely and exclusively''' (opening it such that there are no possible [[race condition|race conditions]]). It's fine assuming local filesystem semantics (NFS or other networking filesystems can have signficantly more complicated semantics for satisfying the "no race conditions" criteria). The function should automatically resolve name collisions and should only fail in cases where permission is denied, the filesystem is read-only or full, or similar conditions exist (returning an error or raising an exception as appropriate to the language/environment).
;Task:
Create a temporary file, '''securely and exclusively''' (opening it such that there are no possible [[race condition|race conditions]]).
It's fine assuming local filesystem semantics (NFS or other networking filesystems can have signficantly more complicated semantics for satisfying the "no race conditions" criteria).
The function should automatically resolve name collisions and should only fail in cases where permission is denied, the filesystem is read-only or full, or similar conditions exist (returning an error or raising an exception as appropriate to the language/environment).
<br><br>

View file

@ -0,0 +1 @@
OPEN (F,STATUS = 'SCRATCH') !Temporary disc storage.

View file

@ -0,0 +1,32 @@
package main
import (
"fmt"
"io/ioutil"
"log"
"os"
)
func main() {
f, err := ioutil.TempFile("", "foo")
if err != nil {
log.Fatal(err)
}
defer f.Close()
// We need to make sure we remove the file
// once it is no longer needed.
defer os.Remove(f.Name())
// … use the file via 'f' …
fmt.Fprintln(f, "Using temporary file:", f.Name())
f.Seek(0, 0)
d, err := ioutil.ReadAll(f)
if err != nil {
log.Fatal(err)
}
fmt.Printf("Wrote and read: %s\n", d)
// The defer statements above will close and remove the
// temporary file here (or on any return of this function).
}

View file

@ -1,3 +1,6 @@
def file = File.createTempFile( "xxx", ".txt" )
file.deleteOnExit()
// There is no requirement in the instructions to delete the file.
//file.deleteOnExit()
println file

View file

@ -0,0 +1,4 @@
$tempFile = [System.IO.Path]::GetTempFileName()
Set-Content -Path $tempFile -Value "FileName = $tempFile"
Get-Content -Path $tempFile
Remove-Item -Path $tempFile