public FileStatus getFileStatus(Path path) {
   path = path.makeQualified(this);
   String pathnameAsDir = path.toString() + "/";
   for(MockFile file: files) {
     if (file.path.equals(path)) {
       return createStatus(file);
     } else if (file.path.toString().startsWith(pathnameAsDir)) {
       return createDirectory(path);
     }
   }
   throw new FileNotFoundException("File " + path + " does not exist");
 }
 public FileStatus[] listStatus(Path path) {
   path = path.makeQualified(this);
   List<FileStatus> result = new ArrayList<FileStatus>();
   String pathname = path.toString();
   String pathnameAsDir = pathname + "/";
   Set<String> dirs = new TreeSet<String>();
   for(MockFile file: files) {
     String filename = file.path.toString();
     if (pathname.equals(filename)) {
       return new FileStatus[]{createStatus(file)};
     } else if (filename.startsWith(pathnameAsDir)) {
       String tail = filename.substring(pathnameAsDir.length());
       int nextSlash = tail.indexOf('/');
       if (nextSlash > 0) {
         dirs.add(tail.substring(0, nextSlash));
       } else {
         result.add(createStatus(file));
       }
     }
   }
   // for each directory add it once
   for(String dir: dirs) {
     result.add(createDirectory(new MockPath(this, pathnameAsDir + dir)));
   }
   return result.toArray(new FileStatus[result.size()]);
 }