scripting@wanadoo.nl




MakePath()

http://www.scriptlogic.com/kixtart/FunctionLibrary_FunctionList.aspx


actual FunctionLibrary list on 'Scriptlogic' site printer-friendly mirror of UDF topic on 'scripting@wanadoo.nl' site close
12 July 2002 MakePath()
AuthorScriptLogic Corporation
Action Creates a multi-level directory structure on a local or remote system.
SyntaxMakePath ( "path" ) 
Parameters
  • path (Required / String) A string representing the directory path structure to create. 
  • RemarksNative alternative to using a freeware utility such as MMD.exe.
    Updated 7-12-2002, based on feedback from Mark Hinsch -- becuase the original version of this UDF had a dependency on the Join UDF, which is now part of KiX 4.10. 
    Returns 0 = Path created,
    -1 = Invalid Path,
    Error Code = Function Failed. 
    DependenciesJoin() 
    Examples
    $path = "\\server\share\dir1\dir2\dir3"
    IF NOT exist($path)
      $rc = MakePath($path)
      IF $rc = 0
        ? "Path created"
      ENDIF
    ENDIF
    
     
    Source
    FUNCTION MakePath ($path)
      ; Creates all the directories in a path.
      ; Returns 0 for success or error number / errorlevel
      DIM $sdirs,$imaxdirs,$istartdir,$i,$srpath
      $makepath=-1
      $sdirs=Split($path,'\')
      $imaxdirs=UBound($sdirs)
      IF Left($path,2)='\\'
        IF $imaxdirs < 4
          EXIT -1
        ELSE
          $srpath='\\'+$sdirs[2]+'\'+$sdirs[3]
          $istartdir=4
        ENDIF
      ELSE
        $srpath=$sdirs[0]
        $istartdir=1
      ENDIF
      IF ($imaxdirs < $istartdir) OR ($imaxdirs = $istartdir AND $sdirs[$imaxdirs] = '')
        EXIT -1
      ELSE
        FOR $i = $istartdir TO $imaxdirs
          $srpath=$srpath+'\'+$sdirs[$i]
          IF NOT Exist($srpath)
            MD "$sRPath"
            IF @error
              $makepath=@error
              EXIT $makepath
            ENDIF
          ENDIF
        NEXT
      ENDIF
      $makepath=0
    ENDFUNCTION ; - MakePath -
     
      original source of UDF topic. show actual FunctionLibrary list on Scriptlogic site close top
              printer-friendly mirror of UDF topic on scripting@wanadoo.nl site  




    Copyright © 2003 www.scriptlogic.com & scripting@wanadoo.nl - last updated on 20 May 2003


    Site Meter