1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/xpcom/io/nsISafeOutputStream.idl Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,39 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#include "nsISupports.idl" 1.10 + 1.11 +/** 1.12 + * This interface provides a mechanism to control an output stream 1.13 + * that takes care not to overwrite an existing target until it is known 1.14 + * that all writes to the destination succeeded. 1.15 + * 1.16 + * An object that supports this interface is intended to also support 1.17 + * nsIOutputStream. 1.18 + * 1.19 + * For example, a file output stream that supports this interface writes to 1.20 + * a temporary file, and moves it over the original file when |finish| is 1.21 + * called only if the stream can be successfully closed and all writes 1.22 + * succeeded. If |finish| is called but something went wrong during 1.23 + * writing, it will delete the temporary file and not touch the original. 1.24 + * If the stream is closed by calling |close| directly, or the stream 1.25 + * goes away, the original file will not be overwritten, and the temporary 1.26 + * file will be deleted. 1.27 + * 1.28 + * Currently, this interface is implemented only for file output streams. 1.29 + */ 1.30 +[scriptable, uuid(5f914307-5c34-4e1f-8e32-ec749d25b27a)] 1.31 +interface nsISafeOutputStream : nsISupports 1.32 +{ 1.33 + /** 1.34 + * Call this method to close the stream and cause the original target 1.35 + * to be overwritten. Note: if any call to |write| failed to write out 1.36 + * all of the data given to it, then calling this method will |close| the 1.37 + * stream and return failure. Further, if closing the stream fails, this 1.38 + * method will return failure. The original target will be overwritten only 1.39 + * if all calls to |write| succeeded and the stream was successfully closed. 1.40 + */ 1.41 + void finish(); 1.42 +};