Re: [go-nuts] Temporary files in go

2018-10-16 Thread Manuel Amador (Rudd-O)
On 12/10/2018 12.35, Robert Engels wrote: > Which is not Windows, which is giving up a lot of options, and is important > to some people, where as just using tmp files is ok. I am not even sure if > windows supports deleting an open file yet. I believe the default behavior is no it does not. --

Re: [go-nuts] Temporary files in go

2018-10-14 Thread Ian Lance Taylor
On Fri, Oct 12, 2018 at 8:10 AM, Greg Saylor wrote: > > If I remember correctly, it would be something like this: > > > fd = open("/tmp", O_TMPFILE | O_RDWR, 0600); > linkat(fd, "", AT_FDCWD, "/tmp/test", AT_EMPTY_PATH); > > This is pretty specific to OS/kernel version and quite possibly the > fi

Re: [go-nuts] Temporary files in go

2018-10-12 Thread Greg Saylor
If I remember correctly, it would be something like this: fd = open("/tmp", O_TMPFILE | O_RDWR, 0600); linkat(fd, "", AT_FDCWD, "/tmp/test", AT_EMPTY_PATH); This is pretty specific to OS/kernel version and quite possibly the filesystem too. This could be entirely too much of an edge case to be

Re: [go-nuts] Temporary files in go

2018-10-12 Thread Robert Engels
Which is not Windows, which is giving up a lot of options, and is important to some people, where as just using tmp files is ok. I am not even sure if windows supports deleting an open file yet. > On Oct 12, 2018, at 3:09 AM, Beoran wrote: > > linkat() and openat() are posix 2008 standard func

Re: [go-nuts] Temporary files in go

2018-10-12 Thread Beoran
linkat() and openat() are posix 2008 standard functions so I wouldn't call this uncommon. As such they are useful to have in Go in one way or the other. The x/unix package is fine for that, though. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group

Re: [go-nuts] Temporary files in go

2018-10-11 Thread Greg Saylor
If I remember correctly, it would be something like this: fd = open("/tmp", O_TMPFILE | O_RDWR, 0600); linkat(fd, "", AT_FDCWD, "/tmp/test", AT_EMPTY_PATH); This is pretty specific to OS/kernel version and quite possibly the filesystem too. This could be entirely too much of an edge case to be re

Re: [go-nuts] Temporary files in go

2018-10-11 Thread robert engels
I think a more “standard” and certainly portable way to do this is with a tmp file, and a rename/move at the end - along with a clean-up of tmp at application start (if worried about crashes). Using the proper file and process permissions on the tmp file - since you need these to protect the fi

Re: [go-nuts] Temporary files in go

2018-10-11 Thread Sam Whited
On Thu, Oct 11, 2018, at 18:48, Greg Saylor wrote: > 1. Create a temporary file and squirrel away the file handle > 2. Unlink the temporary file by name > 3. Various functions would write stuff to the file > 4. If the programs completes to some successful state, create a hardlink to > the file han

Re: [go-nuts] Temporary files in go

2018-10-11 Thread Justin Israel
On Fri, Oct 12, 2018, 2:31 PM Ian Lance Taylor wrote: > On Thu, Oct 11, 2018 at 4:48 PM, Greg Saylor > wrote: > > > > In other programming languages (this is specific to Linux/Unix systems), > in > > the past to ensure security in the even of a program crash, we would do > > something like: > >

Re: [go-nuts] Temporary files in go

2018-10-11 Thread Ian Lance Taylor
On Thu, Oct 11, 2018 at 4:48 PM, Greg Saylor wrote: > > In other programming languages (this is specific to Linux/Unix systems), in > the past to ensure security in the even of a program crash, we would do > something like: > > 1. Create a temporary file and squirrel away the file handle > 2. Unli

[go-nuts] Temporary files in go

2018-10-11 Thread Greg Saylor
Hello, In other programming languages (this is specific to Linux/Unix systems), in the past to ensure security in the even of a program crash, we would do something like: 1. Create a temporary file and squirrel away the file handle 2. Unlink the temporary file by name 3. Various functions would