fork download
  1. local function getTempPath()
  2. local directorySeperator = package.config:match("([^\n]*)\n?")
  3. local exampleTempFilePath = os.tmpname()
  4.  
  5. -- remove generated temp file
  6. pcall(os.remove, exampleTempFilePath)
  7.  
  8. local seperatorIdx = exampleTempFilePath:reverse():find(directorySeperator)
  9. local tempPathStringLength = #exampleTempFilePath - seperatorIdx
  10.  
  11. return exampleTempFilePath:sub(1, tempPathStringLength)
  12. end
  13.  
  14. print(getTempPath())
Success #stdin #stdout 0s 4408KB
stdin
Standard input is empty
stdout
/tmp