` Printed Icetips Article

Icetips Article



Par2: Create (deep) directories
2003-02-04 -- Jeff Slarve
 
Here's something that I use.

!==============================================
DeepMkDir            PROCEDURE  (String pPath)!,Byte 
!==============================================
!Copyright 2000 c Jeff Slarve
MakePath  CString(File:MaxFilePath)
Ndx1      Long
Ndx2      Long
PathLen   Long
SavePath  CString(File:MaxFilePath)
ReturnVal Byte
  CODE
  ReturnVal = 0
  PathLen  = Len(Clip(pPath))
  SavePath = LongPath()
  SetPath(pPath)
  If ErrorCode()
    If pPath[1:2] = '\\' !UNC
      Ndx2 = 3
      Ndx2 = Instring('\', pPath,1,Ndx2)
      Ndx2 = Instring('\', pPath,1,Ndx2+1)
    else
      Ndx2 = 1
    end
    Loop
      Ndx1 = Instring('\', pPath, 1, Ndx2)
      If NOT Ndx1
        If Ndx2 <= PathLen
          Ndx1 = PathLen
          Ndx2 = Ndx1
        else
          Break
        end
      end
      MakePath = pPath[1:Ndx1]
      SetPath(MakePath)
      If ErrorCode()
        If MkDir(MakePath)
          ReturnVal = True
          Message('Error creating: ' & |
             MakePath,'Error!',Icon:Exclamation)
          Break
        end
      end
      Ndx2 = Ndx1 + 1
    end
  end
  SetPath(SavePath)
  Return ReturnVal



Printed May 4, 2024, 9:51 pm
This article has been viewed/printed 35108 times.