diff --git a/src/App/VRMLObject.cpp b/src/App/VRMLObject.cpp index 10887abf32..8dd6ae1f2c 100644 --- a/src/App/VRMLObject.cpp +++ b/src/App/VRMLObject.cpp @@ -72,10 +72,11 @@ void VRMLObject::onChanged(const App::Property* prop) // save the relative paths to the resource files in the project file Resources.setSize(Urls.getSize()); const std::vector& urls = Urls.getValues(); - int index=0; - for (std::vector::const_iterator it = urls.begin(); it != urls.end(); ++it, ++index) { - std::string output = getRelativePath(this->vrmlPath, *it); + int index = 0; + for (const auto& it : urls) { + std::string output = getRelativePath(this->vrmlPath, it); Resources.set1Value(index, output); + ++index; } } GeoFeature::onChanged(prop); @@ -109,7 +110,7 @@ std::string VRMLObject::getRelativePath(const std::string& prefix, const std::st return str; } -std::string VRMLObject::fixRelativePath(const std::string& name, const std::string& resource) const +std::string VRMLObject::fixRelativePath(const std::string& name, const std::string& resource) { // the part before the first '/' must match with object's internal name std::string::size_type pos = resource.find('/'); @@ -128,10 +129,13 @@ void VRMLObject::makeDirectories(const std::string& path, const std::string& sub std::string::size_type pos = subdir.find('/'); while (pos != std::string::npos) { std::string sub = subdir.substr(0, pos); - std::string dir = path + "/" + sub; + std::string dir = path; + dir += '/'; + dir += sub; Base::FileInfo fi(dir); - if (!fi.createDirectory()) + if (!fi.createDirectory()) { break; + } pos = subdir.find('/', pos+1); } } diff --git a/src/App/VRMLObject.h b/src/App/VRMLObject.h index 3360e6a9ed..f2f8abf2d4 100644 --- a/src/App/VRMLObject.h +++ b/src/App/VRMLObject.h @@ -63,9 +63,9 @@ protected: void onChanged(const App::Property*) override; private: - std::string getRelativePath(const std::string&, const std::string&) const; - std::string fixRelativePath(const std::string&, const std::string&) const; - void makeDirectories(const std::string&, const std::string&); + std::string getRelativePath(const std::string& prefix, const std::string& resource) const; + static std::string fixRelativePath(const std::string& name, const std::string& resource); + static void makeDirectories(const std::string& path, const std::string& subdir); bool restoreTextureFinished(Base::Reader &reader); void reloadFile();