Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function cut(line)
- temp= ""
- for i=0,#line do
- temp= string.sub(line,#line-i,#line-i)
- if temp == "/"
- then
- return string.sub(line,#line-i+1,#line)
- end
- end
- end
- -- namefile 1 = name file find
- -- namefile 2 = now file
- function heavy_version_find(namefile1,namefile2,min_numbersimbol)
- if namefile1 == nil or namefile2 == nil
- then
- return
- end
- if min_numbersimbol > #namefile1
- then
- min_numbersimbol= #namefile1
- end
- if min_numbersimbol == nil
- then
- min_numbersimbol= math.floor(#namefile1/3)
- end
- l= #namefile1
- v1= ""
- v2= ""
- v3= cut(namefile2)
- c= 0
- for q=1,#namefile1 do
- for i=1,#namefile2 do
- v1= string.sub(namefile1,1,l)
- v2= string.sub(v3,i,i+l-1)
- c=c+1
- if c == 50
- then
- sleep(0)
- c= 0
- end
- if v1 == v2 and l>=min_numbersimbol
- then
- return true
- else
- return false
- end
- end
- l=l-1
- end
- end
- function easy_version_find(namefile1,namefile2,min_numbersimbol)
- if namefile1 == nil or namefile2 == nil
- then
- return
- end
- if min_numbersimbol > #namefile1
- then
- min_numbersimbol= #namefile1
- end
- if min_numbersimbol == nil
- then
- min_numbersimbol= math.floor(#namefile1/3)
- end
- l= #namefile1
- v1= ""
- v2= ""
- v3= cut(namefile2)
- c= 0
- for i=1,#namefile2 do
- v1= string.sub(namefile1,1,l)
- v2= string.sub(v3,i,i+l-1)
- c=c+1
- if c == 50
- then
- sleep(0)
- c= 0
- end
- if v1 == v2 and l>=min_numbersimbol
- then
- return true
- else
- return false
- end
- end
- end
- otvet= {}
- function findFile(name,dir_list)
- if dir_list == nil
- then
- dir_list= {''}
- end
- if name == nil or name == ' '
- then
- return
- end
- if otvet == nil
- then
- otvet= {}
- end
- now_list= {}
- v_list = {}
- count = 0
- for i=1,#dir_list do
- now_list= fs.list(dir_list[i])
- for d=1,#now_list do
- -- print(dir_list[i]..'/'..now_list[d])
- now_list[d]= dir_list[i]..'/'..now_list[d]
- if fs.isDir(now_list[d])
- then
- v_list[#v_list+1]= now_list[d]
- count=count+1
- end
- if easy_version_find(name,now_list[d],#name)
- then
- otvet[#otvet+1]= now_list[d]
- end
- end
- end
- if count == 0
- then
- return
- end
- findFile(name,v_list,otvet)
- end
- name= "vector"
- name= read()
- findFile(name,nil,nil)
- for i=1,#otvet do
- print(otvet[i])
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement