laserlaser Posted May 30, 2011 Share Posted May 30, 2011 Hello mates, Obviously can not say the new.I write old year. Functions: --[[ Created by Ozan Tartar Cooker-X a.k.a laserlaser -| Bikers! War Of Empire LUA Team File Read System v1.0 ]] -- file_Create function file_Create(filename) return fileCreate(filename) end -- file_Open function file_Open(filename) return fileOpen(filename) end -- file_Write function file_Write(filename,string1,...) local args = {...} local file = file_Open(filename) if file then if args then fileWrite(file,string1,unpack(args)) else fileWrite(file,string1) end fileClose(file) end end -- file_Read function file_Read(filename) local file = file_Open(filename) local buffer = nil if (file) then buffer ='' while not fileIsEOF(file) do buffer = buffer..fileRead(file, 500) end fileClose(file) end return buffer end -- file_Get function file_Get(filename,param) local myBuffer = file_Read(filename) local myValue = nil if ( myBuffer ~= nil ) then for k, v in string.gmatch(myBuffer, "([%w]+)=([%w]+)") do if k==param then myValue=v end end if (myValue ~= nil) then return myValue else return nil end else return nil end end -- file_Set function file_Set(filename,param,value) local myBuffer = file_Read(filename) local isEOF = true local myBuffer1={} if myBuffer ~= nil then local count=1 for k, v in string.gmatch(myBuffer, "(%w+)=(%w+)") do if k==param then myBuffer1[count]=k.."="..value.."\n" isEOF=false else myBuffer1[count]=k.."="..v.."\n" end count = count+1 end if isEOF==true then myBuffer1[count]=param.."="..value.."\n" end local file = file_Open(filename) if file then fileWrite(file,unpack(myBuffer1)) fileClose(file) else return nil end else return nil end end -- file_IsEOF function file_IsEOF(filename) local file = file_Open(filename) if file then local iseof = fileIsEOF(file) fileClose(file) return iseof else return nil end end -- file_Delete function file_Delete(filename) return fileDelete(filename) end -- file_Close function file_Close(fileHandler) return fileClose(fileHandler) end -- file_Exists function file_Exists(filename) return fileExists(filename) end -- file_Size function file_Size(filename) local file=file_Open(filename) if file then local size = fileGetSize(file) file_Close(file) return size else return 0 end end -- file_Flush function file_Flush(fileHandler) return file_Flush(fileHandler) end -- Short fcreate = file_Create fopen = file_Open fwrite = file_Write fread = file_Read fget = file_Get fset = file_Set fisEOF = file_IsEOF fdelete = file_Delete fclose = file_Close fexists = file_Exists fsize = file_Size fflush = file_Flush Fonksiyon Açıklamaları: çoğu fonksiyon aynı. fread = Dosyanın tüm içeriğini dönderir.While döngüsüne gerek kalmaz ;direk local bufferString=fread("a.txt"); yazarsanız bufferString'e a.txt'nin içeriğini aktaracaktır. fget(filename,key) == örneğin a.txt'mizin içi Password=aaaa olsun eğer bu fonksiyonu fget("a.txt","Password") yazarsak bize "aaaa" sonucunu döndürecektir. fset(filename,key,value) == fset(filename,"Password","a1"); yaparsak Password=a1 olacaktır. War OF Empire Lua Team... Alıntı Değildir. Link to comment
UAEpro Posted May 31, 2011 Share Posted May 31, 2011 --[[ Created by Ozan Tartar Cooker-X a.k.a laserlaser -| Bikers! War Of Empire LUA Team File Read System v1.0 ]] -- file_Create function file_Create(filename) return fileCreate(filename) end -- file_Open function file_Open(filename) return fileOpen(filename) end -- file_Write function file_Write(filename,string1,...) local args = {...} local file = file_Open(filename) if file then if args then fileWrite(file,string1,unpack(args)) else fileWrite(file,string1) end fileClose(file) end end -- file_Read function file_Read(filename) local file = file_Open(filename) local buffer = nil if (file) then buffer ='' while not fileIsEOF(file) do buffer = buffer..fileRead(file, 500) end fileClose(file) end return buffer end -- file_Get function file_Get(filename,param) local myBuffer = file_Read(filename) local myValue = nil if ( myBuffer ~= nil ) then for k, v in string.gmatch(myBuffer, "([%w]+)=([%w]+)") do if k==param then myValue=v end end if (myValue ~= nil) then return myValue else return nil end else return nil end end -- file_Set function file_Set(filename,param,value) local myBuffer = file_Read(filename) local isEOF = true local myBuffer1={} if myBuffer ~= nil then local count=1 for k, v in string.gmatch(myBuffer, "(%w+)=(%w+)") do if k==param then myBuffer1[count]=k.."="..value.."\n" isEOF=false else myBuffer1[count]=k.."="..v.."\n" end count = count+1 end if isEOF==true then myBuffer1[count]=param.."="..value.."\n" end local file = file_Open(filename) if file then fileWrite(file,unpack(myBuffer1)) fileClose(file) else return nil end else return nil end end -- file_IsEOF function file_IsEOF(filename) local file = file_Open(filename) if file then local iseof = fileIsEOF(file) fileClose(file) return iseof else return nil end end -- file_Delete function file_Delete(filename) return fileDelete(filename) end -- file_Close function file_Close(fileHandler) return fileClose(fileHandler) end -- file_Exists function file_Exists(filename) return fileExists(filename) end -- file_Size function file_Size(filename) local file=file_Open(filename) if file then local size = fileGetSize(file) file_Close(file) return size else return 0 end end -- file_Flush function file_Flush(fileHandler) return file_Flush(fileHandler) end -- Short fcreate = file_Create fopen = file_Open fwrite = file_Write fread = file_Read fget = file_Get fset = file_Set fisEOF = file_IsEOF fdelete = file_Delete fclose = file_Close fexists = file_Exists fsize = file_Size fflush = file_Flush thank you ^^ Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now