Return TypeFunction nameArguments
voidhdsDirlist::Generate(hzChain&,hzHttpEvent*,unsigned int&,)

Declared in file: hzDissemino.h
Defined in file : hdsGenerate.cpp

Function Logic:

0:START 1:hzChain::AddByte x 2:x; 3:hzChain::AddByte 4:hdsApp::ConvertText rpath apath hdsApp::ConvertText crit ReadDir hzVect::Count 5:!dirents.Count() 6:pVE; 7:hdsVE::Generate 8:x 9:de hzDirent::IsDir 10:de.IsDir() 11:items 12:items 13:m_Order==1||m_Order==2 14:hzDirent::strName hzMapS::Insert 15:m_Order==3||m_Order==4 16:hzDirent::Mtime hzMapM::Insert 17:m_Order 18:m_Order==1 19:x 20:hzMapS::GetObj dirents 21:m_Order==3 22:x 23:hzMapM::GetObj dirents 24:m_Order==2 25:x 26:hzMapS::GetObj dirents 27:m_Order==4 28:x 29:hzMapM::GetObj dirents 30:hzChain::Printf hzChain::Printf hzChain::Printf hzChain::Printf items ci 31:ci.Valid(); 32:hzList::Iter::Element col hzChain::Printf 33:items 34:pE->m_Resarg 35:items ci 36:ci.Valid(); 37:hzList::Iter::Element col 38:col.m_Title==Mtime 39:items 40:col.m_Title==Type 41:items 42:col.m_Title==Size 43:items 44:col.m_Title==Name 45:hzChain::Printf 46:items 47:items x 48:x 49:de hzDirent::IsDir 50:!de.IsDir() 51:items ci 52:ci.Valid(); 53:hzList::Iter::Element col 54:col.m_Title==Mtime 55:hzDirent::Mtime hzXDate::SetByEpoch hzChain::Printf 56:col.m_Title==Type 57:items 58:col.m_Title==Size 59:hzDirent::Size FormalNumber hzChain::Printf 60:col.m_Title==Name 61:hzDirent::txtName hzDirent::txtName hzChain::Printf 62:items 63:items x 64:x 65:de hzDirent::IsDir 66:de.IsDir() 67:items ci 68:ci.Valid(); 69:hzList::Iter::Element col 70:col.m_Title==Mtime 71:hzDirent::Mtime hzXDate::SetByEpoch hzChain::Printf 72:col.m_Title==Type 73:items 74:col.m_Title==Size 75:hzDirent::Size FormalNumber hzChain::Printf 76:col.m_Title==Name 77:pE->m_Resarg 78:hzDirent::txtName hzDirent::txtName hzChain::Printf 79:hzDirent::txtName hzDirent::txtName hzChain::Printf 80:items 81:items 82:items 83: No text

Function body:

void hdsDirlist::Generate (hzChain& C, hzHttpEvent* pE, unsigned int& nLine)
{
   _hzfunc("hdsDirlist::Generate") ;
   hzMapS  <hzString,hzDirent> byName ;
   hzMapM  <uint32_t,hzDirent> byDate ;
   hzVect  <hzDirent>      dirents ;
   hzList  <hdsCol>::Iter  ci ;
   hzDirent    de ;
   hzXDate     date ;
   hdsCol      col ;
   hzAtom      atom ;
   hdsVE*      pVE ;
   hzString    apath ;
   hzString    rpath ;
   hzString    crit ;
   uint32_t    nDirs ;
   uint32_t    nFiles ;
   uint32_t    x ;
   uint32_t    y ;
   C.AddByte(CHAR_NL) ;
   for (x = m_Indent ; x ; x--)
       C.AddByte(CHAR_TAB) ;
   rpath = m_pApp->ConvertText(m_Directory, pE) ;
   apath = m_pApp->m_Docroot + rpath ;
   crit = m_pApp->ConvertText(m_Criteria, pE) ;
   ReadDir(dirents, *apath, *crit) ;
   if (!dirents.Count())
   {
       for (pVE = m_pNone ; pVE ; pVE = pVE->Sibling())
           pVE->Generate(C, pE, nLine) ;
   }
   else
   {
       for (nDirs = nFiles = x = 0; x < dirents.Count() ; x++)
       {
           de = dirents[x] ;
           if (de.IsDir())
               nDirs++ ;
           else
               nFiles++ ;
           if (m_Order == 1|| m_Order == 2)
               byName.Insert(de.strName(), de) ;
           if (m_Order == 3|| m_Order == 4)
               byDate.Insert(de.Mtime(), de) ;
       }
       if (m_Order)
       {
           if (m_Order == 1)
               for (x = 0; x < dirents.Count() ; x++)
                   dirents[x] = byName.GetObj(x) ;
           if (m_Order == 3)
               for (x = 0; x < dirents.Count() ; x++)
                   dirents[x] = byDate.GetObj(x) ;
           if (m_Order == 2)
               for (y = dirents.Count() - 1,x = 0; x < dirents.Count() ; y--, x++)
                   dirents[x] = byName.GetObj(y) ;
           if (m_Order == 4)
               for (y = dirents.Count() - 1,x = 0; x < dirents.Count() ; y--, x++)
                   dirents[x] = byDate.GetObj(y) ;
       }
       C.Printf("<table width="%d" align="center" border="0" cellspacing="0" cellpadding="0" class="%s">\n"            , m_Width, *m_CSS) ;
       C.Printf("<tr valign="top" height="20"><td>Listing %d directories and %d files</td></tr>\n"    , nDirs, nFiles) ;
       C.Printf("<tr valign="top" height="%d">\n\t<td>\n"    , m_Height) ;
       C.Printf("\t<table width="%d" align="center" border="1" cellspacing="1" cellpadding="1" class="%s">\n"            , m_Width, *m_CSS) ;
       C << "\t<tr>\n" ;
       for (ci = m_Cols ; ci.Valid() ; ci++)
       {
           col = ci.Element() ;
           C.Printf("\t<th width="%d">%s</th>\n"  , col.m_nSize, *col.m_Title) ;
       }
       C << "\t</tr>\n" ;
       if (pE->m_Resarg)
       {
           C << "\t<tr>" ;
           for (ci = m_Cols ; ci.Valid() ; ci++)
           {
               col = ci.Element() ;
               if (col.m_Title == "Mtime")
                   C << "<td>---</td>" ;
               else if (col.m_Title == "Type")
                   C << "<td>DIR</td>" ;
               else if (col.m_Title == "Size")
                   C << "<td>---</td>" ;
               else if (col.m_Title == "Name")
                   C.Printf("<td><a href="%s">Back to parent dir</a></td>"  , *m_Directory) ;
               else
                   C << "<td> </td>" ;
           }
           C << "\t</tr>\n" ;
       }
       for (x = 0; x < dirents.Count() ; x++)
       {
           de = dirents[x] ;
           if (!de.IsDir())
               continue ;
           C << "\t<tr>" ;
           for (ci = m_Cols ; ci.Valid() ; ci++)
           {
               col = ci.Element() ;
               if      (col.m_Title == "Mtime")    { date.SetByEpoch(de.Mtime()) ; C.Printf("<td>%s</td>", *date) ; }
               else if (col.m_Title == "Type")     C << "<td>DIR</td>" ;
               else if (col.m_Title == "Size")     C.Printf("<td alight="right">%s</td>"  , FormalNumber(de.Size())) ;
               else if (col.m_Title == "Name")     C.Printf("<td><a href="%s-%s"> %s</a></td>"  , *m_Directory, de.txtName(), de.txtName()) ;
               else
                   C << "<td> </td>" ;
           }
           C << "\t</tr>\n" ;
       }
       for (x = 0; x < dirents.Count() ; x++)
       {
           de = dirents[x] ;
           if (de.IsDir())
               continue ;
           C << "\t<tr>" ;
           for (ci = m_Cols ; ci.Valid() ; ci++)
           {
               col = ci.Element() ;
               if (col.m_Title == "Mtime")
                   { date.SetByEpoch(de.Mtime()) ; C.Printf("<td>%s</td>", *date) ; }
               else if (col.m_Title == "Type")
                   C << "<td>File</td>" ;
               else if (col.m_Title == "Size")
                   C.Printf("<td alight="right">%s</td>"  , FormalNumber(de.Size())) ;
               else if (col.m_Title == "Name")
               {
                   if (pE->m_Resarg)
                       C.Printf("<td><a href="/userdir/%s/%s"> %s</a></td>"  , *pE->m_Resarg, de.txtName(), de.txtName()) ;
                   else
                       C.Printf("<td><a href="/userdir/%s"> %s</a></td>"  , de.txtName(), de.txtName()) ;
               }
               else
                   C << "<td> </td>" ;
           }
           C << "\t</tr>\n" ;
       }
       C << "\t</table>\n</table>\n" ;
   }
}