FileInfo
Zac Elston
zelston at aol.com
Fri Feb 6 15:45:27 EST 2004
found a bug in the fileinfo function that was posted here a while back.
the previous version was
function FileInfo pPath
local tFile, tSaveDir, tFiles, tFileInfo
set the itemdel to "/"
put urlEncode(last item of pPath) into tFile
delete last item of pPath
put the directory into tSaveDir
set the directory to pPath
put the detailed files into tFiles
set the directory to tSaveDir
get lineoffset(tFile, tFiles)
if it > 0 then
return line it of tFiles
end if
end FileInfo
on
get lineoffset(tFile, tFiles)
a match will occur for files that are named with the same begining.
so looking for the details of file.txt
would match on the first occurance of file.txt , including file.txt.v1
in my case, i'm scrapping webservers logs that are rotated nightly.
so looking for access_log would match on access_log.$date
while it's rare that this would occur for most others, the function only
matches on a substring not the entire filename
so I just did an item search. anyone got a beter method?
function FileInfo pPath
--set the wholeMatches to true
--that didn't help
local tFile, tSaveDir, tFiles, tFileInfo
set the itemdel to "/"
put urlEncode(last item of pPath) into tFile
delete last item of pPath
put the directory into tSaveDir
set the directory to pPath
put the detailed files into tFiles
set the directory to tSaveDir
set the itemdel to ","
repeat with x = 1 to the number of lines in tFiles
if item 1 of line x of tFiles = tFile
then
return line x of tFiles
end if
end repeat
end FileInfo
-zac
More information about the use-livecode
mailing list