01: /* jcifs smb client library in Java
02: * Copyright (C) 2003 "Michael B. Allen" <jcifs at samba dot org>
03: *
04: * This library is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License as published by the Free Software Foundation; either
07: * version 2.1 of the License, or (at your option) any later version.
08: *
09: * This library is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12: * Lesser General Public License for more details.
13: *
14: * You should have received a copy of the GNU Lesser General Public
15: * License along with this library; if not, write to the Free Software
16: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17: */
18:
19: package jcifs.smb;
20:
21: public class DosFileFilter implements SmbFileFilter {
22:
23: protected String wildcard;
24: protected int attributes;
25:
26: /* This filter can be considerably more efficient than other file filters
27: * as the specifed wildcard and attributes are passed to the server for
28: * filtering there.
29: */
30: public DosFileFilter(String wildcard, int attributes) {
31: this .wildcard = wildcard;
32: this .attributes = attributes;
33: }
34:
35: /* This returns true if the file's attributes contain any of the attributes
36: * specified for this filter. The wildcard has no influence on this
37: * method as the server should have performed that filtering already. The
38: * attributes are asserted here only because server file systems may not
39: * support filtering by all attributes (e.g. even though ATTR_DIRECTORY was
40: * specified the server may still return objects that are not directories).
41: */
42: public boolean accept(SmbFile file) throws SmbException {
43: return (file.getAttributes() & attributes) != 0;
44: }
45: }
|