#ifndef __UPDATER_REGISTRYCREATOR_H__
#define __UPDATER_REGISTRYCREATOR_H__

#include <csutil/ref.h>

struct iObjectRegistry;

namespace updater
{

    struct ZipFile
    {
        csString file;
        MD5Sum md5;
        size_t size;
    };

class Registry;

/** Class which helps creating repository description files from filesystem.
 */
class RegistryCreator
{
public:
    RegistryCreator (iObjectRegistry* objreg);
    ~RegistryCreator ();

    /** Create a rpository by looking at current directory. Each subdirectory
     * is taken as a module. And subdirs below that go as files into the
     * module.
     */
    Registry* CreateRegistry ();

    void UpdateRegistry(const char* registrypath,const char* filename);

private:
    void CreateModule (const char* name);
    void ReadSubDir (Module* files,
              const char* dirname);
    void ReadZipFile (Module* mod, const char* file, const char* path, ZipFile* zipname, int level = 0 );
    
    
    void ReadZipSubDir(Module* mod, const char* dir,ZipFile* zipname,const char* realpath, int level = 0 );
    
    void ReadZipSubDirNames(Module* mod, const char* dir,ZipFile* zipname,const char* realpath );
    
    void ReadZip (Module* mod,
                  const char* file, const char* path);

    void Sort(const char* path,Module* mod, RegistryFile* regfile);
    
    iObjectRegistry* objreg;
    Registry* registry;
};

} // end of namespace updater

#endif

