X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fdata%2Fmake-file.h;fp=src%2Fdata%2Fmake-file.h;h=d908db336681c9b4179c126abe601f7b1c34f126;hb=7344ce41487d4294726d597b99bbef5c3cfa1ce6;hp=a2bcc76eb11bdda3ec0917844f0c9b11c1175ced;hpb=3db83b515247dca69abbf7ad05d3dbdfec4b524c;p=pspp diff --git a/src/data/make-file.h b/src/data/make-file.h index a2bcc76eb1..d908db3366 100644 --- a/src/data/make-file.h +++ b/src/data/make-file.h @@ -23,25 +23,29 @@ struct file_handle; -/* Prepares to atomically replace a (potentially) existing file - by a new file., by creating a temporary file with the given - PERMISSIONS bits. +/* Prepares to atomically replace a (potentially) existing file by a new file, + by creating a temporary file with the given PERMISSIONS bits. Special files are an exception: they are not atomically replaced but simply opened for writing. - If successful, stores a stream for it opened according to MODE (which should be - "w" or "wb") in *FP. Returns a ticket that can be used to - commit or abort the file replacement. If neither action has - yet been taken, program termination via signal will cause - all resources to be released. The return value must not be - explicitly freed. + If successful, returns a ticket that can be used to commit or abort the file + replacement. If neither action is taken, program termination via signal + will abort. Depending on the function, stores a file descriptor in *FD or a + stream in *FP for the newly opened file. The descriptor or stream is opened + for writing a binary file if BINARY is true, otherwise a text file (this + disctinction only matters on Windows). - The caller is responsible for closing *FP */ + On error, returns NULL and stores NULL in *FP or -1 in *FD. + + The caller is responsible for closing *FP or *FD. */ struct replace_file *replace_file_start (const struct file_handle *fh, - const char *mode, mode_t permissions, + bool binary, mode_t permissions, FILE **fp); +struct replace_file *replace_file_start_fd (const struct file_handle *fh, + bool binary, + mode_t permissions, int *fd); /* Commits or aborts the replacement of a (potentially) existing file by a new file, using the ticket returned by