Ref T660, fixed and renamed to "getRelativeSubDirectories" plus sample

This commit is contained in:
Klaus Basan
2019-07-11 02:50:12 +02:00
parent d1425f86a3
commit 281fa92e83
5 changed files with 69 additions and 8 deletions

View File

@@ -14,6 +14,7 @@
#include "samplesjson.h"
#include "samplesmetadata.h"
#include "samplesperformance.h"
#include "samplesfile.h"
#include <stdio.h>
#include <QCoreApplication>
@@ -55,9 +56,10 @@ int main(int argc, char *argv[])
qtout << "6f .. string concatenation (+=, arg, ..)" << endl;
qtout << "6g .. const &QString vs. QStringLiteral" << endl;
qtout << "7 .. Algorithms" << endl;
qtout << "8 .. File/Directory" << endl;
qtout << "-----" << endl;
qtout << "x .. Bye" << endl;
QString s = qtin.readLine().toLower().trimmed();
const QString s = qtin.readLine().toLower().trimmed();
if (s.startsWith("1")) { CSamplesJson::samples(); }
else if (s.startsWith("2")) { CSamplesChangeObject::samples(); }
@@ -72,6 +74,7 @@ int main(int argc, char *argv[])
else if (s.startsWith("6f")) { CSamplesPerformance::samplesStringConcat(qtout); }
else if (s.startsWith("6g")) { CSamplesPerformance::samplesStringLiteralVsConstQString(qtout); }
else if (s.startsWith("7")) { CSamplesAlgorithm::samples(); }
else if (s.startsWith("8")) { CSamplesFile::samples(qtout); }
else if (s.startsWith("x")) { break; }
}
while (true);

View File

@@ -0,0 +1,29 @@
/* Copyright (C) 2019
* swift Project Community / Contributors
*
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
* directory of this distribution. No part of swift project, including this file, may be copied, modified, propagated,
* or distributed except according to the terms contained in the LICENSE file.
*/
//! \file
//! \ingroup sampleblackmisc
#include "samplesfile.h"
#include "blackmisc/directoryutils.h"
#include "blackmisc/stringutils.h"
using namespace BlackMisc;
namespace BlackSample
{
int CSamplesFile::samples(QTextStream &out)
{
const QString dir = "R:/temp";
out << "Testing directory search " << dir << endl;
const bool f = CDirectoryUtils::containsFileInDir(dir, "*.air", true);
out << "Found " << boolToYesNo(f) << endl;
return 0;
}
} // namespace

View File

@@ -0,0 +1,28 @@
/* Copyright (C) 2019
* swift Project Community / Contributors
*
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
* directory of this distribution. No part of swift project, including this file, may be copied, modified, propagated,
* or distributed except according to the terms contained in the LICENSE file.
*/
//! \file
//! \ingroup sampleblackmisc
#ifndef BLACKSAMPLE_SAMPLESFILE_H
#define BLACKSAMPLE_SAMPLESFILE_H
#include <QTextStream>
namespace BlackSample
{
//! Samples for file/directory
class CSamplesFile
{
public:
//! Run the samples
static int samples(QTextStream &out);
};
} // namespace
#endif