the first part of reimplementing has been done
now we have app object and singletons are only: log logn plugin and app git-svn-id: svn://ttmath.org/publicrep/winix/trunk@628 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
@@ -10,9 +10,19 @@
|
||||
#include "dirs.h"
|
||||
#include "error.h"
|
||||
#include "log.h"
|
||||
#include "db.h"
|
||||
#include "data.h"
|
||||
#include "request.h"
|
||||
|
||||
|
||||
|
||||
void Dirs::SetDb(Db * pdb)
|
||||
{
|
||||
db = pdb;
|
||||
}
|
||||
|
||||
|
||||
void Dirs::SetRequest(Request * prequest)
|
||||
{
|
||||
request = prequest;
|
||||
}
|
||||
|
||||
|
||||
void Dirs::Clear()
|
||||
@@ -21,6 +31,12 @@ void Dirs::Clear()
|
||||
}
|
||||
|
||||
|
||||
bool Dirs::HasReadExecAccessForRoot(const Item & item)
|
||||
{
|
||||
// there must be at least one 'x' (for the root)
|
||||
return (item.privileges & 01111) != 0; // !! in the future there'll be another 'x'
|
||||
}
|
||||
|
||||
|
||||
void Dirs::CheckRootDir()
|
||||
{
|
||||
@@ -28,11 +44,11 @@ void Dirs::CheckRootDir()
|
||||
|
||||
if( i != dir_table.End() )
|
||||
{
|
||||
if( !request.HasReadExecAccessForRoot(*i) )
|
||||
if( !HasReadExecAccessForRoot(*i) )
|
||||
{
|
||||
i->privileges = 0755;
|
||||
log << log1 << "Dirs: there is no access for root (admin) to the root dir, setting 0755 for root dir" << logend;
|
||||
db.EditPrivById(*i, i->id);
|
||||
db->EditPrivById(*i, i->id);
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -52,7 +68,7 @@ void Dirs::CheckRootDir()
|
||||
|
||||
// !! upewnic sie ze baza nie zmieni url (gdyby wczesniej juz byl w bazie pusty url)
|
||||
// !! zrobic jakis wyjatek do wprowadzania roota?
|
||||
if( db.AddItem(root) == WINIX_ERR_OK )
|
||||
if( db->AddItem(root) == WINIX_ERR_OK )
|
||||
{
|
||||
dir_table.PushBack(root);
|
||||
}
|
||||
@@ -65,7 +81,7 @@ void Dirs::ReadDirs()
|
||||
{
|
||||
Clear();
|
||||
|
||||
db.GetDirs(dir_table);
|
||||
db->GetDirs(dir_table);
|
||||
CheckRootDir();
|
||||
dir_table.FindSpecialFolders();
|
||||
}
|
||||
@@ -301,7 +317,7 @@ size_t Dirs::AnalyzeDir(Item * pdir, const std::string & path, long & dir_id, st
|
||||
for( ; i<path.size() && path[i] != '/' ; ++i)
|
||||
analyze_temp += path[i];
|
||||
|
||||
pdir = data.dirs.GetDir(analyze_temp, pdir->id);
|
||||
pdir = GetDir(analyze_temp, pdir->id);
|
||||
|
||||
if( !pdir )
|
||||
return old_i; // analyze_temp is not a directory
|
||||
@@ -327,7 +343,7 @@ size_t Dirs::AnalyzeDir(Item * pdir, const std::string & path, long & dir_id, st
|
||||
*/
|
||||
int Dirs::AnalyzePath(const std::string & path, long & dir_id, std::string & dir, std::string & file)
|
||||
{
|
||||
Item * pdir = data.dirs.GetRootDir();
|
||||
Item * pdir = GetRootDir();
|
||||
dir = '/';
|
||||
file.clear();
|
||||
|
||||
@@ -386,13 +402,30 @@ void Dirs::SplitPath(const std::string & path, std::string & dir, std::string &
|
||||
}
|
||||
|
||||
|
||||
|
||||
// !! dodac kasowanie z bazy
|
||||
bool Dirs::DelDir(long dir_id)
|
||||
{
|
||||
return dir_table.DelById(dir_id);
|
||||
}
|
||||
|
||||
|
||||
Error Dirs::AddDirectory(Item & item, bool add_to_dir_table)
|
||||
{
|
||||
if( item.type != Item::dir )
|
||||
return WINIX_ERR_DIR_EXPECTED;
|
||||
|
||||
Error status = db->AddItem(item);
|
||||
|
||||
if( status == WINIX_ERR_OK )
|
||||
{
|
||||
Item * pdir = AddDir(item);
|
||||
|
||||
if( add_to_dir_table && request->dir_table.back()->id == item.parent_id )
|
||||
request->dir_table.push_back(pdir);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user