[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: existing directories





Martin Schultz wrote:

> Hi,
>
>    maybe something is blocking my mind right now, but I just can't think
> of a good (platform independent) way to test whether a directory exists
> or not. I am trying to write an 'install.pro' routine (not too fancy but
> at least with automatic backup of an old version and automatic creation
> of the target directory if not there). Actually, since I am spawning
> quite a few unix commands anyhow, a good Unix solution would be fine,
> too.

Dear Martin

is_dir will return 1 if directory exist and 0 if not. It is platfom
independent (AIX, NT tested)

; Copyright (c) 1999, Forschungszentrum Juelich GmbH ICG-1
; All rights reserved.
; Unauthorized reproduction prohibited.
; This software may be used, copied, or redistributed as long as it is not
; sold and this copyright notice is reproduced on each copy made.  This
; routine is provided as is without any express or implied warranties
; whatsoever.
;
;+
; NAME:
;       is_dir
;
; PURPOSE:
;       Test if directory exist
;
; CATEGORY:
;       PROG_TOOLS
;
; CALLING SEQUENCE:
;       Result = is_dir(path)
;
; INPUTS:
;       path: The variable to be tested.
;
; OUTPUTS:
;       This function returns 1 if directory exist else it returns 0
;
; EXAMPLE:
;       dir='C:\temp'
;       PRINT, is_dir(dir)
;       -> 1
;
; MODIFICATION HISTORY:
;       Written by:     R.Bauer , 26.01.99
;-


FUNCTION is_dir,path
   errvar=0
   CATCH,errvar
   IF errvar NE 0 THEN RETURN,0
   CD,curr=curr,path
   CD,curr
   RETURN,1

END





>
>
>    BTW: Has anyone written a routine like this before (which is
> documented)? What I have in mind (and working in a rudimentary version)
> is this:
> * create target directory if necessary
>   or copy all files in target directory into BACKUP<date> directory
> * copy all files from a masterdirectory (either by listfile or file
> mask) to target directory
>   or extract them from the RCS system (version control system).
>
> This would be a generic install routine which would come to life by
> package specific caller routines (e.g. install_gamap.pro).
>
> Thanks,
> Martin.
>

Did you thought on a self installing of an zip/exe/tar file with included
directories?
If you try this way you have to test only  if an old version was installed
previously.


Regards

R.Bauer