81 lines
1.6 KiB
C++
Executable File
81 lines
1.6 KiB
C++
Executable File
/*
|
|
* 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.
|
|
*
|
|
*/
|
|
|
|
#ifndef headerfiledir
|
|
#define headerfiledir
|
|
|
|
|
|
#include <vector>
|
|
#include <map>
|
|
#include <string>
|
|
#include "item.h"
|
|
#include "error.h"
|
|
#include "log.h"
|
|
#include "db.h"
|
|
#include "dircontainer.h"
|
|
|
|
|
|
class Dir
|
|
{
|
|
|
|
private:
|
|
public: // !! temporarily
|
|
|
|
|
|
// id = -1;
|
|
Item root;
|
|
|
|
|
|
DirContainer dir_table;
|
|
|
|
|
|
// parent (or -1), item
|
|
//typedef std::multimap<long, Item> DirTable;
|
|
//DirTable dir_table;
|
|
|
|
|
|
bool ExtractName(const char * & s, std::string & name);
|
|
|
|
|
|
|
|
|
|
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 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);
|
|
|
|
bool GetDirChilds(long parent, std::vector<Item> & 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 * GetDir(const std::string & path);
|
|
Item * GetDir(const std::string & name, long parent);
|
|
long GetDirId(const std::string & path);
|
|
long GetDirId(const std::string & name, long parent);
|
|
|
|
};
|
|
|
|
|
|
#endif
|