[ https://issues.apache.org/jira/browse/MINIFICPP-297?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16251555#comment-16251555 ]
ASF GitHub Bot commented on MINIFICPP-297: ------------------------------------------ Github user phrocker commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/181#discussion_r150867403 --- Diff: libminifi/include/utils/file/FileManager.h --- @@ -0,0 +1,113 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef LIBMINIFI_INCLUDE_UTILS_FILEMANAGER_H_ +#define LIBMINIFI_INCLUDE_UTILS_FILEMANAGER_H_ + +#ifdef BOOST_VERSION +#include <boost/filesystem.hpp> +#else +#include <cstdlib> +#endif +#include <cstdio> +#include <unistd.h> +#include <fcntl.h> +#include "io/validation.h" +#include "utils/Id.h" +#include "utils/StringUtils.h" +#ifdef WIN32 +#define stat _stat +#endif + +namespace org { +namespace apache { +namespace nifi { +namespace minifi { +namespace utils { +namespace file { + +/** + * Simple implementation of simple file manager utilities. + * + * unique_file is not a static implementation so that we can support scope driven temporary files. + */ +class FileManager { + public: + + FileManager() { + } + + ~FileManager() { + for (auto file : unique_files_) { + unlink(file.c_str()); + } + } + std::string unique_file(const std::string &location, bool keep = false) { + + if (!IsNullOrEmpty(location)) { + std::string file_name = location + "/" + non_repeating_string_generator_.generate(); + while (!verify_not_exist(file_name)) { + file_name = location + "/" + non_repeating_string_generator_.generate(); + } + if (!keep) + unique_files_.push_back(file_name); --- End diff -- These are temporary files. If we don't specify keep it will be a temp file. > Remove Boost as a dependency for archive extensions > --------------------------------------------------- > > Key: MINIFICPP-297 > URL: https://issues.apache.org/jira/browse/MINIFICPP-297 > Project: NiFi MiNiFi C++ > Issue Type: Bug > Reporter: marco polo > Assignee: marco polo > Fix For: 0.3.0 > > -- This message was sent by Atlassian JIRA (v6.4.14#64029)