haxe/src/sys/io/FileOutput.cs
// Generated by Haxe 4.3.7 (patched: in-memory file output)

#pragma warning disable 109, 114, 219, 429, 168, 162
namespace sys.io {
	public class FileOutput : global::cs.io.NativeOutput {
		
		public FileOutput(global::haxe.lang.EmptyObject empty) : base(((global::haxe.lang.EmptyObject) (global::haxe.lang.EmptyObject.EMPTY) )) {
		}
		
		
		public FileOutput(global::System.IO.Stream stream) : base(((global::haxe.lang.EmptyObject) (global::haxe.lang.EmptyObject.EMPTY) )) {
			global::sys.io.FileOutput.__hx_ctor_sys_io_FileOutput(this, stream);
		}
		
		
		public FileOutput(string path, global::System.IO.Stream stream, bool saveOnClose) : base(((global::haxe.lang.EmptyObject) (global::haxe.lang.EmptyObject.EMPTY) )) {
			global::sys.io.FileOutput.__hx_ctor_sys_io_FileOutput(this, stream);
			this._path = path;
			this._saveOnClose = saveOnClose;
		}
		
		
		protected static void __hx_ctor_sys_io_FileOutput(global::sys.io.FileOutput __hx_this, global::System.IO.Stream stream) {
			global::cs.io.NativeOutput.__hx_ctor_cs_io_NativeOutput(__hx_this, stream);
			__hx_this._path = null;
			__hx_this._saveOnClose = false;
		}
		
		
		private string _path;
		
		private bool _saveOnClose;
		
		public override void close() {
			if (( this._saveOnClose && ( this._path != null ) )) {
				global::System.IO.MemoryStream ms = ( this.stream as global::System.IO.MemoryStream );
				if (( ms != null )) {
					global::sys.FileSystem.WriteFileBytes(this._path, ms.ToArray());
				}
				
			}
			
			base.close();
		}
		
	}
}