arpadboda commented on a change in pull request #674: Minificpp 1007 - ECU C2
integration.
URL: https://github.com/apache/nifi-minifi-cpp/pull/674#discussion_r353283926
##########
File path: nanofi/src/core/file_utils.c
##########
@@ -83,23 +100,62 @@ void remove_directory(const char * dir_path) {
remove_directory(path);
free(path);
}
-
rmdir(dir_path);
+
closedir(d);
}
+#else
+void remove_directory(const char * dir_path) {
+ HANDLE hFind;
+ WIN32_FIND_DATA fd;
+
+ hFind = FindFirstFile(dir_path, &fd);
+ if (hFind == INVALID_HANDLE_VALUE) {
+ return;
+ }
+
+ if (fd.dwFileAttributes != FILE_ATTRIBUTE_DIRECTORY) {
+ DeleteFile(dir_path);
+ FindClose(hFind);
+ return;
+ }
+
+ char * path = concat_path(dir_path, "*");
+ HANDLE hFind1;
+ if ((hFind1 = FindFirstFile(path, &fd)) != INVALID_HANDLE_VALUE) {
+ do {
+ char * entry_name = fd.cFileName;
+ if (!strcmp(entry_name, ".") || !strcmp(entry_name, ".."))
continue;
+ char * entry_path = concat_path(dir_path, entry_name);
+ remove_directory(entry_path);
+ free(entry_path);
+ } while (FindNextFile(hFind1, &fd));
+ }
+ RemoveDirectory(dir_path);
+ FindClose(hFind);
+ FindClose(hFind1);
+ free(path);
+}
+#endif
int make_dir(const char * path) {
if (!path) return -1;
errno = 0;
+#ifdef WIN32
+ int ret = mkdir(path);
+ char path_sep = '\\';
+#else
int ret = mkdir(path,
S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH);
+ char path_sep = '/';
Review comment:
Why don't you simpl use "get_separator()"?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services