From 6a225fc56d6eebd7fc486ba452cc5fdabcd88c8e Mon Sep 17 00:00:00 2001 From: zhangzihao Date: Sun, 10 Jan 2021 09:09:46 +0800 Subject: [PATCH] delete files unuseful from git, but they're still exist. --- libsearch/index/blockdirs.cpp | 22 --- libsearch/index/blockdirs.h | 32 ---- libsearch/index/first-index.h | 1 - libsearch/index/index.pri | 7 - libsearch/index/inotify.cpp | 179 ----------------------- libsearch/index/inotify.h | 37 ----- libsearch/index/messagelist-manager.cpp | 64 -------- libsearch/index/messagelist-manager.h | 32 ---- libsearch/index/test-Inotify-Manager.cpp | 131 ----------------- libsearch/libsearch.h | 1 - 10 files changed, 506 deletions(-) delete mode 100644 libsearch/index/blockdirs.cpp delete mode 100644 libsearch/index/blockdirs.h delete mode 100644 libsearch/index/inotify.cpp delete mode 100644 libsearch/index/inotify.h delete mode 100644 libsearch/index/messagelist-manager.cpp delete mode 100644 libsearch/index/messagelist-manager.h delete mode 100644 libsearch/index/test-Inotify-Manager.cpp diff --git a/libsearch/index/blockdirs.cpp b/libsearch/index/blockdirs.cpp deleted file mode 100644 index 23659ac..0000000 --- a/libsearch/index/blockdirs.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "blockdirs.h" - -//优先级先放一下 -BlockDirs::BlockDirs(QObject *parent) : QObject(parent) -{ - return; -} - -int BlockDirs::setValue(const QString& path, const int &type) -{ - return FAILED; -} - -int BlockDirs::removeValue(const QString& path, const int &type) -{ - return FAILED; -} - -int BlockDirs::getValues() -{ - return FAILED; -} diff --git a/libsearch/index/blockdirs.h b/libsearch/index/blockdirs.h deleted file mode 100644 index ad4e25e..0000000 --- a/libsearch/index/blockdirs.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef BLOCKDIRS_H -#define BLOCKDIRS_H - -#include -#include "global-settings.h" - -#ifndef MYTYPE -#define MYTYPE -#define MYDIR 0 -#define MYFILE 1 -#endif // MYTYPE - -#ifndef SETVALUERESULT -#define SETVALUERESULT -#define DONOTHING 1 -#define FAILED -1 -#define SUCCESSED 0 -#endif // SETVALUERESULT - -class BlockDirs : public QObject -{ - Q_OBJECT -public: - explicit BlockDirs(QObject *parent = nullptr); - int setValue(const QString&, const int&); - int removeValue(const QString&, const int&); - int getValues(); -Q_SIGNALS: - -}; - -#endif // BLOCKDIRS_H diff --git a/libsearch/index/first-index.h b/libsearch/index/first-index.h index 7f2bc18..9665bdc 100644 --- a/libsearch/index/first-index.h +++ b/libsearch/index/first-index.h @@ -7,7 +7,6 @@ #include "traverse_bfs.h" #include "global-settings.h" #include "index-generator.h" -#include "messagelist-manager.h" class FirstIndex : public QThread, public Traverse_BFS { diff --git a/libsearch/index/index.pri b/libsearch/index/index.pri index 14d592e..2f14d4e 100644 --- a/libsearch/index/index.pri +++ b/libsearch/index/index.pri @@ -2,7 +2,6 @@ INCLUDEPATH += $$PWD HEADERS += \ # $$PWD/chinesecharacterstopinyin.h \ - $$PWD/blockdirs.h \ $$PWD/document.h \ $$PWD/filetypefilter.h \ $$PWD/file-reader.h \ @@ -10,8 +9,6 @@ HEADERS += \ $$PWD/index-generator.h \ # $$PWD/inotify-manager.h \ $$PWD/inotify-index.h \ - $$PWD/inotify.h \ - $$PWD/messagelist-manager.h \ $$PWD/traverse_bfs.h \ # $$PWD/text-content-indexer.h \ $$PWD/file-searcher.h \ @@ -19,7 +16,6 @@ HEADERS += \ SOURCES += \ # $$PWD/chinesecharacterstopinyin.cpp \ - $$PWD/blockdirs.cpp \ $$PWD/document.cpp \ $$PWD/filetypefilter.cpp \ $$PWD/file-reader.cpp \ @@ -27,9 +23,6 @@ SOURCES += \ $$PWD/index-generator.cpp \ # $$PWD/inotify-manager.cpp \ $$PWD/inotify-index.cpp \ - $$PWD/inotify.cpp \ - $$PWD/messagelist-manager.cpp \ - $$PWD/test-Inotify-Manager.cpp \ $$PWD/traverse_bfs.cpp \ # $$PWD/text-content-indexer.cpp \ $$PWD/file-searcher.cpp \ diff --git a/libsearch/index/inotify.cpp b/libsearch/index/inotify.cpp deleted file mode 100644 index 81293b3..0000000 --- a/libsearch/index/inotify.cpp +++ /dev/null @@ -1,179 +0,0 @@ -#include "inotify.h" -#include "ukui-search-qdbus.h" - -InotifyManagerRefact::InotifyManagerRefact(const QString& path) : Traverse_BFS(path) -{ - - /*-------------ukuisearchdbus Test start-----------------*/ - qDebug() << "setInotifyMaxUserWatches start"; - UkuiSearchQDBus usQDBus; - usQDBus.setInotifyMaxUserWatches(); - qDebug() << "setInotifyMaxUserWatches end"; - - /*-------------ukuisearchdbus Test End-----------------*/ - - -// dirPath = new QMap(); - m_fd = inotify_init(); - qDebug() << "m_fd----------->" <mlm = new MessageListManager(); - - this->AddWatch("/home"); - this->Traverse(); - this->SendRestMessage(); - - return; - -} - -InotifyManagerRefact::~InotifyManagerRefact(){ -// delete this->mlm; -// this->mlm = nullptr; -// delete dirPath; -// dirPath = nullptr; -} - -void InotifyManagerRefact::DoSomething(const QFileInfo& fileInfo){ -// this->mlm->AddMessage(QVector() << fileInfo.fileName() << fileInfo.absoluteFilePath() << QString(fileInfo.isDir()?"1":"0")); -// if(QString(bool((fileInfo.isDir()))) == QString("1")) -// qDebug()<<"bool((fileInfo.isDir())"<mlm->AddMessage(QVector() << "PLog" << "/home/zpf/baidunetdisk/PLog" << "1"); - if(fileInfo.isDir()){ - this->AddWatch(fileInfo.absoluteFilePath()); - } -// else{ -// this->mlm->AddMessage(QVector() << fileInfo.fileName() << fileInfo.absoluteFilePath() << QString(bool((fileInfo.isDir())))); - // } -} - -void InotifyManagerRefact::SendRestMessage() -{ -// this->mlm->SendMessage(); -} - -bool InotifyManagerRefact::AddWatch(const QString &path){ - //m_fd = inotify_init(); -// qDebug() << "m_fd: " <::Iterator i = currentPath.begin(); i != currentPath.end();){ - if (i.value().length() > path.length()){ - if (i.value().mid(0, path.length()) == path){ - qDebug() << i.value(); - /*--------------------------------*/ - //在此调用删除索引 - IndexGenerator::getInstance()->deleteAllIndex(new QStringList(path)); - /*--------------------------------*/ - currentPath.erase(i++); - } - else{ - i++; - } - } - else{ - i++; - } - } - qDebug() << path; - //这个貌似不用删,先mark一下 - //currentPath.remove(currentPath.key(path)); - return true; -} - -void InotifyManagerRefact::run(){ - - char * p; - char buf[BUF_LEN] __attribute__((aligned(8))); - - ssize_t numRead; - - for (;;) { /* Read events forever */ - numRead = read(m_fd, buf, BUF_LEN); - if (numRead == 0) { - qDebug() << "read() from inotify fd returned 0!"; - } - if (numRead == -1) { - qDebug() << "read"; - } - qDebug() << "Read " << numRead << " bytes from inotify fd"; - - /* Process all of the events in buffer returned by read() */ - - for (p = buf; p < buf + numRead;) { - struct inotify_event * event = reinterpret_cast(p); - if(event->name[0] != '.'){ -// if(true){ - //这个位运算不要在意,只是懒得把文件夹、文件和事件排列组合了,只是看一下事件的类型 - qDebug() << "Read Event: " << num2string[(event->mask & 0x0000ffff)] << currentPath[event->wd] << QString(event->name) << event->cookie << event->wd; - //num2string[event->mask & 0x0000ffff] -// IndexGenerator::getInstance()->creatAllIndex(new QStringList(currentPath[event->wd] + event->name)); - - /*--------------------------------*/ - - //传创建或移动过来的文件路径 - if((event->mask & IN_CREATE) | (event->mask & IN_MOVED_TO)){ - //添加监视要先序遍历,先添加top节点 - if (event->mask & IN_ISDIR){ - AddWatch(currentPath[event->wd] + '/' + event->name); - this->setPath(currentPath[event->wd] + '/' + event->name); - Traverse(); - } -// else { - - //IndexGenerator::getInstance()->creatAllIndex(new QStringList(currentPath[event->wd] + '/' + event->name)); -// this->mlm->AddMessage(QVector() << event->name << (currentPath[event->wd] + '/' + event->name) << QString(bool((event->mask & IN_ISDIR)))); -// this->mlm->SendMessage(); -// } - } - else if((event->mask & IN_DELETE) | (event->mask & IN_MOVED_FROM)){ - if (event->mask & IN_ISDIR){ - RemoveWatch(currentPath[event->wd] + '/' + event->name); - } -// else { - //这里调用删除索引 -// this->mlm->AddMessage(QVector() << event->name << (currentPath[event->wd] + '/' + event->name) << QString(bool((event->mask & IN_ISDIR)))); -// this->mlm->SendDeleteMessage(); - IndexGenerator::getInstance()->deleteAllIndex(new QStringList(currentPath[event->wd] + '/' + event->name)); -// } - } - /*--------------------------------*/ - } - p += sizeof(struct inotify_event) + event->len; - } - } -} diff --git a/libsearch/index/inotify.h b/libsearch/index/inotify.h deleted file mode 100644 index dff0d7e..0000000 --- a/libsearch/index/inotify.h +++ /dev/null @@ -1,37 +0,0 @@ -//aborted --MouseZhangZh -#ifndef INOTIFY_H -#define INOTIFY_H - -#include -#include -#include -#include -#include "traverse_bfs.h" -#include "messagelist-manager.h" -#define BUF_LEN 1024 - -class InotifyManagerRefact : public QThread, public Traverse_BFS -{ - Q_OBJECT -public: - explicit InotifyManagerRefact(const QString&); - ~InotifyManagerRefact(); - - bool AddWatch(const QString&); - bool RemoveWatch(const QString&); - virtual void DoSomething(const QFileInfo &) final; - void SendRestMessage(); -Q_SIGNALS: -protected: - void run() override; -private: - QString *m_watch_path; - int m_fd; - QMap currentPath; - QMap num2string; -// MessageListManager* mlm; - - QMap* dirPath; -}; - -#endif // INOTIFY_H diff --git a/libsearch/index/messagelist-manager.cpp b/libsearch/index/messagelist-manager.cpp deleted file mode 100644 index a3a06e8..0000000 --- a/libsearch/index/messagelist-manager.cpp +++ /dev/null @@ -1,64 +0,0 @@ -#include "messagelist-manager.h" -#include -#include -#include -#include -//#include - -MessageListManager::MessageListManager(){ - this->messageList = new QList>(); - this->ig = IndexGenerator::getInstance(); -// indexGeneratorThread = new QThread(); -// this->ig->moveToThread(indexGeneratorThread); -// connect(this,&MessageListManager::Send, this->ig, &IndexGenerator::creatAllIndex/*, Qt::QueuedConnection*/); -// connect(this,&MessageListManager::Send1, this->ig, [=](QStringList *l){ -// qDebug()<<"send"<<*l; -// }); - -} - -MessageListManager::~MessageListManager(){ - delete this->messageList; -// delete this->indexGeneratorThread; - //delete this->ig; - - this->messageList = nullptr; - this->ig = nullptr; -// this->indexGeneratorThread = nullptr; -} - -void MessageListManager::AddMessage(const QVector& pathVec){ - this->messageList->append(pathVec); - if (static_cast(this->messageList->length()) >= this->length){ - this->SendMessage(); - } -} - -bool MessageListManager::SendMessage(){ - //Q_EMIT Send(this->messageList); - if (this->messageList->empty()){ - return true; - } - -// Q_EMIT Send(this->messageList); -// qDebug() << "emit"; - this->ig->creatAllIndex(this->messageList); - - //sleep(1); - this->messageList->clear(); - return true; -} - -bool MessageListManager::SendDeleteMessage(){ - if (this->messageList->empty()){ - return true; - } - -// this->ig->deleteAllIndex(this->messageList); - this->messageList->clear(); - return true; -} - -void MessageListManager::SetAutoSendMessageLength(const size_t& length){ - this->length = length; -} diff --git a/libsearch/index/messagelist-manager.h b/libsearch/index/messagelist-manager.h deleted file mode 100644 index 1f94c64..0000000 --- a/libsearch/index/messagelist-manager.h +++ /dev/null @@ -1,32 +0,0 @@ -//aborted --MouseZhangZh -#ifndef MESSAGELISTMANAGER_H -#define MESSAGELISTMANAGER_H - -#include -#include "index-generator.h" - -class MessageListManager : public QObject -{ - Q_OBJECT -public: - explicit MessageListManager(); - ~MessageListManager(); - - void AddMessage(const QVector&); - bool SendMessage(); - bool SendDeleteMessage(); - void SetAutoSendMessageLength(const size_t&); - -private: -// QStringList* messageList; - QList>* messageList; - - size_t length = 80000; - IndexGenerator* ig; -// QThread* indexGeneratorThread; - -Q_SIGNALS: - bool Send(QStringList*); -}; - -#endif // MESSAGELISTMANAGER_H diff --git a/libsearch/index/test-Inotify-Manager.cpp b/libsearch/index/test-Inotify-Manager.cpp deleted file mode 100644 index a1dcc7c..0000000 --- a/libsearch/index/test-Inotify-Manager.cpp +++ /dev/null @@ -1,131 +0,0 @@ -#include -#include -#include "inotify-manager.h" -#include "chinesecharacterstopinyin.h" -#include "inotify.h" - -void testTraverse(void){ - /*-------------Inotify Test Start---------------*/ -// QTime t1 = QTime::currentTime(); -// InotifyManager* im = new InotifyManager(); -// im->AddWatch("/home"); -// im->Traverse_BFS("/home", true); -// QTime t2 = QTime::currentTime(); -// qDebug() << t1; -// qDebug() << t2; -// im->start(); - /*-------------Inotify Test End-----------------*/ - - /*-------------PinyinSearch Test Start---------------*/ -// QTime t1 = QTime::currentTime(); -// QString test("test"); -// qDebug() << IndexGenerator::IndexSearch(test); -// QTime t2 = QTime::currentTime(); -// qDebug() << t1; -// qDebug() << t2; - /*-------------PinyinSearch Test End-----------------*/ - - /*-------------InotyifyRefact Test Start---------------*/ -// QTime t1 = QTime::currentTime(); -// InotifyManagerRefact* imr = new InotifyManagerRefact("/home"); -// imr->AddWatch("/home"); -// imr->setPath("/home"); -// imr->Traverse(); -// QTime t2 = QTime::currentTime(); -// qDebug() << t1; -// qDebug() << t2; - /*-------------InotyifyRefact Test End-----------------*/ - - - - exit(0); -} - -void removeTone(){ - /*-------------Remove Tone Start---------------*/ - qDebug() << chineseCharactersToPinyin::find("z测试策士xl123123"); - - QFile file("://index/pinyinWithTone.txt"); - QFile fileOut("/home/zhangzihao/ukui/ns/ukui-search/index/pinyinWithoutTone.txt"); - fileOut.open(QIODevice::WriteOnly/* | QIODevice::Text*/); - - if (!file.open(QFile::ReadOnly | QFile::Text)) { - qDebug("File: '%s' open failed!", file.fileName().toStdString().c_str()); - exit(-1); - } - - while(!file.atEnd()) { - QString content = QString::fromUtf8(file.readLine()); - content.replace("ā", "a") - .replace("á", "a") - .replace("ǎ", "a") - .replace("à", "a") - .replace("ō", "o") - .replace("ó", "o") - .replace("ǒ", "o") - .replace("ò", "o") - .replace("ê", "e") - .replace("ē", "e") - .replace("é", "e") - .replace("ě", "e") - .replace("è", "e") - .replace("ī", "i") - .replace("í", "i") - .replace("ǐ", "i") - .replace("ì", "i") - .replace("ū", "u") - .replace("ú", "u") - .replace("ǔ", "u") - .replace("ù", "u") - //l和n后面的ü写作v - .replace("lǖ", "lv") - .replace("lǘ", "lv") - .replace("lǚ", "lv") - .replace("lǜ", "lv") - .replace("lü", "lv") - .replace("nǖ", "nv") - .replace("nǘ", "nv") - .replace("nǚ", "nv") - .replace("nǜ", "nv") - .replace("nü", "nv") - //l和n后面的ü替换之后,其他的ü替换为u - .replace("ǖ", "u") - .replace("ǘ", "u") - .replace("ǚ", "u") - .replace("ǜ", "u") - .replace("ü", "u") - .replace("ê", "e") - .replace("ɑ", "a") - .replace("", "m") - .replace("ń", "n") - .replace("", "n") - .replace("ɡ", "g"); - //去除同音不同调 - //QString content = QString::fromUtf8(file.readLine()); - - QStringList temp = content.split(" ").first().split(",").toSet().toList(); - QString outContent; - for (auto i : temp){ - outContent += i; - outContent += ","; - } - outContent = outContent.left(outContent.size() - 1); - outContent += " "; - outContent += content.split(" ").last().trimmed(); - outContent += "\n"; - fileOut.write(outContent.toUtf8()); -// temp.toSet().toList(); - //content.split(" ").first().split(",") - - //map[content.split(" ").last().trimmed()] = content.split(" ").first().split(","); - - -// ā á ǎ à ō ó ǒ ò ê ē é ě è ī í ǐ ì ū ú ǔ ù ǖ ǘ ǚ ǜ ü ê ɑ  ń ň  ɡ -// fileOut.write(content.toUtf8()); - qDebug() << content; - } - - file.close(); - fileOut.close(); - /*-------------Remove Tone End-----------------*/ -} diff --git a/libsearch/libsearch.h b/libsearch/libsearch.h index 5819914..a01098e 100644 --- a/libsearch/libsearch.h +++ b/libsearch/libsearch.h @@ -5,7 +5,6 @@ #include "index/file-searcher.h" #include "appsearch/app-match.h" #include "settingsearch/setting-match.h" -#include "index/inotify.h" #include "file-utils.h" #include "global-settings.h" #include "index/first-index.h"