1   /*
2    * $Id: Directory.java 7963 2007-08-21 08:53:15Z dirk.olmes $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.providers.ftp.server;
12  
13  import java.util.Collection;
14  import java.util.Iterator;
15  
16  import org.apache.ftpserver.ftplet.FileObject;
17  
18  public class Directory extends Named
19  {
20  
21      public Directory(String name, ServerState state)
22      {
23          super(name, state);
24      }
25  
26      public boolean isDirectory()
27      {
28          return true;
29      }
30  
31      public boolean isFile()
32      {
33          return false;
34      }
35  
36      public FileObject[] listFiles()
37      {
38          logger.debug("list files");
39          Collection available = getState().getDownloadNames();
40          FileObject[] files = new FileObject[available.size()];
41          int index = 0;
42          for (Iterator names = available.iterator(); names.hasNext();)
43          {
44              String name = (String) names.next();
45              if (logger.isDebugEnabled())
46              {
47                  logger.debug("file available: " + name);
48              }
49              files[index++] = new DownloadFile(name, getState());
50          }
51          return files;
52      }
53  
54  }