@@ -69,6 +69,7 @@ struct dir_tree {
6969 void load_from_memfile (const std::vector<enum_folder_t > &);
7070 DIR_NODE *match (const char *path);
7171 static DIR_NODE *get_child (DIR_NODE *);
72+ bool has_children (DIR_NODE *x) const { return get_child (x) != nullptr ; }
7273
7374 SIMPLE_TREE stree{};
7475};
@@ -1620,7 +1621,7 @@ int icp_delete(int argc, char **argv, imap_context &ctx)
16201621 auto dh = folder_tree.match (argv[2 ]);
16211622 if (dh == nullptr )
16221623 return 1925 ;
1623- if (folder_tree.get_child (dh) != nullptr )
1624+ if (folder_tree.has_children (dh))
16241625 return 1924 ;
16251626 }
16261627
@@ -1762,7 +1763,7 @@ int icp_list(int argc, char **argv, imap_context &ctx) try
17621763 if (!icp_wildcard_match (sys_name.c_str (), search_pattern.c_str ()))
17631764 continue ;
17641765 auto pdir = folder_tree.match (sys_name.c_str ());
1765- auto have_cld = pdir != nullptr && folder_tree.get_child (pdir) != nullptr ;
1766+ auto have_cld = pdir != nullptr && folder_tree.has_children (pdir);
17661767 auto buf = fmt::format (" * LIST (\\ Has{}Children{}{}) \" /\" {}\r\n " ,
17671768 have_cld ? " " : " No" ,
17681769 return_special && special != nullptr ? " " : " " ,
@@ -1815,7 +1816,7 @@ int icp_xlist(int argc, char **argv, imap_context &ctx) try
18151816 continue ;
18161817 auto special = special_folder (fentry.first );
18171818 auto pdir = folder_tree.match (sys_name.c_str ());
1818- auto have = pdir != nullptr && folder_tree.get_child (pdir) != nullptr ;
1819+ auto have = pdir != nullptr && folder_tree.has_children (pdir);
18191820 auto buf = fmt::format (" * XLIST (\\ Has{}Children{}{}) \" /\" {}\r\n " ,
18201821 have ? " " : " No" ,
18211822 special != nullptr ? " " : " " ,
@@ -1879,7 +1880,7 @@ int icp_lsub(int argc, char **argv, imap_context &ctx) try
18791880 if (!icp_wildcard_match (sys_name.c_str (), search_pattern.c_str ()))
18801881 continue ;
18811882 auto pdir = folder_tree.match (sys_name.c_str ());
1882- auto have = pdir != nullptr && folder_tree.get_child (pdir) != nullptr ;
1883+ auto have = pdir != nullptr && folder_tree.has_children (pdir);
18831884 auto buf = fmt::format (" * LSUB (\\ Has{}Children) \" /\" {}\r\n " ,
18841885 have ? " " : " No" , quote_encode (sys_name));
18851886 if (pcontext->stream .write (buf.c_str (), buf.size ()) != STREAM_WRITE_OK)
0 commit comments