/jEdit/tags/jedit-4-5-pre1/org/gjt/sp/jedit/bsh/commands/sourceRelative.bsh

# · Unknown · 21 lines · 18 code · 3 blank · 0 comment · 0 complexity · d1fd4a8fcb3fe557a4095234f698e276 MD5 · raw file

  1. /**
  2. Source a file relative to the callering script's directory.
  3. <p/>
  4. e.g. scripts A running in dir A sources script B in dir B.
  5. Script B can use this command to load additional scripts (data, etc.)
  6. relative to its own location (dir B) without having to explicitly know
  7. its "home" directory (B).
  8. <p/>
  9. Note: this only works for files currently.
  10. @since bsh1.3
  11. @see source( file | URL );
  12. */
  13. sourceRelative( String file )
  14. {
  15. this.dir=dirname( getSourceFileInfo() );
  16. this.path=pathToFile( dir + File.separator + file ) .getAbsolutePath();
  17. return this.interpreter.source( path, this.caller.namespace );
  18. }