2008-12-10 05:42:49 +01:00
|
|
|
/*
|
2010-02-28 01:08:10 +01:00
|
|
|
* This file is a part of Winix
|
2008-12-10 05:42:49 +01:00
|
|
|
* and is not publicly distributed
|
|
|
|
*
|
2010-02-28 22:33:06 +01:00
|
|
|
* Copyright (c) 2008-2010, Tomasz Sowa
|
2008-12-10 05:42:49 +01:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2009-04-21 22:50:55 +02:00
|
|
|
#ifndef headerfilecmslucoredirs
|
|
|
|
#define headerfilecmslucoredirs
|
2008-12-10 05:42:49 +01:00
|
|
|
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
#include <map>
|
|
|
|
#include <string>
|
2009-04-21 22:50:55 +02:00
|
|
|
|
2008-12-10 05:42:49 +01:00
|
|
|
#include "item.h"
|
|
|
|
#include "dircontainer.h"
|
2010-09-18 02:51:12 +02:00
|
|
|
#include "db/db.h"
|
2010-08-10 18:12:50 +02:00
|
|
|
#include "request.h"
|
2008-12-10 05:42:49 +01:00
|
|
|
|
|
|
|
|
2009-11-17 02:04:01 +01:00
|
|
|
// we do not support '..' in a path (for simplicity and security reasons)
|
|
|
|
|
2008-12-21 22:17:09 +01:00
|
|
|
|
|
|
|
class Dirs
|
2008-12-10 05:42:49 +01:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
void Clear();
|
|
|
|
void ReadDirs();
|
2010-08-10 18:12:50 +02:00
|
|
|
|
|
|
|
void SetRequest(Request * prequest);
|
|
|
|
void SetDb(Db * pdb);
|
2008-12-30 02:05:03 +01:00
|
|
|
|
2009-11-17 02:04:01 +01:00
|
|
|
// these methods return false if there is no such a dir
|
|
|
|
bool IsDir(long dir_id);
|
2010-10-19 02:31:20 +02:00
|
|
|
bool GetDirChilds(long parent_id, std::vector<Item*> & childs_tab); // !! zamienic na GetChilds()
|
2009-11-17 02:04:01 +01:00
|
|
|
bool MakePath(long dir_id, std::string & path);
|
2010-03-15 02:47:26 +01:00
|
|
|
bool ChangeParent(long dir_id, long new_parent_id);
|
|
|
|
bool HasParent(long dir_id, long parent_id);
|
2010-03-15 18:09:45 +01:00
|
|
|
bool DelDir(long dir_id);
|
2008-12-30 02:05:03 +01:00
|
|
|
|
2010-03-15 02:47:26 +01:00
|
|
|
int AnalyzePath(const std::string & path, long & dir_id, std::string & dir, std::string & file);
|
2009-11-17 02:04:01 +01:00
|
|
|
static void SplitPath(const std::string & path, std::string & dir, std::string & file);
|
2008-12-30 02:05:03 +01:00
|
|
|
|
2010-10-19 02:31:20 +02:00
|
|
|
DirContainer::ParentIterator FindFirstParent(long parent_id); // !! zmienic w koncu nazwe na FindFirstChild
|
2010-02-16 01:37:00 +01:00
|
|
|
DirContainer::ParentIterator NextParent(DirContainer::ParentIterator i);
|
|
|
|
DirContainer::ParentIterator ParentEnd();
|
2008-12-30 02:05:03 +01:00
|
|
|
|
2010-03-15 02:47:26 +01:00
|
|
|
|
2009-11-17 02:04:01 +01:00
|
|
|
// these methods return null if there is no such a dir
|
2010-08-10 18:12:50 +02:00
|
|
|
// !! zmienic nazwy wskazujace ze operujemy tylko na lokalnej tablicy
|
2008-12-30 02:05:03 +01:00
|
|
|
Item * GetRootDir();
|
2009-11-16 00:55:11 +01:00
|
|
|
Item * GetEtcDir();
|
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
|
|
|
|
2009-02-06 14:12:03 +01:00
|
|
|
void CheckRootDir();
|
|
|
|
|
2010-08-10 18:12:50 +02:00
|
|
|
|
|
|
|
// !! jak juz wczesniejsze nazwy beda zmienione to tutaj damy AddDir()
|
2010-08-10 22:43:38 +02:00
|
|
|
Error AddDirectory(Item & item, bool add_to_dir_tab = false);
|
2009-02-06 14:12:03 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
2010-08-10 18:12:50 +02:00
|
|
|
Request * request;
|
|
|
|
Db * db;
|
|
|
|
|
2010-08-10 22:43:38 +02:00
|
|
|
DirContainer dir_tab;
|
2009-02-06 14:12:03 +01:00
|
|
|
|
2010-03-15 02:47:26 +01:00
|
|
|
size_t AnalyzeDir(Item * pdir, const std::string & path, long & dir_id, std::string & dir);
|
|
|
|
std::string analyze_temp;
|
|
|
|
|
2009-02-06 14:12:03 +01:00
|
|
|
bool ExtractName(const char * & s, std::string & name);
|
2010-08-10 18:12:50 +02:00
|
|
|
bool HasReadExecAccessForRoot(const Item & item);
|
2009-02-06 14:12:03 +01:00
|
|
|
|
2008-12-10 05:42:49 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|