internal virtual void DoShareEnum(List<object> list, bool files, string wildcard, int
searchAttributes, ISmbFilenameFilter fnf, ISmbFileFilter ff)
{
string p = Url.AbsolutePath;
IOException last = null;
IFileEntry[] entries;
UniAddress addr;
IFileEntry e;
Hashtable map;
if (p.LastIndexOf('/') != (p.Length - 1))
{
throw new SmbException(Url + " directory must end with '/'");
}
if (GetType() != TypeServer)
{
throw new SmbException("The requested list operations is invalid: " + Url);
}
map = new Hashtable();
if (_enableDfs && Dfs.IsTrustedDomain(GetServer(), Auth))
{
try
{
entries = DoDfsRootEnum();
for (int ei = 0; ei < entries.Length; ei++)
{
e = entries[ei];
if (map.ContainsKey(e) == false)
{
map.Put(e, e);
}
}
}
catch (IOException ioe)
{
if (Log.Level >= 4)
{
Runtime.PrintStackTrace(ioe, Log);
}
}
}
addr = GetFirstAddress();
while (addr != null)
{
try
{
last = null;
DoConnect();
try
{
entries = DoMsrpcShareEnum();
}
catch (IOException ioe)
{
if (Log.Level >= 3)
{
Runtime.PrintStackTrace(ioe, Log);
}
entries = DoNetShareEnum();
}
for (int ei = 0; ei < entries.Length; ei++)
{
e = entries[ei];
if (map.ContainsKey(e) == false)
{
map.Put(e, e);
}
}
break;
}
catch (IOException ioe)
{
if (Log.Level >= 3)
{
Runtime.PrintStackTrace(ioe, Log);
}
last = ioe;
if (!(ioe is SmbAuthException))
{
RemoveCurrentAddress();
addr = GetNextAddress();
}
else
{
break;
}
}
}
if (last != null && map.Count == 0)
{
if (last is SmbException == false)
{
throw new SmbException(Url.ToString(), last);
}
throw (SmbException)last;
}
//Iterator iter = map.Keys.Iterator();
//while (iter.HasNext())
foreach (var item in map.Keys)
{
e = (IFileEntry)item;
string name = e.GetName();
if (fnf != null && fnf.Accept(this, name) == false)
{
continue;
}
if (name.Length > 0)
{
// if !files we don't need to create SmbFiles here
SmbFile f = new SmbFile(this, name, e.GetType(), AttrReadonly
| AttrDirectory, 0L, 0L, 0L);
if (ff != null && ff.Accept(f) == false)
{
continue;
}
if (files)
{
list.Add(f);
}
else
{
list.Add(name);
}
}
}
}