FUNCTION dir2root, filename ; Description: This function takes a file name with a full directory path and ; returns the directory path without the file name. ; ; Input Parameters: ; ; filename - STRING - The full directory path and file name to be processed. ; ; Return Value: ; ; The input parameter "filename" is returned with the file name removed. For ; example, for the filename '/data/dmb/ngc7789.fits', the function would ; return the string '/data/dmb/'. ; In more detail, if the parameter "filename" is not a string, then the ; function returns an empty string ''. If the parameter "filename" does not ; contain any instances of the character '/', then the function also returns ; an empty string ''. If the parameter "filename" does not start with the ; character '/', then the function also returns an empty string ''. If the ; parameter "filename" starts with the character '/', then the function ; returns the substring in "filename" starting with the first character of ; "filename" and ending with the last instance of the character '/'. ; ; Author: Dan Bramich (dmb@ing.iac.es) ; ; History: ; ; 19/05/2008 - Module created (dmb) ;Check that "filename" is a scalar string ;If "filename" is an empty string, then return an empty string ;Decompose "filename" into individual characters ;Find the occurrences of "/" in "filename" ;If "filename" does not contain any instances of the character "/", then ;return an empty string ;If "filename" does not start with the character '/', then return an empty ;string ;If "filename" does start with the character '/', then return the substring ;in "filename" starting with the first character of "filename" and ending ;with the last instance of the character '/'.