1. Help

I can't seem to find a way to quietly (without a black box) delete a file. I'm using EU 2.4 in windiows 7. Help would be appreciated.

new topic     » topic index » view message » categorize

2. Re: Help

gwalters said...

I can't seem to find a way to quietly (without a black box) delete a file. I'm using EU 2.4 in windiows 7. Help would be appreciated.

Firstly, sorry you have to use an ancient version of Euphoria smile

Try something like this (p.s. I can't remember which libraries you have to include but I'm sure you'll work that out.)

function delete_file( sequence pFilePath) 
atom lLib 
atom lFunc 
atom lMem 
atom lRet 
 
lLib = open_dll("kernel32.dll") 
if lLib < 0 then 
    return -1 -- failed to open library 
end if 
 
lFunc = define_c_func(lLib, "DeleteFileA", {C_POINTER}, C_INT) 
if lFunc < 0 then 
    return -2 -- failed to define function 
end if 
 
lMem = allocate( length(pFilePath) + 1) 
if lMem = 0 then 
    return -3 -- failed to allocate RAM 
end if 
 
poke(lMem, pFilePath) 
poke(lMem + length(pFilePath), 0) 
 
lRet = c_func(lFunc, {lMem}) 
 
free(lMem) 
 
return (lRet != 0) -- 0 means failed, 1 means deleted 
 
end function 

(ed. Fixed c_func() call syntax. - It seems to work!)

new topic     » goto parent     » topic index » view message » categorize

3. Re: Help

Thanks Derek, it worked quite well. This would be a nice addition to the current win32lib if it doesn't have one.

George

new topic     » goto parent     » topic index » view message » categorize

4. Re: Help

gwalters said...

This would be a nice addition to the current win32lib if it doesn't have one.

Doesn't need it as it's in the standard library now, and works for both Windows and *nix. Of course, you'd have to upgrade to the current Euphoria release first.

new topic     » goto parent     » topic index » view message » categorize

5. Re: Help

gwalters said...

Thanks Derek, it worked quite well. This would be a nice addition to the current win32lib if it doesn't have one.

George

It has one, the naming convention makes it something like deleteFile(). It might even be in the version you are using.

new topic     » goto parent     » topic index » view message » categorize

6. Re: Help

It's also in WIN32FIL.EW by:

-- Win32 file functions by Jeffrey Fielding (JJProg@cyberbury.net) 
-- Win32 directory functions added by Brian Broker (bkb@cnw.com) 

from years ago.

useless

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu