fixed: the core didn't test for special folder when system was running
(now mkdir addes correctly special folders)
added: function 'reload'
param: 'templates' - reloading templates
git-svn-id: svn://ttmath.org/publicrep/cmslu/trunk@519 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
@@ -11,6 +11,9 @@
|
||||
#include "log.h"
|
||||
|
||||
|
||||
std::string DirContainer::dir_etc = "etc";
|
||||
|
||||
|
||||
DirContainer::DirContainer()
|
||||
{
|
||||
is_root = false;
|
||||
@@ -62,10 +65,9 @@ bool DirContainer::Empty()
|
||||
|
||||
// looking for '/etc'
|
||||
// 'root' is found beforehand
|
||||
// CheckSpecialFolder() may not find everything (when the first is a special folder and then the root)
|
||||
void DirContainer::FindSpecialFolders()
|
||||
{
|
||||
static std::string etc = "etc";
|
||||
|
||||
is_etc = false;
|
||||
|
||||
if( !is_root )
|
||||
@@ -75,7 +77,7 @@ static std::string etc = "etc";
|
||||
|
||||
for( ; i!=ParentEnd() ; i = NextParent(i) )
|
||||
{
|
||||
if( i->second->url == etc )
|
||||
if( i->second->url == dir_etc )
|
||||
{
|
||||
is_etc = true;
|
||||
etc_iter = i->second;
|
||||
@@ -85,6 +87,27 @@ static std::string etc = "etc";
|
||||
}
|
||||
|
||||
|
||||
// this is used with PushBack() method
|
||||
void DirContainer::CheckSpecialFolder(const Item & item, Iterator iter)
|
||||
{
|
||||
if( item.parent_id == -1 )
|
||||
{
|
||||
is_root = true;
|
||||
root_iter = iter;
|
||||
}
|
||||
|
||||
if( !is_root )
|
||||
return;
|
||||
|
||||
if( item.parent_id==root_iter->id && item.url==dir_etc )
|
||||
{
|
||||
is_etc = true;
|
||||
etc_iter = iter;
|
||||
log << log1 << "DirCont: added special folder: /etc" << logend;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
DirContainer::Iterator DirContainer::PushBack(const Item & item)
|
||||
{
|
||||
if( item.parent_id == -1 && is_root )
|
||||
@@ -94,12 +117,7 @@ DirContainer::Iterator DirContainer::PushBack(const Item & item)
|
||||
}
|
||||
|
||||
Iterator last_iter = table.insert(table.end(), item);
|
||||
|
||||
if( item.parent_id == -1 )
|
||||
{
|
||||
is_root = true;
|
||||
root_iter = last_iter;
|
||||
}
|
||||
CheckSpecialFolder(item, last_iter);
|
||||
|
||||
log << log2 << "DirCont: added dir, url: " << item.url << ", id: " << item.id << ", parent_id: " << item.parent_id << logend;
|
||||
|
||||
|
||||
@@ -57,6 +57,8 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
void CheckSpecialFolder(const Item & item, Iterator iter);
|
||||
|
||||
// main table with dirs
|
||||
Table table;
|
||||
|
||||
@@ -75,6 +77,9 @@ private:
|
||||
// indexes
|
||||
TableId table_id;
|
||||
TableParent table_parent;
|
||||
|
||||
// names of folders
|
||||
static std::string dir_etc;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ public:
|
||||
added_dir,
|
||||
added_thread,
|
||||
defaulted_dir,
|
||||
reloaded_templates,
|
||||
loggedout
|
||||
};
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#define FUN_LAST 13
|
||||
#define FUN_CREATETHREAD 14
|
||||
#define FUN_THREAD 15
|
||||
#define FUN_RELOAD 16
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ void Functions::ReadFunctions()
|
||||
|
||||
f.item.user_id = -1;
|
||||
f.item.group_id = -1;
|
||||
f.item.privileges = 0644;
|
||||
f.item.privileges = 0755;
|
||||
f.item.parent_id = -1; // !! temporarily doesn't matter
|
||||
f.item.id = -1;
|
||||
f.item.type = Item::file;
|
||||
@@ -96,9 +96,14 @@ void Functions::ReadFunctions()
|
||||
f.item.url = "thread";
|
||||
table.insert( std::make_pair(f.item.url, f) );
|
||||
|
||||
// -----------
|
||||
// FunctionCodeParser fc;
|
||||
// fc.Parse(Item()); // temporary for linking
|
||||
|
||||
// functions which need more privileges
|
||||
|
||||
f.code = FUN_RELOAD;
|
||||
f.item.url = "reload";
|
||||
f.item.privileges = 0700;
|
||||
table.insert( std::make_pair(f.item.url, f) );
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user