2008-12-10 05:42:49 +01:00
|
|
|
/*
|
|
|
|
* This file is a part of CMSLU -- Content Management System like Unix
|
|
|
|
* and is not publicly distributed
|
|
|
|
*
|
|
|
|
* Copyright (c) 2008, Tomasz Sowa
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2008-12-21 22:17:09 +01:00
|
|
|
#ifndef headerfiledirs
|
|
|
|
#define headerfiledirs
|
2008-12-10 05:42:49 +01:00
|
|
|
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
#include <map>
|
|
|
|
#include <string>
|
|
|
|
#include "item.h"
|
|
|
|
#include "error.h"
|
|
|
|
#include "log.h"
|
|
|
|
#include "db.h"
|
|
|
|
#include "dircontainer.h"
|
|
|
|
|
|
|
|
|
2008-12-21 22:17:09 +01:00
|
|
|
|
|
|
|
class Dirs
|
2008-12-10 05:42:49 +01:00
|
|
|
{
|
|
|
|
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);
|
|
|
|
|
2008-12-22 17:03:03 +01:00
|
|
|
bool GetRootDir(Item ** item);
|
|
|
|
|
2008-12-10 05:42:49 +01:00
|
|
|
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);
|
|
|
|
|
2008-12-30 02:05:03 +01:00
|
|
|
//!! ta nie bedzie chyba potrzebna
|
2008-12-10 05:42:49 +01:00
|
|
|
bool GetDirChilds(long parent, std::vector<Item> & childs_table); // only returns dir-children
|
|
|
|
|
2008-12-30 02:05:03 +01:00
|
|
|
bool GetDirChilds(long parent, std::vector<Item*> & childs_table); // only returns dir-children
|
|
|
|
|
2008-12-10 05:42:49 +01:00
|
|
|
bool MakePath(long id, std::string & path);
|
|
|
|
|
|
|
|
|
|
|
|
// with an Error exception
|
|
|
|
// if the path or name are invalid these methods throw an exception
|
2008-12-30 02:05:03 +01:00
|
|
|
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();
|
2008-12-10 05:42:49 +01:00
|
|
|
Item * GetDir(const std::string & name, long parent);
|
2008-12-30 02:05:03 +01:00
|
|
|
Item * GetDir(const std::string & path);
|
|
|
|
Item * GetDir(long id);
|
|
|
|
|
2009-04-20 00:13:21 +02:00
|
|
|
Item * AddDir(const Item & item);
|
2008-12-31 19:28:12 +01:00
|
|
|
|
|
|
|
|
|
|
|
static void SplitPath(const std::string & path, std::string & dir, std::string & file);
|
2008-12-10 05:42:49 +01:00
|
|
|
|
2009-02-06 14:12:03 +01:00
|
|
|
|
|
|
|
void DeleteDir(long id);
|
|
|
|
|
|
|
|
|
|
|
|
void CheckRootDir();
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
DirContainer dir_table;
|
|
|
|
|
|
|
|
bool ExtractName(const char * & s, std::string & name);
|
|
|
|
|
|
|
|
|
2008-12-10 05:42:49 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|