added: new winix function: mount

displaying all mount points
changed: struct Cur has now 'mount' pointer
         we should not use system->mounts.pmount now
         (it will be removed in the future)
changed: all mount point parameters are now propagated to childs mount points
         (if not defined there)



git-svn-id: svn://ttmath.org/publicrep/winix/trunk@745 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
2011-06-21 21:24:49 +00:00
parent 700a6fe643
commit 1d6ff73aad
22 changed files with 721 additions and 263 deletions

View File

@@ -2,13 +2,14 @@
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2010, Tomasz Sowa
* Copyright (c) 2008-2011, Tomasz Sowa
* All rights reserved.
*
*/
#include "templates.h"
#include "core/misc.h"
#include "core/mounts.h"
@@ -49,6 +50,141 @@ void mount_first_html_template(Info & i)
}
static bool mount_tab_inited = false;
static Mounts::MountTab::const_iterator mount_iter;
static std::wstring dir_str;
void mount_cur_type(Info & i)
{
i.out << system->mounts.GetMountType(cur->mount->type);
}
void mount_cur_dir(Info & i)
{
Item * pdir = system->dirs.GetDir(cur->mount->dir_id);
if( pdir && system->dirs.MakePath(pdir->id, dir_str) )
i.out << dir_str;
}
void mount_cur_fs(Info & i)
{
i.out << system->mounts.GetMountFs(cur->mount->fs);
}
void mount_print_parlist(Info & i, const Mount::Param & param)
{
bool was_printed = false;
for(size_t p=0 ; p < param.size() ; ++p)
{
if( param[p].defined )
{
if( was_printed )
i.out << ", ";
i.out << system->mounts.GetMountPar(p);
was_printed = true;
if( !param[p].arg.empty() )
{
i.out << "(";
for(size_t a=0 ; a < param[p].arg.size() ; ++a)
{
i.out << param[p].arg[a];
if( a + 1 < param[p].arg.size() )
i.out << ", ";
}
i.out << ")";
}
}
}
}
void mount_cur_parlist(Info & i)
{
mount_print_parlist(i, cur->mount->param);
}
void mount_tab(Info & i)
{
const Mounts::MountTab * pmount_tab = system->mounts.GetMountTab();
if( i.iter == 0 )
{
mount_iter = pmount_tab->begin();
}
else
{
if( mount_iter != pmount_tab->end() )
++mount_iter;
}
mount_tab_inited = (mount_iter != pmount_tab->end());
i.res = mount_tab_inited;
}
void mount_tab_type(Info & i)
{
if( mount_tab_inited )
{
i.out << system->mounts.GetMountType(mount_iter->second.type);
}
}
void mount_tab_dir(Info & i)
{
if( mount_tab_inited )
{
Item * pdir = system->dirs.GetDir(mount_iter->second.dir_id);
if( pdir && system->dirs.MakePath(pdir->id, dir_str) )
i.out << dir_str;
}
}
void mount_tab_fs(Info & i)
{
if( mount_tab_inited )
{
i.out << system->mounts.GetMountFs(mount_iter->second.fs);
}
}
void mount_tab_parlist(Info & i)
{
if( !mount_tab_inited )
return;
mount_print_parlist(i, mount_iter->second.param);
}
} // namespace TemplatesFunctions