/* * This file is a part of CMSLU -- Content Management System like Unix * and is not publicly distributed * * Copyright (c) 2008-2009, Tomasz Sowa * All rights reserved. * */ #ifndef headerfilecmslucoredirs #define headerfilecmslucoredirs #include #include #include #include "item.h" #include "dircontainer.h" class Dirs { public: void Clear(); void ReadDirs(); // without any exceptions // these methods return false in a case the path or name (with a specific parent) are invalid // we do not support '..' in a path (for security reason) bool IsDir(long id); bool GetRootDir(Item ** item); bool GetDir(const std::string & path, Item ** item); bool GetDir(const std::string & name, long parent, Item ** item); bool GetDirId(const std::string & path, long * id); bool GetDirId(const std::string & name, long parent, long * id); //!! ta nie bedzie chyba potrzebna bool GetDirChilds(long parent, std::vector & childs_table); // only returns dir-children bool GetDirChilds(long parent, std::vector & childs_table); // only returns dir-children bool MakePath(long id, std::string & path); // with an Error exception // if the path or name are invalid these methods throw an exception Item * GetDirT(const std::string & path); Item * GetDirT(const std::string & name, long parent); long GetDirIdT(const std::string & path); long GetDirIdT(const std::string & name, long parent); // !! nowy interfejs // returns null if there is no a root dir Item * GetRootDir(); Item * GetDir(const std::string & name, long parent); Item * GetDir(const std::string & path); Item * GetDir(long id); Item * AddDir(const Item & item); static void SplitPath(const std::string & path, std::string & dir, std::string & file); void DeleteDir(long id); void CheckRootDir(); private: DirContainer dir_table; bool ExtractName(const char * & s, std::string & name); }; #endif