Return Type | Function name | Arguments |
---|---|---|
void | hdsDirlist::Generate | (hzChain&,hzHttpEvent*,unsigned int&,) |
Declared in file: hzDissemino.h
Defined in file : hdsGenerate.cpp
Function Logic:
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" ; } }