2010-08-10 18:12:50 +02:00
|
|
|
/*
|
|
|
|
* This file is a part of Winix
|
|
|
|
* and is not publicly distributed
|
|
|
|
*
|
2014-02-12 17:30:49 +01:00
|
|
|
* Copyright (c) 2010-2014, Tomasz Sowa
|
2010-08-10 18:12:50 +02:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2011-01-23 15:15:30 +01:00
|
|
|
#ifndef headerfile_winix_functions_rm
|
|
|
|
#define headerfile_winix_functions_rm
|
2010-08-10 18:12:50 +02:00
|
|
|
|
|
|
|
#include "functionbase.h"
|
|
|
|
|
2014-02-12 17:30:49 +01:00
|
|
|
namespace Winix
|
|
|
|
{
|
2010-08-10 18:12:50 +02:00
|
|
|
|
|
|
|
|
|
|
|
namespace Fun
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
class Rm : public FunctionBase
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
Rm();
|
|
|
|
bool HasAccess();
|
2011-01-05 22:24:11 +01:00
|
|
|
void MakePost();
|
2010-08-10 18:12:50 +02:00
|
|
|
|
2012-01-25 00:03:36 +01:00
|
|
|
// removing the whole directory structure
|
|
|
|
// if remove_this_dir is false then only content of dir is removed
|
|
|
|
void RemoveDirTree(Item & dir, bool remove_this_dir, bool check_access = true);
|
|
|
|
|
|
|
|
// removing either a file or a symlink
|
2013-05-06 09:23:44 +02:00
|
|
|
bool RemoveFileOrSymlink(long item_id, bool check_access = true);
|
2012-01-25 00:03:36 +01:00
|
|
|
bool RemoveFileOrSymlink(Item & item, bool check_access = true);
|
2011-01-24 00:23:24 +01:00
|
|
|
|
|
|
|
// removing either a directory or a symlink or a file
|
2012-01-25 00:03:36 +01:00
|
|
|
// if item_id is a directory then the whole subdirectories are removed too
|
2012-06-03 04:14:33 +02:00
|
|
|
bool RemoveItemById(long item_id, bool check_access = true);
|
|
|
|
|
|
|
|
// removing either a directory or a symlink or a file
|
|
|
|
// if path is a directory then the whole subdirectories are removed too
|
|
|
|
// path must begin with a slash (or can be empty then the root directory is removed)
|
|
|
|
bool RemoveItemByPath(const std::wstring & path, bool check_access = true);
|
|
|
|
|
2011-01-24 00:23:24 +01:00
|
|
|
|
2010-08-10 18:12:50 +02:00
|
|
|
private:
|
|
|
|
|
2011-01-24 00:23:24 +01:00
|
|
|
// for deleting content in a directory (files and symlinks)
|
|
|
|
DbItemQuery content_dir_iq;
|
|
|
|
std::vector<Item> content_item_tab;
|
2010-12-10 22:07:01 +01:00
|
|
|
std::wstring path;
|
2010-08-10 18:12:50 +02:00
|
|
|
|
2011-01-05 22:24:11 +01:00
|
|
|
// for logging
|
|
|
|
std::wstring old_url;
|
|
|
|
|
2011-01-24 00:23:24 +01:00
|
|
|
// for removing an item by id
|
|
|
|
DbItemQuery rm_by_id_iq;
|
|
|
|
Item rm_by_id_item;
|
|
|
|
|
2012-06-03 04:14:33 +02:00
|
|
|
std::vector<Item*> rm_path_dir_tab;
|
|
|
|
Item rm_path_item;
|
|
|
|
|
2012-01-25 00:03:36 +01:00
|
|
|
bool HasAccessToDir(const Item & dir, bool only_content);
|
2011-01-05 22:24:11 +01:00
|
|
|
void Prepare();
|
|
|
|
void Clear();
|
2012-01-25 00:03:36 +01:00
|
|
|
|
|
|
|
bool RemoveFile(Item & item);
|
|
|
|
bool RemoveDirFiles(long dir_id, bool check_access);
|
|
|
|
void RemoveCurrentDir(Item * parent_dir, Item * current_dir, bool check_access);
|
|
|
|
void RemoveDirTree(Item * parent_dir, Item * current_dir, bool remove_this_dir, bool check_access);
|
|
|
|
void RemoveStaticFile(const std::wstring & path);
|
|
|
|
void RemoveStaticFile(const Item & item);
|
2011-01-05 22:24:11 +01:00
|
|
|
void RemoveDirContent();
|
|
|
|
void RemoveDir();
|
2011-06-24 22:53:21 +02:00
|
|
|
void CreateJSON(bool status);
|
2010-08-10 18:12:50 +02:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
2014-02-12 17:30:49 +01:00
|
|
|
} // namespace Winix
|
|
|
|
|
2010-08-10 18:12:50 +02:00
|
|
|
#endif
|