adamdebreceni commented on a change in pull request #1211: URL: https://github.com/apache/nifi-minifi-cpp/pull/1211#discussion_r749136836
########## File path: libminifi/include/utils/file/FileView.h ########## @@ -0,0 +1,184 @@ +/** + * 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. + */ + +#pragma once + +#include <filesystem> +#include <fstream> +#include <string> +#include <memory> + +#include "utils/gsl.h" +#include "core/logging/LoggerConfiguration.h" + +#ifdef WIN32 +#include <stdio.h> +#include <Windows.h> +#else +#include <sys/mman.h> +#include <fcntl.h> +#include <unistd.h> +#endif + +namespace org::apache::nifi::minifi::utils::file { + +class FileView { + static std::string getLastError() { +#ifdef WIN32 + return std::system_category().message(GetLastError()); +#else + return std::system_category().message(errno); +#endif + } +#ifdef WIN32 + struct FileHandle { Review comment: I took a stab at a custom buffering solution but it quickly felt like reimplementing the paging logic the memory mapping gives us (just less performant) so I would stick with the memory mapped solution regarding including a thirdparty in order to avoid bloat seems nice, but it is harder to modify (fix) and we are at the mercy of the owners for maintenance (in the library you linked the owner commented in one of the issues that they can't work on this project for now), since the current solution is less than 200 lines and essentially a wrapper around platform utils, and is tested on every application start, and is currently used in a single place, I feel like we should wait with replacing it with a thirdparty until we have multiple uses for it and/or more extensive requirements, like specifying offset/size -- 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. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
