--- /dev/null
+/*
+ * ReQStringUtil.cpp
+ *
+ * License: Public Domain
+ * You can use and modify this file without any restriction.
+ * Do what you want.
+ * No warranties and disclaimer of any damages.
+ * You also can use this license: http://www.wtfpl.net
+ * The latest sources: https://github.com/republib
+ */
+
+/** @file
+ * @brief Processors for pattern matching.
+ *
+ * Patterns can contain wildcards: '*' for any string
+ */
+/** @file base/ReMatcher.hpp
+ *
+ * @brief Efficient pattern matching.
+ */
+#include "base/rebase.hpp"
+
+
+/**
+ * Constructor.
+ *
+ * @param pattern a pattern with wildcards '*' (any string)
+ * @param caseSensitivity caseSensitive or caseInsensitive
+ * @param anchored <code>true<code>: the pattern starts at the strings
+ * start<br>
+ * <code>false<code>: the pattern can start anywhere in
+ * the string
+ */
+
+ReMatcher::ReMatcher(const QString& pattern, Qt::CaseSensitivity caseSensivity,
+ bool anchored) :
+ m_needles(),
+ m_restLengths(),
+ m_anchored(anchored),
+ m_caseSensivitiy(caseSensivity) {
+ setPattern(pattern);
+}
+
+/**
+ * Tests whether the given string matches the pattern.
+ *
+ * @param text the text to test
+ * @return <code>true</code>: the pattern matches
+ */
+bool ReMatcher::matches(const QString& text) {
+ bool found = m_needles.size() == 0;
+ if (!found) {
+ found =
+ m_anchored ?
+ text.startsWith(m_needles.at(0), m_caseSensivitiy) : true;
+ if (found) {
+ int startIx = m_anchored ? 1 : 0;
+ int textIndex = m_anchored ? m_needles.at(0).length() : 0;
+ for (int ix = startIx; found && ix < m_needles.size(); ix++) {
+ found = text.size() - textIndex >= m_restLengths.at(ix);
+ if (found)
+ found = (textIndex = text.indexOf(m_needles.at(ix),
+ textIndex, m_caseSensivitiy)) >= 0;
+ }
+ }
+ }
+ return found;
+}
+
+/**
+ * Sets the search pattern.
+ *
+ * @param pattern the search pattern, with wildcards '*' (any string)
+ */
+void ReMatcher::setPattern(const QString& pattern) {
+ if (pattern.isEmpty())
+ m_needles.clear();
+ else {
+ if (pattern.startsWith("*"))
+ m_anchored = false;
+ m_needles = pattern.split('*');
+ // Eliminate empty entries:
+ for (int ix = m_needles.size() - 1; ix >= 0; ix--) {
+ if (m_needles.at(ix).length() == 0)
+ m_needles.removeAt(ix);
+ else
+ m_restLengths.append(0);
+ }
+ int sum = 0;
+ for (int ix = m_needles.size() - 1; ix >= 0; ix--) {
+ int size = m_needles.at(ix).size();
+ m_restLengths.append(size + sum);
+ sum += size;
+ }
+ }
+}
+
+/**
+ * Constructor.
+ *
+ * @param patterns a list of patterns with wildcards '*' (any string)
+ * @param caseSensitivity caseSensitive or caseInsensitive
+ * @param anchored <code>true<code>: the pattern starts at the strings
+ * start<br>
+ * <code>false<code>: the pattern can start anywhere in
+ * the string
+ */
+ReListMatcher::ReListMatcher(const QStringList& patterns,
+ Qt::CaseSensitivity caseSensitivty, bool anchored) :
+ m_list(),
+ m_empty(false)
+{
+ QStringList::const_iterator it;
+ for (it = patterns.constBegin(); it != patterns.cend(); ++it){
+ m_list.append(new ReMatcher(*it, caseSensitivty, anchored));
+ m_empty = true;
+ }
+}
+/**
+ * Destructor.
+ */
+ReListMatcher::~ReListMatcher(){
+ destroy();
+}
+/**
+ * Frees the resources.
+ */
+void ReListMatcher::destroy(){
+ QList<ReMatcher*>::const_iterator it;
+ for (it = m_list.constBegin(); it != m_list.cend(); ++it){
+ delete *it;
+ }
+ m_list.clear();
+}
+
+/**
+ * Returns whether the pattern list is empty.
+ *
+ * @return <code>true</code>: the pattern list is empty
+ */
+bool ReListMatcher::empty() const
+{
+ return m_empty;
+}
+
+/**
+ * Tests whether at least one pattern of the list matches the given text
+ * @param text text to test
+ * @return <code>true</code>: one of the stored patterns matches the text<br>
+ * <code>false</code>: none of the patterns matches
+ */
+bool ReListMatcher::matches(const QString& text)
+{
+ QList<ReMatcher*>::const_iterator it;
+ bool rc = false;
+ for (it = m_list.constBegin(); ! rc && it != m_list.cend(); ++it){
+ rc = (*it)->matches(text);
+ }
+ return rc;
+}
+
+
+/**
+ * Constructor.
+ *
+ * @param includes a list of include patterns
+ * @param excludes a list of exclude patterns
+ * @param caseSensitivity caseSensitive or caseInsensitive
+ * @param anchored <code>true<code>: the pattern starts at the strings
+ * start<br>
+ * <code>false<code>: the pattern can start anywhere in
+ * the string
+ */
+ReIncludeExcludeMatcher::ReIncludeExcludeMatcher(const QStringList& includes,
+ const QStringList& excludes, Qt::CaseSensitivity caseSensitivty,
+ bool anchored) :
+ m_includes(includes, caseSensitivty, anchored),
+ m_excludes(excludes, caseSensitivty, anchored)
+{
+}
+
+/**
+ * Tests whether a text matches the include patterns and does not match the
+ * exclude patterns.
+ *
+ * @param text text to test
+ * @param excludeToo <code>true</code>: the exclude patterns will be tested
+ * @return <code>true</code>: at least one of the include patterns
+ * matches and none of the exclude patterns matches
+ */
+bool ReIncludeExcludeMatcher::matches(const QString& text, bool excludeToo)
+{
+ bool rc = m_includes.matches(text);
+ if (rc && excludeToo && ! m_excludes.empty())
+ rc = ! m_excludes.matches(text);
+ return rc;
+}
--- /dev/null
+/*
+ * ReQStringUtil.hpp
+ *
+ * License: Public Domain
+ * You can use and modify this file without any restriction.
+ * Do what you want.
+ * No warranties and disclaimer of any damages.
+ * You also can use this license: http://www.wtfpl.net
+ * The latest sources: https://github.com/republib
+ */
+
+#ifndef REMATCHER_HPP
+#define REMATCHER_HPP
+
+
+/**
+ * Processor for an efficient test whether a text matches a pattern.
+ *
+ * A pattern can contain wildcards: '*' for any string.
+ */
+class ReMatcher {
+public:
+ ReMatcher(const QString& pattern, Qt::CaseSensitivity caseSensitivty =
+ Qt::CaseSensitive, bool anchored = false);
+public:
+ bool matches(const QString& text);
+ void setPattern(const QString& pattern);
+protected:
+ QStringList m_needles;
+ // m_restLengths[ix] = sum(m_needles[ix..last].size()
+ QList<int> m_restLengths;
+ bool m_anchored;
+ Qt::CaseSensitivity m_caseSensivitiy;
+};
+
+/**
+ * Processor for efficient test whether a text matches a list of patterns.
+ */
+class ReListMatcher {
+public:
+ ReListMatcher(const QStringList& patterns, Qt::CaseSensitivity caseSensitivty =
+ Qt::CaseSensitive, bool anchored = false);
+ ~ReListMatcher();
+public:
+ bool matches(const QString& text);
+ bool empty() const;
+protected:
+ void destroy();
+protected:
+ QList<ReMatcher*> m_list;
+ bool m_empty;
+};
+
+/**
+ * Processor for efficient test whether a text matches an include pattern list
+ * and not an exclude pattern list.
+ */
+class ReIncludeExcludeMatcher{
+public:
+ ReIncludeExcludeMatcher(const QStringList& includes, const QStringList& excludes,
+ Qt::CaseSensitivity caseSensitivty = Qt::CaseSensitive,
+ bool anchored = false);
+public:
+ bool matches(const QString& text, bool excludeToo = true);
+protected:
+ ReListMatcher m_includes;
+ ReListMatcher m_excludes;
+};
+
+#endif // REMATCHER_HPP
* The latest sources: https://github.com/republib
*/
+#include "base/rebase.hpp"
+QStringList ReQStringUtils::m_emptyList;
+
/** @file
- * @brief Missed operation for <code>ReString</code>s.
+ * @brief Missed operation for <code>QString</code>s.
*/
-/** @file rplcore/rplqstring.hpp
+/** @file base/ReQStringUtils.hpp
*
- * @brief Definitions for missed operation for <code>ReString</code>s.
+ * @brief Definitions for missed operation for <code>QString</code>s.
*/
#include "base/rebase.hpp"
-#include <QtCore/qmath.h>
-#include <QDateTime>
/**
* Removes end of line characters if any.
return rc;
}
-/**
- * Constructor.
- *
- * @param pattern a pattern with wildcards '*' (any string)
- * @param caseSensitivity caseSensitive or caseInsensitive
- * @param anchored <code>true<code>: the pattern starts at the strings
- * start<br>
- * <code>false<code>: the pattern can start anywhere in
- * the string
- */
-
-ReMatcher::ReMatcher(const QString& pattern, Qt::CaseSensitivity caseSensivity,
- bool anchored) :
- m_needles(),
- m_restLengths(),
- m_anchored(anchored),
- m_caseSensivitiy(caseSensivity) {
- setPattern(pattern);
-}
-
-/**
- * Tests whether the given string matches the pattern.
- *
- * @param text the text to test
- * @return <code>true</code>: the pattern matches
- */
-bool ReMatcher::matches(const QString& text) {
- bool found = m_needles.size() == 0;
- if (!found) {
- found =
- m_anchored ?
- text.startsWith(m_needles.at(0), m_caseSensivitiy) : true;
- if (found) {
- int startIx = m_anchored ? 1 : 0;
- int textIndex = m_anchored ? m_needles.at(0).length() : 0;
- for (int ix = startIx; found && ix < m_needles.size(); ix++) {
- found = text.size() - textIndex >= m_restLengths.at(ix);
- if (found)
- found = (textIndex = text.indexOf(m_needles.at(ix),
- textIndex, m_caseSensivitiy)) >= 0;
- }
- }
- }
- return found;
-}
-
-/**
- * Sets the search pattern.
- *
- * @param pattern the search pattern, with wildcards '*' (any string)
- */
-void ReMatcher::setPattern(const QString& pattern) {
- m_needles = pattern.split('*');
- // Eliminate empty entries:
- for (int ix = m_needles.size() - 1; ix >= 0; ix--) {
- if (m_needles.at(ix).length() == 0)
- m_needles.removeAt(ix);
- else
- m_restLengths.append(0);
- }
- int sum = 0;
- for (int ix = m_needles.size() - 1; ix >= 0; ix--) {
- int size = m_needles.at(ix).size();
- m_restLengths.append(size + sum);
- sum += size;
- }
-
-}
-
-/**
- * Constructor.
- *
- * @param patterns a list of patterns with wildcards '*' (any string)
- * @param caseSensitivity caseSensitive or caseInsensitive
- * @param anchored <code>true<code>: the pattern starts at the strings
- * start<br>
- * <code>false<code>: the pattern can start anywhere in
- * the string
- */
-ReListMatcher::ReListMatcher(const QStringList& patterns,
- Qt::CaseSensitivity caseSensitivty, bool anchored) :
- m_patternList(patterns.size())
-{
- QStringList::const_iterator it;
- for (it = patterns.constBegin(); it != patterns.cend(); ++it){
- m_list.append(new ReMatcher(*it, caseSensitivty, anchored));
- }
-}
-/**
- * Destructor.
- */
-ReListMatcher::~ReListMatcher(){
- QList<ReMatcher*>::const_iterator it;
- for (it = m_list.constBegin(); it != patterns.cend(); ++it){
- delete *it;
- }
- m_list.clear();
-}
-/**
- * Tests whether at least one pattern of the list matches the given text
- * @param text text to test
- * @return <code>true</code>: one of the stored patterns matches the text<br>
- * <code>false</code>: none of the patterns matches
- */
-bool ReListMatcher::matches(const QString& text)
-{
- QList<ReMatcher*>::const_iterator it;
- bool rc = false;
- for (it = m_list.constBegin(); ! rc && it != patterns.cend(); ++it){
- rc = it->matches(text);
- }
- return rc;
-}
-
-/**
- * Constructor.
- *
- * @param includes a list of include patterns
- * @param excludes a list of exclude patterns
- * @param caseSensitivity caseSensitive or caseInsensitive
- * @param anchored <code>true<code>: the pattern starts at the strings
- * start<br>
- * <code>false<code>: the pattern can start anywhere in
- * the string
- */
-ReIncludeExcludeMatcher::ReIncludeExcludeMatcher(const QStringList& includes,
- const QStringList& excludes, Qt::CaseSensitivity caseSensitivty,
- bool anchored) :
- m_includes(includes, caseSensitivty, anchored),
- m_excludes(excludes, caseSensitivty, anchored)
-{
-}
-
-/**
- * Tests whether a text matches the include patterns and does not match the
- * exclude patterns.
- *
- * @param text text to test
- * @param excludeToo <code>true</code>: the exclude patterns will be tested
- * @return <code>true</code>: at least one of the include patterns
- * matches and none of the exclude patterns matches
- */
-bool ReIncludeExcludeMatcher::matches(const QString& text, bool excludeToo)
-{
- bool rc = m_includes.matches(text);
- if (rc && excludeToo && m_excludes.size() > 0)
- rc = ! m_excludes.matches(text);
- return rc;
-}
* The latest sources: https://github.com/republib
*/
-#ifndef RPLQSTRING_HPP
-#define RPLQSTRING_HPP
+#ifndef REQSTRINGUTILS_HPP
+#define REQSTRINGUTILS_HPP
/**
* Some useful static functions handling <code>QString</code> instances.
digit >= 'a' && digit <= 'f' ? digit - 'a' + 10 : -1;
}
static char* utf8(const ReString& source, char buffer[], size_t bufferSize);
+public:
+ static QStringList m_emptyList;
};
/**
QDateTime m_dateTime;
};
-/**
- * Processor for efficient test whether a text matches a pattern ('*' for any string).
- */
-class ReMatcher {
-public:
- ReMatcher(const QString& pattern, Qt::CaseSensitivity caseSensitivty =
- Qt::CaseSensitive, bool anchored = false);
-public:
- bool matches(const QString& text);
- void setPattern(const QString& pattern);
-protected:
- QStringList m_needles;
- // m_restLengths[ix] = sum(m_needles[ix..last].size()
- QList<int> m_restLengths;
- bool m_anchored;
- Qt::CaseSensitivity m_caseSensivitiy;
-};
-
-/**
- * Processor for efficient test whether a text matches a list of patterns.
- */
-class ReListMatcher {
-public:
- ReListMatcher(const QStringList& patterns, Qt::CaseSensitivity caseSensitivty =
- Qt::CaseSensitive, bool anchored = false);
- ~ReListMatcher();
-public:
- bool matches(const QString& text);
-protected:
- QList<ReMatcher*> m_list;
-};
-
-/**
- * Processor for efficient test whether a text matches an include pattern list
- * and not an exclude pattern list.
- */
-class ReIncludeExcludeMatcher{
-public:
- ReIncludeExcludeMatcher(const QStringList& includes, const QStringList& excludes,
- Qt::CaseSensitivity caseSensitivty = Qt::CaseSensitive,
- bool anchored = false);
-public:
- bool matches(const QString& text, bool excludeToo = true);
-protected:
- ReListMatcher m_includes;
- ReListMatcher m_excludes;
-};
-
-#endif // RPLQSTRING_HPP
+#endif // REQSTRINGUTILS_HPP
#include <QDataStream>
#include <QMutex>
#include <QRegularExpression>
+#include <QDateTime>
#include <QtCore/qmath.h>
#include <QTranslator>
#include <QDateTime>
#include "base/ReException.hpp"
#include "base/ReContainer.hpp"
#include "base/ReStringUtils.hpp"
-#include "ReQStringUtils.hpp"
+#include "base/ReQStringUtils.hpp"
#include "base/ReConfigurator.hpp"
#include "base/ReConfig.hpp"
#include "base/ReTerminator.hpp"
#include "base/ReFileUtils.hpp"
#include "base/ReFile.hpp"
#include "base/ReDiff.hpp"
+#include "base/ReMatcher.hpp"
#include "base/ReTest.hpp"
#endif // REBASE_HPP
void testReWriter();
void testReFile();
void testReFileUtils();
+ void testReMatcher();
+ testReMatcher();
testReQStringUtil();
testReFile();
testReFileUtils();
--- /dev/null
+/*
+ * cuReFileSystem.cpp
+ *
+ * License: Public Domain
+ * You can use and modify this file without any restriction.
+ * Do what you want.
+ * No warranties and disclaimer of any damages.
+ * You also can use this license: http://www.wtfpl.net
+ * The latest sources: https://github.com/republib
+ */
+#include "base/rebase.hpp"
+#include "os/reos.hpp"
+
+/** @file
+ * @brief Unit test of the basic exceptions.
+ */
+
+class TestReFileSystem: public ReTest {
+public:
+ TestReFileSystem() :
+ ReTest("ReFileSystem") {
+ doIt();
+ }
+private:
+ QByteArray m_base;
+ QByteArray m_subDir1;
+protected:
+ void init(){
+ m_base = ReFileUtils::tempDir("refilesystem");
+ m_subDir1 = tempDir("dir1", "refilesystem");
+ tempDir("dir2", "refilesystem");
+ QString node;
+ for (int ix = 1; ix <= 7; ix++){
+ node.sprintf("test%d.txt", ix);
+ QString fn = ReFileUtils::tempFile(node, "refilesystem", false);
+ ReFileUtils::writeToFile(fn, node);
+ fn.sprintf("%stext%d.txt", m_subDir1.constData(), ix);
+ ReFileUtils::writeToFile(fn, fn);
+ }
+ }
+ void testReLocalFileSystem() {
+ ReLocalFileSytem fs(m_base);
+ fs.
+
+ }
+ virtual void run() {
+ init();
+ testReLocalFileSystem();
+ }
+};
+void testReFileSystem() {
+ TestReFileSystem test;
+}
+
--- /dev/null
+/*
+ * cuReMatcher.cpp
+ *
+ * License: Public Domain
+ * You can use and modify this file without any restriction.
+ * Do what you want.
+ * No warranties and disclaimer of any damages.
+ * You also can use this license: http://www.wtfpl.net
+ * The latest sources: https://github.com/republib
+ */
+/** @file
+ * @brief Unit test of the ReString tools.
+ */
+
+#include "../base/rebase.hpp"
+
+class TestReMatcher: public ReTest {
+public:
+ TestReMatcher() :
+ ReTest("ReMatcher") {
+ doIt();
+ }
+
+public:
+ void testBasics() {
+ ReMatcher m1("a*b*c", Qt::CaseSensitive, true);
+ checkT(m1.matches("a b c d"));
+ checkT(m1.matches("abc d"));
+ checkT(m1.matches("ababc"));
+ checkT(m1.matches("abc"));
+ checkF(m1.matches("aBc"));
+
+ ReMatcher m2("a*b*c", Qt::CaseSensitive, false);
+ checkT(m2.matches("a b c d"));
+ checkT(m2.matches("ababc"));
+ checkT(m2.matches("a b a b c"));
+ checkT(m2.matches(" abc"));
+ checkF(m2.matches(" ab"));
+
+ ReMatcher m3("a**B*C", Qt::CaseInsensitive, true);
+ checkT(m3.matches("a b c d"));
+ checkT(m3.matches("abc d"));
+ checkT(m3.matches("ababc"));
+ checkT(m3.matches("abc"));
+
+ ReMatcher m4("A*B*c", Qt::CaseInsensitive, false);
+ checkT(m4.matches("a b c d"));
+ checkT(m4.matches("ababc"));
+ checkT(m4.matches("a b a b c"));
+ checkT(m4.matches(" abc"));
+ checkF(m4.matches(" ab"));
+
+ m4.setPattern("*");
+ checkT(m4.matches("x"));
+ m4.setPattern("");
+ checkT(m4.matches("any"));
+ }
+ void testList(){
+ QStringList patterns;
+ patterns << "*.txt" << "*.doc";
+ ReListMatcher matcher(patterns, Qt::CaseInsensitive, true);
+ checkT(matcher.matches("README.TXT"));
+ checkT(matcher.matches("Xyz.Doc"));
+ checkF(matcher.matches("a.doc.bak"));
+
+ ReListMatcher matcher2(ReQStringUtils::m_emptyList, Qt::CaseInsensitive, true);
+ checkT(matcher2.matches("abc"));
+
+ }
+
+ virtual void run(void) {
+ testBasics();
+ testList();
+ }
+};
+void testReMatcher() {
+ TestReMatcher test;
+}
+
../base/ReLogger.cpp \
../base/ReStringUtils.cpp \
../base/ReTerminator.cpp \
+ ../base/ReMatcher.cpp \
../base/ReTest.cpp \
../base/ReWriter.cpp \
../gui/ReStateStorage.cpp \
../gui/ReSettings.cpp \
../gui/ReEdit.cpp \
+ ../os/ReFileSystem.cpp \
+ cuReFileSystem.cpp \
cuReConfig.cpp \
cuReContainer.cpp \
cuReWriter.cpp \
cuReEdit.cpp \
cuReStateStorage.cpp \
cuReSettings.cpp \
+ cuReMatcher.cpp \
allTests.cpp
HEADERS += \
connect(&m_timer, SIGNAL(timeout()), this, SLOT(timeout()));
}
-/**
- * Destructor.
- */
-ReDelayedStorage::~ReDelayedStorage()
-{
-
-}
-
/**
* Finds the index of the widget in the list.
*
class ReLogger;
class QMainWindow;
class ReDelayedStorage : protected QObject{
- Q_OBJECT
enum ObjType {
OT_UNDEF,
OT_WINDOW
} ObjInfo;
public:
ReDelayedStorage(const QString& file, ReLogger* m_logger, int delay = 5);
- virtual ~ReDelayedStorage();
+ virtual ~ReDelayedStorage(){}
public:
void storeWindow(const QMainWindow* window);
public:
m_writeable = writeable;
}
-/**
- * Tests whether a node matches at least one entry of a pattern list.
- * @param patterns the list of patterns to test
- * @param node the filename to test
- * @return <code>true</code>: at least one entry pattern matches
- */
-bool ReFileSystem::match(const QStringList& patterns, const QString& node)
-{
- QStringUtils::
-}
-
/**
* Constructor.
*/
-ReLinuxFS::ReLinuxFS(const QString& basePath) :
- m_path(basePath),
+ReLocalFileSytem::ReLocalFileSytem(const QString& basePath) :
+ ReFileSystem("localfs"),
+ m_basePath(basePath),
m_currentPath(basePath),
m_dir(basePath)
{
* EC_PATH_NOT_FOUND directory does not exist<br>
* EC_NOT_ACCESSIBLE parent not readable
*/
-ReFileSystem::ErrorCode ReLinuxFS::setDirectory(const QString& path)
+ReFileSystem::ErrorCode ReLocalFileSytem::setDirectory(const QString& path)
{
ErrorCode rc = m_dir.setCurrent(path) ? EC_SUCCESS : EC_PATH_NOT_FOUND;
m_currentPath = m_dir.absolutePath();
*
* @return the name of the current directory
*/
-const QString&ReLinuxFS::directory() const
+const QString& ReLocalFileSytem::directory() const
{
- return m_currentDir;
+ return m_currentPath;
}
/**
* Can contain wildcard '*' (for any string)
* @return a list of the files matching the patterns
*/
-QList<ReFileMetaData*> ReLinuxFS::listInfos(const QString& pattern,
- const QStringList& excludePatterns)
+int ReLocalFileSytem::listInfos(const ReIncludeExcludeMatcher& matcher,
+ QList<ReFileMetaData*>& list)
{
QList<ReFileMetaData*> rc;
QStringList list = pattern.size() == 0 ? m_dir.entryList()
class ReFileMetaData {
public:
- FileMetaData(const QString& node);
- virtual ~FileMetaData();
+ ReFileMetaData(const QString& node);
+ virtual ~ReFileMetaData();
public:
QString m_node;
QDateTime m_modified;
};
class ReFileSystem {
+public:
enum ListOption {
LO_UNDEF = 0,
LO_FILES = 1,
* can be in the result list
* @return a list of the files matching the patterns
*/
- virtual QList<ReFileMetaData*> listInfos(const QStringList& patterns,
- const QStringList& excludePatterns) = 0;
+ virtual int listInfos(const ReIncludeExcludeMatcher& matcher,
+ QList<ReFileMetaData*>& list) = 0;
public:
- bool getWriteable() const;
+ bool writeable() const;
void setWriteable(bool writeable);
-public:
- static bool match(const QStringList& patterns, const QString& node);
protected:
QString m_name;
QString m_directory;
bool m_writeable;
};
-class ReLinuxFS : public ReFileSystem {
+class ReLocalFileSytem : public ReFileSystem {
public:
- ReLinuxFS(const QString& basePath);
- virtual ~ReLinuxFS();
- // ReFileSystem interface
+ ReLocalFileSytem(const QString& basePath);
+ virtual ~ReLocalFileSytem();
public:
ErrorCode setDirectory(const QString& path);
const QString& directory() const;
- QList<ReFileMetaData*> listInfos(const QStringList& patterns,
- const QStringList& excludePatterns);
+ virtual int listInfos(const ReIncludeExcludeMatcher& matcher,
+ QList<ReFileMetaData*>& list);
protected:
QString m_basePath;
QString m_currentPath;
#ifndef OS_RETRAVERSER_HPP_
#define OS_RETRAVERSER_HPP_
-#include "string/ReMatcher.hpp"
+#include "base/ReMatcher.hpp"
#ifdef __linux__
#include <sys/types.h>
#include <sys/stat.h>
public:
const ReFileTime_t* accessed();
ReFileSize_t fileSize();
- const char* filetimeAsString(ReByteBuffer& buffer);
+ const char* filetimeAsString(QByteArray& buffer);
bool findFirst();
bool findNext();
void freeEntry();
bool isRegular();
const ReFileTime_t* modified();
const char* node() const;
- const char* rightsAsString(ReByteBuffer& buffer, bool numerical,
- int ownerWidth);
+ const char* rightsAsString(QByteArray& buffer, bool numerical,
+ int ownerWidth);
Type_t type();
char typeAsChar();
public:
static const char* filetimeToString(const ReFileTime_t* time,
- ReByteBuffer& buffer);
+ QByteArray& buffer);
static time_t filetimeToTime(const ReFileTime_t* time);
#if defined __WIN32__
- static bool getFileOwner(HANDLE handle, const char* file, ReByteBuffer& name,
+ static bool getFileOwner(HANDLE handle, const char* file, QByteArray& name,
ReLogger* logger = NULL);
static bool getPrivilege(const char* privilege, ReLogger* logger);
#endif
static void timeToFiletime(time_t time, ReFileTime_t& filetime);
public:
- ReByteBuffer m_path;
- ReByteBuffer m_fullName;
+ QByteArray m_path;
+ QByteArray m_fullName;
int m_passNo;
ReLogger* m_logger;
#ifdef __linux__
bool m_getPrivilege;
#endif
};
-class ReDirEntryFilter: public ReSerializable {
+class ReDirEntryFilter {
public:
ReDirEntryFilter();
~ReDirEntryFilter();
public:
virtual void deserialize(const uint8_t*& sequence, size_t& length);
bool match(ReDirStatus_t& entry);
- virtual ReByteBuffer& serialize(ReByteBuffer& sequence);
+ virtual QByteArray& serialize(QByteArray& sequence);
public:
ReDirStatus_t::Type_t m_types;
RePatternList* m_nodePatterns;
public:
ReDirTreeStatistic();
public:
- const char* statisticAsString(ReByteBuffer& buffer, bool append = false,
- const char* formatFiles = "%8d ", const char* formatSizes = "%12.6f",
- const char* formatDirs = "%7d ");
+ const char* statisticAsString(QByteArray& buffer, bool append = false,
+ const char* formatFiles = "%8d ", const char* formatSizes = "%12.6f",
+ const char* formatDirs = "%7d ");
/**
* Resets the counters.
*/
class ReTraverser: public ReDirTreeStatistic {
public:
ReTraverser(const char* base, ReTraceUnit* tracer = NULL, ReLogger* logger =
- NULL);
+ NULL);
virtual ~ReTraverser();
public:
void changeBase(const char* base);
protected:
void destroy();
void freeEntry(int level);
- bool initEntry(const ReByteBuffer& parent, const char* node, int level);
+ bool initEntry(const QByteArray& parent, const char* node, int level);
/**
* Tests whether a directory should be processed.
* @param node the base name of the subdir
int m_minLevel;
int m_maxLevel;
int m_level;
- ReByteBuffer m_base;
+ QByteArray m_base;
ReDirStatus_t* m_dirs[MAX_ENTRY_STACK_DEPTH];
/// each directory will be passed twice: for all files + for directories only
/// 1: depth first 2: breadth first
#ifndef OS_REOS_HPP_
#define OS_REOS_HPP_
-
+#ifndef REBASE_HPP
+#include "base/rebase.hpp"
+#endif
#if defined __linux__
#include "unistd.h"
#include <dirent.h>
#error "unknown os"
#endif
+#if defined __linux__
+typedef struct timespec ReFileTime_t;
+typedef __off_t ReFileSize_t;
+#elif defined __WIN32__
+typedef FILETIME ReFileTime_t;
+typedef int64_t ReFileSize_t;
+#endif
/** Returns whether a time is greater (younger) than another.
* @param time1 first operand
* @param time2 second operand
|| (time1.tv_sec == time2.tv_sec && time1.tv_nsec > time2.tv_nsec);
#else
return time1.dwHighDateTime > time2.dwHighDateTime
- || (time1.dwHighDateTime == time2.dwHighDateTime
- && time1.dwLowDateTime > time2.dwLowDateTime);
+ || (time1.dwHighDateTime == time2.dwHighDateTime
+ && time1.dwLowDateTime > time2.dwLowDateTime);
#endif
}
-#include "os/ReTraverser.hpp"
-#include "os/ReDirTools.hpp"
-#include "net/renet.hpp"
-#include "os/ReRemoteDir.hpp"
#include "os/ReFileSystem.hpp"
#endif /* OS_REOS_HPP_ */