BasicIo::path() returns const ref
This commit is contained in:
parent
0726104b1a
commit
45300ad667
@ -240,7 +240,7 @@ namespace Exiv2 {
|
||||
comprehensive error messages where only a BasicIo instance is
|
||||
available.
|
||||
*/
|
||||
virtual std::string path() const =0;
|
||||
virtual const std::string& path() const noexcept =0;
|
||||
|
||||
/*!
|
||||
@brief Mark all the bNone blocks to bKnow. This avoids allocating memory
|
||||
@ -472,7 +472,7 @@ namespace Exiv2 {
|
||||
//! Returns true if the file position has reached the end, otherwise false.
|
||||
bool eof() const override;
|
||||
//! Returns the path of the file
|
||||
std::string path() const override;
|
||||
const std::string& path() const noexcept override;
|
||||
|
||||
/*!
|
||||
@brief Mark all the bNone blocks to bKnow. This avoids allocating memory
|
||||
@ -654,7 +654,7 @@ namespace Exiv2 {
|
||||
//!Returns true if the IO position has reached the end, otherwise false.
|
||||
bool eof() const override;
|
||||
//! Returns a dummy path, indicating that memory access is used
|
||||
std::string path() const override;
|
||||
const std::string& path() const noexcept override;
|
||||
|
||||
/*!
|
||||
@brief Mark all the bNone blocks to bKnow. This avoids allocating memory
|
||||
@ -898,7 +898,7 @@ namespace Exiv2 {
|
||||
//!Returns true if the IO position has reached the end, otherwise false.
|
||||
bool eof() const override;
|
||||
//!Returns the URL of the file.
|
||||
std::string path() const override;
|
||||
const std::string& path() const noexcept override;
|
||||
|
||||
/*!
|
||||
@brief Mark all the bNone blocks to bKnow. This avoids allocating memory
|
||||
|
||||
@ -469,10 +469,7 @@ namespace Exiv2 {
|
||||
|
||||
bool statOk = true;
|
||||
mode_t origStMode = 0;
|
||||
std::string spf;
|
||||
char* pf = nullptr;
|
||||
spf = path();
|
||||
pf = const_cast<char*>(spf.c_str());
|
||||
char* pf = const_cast<char*>(path().c_str());
|
||||
|
||||
// Get the permissions of the file, or linked-to file, on platforms which have lstat
|
||||
#ifdef EXV_HAVE_LSTAT
|
||||
@ -720,7 +717,7 @@ namespace Exiv2 {
|
||||
return std::feof(p_->fp_) != 0;
|
||||
}
|
||||
|
||||
std::string FileIo::path() const
|
||||
const std::string& FileIo::path() const noexcept
|
||||
{
|
||||
return p_->path_;
|
||||
}
|
||||
@ -1044,9 +1041,10 @@ namespace Exiv2 {
|
||||
return p_->eof_;
|
||||
}
|
||||
|
||||
std::string MemIo::path() const
|
||||
const std::string& MemIo::path() const noexcept
|
||||
{
|
||||
return "MemIo";
|
||||
static std::string _path{"MemIo"};
|
||||
return _path;
|
||||
}
|
||||
|
||||
void MemIo::populateFakeData() {
|
||||
@ -1116,7 +1114,7 @@ namespace Exiv2 {
|
||||
void XPathIo::transfer(BasicIo& src) {
|
||||
if (isTemp_) {
|
||||
// replace temp path to gent path.
|
||||
std::string currentPath = path();
|
||||
auto& currentPath = path();
|
||||
setPath(ReplaceStringInPlace(currentPath, XPathIo::TEMP_FILE_EXT, XPathIo::GEN_FILE_EXT));
|
||||
// rename the file
|
||||
tempFilePath_ = path();
|
||||
@ -1585,7 +1583,7 @@ namespace Exiv2 {
|
||||
return p_->eof_;
|
||||
}
|
||||
|
||||
std::string RemoteIo::path() const
|
||||
const std::string& RemoteIo::path() const noexcept
|
||||
{
|
||||
return p_->path_;
|
||||
}
|
||||
@ -1989,8 +1987,9 @@ namespace Exiv2 {
|
||||
return file.write(buf.c_data(), buf.size());
|
||||
}
|
||||
|
||||
std::string ReplaceStringInPlace(std::string subject, const std::string& search,
|
||||
const std::string& replace) {
|
||||
/// \todo do it in place!
|
||||
std::string ReplaceStringInPlace(std::string subject, const std::string& search, const std::string& replace)
|
||||
{
|
||||
size_t pos = 0;
|
||||
while((pos = subject.find(search, pos)) != std::string::npos) {
|
||||
subject.replace(pos, search.length(), replace);
|
||||
|
||||
@ -133,7 +133,7 @@ namespace Exiv2 {
|
||||
bool isTgaType(BasicIo& iIo, bool /*advance*/)
|
||||
{
|
||||
// not all TARGA files have a signature string, so first just try to match the file name extension
|
||||
std::string path = iIo.path();
|
||||
const std::string& path = iIo.path();
|
||||
if( path.rfind(".tga") != std::string::npos
|
||||
|| path.rfind(".TGA") != std::string::npos) {
|
||||
return true;
|
||||
|
||||
Binary file not shown.
Loading…
Reference in New Issue
Block a user