private void checkAttributues(VsphereConnHandler connHandler)
      throws IOException, FileFaultFaultMsg, GuestOperationsFaultFaultMsg, InvalidStateFaultMsg,
          RuntimeFaultFaultMsg, TaskInProgressFaultMsg, InvalidPropertyFaultMsg {

    ManagedObjectReference fileManager = getFileManager(connHandler);
    GuestListFileInfo res = null;
    try {
      res =
          connHandler
              .getClient()
              .getVimPort()
              .listFilesInGuest(fileManager, vm, credentials, getPathInVm(), null, null, null);
    } catch (SOAPFaultException e) {
      if (isFileNotFound(e)) {
        return;
      }
      throw e;
    }
    if (res.getFiles().size() == 1) {
      // only one result - it's a file
      GuestFileInfo guestFileInfo = res.getFiles().get(0);

      updateAttributes(guestFileInfo);
    } else {
      // more than one result - it's a directory.
      // find the entry for "."
      for (GuestFileInfo f : res.getFiles()) {
        if (f.getPath().equals(".")) {
          updateAttributes(f);
          break;
        }
      }
    }
  }
  @Override
  public AbstractFile[] ls() throws IOException, UnsupportedFileOperationException {
    List<GuestFileInfo> fileInfos = new ArrayList<GuestFileInfo>();
    int index = 0;
    VsphereConnHandler connHandler = null;
    try {

      connHandler = getConnHandler();

      ManagedObjectReference fileManager = getFileManager(connHandler);
      boolean haveRemaining;
      do {
        GuestListFileInfo res =
            connHandler
                .getClient()
                .getVimPort()
                .listFilesInGuest(fileManager, vm, credentials, getPathInVm(), index, null, null);
        haveRemaining = (res.getRemaining() != 0);

        fileInfos.addAll(res.getFiles());
        index = fileInfos.size();
      } while (haveRemaining);

      String parentPath = PathUtils.removeTrailingSeparator(fileURL.getPath()) + SEPARATOR;

      Collection<AbstractFile> res = new ArrayList<AbstractFile>();
      for (GuestFileInfo f : fileInfos) {
        final String name = getFileName(f.getPath());
        if (name.equals(".") || name.equals("..")) {
          continue;
        }

        FileURL childURL = (FileURL) fileURL.clone();
        childURL.setPath(parentPath + name);

        AbstractFile newFile = new VSphereFile(childURL, this, f);
        res.add(newFile);
      }
      return res.toArray(new AbstractFile[0]);
    } catch (FileFaultFaultMsg e) {
      translateandLogException(e);
    } catch (GuestOperationsFaultFaultMsg e) {
      translateandLogException(e);
    } catch (InvalidStateFaultMsg e) {
      translateandLogException(e);
    } catch (RuntimeFaultFaultMsg e) {
      translateandLogException(e);
    } catch (TaskInProgressFaultMsg e) {
      translateandLogException(e);
    } catch (InvalidPropertyFaultMsg e) {
      translateandLogException(e);
    } catch (URISyntaxException e) {
      translateandLogException(e);
    } finally {
      releaseConnHandler(connHandler);
    }
    // we never get here..
    return null;
  }