Re: RENAME problem: directories with spaces?

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

Al Getz wrote:

<snip>

> Hi Dan,
> 
> Can you use the Win API here?

The following code uses the Windows API:
include misc.e
include dll.e
include machine.e

atom Kernel32
integer MoveFile

if platform() = WIN32 then
   Kernel32 = open_dll("kernel32.dll")
MoveFile = define_c_func(Kernel32, "MoveFileA", {C_POINTER, C_POINTER},
   C_LONG)
end if

function rename (sequence oldName, sequence newName)
   atom lpszOldname, lpszNewname, ret

   lpszOldname = allocate_string(oldName)
   lpszNewname = allocate_string(newName)
   ret = c_func(MoveFile, {lpszOldname, lpszNewname})
   free(lpszOldname)
   free(lpszNewname)
   return ret                                          -- 0 on error
end function

-- Demo
-- In contrast to using system("rename ...", ...), here the new name
-- can and must contain the appropriate path.
? rename("c:\\temp\\the old one", "c:\\temp\\the new one")


Regards,
   Juergen

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

Search



Quick Links

User menu

Not signed in.

Misc Menu