walker.h
author Stiletto <blasux@blasux.ru>
Sat, 12 Feb 2011 13:45:55 +0300
changeset 0 56281d90869c
permissions -rw-r--r--
Initial commit
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
56281d90869c Initial commit
Stiletto <blasux@blasux.ru>
parents:
diff changeset
     1
#ifndef _WALKER_H_INCLUDED_
56281d90869c Initial commit
Stiletto <blasux@blasux.ru>
parents:
diff changeset
     2
#define _WALKER_H_INCLUDED_
56281d90869c Initial commit
Stiletto <blasux@blasux.ru>
parents:
diff changeset
     3
#include <string>
56281d90869c Initial commit
Stiletto <blasux@blasux.ru>
parents:
diff changeset
     4
#include <magic.h>
56281d90869c Initial commit
Stiletto <blasux@blasux.ru>
parents:
diff changeset
     5
56281d90869c Initial commit
Stiletto <blasux@blasux.ru>
parents:
diff changeset
     6
class MagicWalker {
56281d90869c Initial commit
Stiletto <blasux@blasux.ru>
parents:
diff changeset
     7
    
56281d90869c Initial commit
Stiletto <blasux@blasux.ru>
parents:
diff changeset
     8
    public:
56281d90869c Initial commit
Stiletto <blasux@blasux.ru>
parents:
diff changeset
     9
        std::string root;
56281d90869c Initial commit
Stiletto <blasux@blasux.ru>
parents:
diff changeset
    10
        MagicWalker(const std::string root);
56281d90869c Initial commit
Stiletto <blasux@blasux.ru>
parents:
diff changeset
    11
        ~MagicWalker ();
56281d90869c Initial commit
Stiletto <blasux@blasux.ru>
parents:
diff changeset
    12
        void Run() { HandleDir(root.c_str()); }
56281d90869c Initial commit
Stiletto <blasux@blasux.ru>
parents:
diff changeset
    13
    protected:
56281d90869c Initial commit
Stiletto <blasux@blasux.ru>
parents:
diff changeset
    14
        virtual int HandleFile(const char *filename);
56281d90869c Initial commit
Stiletto <blasux@blasux.ru>
parents:
diff changeset
    15
        virtual int HandleDir(const char *dirname);
56281d90869c Initial commit
Stiletto <blasux@blasux.ru>
parents:
diff changeset
    16
        const char *GetFileMagic(const char *filename);
56281d90869c Initial commit
Stiletto <blasux@blasux.ru>
parents:
diff changeset
    17
        magic_t magic;
56281d90869c Initial commit
Stiletto <blasux@blasux.ru>
parents:
diff changeset
    18
};
56281d90869c Initial commit
Stiletto <blasux@blasux.ru>
parents:
diff changeset
    19
56281d90869c Initial commit
Stiletto <blasux@blasux.ru>
parents:
diff changeset
    20
#endif