Skip to content

Commit 5a7c47d

Browse files
committed
Updated wsjcpp-core and wsjcpp.yml
1 parent 4acfbc9 commit 5a7c47d

File tree

9 files changed

+96
-58
lines changed

9 files changed

+96
-58
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
wsjcpp-arguments
22
tmp/*
33
.vscode/*
4+
.wsjcpp-logs/*
5+
.wsjcpp-cache/*
46

57
# Prerequisites
68
*.d

src.wsjcpp/CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ set (WSJCPP_LIBRARIES "")
1010
set (WSJCPP_INCLUDE_DIRS "")
1111
set (WSJCPP_SOURCES "")
1212

13-
# wsjcpp-core
14-
list (APPEND WSJCPP_INCLUDE_DIRS "./src.wsjcpp/wsjcpp-core")
15-
list (APPEND WSJCPP_SOURCES "./src.wsjcpp/wsjcpp-core/wsjcpp_core.h")
16-
list (APPEND WSJCPP_SOURCES "./src.wsjcpp/wsjcpp-core/wsjcpp_core.cpp")
13+
# wsjcpp/wsjcpp-core
14+
list (APPEND WSJCPP_INCLUDE_DIRS "./src.wsjcpp/wsjcpp_wsjcpp_core")
15+
list (APPEND WSJCPP_SOURCES "./src.wsjcpp/wsjcpp_wsjcpp_core/wsjcpp_core.h")
16+
list (APPEND WSJCPP_SOURCES "./src.wsjcpp/wsjcpp_wsjcpp_core/wsjcpp_core.cpp")

src.wsjcpp/wsjcpp-core/wsjcpp.hold.yml

Lines changed: 0 additions & 38 deletions
This file was deleted.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
wsjcpp_version: v0.0.1
2+
cmake_cxx_standard: 11
3+
cmake_minimum_required: 3.0
4+
5+
name: wsjcpp/wsjcpp-core
6+
version: v0.0.2
7+
description: Basic Utils for wsjcpp
8+
issues: https://github.com/wsjcpp/wsjcpp-core/issues
9+
repositories:
10+
- type: main
11+
url: "https://github.com/wsjcpp/wsjcpp-core"
12+
keywords:
13+
- c++
14+
- wsjcpp
15+
16+
authors:
17+
- name: Evgenii Sopov
18+
19+
20+
required-libraries:
21+
- pthread
22+
23+
distribution:
24+
- source-file: src/wsjcpp_core.cpp
25+
target-file: wsjcpp_core.cpp
26+
sha1: "bede8216bc5aaf105e86a9572c3d9066a71026b7"
27+
type: "source-code"
28+
- source-file: src/wsjcpp_core.h
29+
target-file: wsjcpp_core.h
30+
sha1: "b3d842d01fe13c5463fc3af61c5408ac437c65aa"
31+
type: "source-code"
32+
33+
unit-tests:
34+
folder: unit-tests # default
35+
files:
36+
- unit-tests/src/main.cpp
37+
- unit-tests/src/unit_tests.h
38+
- unit-tests/src/unit_tests.cpp
39+

src.wsjcpp/wsjcpp-core/wsjcpp_core.cpp renamed to src.wsjcpp/wsjcpp_wsjcpp_core/wsjcpp_core.cpp

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,34 @@ std::string WSJCppCore::doNormalizePath(const std::string & sPath) {
9696

9797
// ---------------------------------------------------------------------
9898

99+
std::string WSJCppCore::extractFilename(const std::string &sPath) {
100+
// split path by /
101+
std::vector<std::string> vNames;
102+
std::string s = "";
103+
int nStrLen = sPath.length();
104+
for (int i = 0; i < sPath.length(); i++) {
105+
if (sPath[i] == '/') {
106+
vNames.push_back(s);
107+
s = "";
108+
if (i == nStrLen-1) {
109+
vNames.push_back("");
110+
}
111+
} else {
112+
s += sPath[i];
113+
}
114+
}
115+
if (s != "") {
116+
vNames.push_back(s);
117+
}
118+
std::string sRet;
119+
if (vNames.size() > 0) {
120+
sRet = vNames[vNames.size()-1];
121+
}
122+
return sRet;
123+
}
124+
125+
// ---------------------------------------------------------------------
126+
99127
std::string WSJCppCore::getCurrentDirectory() {
100128
char cwd[PATH_MAX];
101129
if (getcwd(cwd, sizeof(cwd)) == NULL) {
@@ -275,20 +303,20 @@ bool WSJCppCore::makeDir(const std::string &sDirname) {
275303
std::cout << "FAILED create folder " << sDirname << std::endl;
276304
return false;
277305
}
278-
std::cout << "nStatus: " << nStatus << std::endl;
306+
// std::cout << "nStatus: " << nStatus << std::endl;
279307
return true;
280308
}
281309

282310
// ---------------------------------------------------------------------
283311

284312
bool WSJCppCore::writeFile(const std::string &sFilename, const std::string &sContent) {
285313

286-
std::ofstream f(sFilename, std::ifstream::in);
314+
// std::ofstream f(sFilename, std::ifstream::in);
315+
std::ofstream f(sFilename, std::ios::out);
287316
if (!f) {
288-
std::cout << "FAILED could not create file to wtite " << sFilename << std::endl;
317+
WSJCppLog::err("WSJCppCore", "Could not create file to write '" + sFilename + "'");
289318
return false;
290319
}
291-
292320
f << sContent << std::endl;
293321
f.close();
294322
return true;
@@ -492,3 +520,5 @@ void WSJCppLog::add(WSJCppColorModifier &clr, const std::string &sType, const st
492520
logFile << sLogMessage << std::endl;
493521
logFile.close();
494522
}
523+
524+

src.wsjcpp/wsjcpp-core/wsjcpp_core.h renamed to src.wsjcpp/wsjcpp_wsjcpp_core/wsjcpp_core.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ class WSJCppCore {
1818
const std::string &sLibraryNameForExports
1919
);
2020

21-
static std::string doNormalizePath(const std::string & sPath);
21+
static std::string doNormalizePath(const std::string &sPath);
22+
static std::string extractFilename(const std::string &sPath);
2223
static std::string getCurrentDirectory();
2324

2425
static long currentTime_milliseconds();
@@ -95,11 +96,12 @@ class WSJCppLog {
9596
static void ok(const std::string &sTag, const std::string &sMessage);
9697
static void setLogDirectory(const std::string &sDirectoryPath);
9798
static void setPrefixLogFile(const std::string &sPrefixLogFile);
98-
// static nlohmann::json getLastLogs();
9999
static void initGlobalVariables();
100100

101101
private:
102102
static void add(WSJCppColorModifier &clr, const std::string &sType, const std::string &sTag, const std::string &sMessage);
103103
};
104104

105105
#endif // WSJCPP_CORE_H
106+
107+

src/wsjcpp_arguments.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,3 +363,4 @@ std::string WSJCppArguments::help() {
363363
}
364364

365365
// ---------------------------------------------------------------------
366+

src/wsjcpp_arguments.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,3 +116,4 @@ class WSJCppArguments {
116116
// ---------------------------------------------------------------------
117117

118118
#endif // WSJCPP_ARGUMENTS_H
119+

wsjcpp.yml

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
wsjcpp_version: v0.0.1
32
cmake_cxx_standard: 11
43
cmake_minimum_required: 3.0
@@ -21,22 +20,24 @@ authors:
2120
- name: Evgenii Sopov
2221
2322

24-
requirements:
25-
libs:
26-
- pthread
27-
packages:
28-
- name: "wsjcpp/wsjcpp-core"
29-
version: "v0.0.1"
30-
url: "https://github.com/wsjcpp/wsjcpp-core:v0.0.1"
23+
required-libraries:
24+
- pthread
25+
26+
dependencies:
27+
- name: "wsjcpp/wsjcpp-core"
28+
version: "v0.0.2"
29+
url: "https://github.com/wsjcpp/wsjcpp-core:master"
30+
origin: "https://github.com/"
31+
installation-dir: "./src.wsjcpp/wsjcpp_wsjcpp_core"
3132

3233
distribution:
3334
- source-file: src/wsjcpp_arguments.cpp
3435
target-file: wsjcpp_arguments.cpp
35-
sha1: "99c2b2d74c99f5427b28df9e2211545ec0c1c6c2"
36+
sha1: "a6d1156597470cabdf368e5733b75a22d8a7fe1f"
3637
type: "source-code"
3738
- source-file: src/wsjcpp_arguments.h
3839
target-file: wsjcpp_arguments.h
39-
sha1: "7029bc352d471e9aa778573a8aee162f2bd5cf95"
40+
sha1: "cfc5cce21522378a594a25b11ac61d6a4a3f2863"
4041
type: "source-code"
4142

4243
unit-tests:

0 commit comments

Comments
 (0)