2008-12-10 05:42:49 +01:00
|
|
|
/*
|
2010-02-28 01:08:10 +01:00
|
|
|
* This file is a part of Winix
|
2014-10-04 20:04:03 +02:00
|
|
|
* and is distributed under the 2-Clause BSD licence.
|
|
|
|
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2014-02-12 17:30:49 +01:00
|
|
|
* Copyright (c) 2008-2014, Tomasz Sowa
|
2008-12-10 05:42:49 +01:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
2014-10-04 20:04:03 +02:00
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions are met:
|
|
|
|
*
|
|
|
|
* 1. Redistributions of source code must retain the above copyright notice,
|
|
|
|
* this list of conditions and the following disclaimer.
|
|
|
|
*
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
|
|
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*
|
2008-12-10 05:42:49 +01:00
|
|
|
*/
|
|
|
|
|
2011-01-23 15:15:30 +01:00
|
|
|
#ifndef headerfile_winix_core_dircontainer
|
|
|
|
#define headerfile_winix_core_dircontainer
|
2008-12-10 05:42:49 +01:00
|
|
|
|
2009-02-06 14:12:03 +01:00
|
|
|
#include <list>
|
2008-12-10 05:42:49 +01:00
|
|
|
#include <map>
|
|
|
|
#include "item.h"
|
2009-04-21 22:50:55 +02:00
|
|
|
|
2008-12-10 05:42:49 +01:00
|
|
|
|
2014-02-12 17:30:49 +01:00
|
|
|
namespace Winix
|
|
|
|
{
|
|
|
|
|
|
|
|
|
2008-12-10 05:42:49 +01:00
|
|
|
|
|
|
|
class DirContainer
|
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
2009-02-06 14:12:03 +01:00
|
|
|
typedef std::list<Item> Table;
|
|
|
|
typedef Table::iterator Iterator;
|
|
|
|
typedef Table::size_type SizeType;
|
2008-12-10 05:42:49 +01:00
|
|
|
|
|
|
|
typedef std::map<long, Iterator> TableId;
|
|
|
|
typedef std::multimap<long, Iterator> TableParent;
|
|
|
|
typedef TableParent::iterator ParentIterator;
|
|
|
|
typedef TableParent::size_type ParentSizeType;
|
|
|
|
|
|
|
|
|
|
|
|
DirContainer();
|
|
|
|
|
2008-12-22 17:03:03 +01:00
|
|
|
Iterator GetRoot();
|
2009-11-16 00:55:11 +01:00
|
|
|
Iterator GetEtc();
|
2010-11-04 17:46:19 +01:00
|
|
|
Iterator GetVar();
|
2008-12-22 17:03:03 +01:00
|
|
|
|
2008-12-10 05:42:49 +01:00
|
|
|
Iterator Begin();
|
|
|
|
Iterator End();
|
|
|
|
SizeType Size();
|
|
|
|
bool Empty();
|
2009-04-20 00:13:21 +02:00
|
|
|
Iterator PushBack(const Item & item);
|
2010-03-15 02:47:26 +01:00
|
|
|
bool ChangeParent(long dir_id, long new_parent_id);
|
2008-12-10 05:42:49 +01:00
|
|
|
void Clear();
|
|
|
|
|
|
|
|
Iterator FindId(long id);
|
|
|
|
|
2009-02-06 14:12:03 +01:00
|
|
|
bool DelById(long id);
|
|
|
|
|
2012-01-25 00:03:36 +01:00
|
|
|
ParentIterator ParentBegin(); // IMPROVE ME: may it should be renamed to ChildBegin() similarly as FindFirstChild() ?
|
2008-12-10 05:42:49 +01:00
|
|
|
ParentIterator ParentEnd();
|
|
|
|
ParentSizeType ParentSize();
|
|
|
|
bool ParentEmpty();
|
2011-01-05 22:24:11 +01:00
|
|
|
ParentIterator FindFirstChild(long parent);
|
|
|
|
ParentIterator NextChild(ParentIterator pi);
|
2008-12-10 05:42:49 +01:00
|
|
|
|
2010-11-21 01:19:17 +01:00
|
|
|
bool IsNameOfSpecialFolder(const std::wstring & name);
|
2009-11-16 00:55:11 +01:00
|
|
|
void FindSpecialFolders();
|
2008-12-10 05:42:49 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
2009-11-16 18:43:23 +01:00
|
|
|
void CheckSpecialFolder(const Item & item, Iterator iter);
|
|
|
|
|
2008-12-10 05:42:49 +01:00
|
|
|
// main table with dirs
|
|
|
|
Table table;
|
|
|
|
|
2008-12-22 17:03:03 +01:00
|
|
|
// true if there is a root dir in the table
|
|
|
|
bool is_root;
|
|
|
|
|
2009-02-06 14:12:03 +01:00
|
|
|
// root
|
|
|
|
Iterator root_iter;
|
2008-12-22 17:03:03 +01:00
|
|
|
|
2009-11-16 00:55:11 +01:00
|
|
|
// true if there is a etc dir in the table
|
|
|
|
bool is_etc;
|
|
|
|
|
|
|
|
// etc
|
|
|
|
Iterator etc_iter;
|
|
|
|
|
2010-11-04 17:46:19 +01:00
|
|
|
// true if there is a var dir in the table
|
|
|
|
bool is_var;
|
|
|
|
|
|
|
|
// var
|
|
|
|
Iterator var_iter;
|
|
|
|
|
2008-12-10 05:42:49 +01:00
|
|
|
// indexes
|
|
|
|
TableId table_id;
|
|
|
|
TableParent table_parent;
|
2009-11-16 18:43:23 +01:00
|
|
|
|
|
|
|
// names of folders
|
2010-11-21 01:19:17 +01:00
|
|
|
static std::wstring dir_etc, dir_var;
|
2008-12-10 05:42:49 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2014-02-12 17:30:49 +01:00
|
|
|
|
|
|
|
} // namespace Winix
|
|
|
|
|
|
|
|
|
2008-12-10 05:42:49 +01:00
|
|
|
#endif
|