print directory tree

前端 未结 10 1483
傲寒
傲寒 2020-12-03 08:45

I have to print a directory tree (like tree command), example:

 .
 +---A
 |   +---IMAGES
 |       +---BACKUP
 +---ADOKS
 |   +---ROZDZIAL_2
 |   +---ROZDZIAL         


        
10条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-03 09:19

    You need to print out "|" whenever on the corresponding level you are not processing the last entry, but one of the entries before the last. You need to know this for every level separately, so you could add a bit mask or a string (say) as an extra argument to 'getInto'.

提交回复
热议问题