Ctreectl Creating a directory tree

Source: Internet
Author: User

Root directory file:

M_strrootpath.format (_t ("%ssyswsp"), __main_home__);

M_strrootpath is the root directory file path.

Example: WINDOWS\\:RELEASE\\:SYSWSP


Browerfile (0, M_strrootpath);

1 voidUmsdirectorytree::browerfile (LongCallnum, CString strfiles)2 {3callnum++;4 CFileFind Ffinder;5Strfiles + = _t ("\\*.*");6 7BOOL res =Ffinder.findfile (strfiles);8      while(RES)9     {Tenres =ffinder.findnextfile (); One         if(Ffinder.isdirectory () &&!ffinder.isdots ()) A         { -CString Strfilespath =Ffinder.getfilepath (); -CString Strfilesname =ffinder.getfilename (); the             intpos = Strfilesname.find (_t ("@"),0); -M_strselectnode = Strfilesname.mid (pos+1); -             Switch(Callnum) -             { +              Case 1: -M_strhtfir = M_tree.insertitem (m_strselectnode.getstring (),0,0, NULL); +                  Break; A              Case 2: atM_strhtsec = M_tree.insertitem (m_strselectnode.getstring (),0,0, M_strhtfir); -                  Break; -              Case 3: -M_strhtthr = M_tree.insertitem (m_strselectnode.getstring (),0,0, m_strhtsec); -                  Break; -              Case 4: inM_strhtfou = M_tree.insertitem (m_strselectnode.getstring (),0,0, m_strhtthr); -                  Break; to              Case 5: +M_strhtfif = M_tree.insertitem (m_strselectnode.getstring (),0,0, M_strhtfou); -                  Break; the             default: *M_strhtsix = M_tree.insertitem (m_strselectnode.getstring (),0,0, M_strhtfir); $                  Break;Panax Notoginseng             } - browerfile (Callnum, strfilespath); the         } +         Else if(!ffinder.isdirectory () &&!ffinder.isdots ()) A         { the CString Strwsppath; +Strwsppath =Ffinder.getfilepath (); -CString Strwspname =ffinder.getfilename (); $             intpos = Strwspname.find ((_t ("@")),0); $Strwspname = Strwspname.mid (pos+1); -pos = Strwspname.find (_t ("."),0); -M_strselectnode =Strwspname.left (POS); the  -             Switch(Callnum)Wuyi             { the              Case 1: -M_strhtroot = M_tree.insertitem (m_strselectnode.getstring (),0,0, NULL); Wu                  Break; -              Case 2: AboutM_strhtend = M_tree.insertitem (m_strselectnode.getstring (),0,0, M_strhtfir); $                  Break; -              Case 3: -M_strhtend = M_tree.insertitem (m_strselectnode.getstring (),0,0, m_strhtsec); -                  Break; A              Case 4: +M_strhtend = M_tree.insertitem (m_strselectnode.getstring (),0,0, m_strhtthr); the                  Break; -              Case 5: $M_strhtend = M_tree.insertitem (m_strselectnode.getstring (),0,0, M_strhtfou); the                  Break; the             default: theM_strhtsix = M_tree.insertitem (m_strselectnode.getstring (),0,0, m_strhtfif); the                  Break; -             } in         } the     } the ffinder.close (); About}


Findnextfiles () is primarily responsible for finding subdirectories in each level of the node directory, whose return value is not 0, indicates that there are subdirectories and the return value is 0, indicating that the level directory already has no subdirectories.

All subdirectories in the level directory are traversed through the while () loop.

The while () loop body iterates through the next level of directory through a recursive call and inserts all directories at the next level through the switch branch structure into the previous node directory, so that the loop-recursive call will generate the tree.

Ctreectl Creating a directory tree

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.