diff --git a/lua/starfall/libs_cl/file.lua b/lua/starfall/libs_cl/file.lua index 93ca6ce6d..5e2466817 100644 --- a/lua/starfall/libs_cl/file.lua +++ b/lua/starfall/libs_cl/file.lua @@ -342,12 +342,17 @@ function file_library.delete(path) end --- Deletes a temp file --- @param filename path The temp file name. Must be only a file and not a path +-- @param string filename The temp file name. Must be only a file and not a path -- @return boolean? True if successful, nil if it wasn't found -function file_library.deleteTemp(path) - checkpermission (instance, path, "file.writeTemp") +function file_library.deleteTemp(filename) + checkpermission (instance, nil, "file.writeTemp") checkluatype (path, TYPE_STRING) - path = "sf_filedatatemp/"..instance.player:SteamID64().."/" .. SF.NormalizePath(path) + + if #filename > 128 then SF.Throw("Filename is too long!", 2) end + checkExtension(filename) + filename = string.lower(string.GetFileFromFilename(filename)) + + local path = "sf_filedatatemp/"..instance.player:SteamID64().."/"..filename if file.Exists(path, "DATA") then file.Delete(path) return true