lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Tue, 2008-04-08 at 18:16 +1200, Geoff Leyland wrote:
> Thanks Gary,
> 
> I hadn't really thought of that.  I'm copying a "read-only" data file  
> to a tmpname before I muck with it so I was thinking in shell  
> operations.
> 
> If read/write might be slow, then os.execute's fine.  The data might  
> be tens or low hundreds of MB.

Copy is something which generally has to implemented in user space,
there isn't normally a system call to do it.  Hence no POSIXy or Unixy
way of doing it.  

Although if you want to be really tricky:
	src = open("srcfile", O_RDONLY)
	dst = open("dstfile", O_WRONLY);
	splice(src,NULL, dst, NULL, st.st_size, 0);

Not exactly portable at the last step however...

	Regards,
	nash