From b26c78a33b49998c50c497474f56e701b2469080 Mon Sep 17 00:00:00 2001 From: Chi Min Yong Date: Wed, 19 May 2021 20:37:38 +0800 Subject: [PATCH 1/2] Support clearing directory --- nitro/nitro.vcxproj | 1 + nitro/nitro.vcxproj.filters | 18 ++++++++++++------ nitro/src/main/Functions/fs_ext.cpp | 18 ++++++++++++++++++ nitro/src/main/Functions/fs_ext.h | 3 +++ nitro/src/test/Functions/fs_ext.test.cpp | 10 ++++++---- 5 files changed, 40 insertions(+), 10 deletions(-) create mode 100644 nitro/src/main/Functions/fs_ext.cpp diff --git a/nitro/nitro.vcxproj b/nitro/nitro.vcxproj index 276a432..d847cff 100644 --- a/nitro/nitro.vcxproj +++ b/nitro/nitro.vcxproj @@ -52,6 +52,7 @@ + diff --git a/nitro/nitro.vcxproj.filters b/nitro/nitro.vcxproj.filters index 78d1b0e..c49f927 100644 --- a/nitro/nitro.vcxproj.filters +++ b/nitro/nitro.vcxproj.filters @@ -54,6 +54,9 @@ {32fab255-14c2-421b-b489-35537f8e9d5e} + + {92726427-7da4-410e-aed0-fd3baf3e765e} + @@ -151,12 +154,6 @@ Header Files\Allocator - - Source Files - - - Source Files - Test Source Files\Functions @@ -166,5 +163,14 @@ Test Source Files\Functions + + Source Files\Functions + + + Source Files\Functions + + + Source Files\Functions + \ No newline at end of file diff --git a/nitro/src/main/Functions/fs_ext.cpp b/nitro/src/main/Functions/fs_ext.cpp new file mode 100644 index 0000000..fc4393c --- /dev/null +++ b/nitro/src/main/Functions/fs_ext.cpp @@ -0,0 +1,18 @@ +// Copyright ii887522 + +#include "fs_ext.h" // NOLINT(build/include_subdir) +#include +#include + +using std::string; +using std::filesystem::remove_all; +using std::filesystem::create_directory; + +namespace ii887522::nitro { + +void emptyDir(const string& path) { + remove_all(path); + create_directory(path); +} + +} // namespace ii887522::nitro diff --git a/nitro/src/main/Functions/fs_ext.h b/nitro/src/main/Functions/fs_ext.h index 3bfd529..d740ecf 100644 --- a/nitro/src/main/Functions/fs_ext.h +++ b/nitro/src/main/Functions/fs_ext.h @@ -30,6 +30,9 @@ template typename U> void write(const string& f file.close(); } +// Param path: it must ends with either '/' or '\\' +void emptyDir(const string& path); + } // namespace ii887522::nitro #endif // NITRO_SRC_MAIN_FUNCTIONS_FS_EXT_H_ diff --git a/nitro/src/test/Functions/fs_ext.test.cpp b/nitro/src/test/Functions/fs_ext.test.cpp index f5fe291..635d66d 100644 --- a/nitro/src/test/Functions/fs_ext.test.cpp +++ b/nitro/src/test/Functions/fs_ext.test.cpp @@ -21,16 +21,18 @@ static void testRead() { assert((read("res/test/a.dat").size() == 0u)); { const vector str{ read("res/test/b.dat") }; - assert(str.size() == 2u); + assert(str.size() == 3u); assert(str[0u] == 'a'); - assert(str[1u] == '\n'); + assert(str[1u] == '\r'); + assert(str[2u] == '\n'); } { const vector str{ read("res/test/c.dat") }; - assert(str.size() == 3u); + assert(str.size() == 4u); assert(str[0u] == 'a'); assert(str[1u] == 'b'); - assert(str[2u] == '\n'); + assert(str[2u] == '\r'); + assert(str[3u] == '\n'); } { const vector ns{ read("res/test/d.dat") }; From f42ae046eec96ce44228c3c950346768358be744 Mon Sep 17 00:00:00 2001 From: Chi Min Yong Date: Wed, 19 May 2021 20:43:20 +0800 Subject: [PATCH 2/2] Release 1.2.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3e2e80d..523ae53 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nitro", - "version": "1.1.1", + "version": "1.2.0", "description": "It is a general purpose C++ library that can help developers create various kinds of applications in no time.", "scripts": { "install": "node build.js"