winix/core/dirs.h

85 lines
2.0 KiB
C++
Executable File

/*
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2010, Tomasz Sowa
* All rights reserved.
*
*/
#ifndef headerfilecmslucoredirs
#define headerfilecmslucoredirs
#include <vector>
#include <map>
#include <string>
#include "item.h"
#include "dircontainer.h"
#include "db.h"
#include "request.h"
// we do not support '..' in a path (for simplicity and security reasons)
class Dirs
{
public:
void Clear();
void ReadDirs();
void SetRequest(Request * prequest);
void SetDb(Db * pdb);
// 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_tab);
bool MakePath(long dir_id, std::string & path);
bool ChangeParent(long dir_id, long new_parent_id);
bool HasParent(long dir_id, long parent_id);
bool DelDir(long dir_id);
int AnalyzePath(const std::string & path, long & dir_id, std::string & dir, std::string & file);
static void SplitPath(const std::string & path, std::string & dir, std::string & file);
DirContainer::ParentIterator FindFirstParent(long parent_id);
DirContainer::ParentIterator NextParent(DirContainer::ParentIterator i);
DirContainer::ParentIterator ParentEnd();
// these methods return null if there is no such a dir
// !! zmienic nazwy wskazujace ze operujemy tylko na lokalnej tablicy
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 CheckRootDir();
// !! jak juz wczesniejsze nazwy beda zmienione to tutaj damy AddDir()
Error AddDirectory(Item & item, bool add_to_dir_tab = false);
private:
Request * request;
Db * db;
DirContainer dir_tab;
size_t AnalyzeDir(Item * pdir, const std::string & path, long & dir_id, std::string & dir);
std::string analyze_temp;
bool ExtractName(const char * & s, std::string & name);
bool HasReadExecAccessForRoot(const Item & item);
};
#endif