lua-users home
lua-l archive

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


>>>>> "BN" == Brett Nash <nash@nash.id.au> writes:

 >> 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.

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

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

 BN> Not exactly portable at the last step however...

let's leave splice() and Linux alone. generally, that's a bad
practice, you may copy only part of the file. 

-- 
Yours sincerely, Eugeny.
Doctor Web, Ltd. http://www.drweb.com
+79119997425