1. Help
- Posted by gwalters Dec 09, 2013
- 2008 views
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.
2. Re: Help
- Posted by DerekParnell (admin) Dec 09, 2013
- 1979 views
- Last edited Dec 10, 2013
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
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!)
3. Re: Help
- Posted by gwalters Dec 11, 2013
- 1813 views
Thanks Derek, it worked quite well. This would be a nice addition to the current win32lib if it doesn't have one.
George
4. Re: Help
- Posted by DerekParnell (admin) Dec 11, 2013
- 1792 views
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.
5. Re: Help
- Posted by SDPringle Dec 12, 2013
- 1638 views
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.
6. Re: Help
- Posted by useless_ Dec 12, 2013
- 1677 views
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