code: public static Resource createFromRoot(File rootFile)
    {
      File root = rootFile;
      String path = "/";
  
      if(!root.isDirectory())
      {
        root = rootFile.getParentFile();
        path = rootFile.getName();
      }
  
      return create(root, path);
    }
docs: Creates a file resource from a file, with the root as this file (if it is a directory
  otherwise its parent).
  
  @param rootFile the root file
  @return the resource (points to this file)