RE: unlink and rename functions for Linux exu
- Posted by freeplay at mailandnews.com Aug 22, 2001
- 340 views
Thanks Irv - I'll give that a whirl. Regards, FP. >===== Original Message From Irv Mullins <irvm at ellijay.com> ===== > >On Wednesday 22 August 2001 07:28, freeplay at mailandnews.com wrote: > >> I have the following two functions for unlinking and renaming files with >> the exw.exe Windows interpreter. Can I do a similar thing with the exu >> Linux interpreter? > >system("rm /foo/bar/link",0) > >system("mv /foo/bar/fileold /foo/bar/filenew",0) > >Unlike Windows, Linux doesn't pop up a "DOS" box when you call >system functions from an xWindows program, so there's no need to >go thru the hassles shown below. > >Regards, >Irv > >> >> function unlink_win(sequence filename) >> >> atom kernel32 >> atom deletefile >> atom a >> atom r >> >> kernel32 = open_dll("kernel32.dll") >> >> if kernel32 = 0 then >> return(-1) >> end if >> >> deletefile = define_c_func(kernel32, "DeleteFileA", {C_POINTER}, C_INT) >> >> if deletefile = -1 then >> return(-1) >> end if >> >> a = allocate_string(filename) >> >> r = c_func(deletefile, {a}) >> >> free(a) >> >> if r != 1 then >> return(-1) >> end if >> >> return(0) >> >> end function >> >> function rename_win(sequence oldname, sequence newname) >> >> atom kernel32 >> atom movefile >> atom old >> atom new >> atom r >> >> kernel32 = open_dll("kernel32.dll") >> >> if kernel32 = 0 then >> return(-1) >> end if >> >> movefile = define_c_func(kernel32, "MoveFileA", {C_POINTER, C_POINTER}, >> C_INT) >> >> if movefile = -1 then >> return(-1) >> end if >> >> old = allocate_string(oldname) >> new = allocate_string(newname) >> >> r = c_func(movefile, {old, new}) >> >> free(old) >> free(new) >> >> if r != 1 then >> return(-1) >> end if >> >> return(0) >> >> end function >> >> >> Regards, >> >> FP. >> > >