Re: RENAME problem: directories with spaces?
- Posted by Juergen Luethje <j.lue at gmx.de> Sep 04, 2006
- 567 views
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