简体   繁体   中英

Keep Lua tmpfile after execute

Uploades file represented as tmpfile() and will be removed then script exits. How to hardlink this file to keep its content after removing tmpfile?

How to get name of file by its handle?

> a=io.tmpfile()
> print(a)
file (0x20c8790)
> lfs=require"lfs"
> lfs.link(a,"/tmp/aaaa")
stdin:1: bad argument #1 to 'link' (string expected, got FILE*)
stack traceback:
    [C]: in function 'lfs.link'
    stdin:1: in main chunk
    [C]: in ?

This file is too big to copy it by byte to another.

io.tmpfile uses tmpfile of stdio.h, so it wont be possible to adjust this exported function. you can use libraries such as pl.path to get full path of temp file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM