Re: Opening a file - File Open Dialog spoils future code

new topic     » goto parent     » topic index » view thread      » older message » newer message

CChris wrote:
> 
> I am only saying two things:
> 1/ since ex.err may land in folders from where no Eu rogram was ever run,
> other
> processes must interfere in some cases (in case of a crash? I don't know);
> 2/ since use of the current directory is so confusing for practical use under
> Windows, and since there is such an excessive concern about avoiding confuion
> in the language, I think relying on what the "current directory" happens to
> be in an only mildly deterministic way (from the user standpoint) should be
> actively discouraged in some way.

I've run a simple test, and the c-library and win32 routines seem 
interchangeable, which isn't surprising, since the runtime library probably
just wraps the win32 functions.  Now we need to find the magic that disrupts
this behavior:
include dll.e
include file.e
include machine.e
object void
constant 
k32 = open_dll("kernel32.dll"),
GetCurrentDirectoryA = define_c_func( k32, "GetCurrentDirectoryA", {C_INT,
C_POINTER}, C_INT ),
SetCurrentDirectoryA = define_c_func( k32, "SetCurrentDirectoryA", {C_POINTER},
C_INT )

function pwd()
	atom buf, chars
	sequence d
	buf = allocate( 1025 )
	chars = c_func( GetCurrentDirectoryA, {1024, buf})
	d = peek( buf & chars )
	free( buf )
	return d
end function

procedure cd( sequence d )
	atom buf, ok
	
	buf = allocate_string( d )
	ok = c_func( SetCurrentDirectoryA, {buf})
	free(buf)
end procedure

procedure checkdir()
	printf(1, "current_dir: '%s'\n", {current_dir()})
	printf(1, "Win32:       '%s'\n\n", {pwd()})
end procedure

puts(1, "The starting current_dir():\n")
checkdir()

puts(1, "Calling chdir(\"..\")\n")
void = chdir("..")

checkdir()

puts(1, "Calling cd(\"..\")\n")
cd( ".." )

checkdir()


new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu