Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

Commit

Permalink
Merge branch 'develop' into 'master'
Browse files Browse the repository at this point in the history
Release 1.3.0

See merge request ii887522/nitro!58
  • Loading branch information
ii887522 committed May 25, 2021
2 parents 3607329 + ed7a226 commit 0d8af75
Show file tree
Hide file tree
Showing 20 changed files with 133 additions and 2 deletions.
20 changes: 19 additions & 1 deletion nitro/nitro.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,24 @@
<ClCompile Include="src\test\Reactive\UnaryReactive.test.cpp" />
<ClCompile Include="src\test\Struct\Vector.test.cpp" />
</ItemGroup>
<ItemGroup>
<Text Include="res\test\c\a.txt" />
<Text Include="res\test\e\a.txt" />
<Text Include="res\test\f\a.txt" />
<Text Include="res\test\f\b.txt" />
<Text Include="res\test\h\a.txt" />
<Text Include="res\test\i\a.txt" />
<Text Include="res\test\i\b.txt" />
</ItemGroup>
<ItemGroup>
<Image Include="res\test\d\0.png" />
<Image Include="res\test\e\0.png" />
<Image Include="res\test\g\0.png" />
<Image Include="res\test\g\1.png" />
<Image Include="res\test\h\0.png" />
<Image Include="res\test\h\1.png" />
<Image Include="res\test\i\0.PNG" />
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
Expand Down Expand Up @@ -175,7 +193,7 @@
<ClCompile>
<WarningLevel>Level4</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>TEST;LINEAR_ALLOCATOR;LONG_TERM_ALLOCATOR_SIZE=16384u;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>TEST;LINEAR_ALLOCATOR;LONG_TERM_ALLOCATOR_SIZE=32768u;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpplatest</LanguageStandard>
<LanguageStandard_C>stdc17</LanguageStandard_C>
Expand Down
70 changes: 70 additions & 0 deletions nitro/nitro.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,30 @@
<Filter Include="Source Files\Functions">
<UniqueIdentifier>{92726427-7da4-410e-aed0-fd3baf3e765e}</UniqueIdentifier>
</Filter>
<Filter Include="Test Resource Files">
<UniqueIdentifier>{16b00558-22b0-4075-9661-c3cafc92529f}</UniqueIdentifier>
</Filter>
<Filter Include="Test Resource Files\c">
<UniqueIdentifier>{41c109c4-222c-4301-b486-fa7b2763ddc2}</UniqueIdentifier>
</Filter>
<Filter Include="Test Resource Files\d">
<UniqueIdentifier>{1c30cd5a-27a1-40c1-9987-c4cbd823130a}</UniqueIdentifier>
</Filter>
<Filter Include="Test Resource Files\e">
<UniqueIdentifier>{d81ce25b-708f-435b-83e7-4ca29835f6ce}</UniqueIdentifier>
</Filter>
<Filter Include="Test Resource Files\f">
<UniqueIdentifier>{afc50c9c-b1c9-44e1-9fe6-2d4aed9a85fb}</UniqueIdentifier>
</Filter>
<Filter Include="Test Resource Files\g">
<UniqueIdentifier>{4a266acb-8d45-4dc8-8afc-dd948b5f35a8}</UniqueIdentifier>
</Filter>
<Filter Include="Test Resource Files\h">
<UniqueIdentifier>{d285a3ba-e38a-47d7-bde1-89028999adcb}</UniqueIdentifier>
</Filter>
<Filter Include="Test Resource Files\i">
<UniqueIdentifier>{e75b8eca-39bf-4700-978e-fdc3c31d4a78}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\main\Any\AnimatedAny.h">
Expand Down Expand Up @@ -173,4 +197,50 @@
<Filter>Source Files\Functions</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<Text Include="res\test\c\a.txt">
<Filter>Test Resource Files\c</Filter>
</Text>
<Text Include="res\test\e\a.txt">
<Filter>Test Resource Files\e</Filter>
</Text>
<Text Include="res\test\f\a.txt">
<Filter>Test Resource Files\f</Filter>
</Text>
<Text Include="res\test\f\b.txt">
<Filter>Test Resource Files\f</Filter>
</Text>
<Text Include="res\test\h\a.txt">
<Filter>Test Resource Files\h</Filter>
</Text>
<Text Include="res\test\i\a.txt">
<Filter>Test Resource Files\i</Filter>
</Text>
<Text Include="res\test\i\b.txt">
<Filter>Test Resource Files\i</Filter>
</Text>
</ItemGroup>
<ItemGroup>
<Image Include="res\test\d\0.png">
<Filter>Test Resource Files\d</Filter>
</Image>
<Image Include="res\test\e\0.png">
<Filter>Test Resource Files\e</Filter>
</Image>
<Image Include="res\test\g\0.png">
<Filter>Test Resource Files\g</Filter>
</Image>
<Image Include="res\test\g\1.png">
<Filter>Test Resource Files\g</Filter>
</Image>
<Image Include="res\test\h\0.png">
<Filter>Test Resource Files\h</Filter>
</Image>
<Image Include="res\test\h\1.png">
<Filter>Test Resource Files\h</Filter>
</Image>
<Image Include="res\test\i\0.PNG">
<Filter>Test Resource Files\i</Filter>
</Image>
</ItemGroup>
</Project>
Empty file added nitro/res/test/c/a.txt
Empty file.
Binary file added nitro/res/test/d/0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added nitro/res/test/e/0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file added nitro/res/test/e/a.txt
Empty file.
Empty file added nitro/res/test/f/a.txt
Empty file.
Empty file added nitro/res/test/f/b.txt
Empty file.
Binary file added nitro/res/test/g/0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added nitro/res/test/g/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added nitro/res/test/h/0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added nitro/res/test/h/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file added nitro/res/test/h/a.txt
Empty file.
Binary file added nitro/res/test/i/0.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file added nitro/res/test/i/a.txt
Empty file.
Empty file added nitro/res/test/i/b.txt
Empty file.
8 changes: 8 additions & 0 deletions nitro/src/main/Functions/fs_ext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using std::string;
using std::filesystem::remove_all;
using std::filesystem::create_directory;
using std::filesystem::directory_iterator;

namespace ii887522::nitro {

Expand All @@ -15,4 +16,11 @@ void emptyDir(const string& path) {
create_directory(path);
}

bool hasFileWithExtension(const string& dirPath, const string& extensionName) {
for (const auto& entry : directory_iterator{ dirPath }) {
if (entry.path().string().ends_with(extensionName)) return true;
}
return false;
}

} // namespace ii887522::nitro
2 changes: 2 additions & 0 deletions nitro/src/main/Functions/fs_ext.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ template <typename T, template <typename> typename U> void write(const string& f
// Param path: it must ends with either '/' or '\\'
void emptyDir(const string& path);

bool hasFileWithExtension(const string& dirPath, const string& extensionName);

} // namespace ii887522::nitro

#endif // NITRO_SRC_MAIN_FUNCTIONS_FS_EXT_H_
33 changes: 33 additions & 0 deletions nitro/src/test/Functions/fs_ext.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,21 @@
#include <cassert>
#include <vector>
#include <fstream>
#include <filesystem>
#include "../../main/Functions/fs_ext.h"
#include "../../main/Struct/Range.h"

using std::vector;
using std::ios;
using std::filesystem::create_directory;
using std::filesystem::remove_all;

namespace ii887522::nitro {

static void init() {
create_directory("res/test/a/");
}

static void testRead() {
try {
read<char, vector>("a");
Expand Down Expand Up @@ -87,9 +94,35 @@ static void testWrite() {
}
}

static void testHasFileWithExtension() {
assert(!hasFileWithExtension("res/test/a/", ".txt"));
assert(hasFileWithExtension("res/test/c/", ".txt"));
assert(!hasFileWithExtension("res/test/d/", ".txt"));
assert(hasFileWithExtension("res/test/e/", ".txt"));
assert(hasFileWithExtension("res/test/f/", ".txt"));
assert(!hasFileWithExtension("res/test/g/", ".txt"));
assert(hasFileWithExtension("res/test/h/", ".txt"));
assert(hasFileWithExtension("res/test/i/", ".txt"));
assert(!hasFileWithExtension("res/test/a/", ".png"));
assert(!hasFileWithExtension("res/test/c/", ".png"));
assert(hasFileWithExtension("res/test/d/", ".png"));
assert(hasFileWithExtension("res/test/e/", ".png"));
assert(!hasFileWithExtension("res/test/f/", ".png"));
assert(hasFileWithExtension("res/test/g/", ".png"));
assert(hasFileWithExtension("res/test/h/", ".png"));
assert(!hasFileWithExtension("res/test/i/", ".png"));
}

static void free() {
remove_all("res/test/a/");
}

void testFsExt() {
init();
testRead();
testWrite();
testHasFileWithExtension();
free();
}

} // namespace ii887522::nitro
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nitro",
"version": "1.2.0",
"version": "1.3.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"
Expand Down

0 comments on commit 0d8af75

Please sign in to comment.