Simplified some path writes
This commit is contained in:
@@ -238,7 +238,7 @@ namespace lms::zip
|
||||
{
|
||||
assert(_currentEntry != std::cend(_entries));
|
||||
|
||||
std::ifstream ifs{ _currentEntry->filePath.c_str(), std::ios_base::binary };
|
||||
std::ifstream ifs{ _currentEntry->filePath, std::ios_base::binary };
|
||||
if (!ifs)
|
||||
throw FileException{ _currentEntry->filePath, "cannot open file", errno };
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace lms::core
|
||||
{
|
||||
try
|
||||
{
|
||||
_config.readFile(p.string().c_str());
|
||||
_config.readFile(p.c_str());
|
||||
}
|
||||
catch (libconfig::FileIOException& e)
|
||||
{
|
||||
|
||||
@@ -39,13 +39,13 @@ namespace lms
|
||||
Wt::Http::ResponseContinuation* FileResourceHandler::processRequest(const Wt::Http::Request& request, Wt::Http::Response& response)
|
||||
{
|
||||
::uint64_t startByte{ _offset };
|
||||
std::ifstream ifs{ _path.string().c_str(), std::ios::in | std::ios::binary };
|
||||
std::ifstream ifs{ _path, std::ios::in | std::ios::binary };
|
||||
|
||||
if (startByte == 0)
|
||||
{
|
||||
if (!ifs)
|
||||
{
|
||||
LMS_LOG(UTILS, ERROR, "Cannot open file stream for '" << _path.string() << "'");
|
||||
LMS_LOG(UTILS, ERROR, "Cannot open file stream for " << _path);
|
||||
response.setStatus(404);
|
||||
return {};
|
||||
}
|
||||
@@ -54,7 +54,7 @@ namespace lms
|
||||
const ::uint64_t fileSize{ static_cast<::uint64_t>(ifs.tellg()) };
|
||||
ifs.seekg(0, std::ios::beg);
|
||||
|
||||
LMS_LOG(UTILS, DEBUG, "File '" << _path.string() << "', fileSize = " << fileSize);
|
||||
LMS_LOG(UTILS, DEBUG, "File " << _path << ", fileSize = " << fileSize);
|
||||
|
||||
response.addHeader("Accept-Ranges", "bytes");
|
||||
|
||||
@@ -99,7 +99,7 @@ namespace lms
|
||||
}
|
||||
else if (!ifs)
|
||||
{
|
||||
LMS_LOG(UTILS, ERROR, "Cannot reopen file stream for '" << _path.string() << "'");
|
||||
LMS_LOG(UTILS, ERROR, "Cannot reopen file stream for " << _path);
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace lms::core::pathUtils
|
||||
{
|
||||
core::Crc32Calculator crc32;
|
||||
|
||||
std::ifstream ifs{ p.string().c_str(), std::ios_base::binary };
|
||||
std::ifstream ifs{ p, std::ios_base::binary };
|
||||
if (ifs)
|
||||
{
|
||||
do
|
||||
@@ -51,7 +51,7 @@ namespace lms::core::pathUtils
|
||||
}
|
||||
else
|
||||
{
|
||||
LMS_LOG(DBUPDATER, ERROR, "Failed to open file '" << p.string() << "'");
|
||||
LMS_LOG(DBUPDATER, ERROR, "Failed to open file " << p);
|
||||
throw LmsException("Failed to open file '" + p.string() + "'");
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ namespace lms::core::pathUtils
|
||||
{
|
||||
};
|
||||
|
||||
if (stat(file.string().c_str(), &sb) == -1)
|
||||
if (stat(file.c_str(), &sb) == -1)
|
||||
throw LmsException("Failed to get stats on file '" + file.string() + "'");
|
||||
|
||||
return Wt::WDateTime::fromTime_t(sb.st_mtime);
|
||||
@@ -95,7 +95,7 @@ namespace lms::core::pathUtils
|
||||
|
||||
if (std::filesystem::exists(excludePath, ec))
|
||||
{
|
||||
LMS_LOG(DBUPDATER, DEBUG, "Found '" << excludePath.string() << "': skipping directory");
|
||||
LMS_LOG(DBUPDATER, DEBUG, "Found " << excludePath << ": skipping directory");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -135,7 +135,7 @@ namespace lms::core::pathUtils
|
||||
|
||||
bool hasFileAnyExtension(const std::filesystem::path& file, std::span<const std::filesystem::path> supportedExtensions)
|
||||
{
|
||||
const std::filesystem::path extension{ stringUtils::stringToLower(file.extension().string()) };
|
||||
const std::filesystem::path extension{ stringUtils::stringToLower(file.extension().c_str()) };
|
||||
|
||||
return (std::find(std::cbegin(supportedExtensions), std::cend(supportedExtensions), extension) != std::cend(supportedExtensions));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user