Export the hzDirSync to a file
| Return Type | Function name | Arguments |
|---|---|---|
| hzEcode | hzFileset::Export | (const char*,) |
Declared in file: hzDirectory.h
Defined in file : hzDirectory.cpp
Function Logic:
Function body:
hzEcode hzFileset::Export (const char* filepath)
{
// Export the hzDirSync to a file
//
// Arguments: 1) filepath The 'horizon' file
//
// Returns: E_ARGUMENT If the export filename is not supplied
// E_OPENFAIL If the export file cannot be opened
// E_WRITEFAIL If the export file cannot be written to or there was a write failure
// E_OK If the export was successful
_hzfunc("hzFileset::Export()") ;
hzList<hzDirent*>::Iter I ; // Directory listing
std::ofstream os ; // For writing file
hzChain Z ; // For formulating output
hzDirent* pDX ; // Directory
hzDirent* pFX ; // File
uint32_t totSize = 0; // Total size of all files
uint32_t nD ; // Fileset directory iterator
uint32_t nF ; // Fileset file iterator
uint32_t fileLo ; // Object position of first file in the given directory
uint32_t fileHi ; // Object position of last file in the given directory
char cvLine [512]; // Working buffer
if (!filepath || !filepath[0])
return E_ARGUMENT ;
os.open(filepath) ;
if (os.fail())
return E_OPENFAIL ;
Z.Printf("# Export: %s Directories\n", FormalNumber(m_dirs.Count(),0));
Z.Printf("# Export: %s Files\n", FormalNumber(m_file.Count(),0));
os << Z ;
if (os.fail())
return E_WRITEFAIL ;
for (nD = 0; nD < m_dirs.Count() ; nD++)
{
pDX = m_dirs.GetObj(nD) ;
sprintf(cvLine, "D %010d %08x %010u %010u %010u %05d %05d %s\n",
pDX->Inode(), pDX->Mode(), pDX->Size(), pDX->Ctime(), pDX->Mtime(), pDX->Owner(), pDX->Group(), pDX->txtName()) ;
os << cvLine ;
fileLo = m_file.First(pDX->strName()) ;
if (fileLo < 0)
continue ;
fileHi = m_file.Last(pDX->strName()) ;
for (nF = fileLo ; nF <&eq; fileHi ; nF++)
// for (I = pDX->m_Kinder ; I.Valid() ; I++)
{
// pFX = I.Element() ;
pFX = m_file.GetObj(nF) ;
if (pFX->IsDir())
continue ;
totSize += pFX->Size() ;
sprintf(cvLine, "F %010d %08x %010u %010u %010u %05d %05d %s\n",
pFX->Inode(), pFX->Mode(), pFX->Size(), pFX->Ctime(), pFX->Mtime(), pFX->Owner(), pFX->Group(), pFX->txtName()) ;
os << cvLine ;
}
}
if (os.fail())
return E_WRITEFAIL ;
os << "# Export Complete - total " << FormalNumber(totSize,0)<< " bytes\n" ;
os.close() ;
return E_OK ;
}