;+
; NAME:
;	dirpath
;
; PURPOSE:
;	Converts input into a directory with a delimiter on the end.
;	Takes OS differences into account.
;
; CATEGORY:
;	System File Utility
;
; CALLING SEQUENCE:
; 
;	Result = DIRPATH(Rootdir, Subdirs)
;
; INPUTS:
;	Rootdir:	The first portion of the directory structure
;
; OPTIONAL INPUTS:
;	Subdirs	STRARR	List of subdirectories to add to rootdir 
;	
; KEYWORD PARAMETERS:
;	None
;
; OUTPUTS:
;	Returns directory with correct delimiters.
;
; PROCEDURE:
;	Uses !DELIMITER if defined, else uses GET_DELIM()
;
; EXAMPLE:
;	dir = DIRPATH(getenv('NRL_LIB'),['idl','expfac']) returns
;	DIR	STRING = '/net/cronus/opt/local/idl_nrl_lib/idl/expfac/'
;	for OS Solaris (UNIX)
;
; MODIFICATION HISTORY:
; 	Written by:	N. Rich, 01/12/17, NRL
;
;	@(#)dirpath.pro	1.1, 12/17/01 LASCO IDL LIBRARY
;-

function dirpath, rootdir, subdirs

IF DATATYPE(!delimiter) EQ 'STR' THEN dlm = !delimiter ELSE dlm = get_delim()

outdir = rootdir
sz = size(subdirs)
IF sz[0] GT 0 THEN FOR i=0,sz[1]-1 DO outdir = outdir+dlm+subdirs[i]
outdir = outdir +dlm

return, outdir

end

