function f_r(FilePath, Content) local file = io.open(FilePath, "w") if file then file:write(Content) file:close() return true end return false end function RandomString(List) return List[math.random(1, #List)] end String_List = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'n', 'w', 'x', 'y', 'z'} Byte_String = RandomString(String_List) if Content == nil then Content = '' end for i=1, 1 * 1024 do Content = Content .. Byte_String end KiloByte_String = Content Content = '' for i=1, 1 * 1024 do Content = Content .. KiloByte_String end MegaByte_String = Content Content = '' for i=1, 1 * 10 do Content = Content .. MegaByte_String end x10MegaByte_String = Content --[[ Content = '' for i=1, 1 * 1024 do Content = Content .. MegaByte_String end GigaByte_String = Content ]] function GenerateContent(Type, Size) if Type == nil or Type == '' then gg.alert('GenerateContent > Type == nil' ,'return false') return false, 'Type == nil' end if Size == nil or Size == '' then gg.alert('GenerateContent > Size == nil' ,'return false') return false, 'Size == nil' end if Type == 'B' then String = Byte_String elseif Type == 'KB' then String = KiloByte_String elseif Type == 'MB' then String = MegaByte_String elseif Type == '10MB' then String = x10MegaByte_String elseif Type == 'GB' then Size = Size * 1024 String = MegaByte_String elseif Type == 'TB' then Size = Size * 1024 * 1024 String = MegaByte_String else gg.alert('GenerateContent > Type Out of range\nYour type function content is['..Type..']', 'return false') return false, 'Type Out of range' end if Type == 'GB' or Type == 'TB' then gg.toast('你选择了 GigaByte TeraByte 字节单位的生成 可能会造成卡顿及长时间等待情况 如有不对请立即停止脚本') end Content = '' for i=1, Size do Content = Content .. String end return Content end content, error = GenerateContent('10MB', 10.24) if func == false then return gg.alert('错误:\n'..error, '取消') end for i=1, 10 do f_r(gg.getFile()..i..'.txt', content) gg.toast(i..'已完成') end