#ifndef INCLUDED_ZIPCHECK_
#define INCLUDED_ZIPCHECK_

#include <iosfwd>
#include <string>
#include <vector>
#include <sstream>

#include <bobcat/coutextractor>

#include "../err/err.h"
#include "../types/types.h"
#include "../ordertxt/ordertxt.h"

    // Inspect the content of a zip
    //  - must contain metadata.txt (inspect)
    //  
class ZipCheck: private Types, private Err
{
    unsigned d_nRegularFiles;

    std::string d_dir;                          // initially: the extraction
                                                // dir, then the exercise dir
    std::string d_path;                         // current path name

    FBB::CoutExtractor d_coutExtractor;

    OrderTxt d_orderTxt;

    public:
        ZipCheck();
        bool inspect(std::string const &zipName);   // true: all OK

        Map const &orderTxtMap() const;
        using Err::error;

    private:
        void invalid(std::string const &entry);
        size_t chdir(std::string const &subDir);

                                                    // err() if no text file
        bool isTextFile(std::string const &entry);  // was: checktextfile.cc

        void exerciseDir(std::string const &dirname);
        void exerciseSubdir(std::string const &subdir);
        void cdParent(size_t pathLength);
        static bool isDotDir(std::string const &entry); // in skipdotdirs.cc
        bool inOrderTxt(std::string const &entry) const;
        void requireInOrderTxt(std::string const &entry);
        void errNotInOrderTxt(std::string const &entry);
        void inspectExerciseDir();
        void inspectExerciseSubdir();
};

inline ZipCheck::Map const &ZipCheck::orderTxtMap() const
{
    return d_orderTxt.map();
}

#endif


