Load all passive HTML files found in the document root (recurses to sub-dirs) Arguments: None
| Return Type | Function name | Arguments |
|---|---|---|
| hzEcode | hdsApp::LoadPassives | (void) |
Declared in file: hzDissemino.h
Defined in file : hdsConfig.cpp
Function Logic:
Function body:
hzEcode hdsApp::LoadPassives (void)
{
// Category: Page and Article Config Read Functions
//
// Load all passive HTML files found in the document root (recurses to sub-dirs)
//
// Arguments: None
//
// Returns: E_CONFIG If there is a syntax error
// E_OK If no errors occured
_hzfunc("hdsApp::loadPassives") ;
hzList<hzPair>::Iter lp ; // Passives iterator
hzVect <hzString> dirs ; // Needed for ListDir call
hzArray <hzString> files ; // Passive files matching the criteria
ifstream is ; // For reading in file
const char* i ; // Filename with/without leading slash
hdsFile* pFile ; // Passive file
hzChain Z ; // For storing file content
hzPair p ; // File criteria and HTML type
hzString S ; // Current criteria
hzString path ; // Current path
hzString fpath ; // Current full path (docroot + path)
uint32_t n ; // File iterator
hzEcode rc ; // Return code
for (lp = m_Passives ; lp.Valid() ; lp++)
{
p = lp.Element() ;
i = *p.name ;
if (*i == CHAR_FWSLASH)
i++ ;
rc = FindfilesStd(files, i) ;
if (rc == E_NOTFOUND)
{
m_pLog->Log("WARNING: file garner: Cannot find files matching %s\n", *p.name) ;
continue ;
}
if (rc != E_OK)
{
m_pLog->Log("ERROR in file garner: Cannot utilize [%s], error=%s\n", *S, Err2Txt(rc)) ;
break ;
}
for (n = 0; n < files.Count() ; n++)
{
S = files[n] ;
is.open(*S) ;
if (is.fail())
{ m_pLog->Log("WARNING: file %s cannot be opened\n", *p.name) ; continue ; }
Z << is ;
is.close() ;
is.clear() ;
if (memcmp(*S, *m_Docroot, m_Docroot.Length()))
m_pLog->Log("Please check basis for file [%s]\n", *p.name) ;
else
{
pFile = new hdsFile() ;
pFile->m_filepath = p.name ;
pFile->m_Mimetype = Str2Mimetype(p.value) ;
pFile->m_rawValue = Z ;
if (pFile->m_Mimetype == HMTYPE_TXT_HTML)
Gzip(pFile->m_zipValue, Z) ;
m_ResourcesPath.Insert(pFile->m_filepath, pFile) ;
m_pLog->Log("Added passive file %s (%d,%d)\n", *pFile->m_filepath, pFile->m_rawValue.Size(), pFile->m_zipValue.Size()) ;
}
Z.Clear() ;
}
}
return rc ;
}