// File: /workspace/github_c_makefile_star2_O1/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 0x58560
movq 0xcb8e8(%rip), %rax     # 0x16c610
addq $0x10, %rax
movq %rax, (%rbx)
movq $0x0, 0x38(%rbx)
movb $0x0, 0x40(%rbx)
leaq 0x73d2a(%rip), %rsi     # 0x114a6c
leaq 0x30(%rsp), %rdi
callq 0x579f0
leaq 0x18(%rsp), %rdi
movq %r14, %rsi
callq 0x570b0
leaq 0x723c6(%rip), %rsi     # 0x113126
leaq 0x48(%rsp), %rdi
callq 0x55ed0
cmpl $0x6, %ebp
ja 0xa0ed7
movl %ebp, %eax
leaq 0x71a98(%rip), %rcx     # 0x112814
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x18(%rsp), %rdi
callq 0x585e0
movq %rax, %r14
leaq 0x71ab0(%rip), %rsi     # 0x112849
movq %rsp, %rdi
callq 0x579f0
movq %rsp, %rdi
leaq 0x30(%rsp), %rsi
callq 0x562f0
movq %rax, %rdi
callq 0x585e0
movq %r14, %rdi
movq %rax, %rsi
callq 0x586e0
movq %rax, 0x38(%rbx)
movq %rsp, %rdi
callq 0x59200
cmpq $0x0, 0x38(%rbx)
je 0xa0ea9
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x40(%rax)
testq %rax, %rax
js 0xa0ea9
movq (%rbx), %rcx
movq %rbx, %rdi
movq %rax, %rsi
callq *0x20(%rcx)
jmp 0xa0ea9
leaq 0x18(%rsp), %rdi
callq 0x585e0
movq %rax, %r14
leaq 0x5354e(%rip), %rsi     # 0xf435d
movq %rsp, %rdi
callq 0x579f0
movq %rsp, %rdi
leaq 0x30(%rsp), %rsi
callq 0x562f0
movq %rax, %rdi
callq 0x585e0
jmp 0xa0e92
leaq 0x18(%rsp), %rdi
callq 0x585e0
movq %rax, %r14
leaq 0x71a0b(%rip), %rsi     # 0x11284d
movq %rsp, %rdi
callq 0x579f0
movq %rsp, %rdi
leaq 0x30(%rsp), %rsi
callq 0x562f0
movq %rax, %rdi
callq 0x585e0
jmp 0xa0e92
leaq 0x18(%rsp), %rdi
callq 0x585e0
movq %rax, %r14
leaq 0x719d4(%rip), %rsi     # 0x112849
movq %rsp, %rdi
callq 0x579f0
movq %rsp, %rdi
leaq 0x30(%rsp), %rsi
callq 0x562f0
movq %rax, %rdi
callq 0x585e0
movq %r14, %rdi
movq %rax, %rsi
callq 0x586e0
movq %rax, 0x38(%rbx)
movq %rsp, %rdi
callq 0x59200
cmpq $0x0, 0x38(%rbx)
je 0xa0ec4
leaq 0x20(%rbx), %rdi
leaq 0x18(%rsp), %rsi
callq 0x555f0
movb $0x1, 0x40(%rbx)
jmp 0xa0ee7
callq 0x58490
cmpl $0xd, (%rax)
jne 0xa0ee0
movl $0x9, 0x18(%rbx)
jmp 0xa0ee7
movl $0x2, 0x18(%rbx)
jmp 0xa0ee7
movl $0x3, 0x18(%rbx)
leaq 0x48(%rsp), %rdi
callq 0x58680
leaq 0x18(%rsp), %rdi
callq 0x59200
leaq 0x30(%rsp), %rdi
callq 0x59200
addq $0x60, %rsp
popq %rbx
popq %r14
popq %rbp
retq
jmp 0xa0f3a
jmp 0xa0f3a
jmp 0xa0f3a
jmp 0xa0f3a
jmp 0xa0f3a
jmp 0xa0f1e
jmp 0xa0f1e
jmp 0xa0f1e
movq %rax, %r14
movq %rsp, %rdi
callq 0x59200
jmp 0xa0f3d
movq %rax, %r14
jmp 0xa0f47
movq %rax, %r14
jmp 0xa0f51
movq %rax, %r14
jmp 0xa0f5b
movq %rax, %r14
leaq 0x48(%rsp), %rdi
callq 0x58680
leaq 0x18(%rsp), %rdi
callq 0x59200
leaq 0x30(%rsp), %rdi
callq 0x59200
movq %rbx, %rdi
callq 0x56c30
movq %r14, %rdi
callq 0x57090
nop