64 lines
1.2 KiB
C++
Executable File
64 lines
1.2 KiB
C++
Executable File
/*
|
|
* 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 <vector>
|
|
#include <map>
|
|
#include <string>
|
|
|
|
#include "item.h"
|
|
#include "dircontainer.h"
|
|
|
|
|
|
// we do not support '..' in a path (for simplicity and security reasons)
|
|
|
|
|
|
class Dirs
|
|
{
|
|
public:
|
|
|
|
void Clear();
|
|
void ReadDirs();
|
|
|
|
|
|
// these methods return false if there is no such a dir
|
|
bool IsDir(long dir_id);
|
|
bool GetDirChilds(long parent_id, std::vector<Item*> & childs_table);
|
|
bool MakePath(long dir_id, std::string & path);
|
|
|
|
static void SplitPath(const std::string & path, std::string & dir, std::string & file);
|
|
|
|
|
|
// these methods return null if there is no such a dir
|
|
Item * GetRootDir();
|
|
Item * GetEtcDir();
|
|
Item * GetDir(const std::string & name, long parent);
|
|
Item * GetDir(const std::string & path);
|
|
Item * GetDir(long id);
|
|
Item * AddDir(const Item & item);
|
|
|
|
void DeleteDir(long id);
|
|
void CheckRootDir();
|
|
|
|
|
|
private:
|
|
|
|
DirContainer dir_table;
|
|
|
|
bool ExtractName(const char * & s, std::string & name);
|
|
|
|
|
|
};
|
|
|
|
|
|
#endif
|