PDA

View Full Version : Asterisk convention is possible?



mia
November 22nd, 2003, 09:48 AM
Hi there. I need to use in Girder command "file exist" partially name of file. Possible to use asterisk convention (c:\any\place*\file*.*)? Tried for this, but girder say that file not exist. TIA

Promixis
November 23rd, 2003, 12:46 PM
Here is some code I wrote to work with files. It should give you some details on how to do what you are asking.





-- Attributes
-- Win32 file attribs are
FAReadOnly = 1
FAHidden = 2
FASystem =4
FADir = 16

-- ************************************************** **************************
function FileTableMake (dir,fn,exclude,allowdirchange)
-- builds a table of subdir and files within a directory
-- dir = directory
-- fn = filename, if nil assumes *.*
-- exclude = file attribs to exclude, if nil or 0 show all
-- uses Win32 Attribs ie - hidden = 2, system = 4, directory = 16 which can or'd together
-- allowdirchange, 0 = no, 1 = up only, 2 = sub dir only, 3 = both, if nil assume 0

-- table structure
-- table.path = path
-- table [x].fn = filename
-- table [x].fa = fileattributes
-- table [x].sz = filesize

local ret,handle,fd,ft

ft ={}
fn = fn or "*.*"
exclude = exclude or bor (2,4)
exclude = bor (exclude,16) -- directories
allowdirchange = allowdirchange or 0

if strsub (dir,-1,-1) ~= "\\" then
dir = dir .. "\\"
end
ft.path = dir

-- read directories first
if allowdirchange ~= 0 then --
ret, handle, fd = FindFirstFile(dir.."*.*")
if &#40;ret<0&#41; then
return nil
end
repeat
if fd.FileAttributes == bor &#40;fd.FileAttributes,16&#41; then -- directory
if fd.Filename ~= "." then --not sure what "." is for
if fd.Filename ~= ".." or allowdirchange ~= 2 then -- no change up
if fd.Filename == ".." or allowdirchange ~= 1 then
tinsert &#40;ft, &#123;fn=fd.Filename, fa=fd.FileAttributes, sz=fd.FileSizeLow&#125;&#41;
end
end
end
end
ret, fd = FindNextFile&#40;handle&#41;
until &#40;ret == 0&#41;
FindClose&#40;handle&#41;
end

-- read file list
ret, handle, fd = FindFirstFile&#40;dir..fn&#41;
if &#40;ret<0&#41; then
return nil
end
repeat
-- print &#40;fd.Filename.. "\t\t" .. fd.FileAttributes.. "\t" ..fd.FileSizeLow..""&#41;
if band &#40;fd.FileAttributes,exclude&#41; == 0 then -- exclude
tinsert &#40;ft, &#123;fn=fd.Filename, fa=fd.FileAttributes, sz=fd.FileSizeLow&#125;&#41;
end
ret, fd = FindNextFile&#40;handle&#41;
until &#40;ret == 0&#41;
FindClose&#40;handle&#41;

return ft
end
-- ************************************************** **************************