copytree.bmx 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. SuperStrict
  2. Framework BRL.FileSystem
  3. Import BRL.StandardIO
  4. Import "timestamp.c"
  5. Extern
  6. Function timestamp(fromFile$z, toFile$z)
  7. End Extern
  8. Local fromBase:String = "/PATH/TO/boost_1_80_0/boost/"
  9. Local toBase:String = "/PATH/TO/boost.mod/core.mod/src/boost/"
  10. processDir(fromBase, toBase)
  11. Function processDir(fromBase:String, toBase:String, indent:Int = 0)
  12. Local fromDir:Byte Ptr = ReadDir(fromBase)
  13. If fromDir Then
  14. Local ind:String = ""
  15. For Local i:Int = 0 Until indent
  16. ind:+ " "
  17. Next
  18. Print ind + "Processing dir : " + fromBase
  19. Local file:String = NextFile(fromDir)
  20. While file
  21. If Not file.StartsWith(".") Then
  22. Local fromFile:String = fromBase + file
  23. Select FileType(fromFile)
  24. Case FILETYPE_FILE
  25. Local toFile:String = toBase + file
  26. Print ind + "Copying : " + file + " --> " + toFile
  27. CopyFile(fromFile, toFile)
  28. timestamp(fromFile, toFile)
  29. Case FILETYPE_DIR
  30. Local toDir:String = toBase + file
  31. If Not FileType(toDir) Then
  32. ' create folder
  33. Print ind + "** Creating : " + toDir
  34. CreateDir(toDir)
  35. End If
  36. processDir(fromBase + file + "/", toDir + "/", indent + 2)
  37. End Select
  38. End If
  39. file = NextFile(fromDir)
  40. Wend
  41. CloseDir(fromDir)
  42. EndIf
  43. End Function