// File: /workspace/github_c_makefile_star2_O2/enzo1982[P]smooth/classes/io/drivers/driver_ansi.cpp
// Function: smooth::IO::DriverANSI::DriverANSI(smooth::String const&, int)
S::IO::DriverANSI::DriverANSI(const String &file, Int mode) : Driver()
{
	stream	    = NIL;
	closeStream = False;

#if defined __WIN32__
	/* Add N mode option and Unicode prefix on Windows.
	 */
	String	 options  = "N";
	String	 fileName = Directory::MakeExtendedPath(file);
#else
	/* Use e mode option on other systems.
	 */
	String	 options  = "e";
	String	 fileName = file;

	/* Set output format to UTF-8 on non-Windows systems.
	 */
	String::OutputFormat	 outputFormat("UTF-8");
#endif

	switch (mode)
	{
		default:
			lastError = IO_ERROR_BADPARAM;

			return;
		case OS_APPEND:		   // open a file for appending data
			stream = fopen(fileName, String("r+b").Append(options));

			if (stream != NIL)
			{
				Int64	 size = GetSize();

				if (size >= 0) Seek(size);
			}

			break;
		case OS_REPLACE:	   // create or overwrite a file
			stream = fopen(fileName, String("w+b").Append(options));

			break;
		case IS_READ | IS_WRITE:   // open a file for reading data
			stream = fopen(fileName, String("r+b").Append(options));

			break;
		case IS_READ:		   // open a file in read only mode
			stream = fopen(fileName, String("rb").Append(options));

			break;
	}

	/* Check if stream was opened successfully.
	 */
	if (stream == NIL)
	{
		if (errno == EACCES) lastError = IO_ERROR_NOACCESS;
		else		     lastError = IO_ERROR_UNEXPECTED;

		return;
	}

	streamID = fileName;

	closeStream = True;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x60, %rsp
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %rbx
callq 0x59850
movq 0xc554c(%rip), %rax     # 0x161610
addq $0x10, %rax
movq %rax, (%rbx)
andq $0x0, 0x38(%rbx)
movb $0x0, 0x40(%rbx)
leaq 0x67a31(%rip), %rsi     # 0x103b0c
leaq 0x30(%rsp), %rdi
callq 0x58c40
leaq 0x18(%rsp), %rdi
movq %r14, %rsi
callq 0x58280
leaq 0x660cd(%rip), %rsi     # 0x1021c6
leaq 0x48(%rsp), %rdi
callq 0x56fa0
cmpl $0x6, %ebp
ja 0x9c270
movl %ebp, %eax
leaq 0x657a3(%rip), %rcx     # 0x1018b8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x18(%rsp), %rdi
callq 0x598d0
movq %rax, %r14
leaq 0x657bb(%rip), %rsi     # 0x1018ed
movq %rsp, %rdi
callq 0x58c40
movq %rsp, %rdi
leaq 0x30(%rsp), %rsi
callq 0x573e0
movq %rax, %rdi
callq 0x598d0
movq %r14, %rdi
movq %rax, %rsi
callq 0x599d0
movq %rax, 0x38(%rbx)
movq %rsp, %rdi
callq 0x5a588
cmpq $0x0, 0x38(%rbx)
je 0x9c25d
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x40(%rax)
testq %rax, %rax
js 0x9c242
movq (%rbx), %rcx
movq %rbx, %rdi
movq %rax, %rsi
callq *0x20(%rcx)
jmp 0x9c242
leaq 0x18(%rsp), %rdi
callq 0x598d0
movq %rax, %r14
leaq 0x4719c(%rip), %rsi     # 0xe3344
movq %rsp, %rdi
callq 0x58c40
movq %rsp, %rdi
leaq 0x30(%rsp), %rsi
callq 0x573e0
movq %rax, %rdi
callq 0x598d0
jmp 0x9c22b
leaq 0x18(%rsp), %rdi
callq 0x598d0
movq %rax, %r14
leaq 0x65716(%rip), %rsi     # 0x1018f1
movq %rsp, %rdi
callq 0x58c40
movq %rsp, %rdi
leaq 0x30(%rsp), %rsi
callq 0x573e0
movq %rax, %rdi
callq 0x598d0
jmp 0x9c22b
leaq 0x18(%rsp), %rdi
callq 0x598d0
movq %rax, %r14
leaq 0x656df(%rip), %rsi     # 0x1018ed
movq %rsp, %rdi
callq 0x58c40
movq %rsp, %rdi
leaq 0x30(%rsp), %rsi
callq 0x573e0
movq %rax, %rdi
callq 0x598d0
movq %r14, %rdi
movq %rax, %rsi
callq 0x599d0
movq %rax, 0x38(%rbx)
movq %rsp, %rdi
callq 0x5a588
cmpq $0x0, 0x38(%rbx)
je 0x9c25d
leaq 0x20(%rbx), %rdi
leaq 0x18(%rsp), %rsi
callq 0x56630
movb $0x1, 0x40(%rbx)
jmp 0x9c280
callq 0x59780
cmpl $0xd, (%rax)
jne 0x9c279
movl $0x9, 0x18(%rbx)
jmp 0x9c280
movl $0x2, 0x18(%rbx)
jmp 0x9c280
movl $0x3, 0x18(%rbx)
leaq 0x48(%rsp), %rdi
callq 0x59970
leaq 0x18(%rsp), %rdi
callq 0x5a588
leaq 0x30(%rsp), %rdi
callq 0x5a588
addq $0x60, %rsp
popq %rbx
popq %r14
popq %rbp
retq
jmp 0x9c2d3
jmp 0x9c2d3
jmp 0x9c2d3
jmp 0x9c2d3
jmp 0x9c2d3
jmp 0x9c2b7
jmp 0x9c2b7
jmp 0x9c2b7
movq %rax, %r14
movq %rsp, %rdi
callq 0x5a588
jmp 0x9c2d6
movq %rax, %r14
jmp 0x9c2e0
movq %rax, %r14
jmp 0x9c2ea
movq %rax, %r14
jmp 0x9c2f4
movq %rax, %r14
leaq 0x48(%rsp), %rdi
callq 0x59970
leaq 0x18(%rsp), %rdi
callq 0x5a588
leaq 0x30(%rsp), %rdi
callq 0x5a588
movq %rbx, %rdi
callq 0x57db0
movq %r14, %rdi
callq 0x58260