@@ -149,7 +149,7 @@ vector<Signature *> ASiContainer::signatures() const
149149 */
150150void ASiContainer::addDataFile (const string &path, const string &mediaType)
151151{
152- string fileName = File::fileName (path);
152+ auto fileName = File::fileName (path);
153153 addDataFileChecks (fileName, mediaType);
154154 auto nativePath = File::encodeName (path);
155155 auto size = File::fileSize (nativePath);
@@ -165,8 +165,8 @@ void ASiContainer::addDataFile(const string &path, const string &mediaType)
165165 *data << is->rdbuf ();
166166 is = std::move (data);
167167 }
168- d->properties [fileName] = { appInfo (), File::modifiedTime (path), size };
169- d->documents .push_back (new DataFilePrivate (std::move (is), std::move (fileName), mediaType));
168+ d->properties [string ( fileName) ] = { appInfo (), File::modifiedTime (path), size };
169+ d->documents .push_back (new DataFilePrivate (std::move (is), string (fileName), mediaType));
170170}
171171
172172void ASiContainer::addDataFile (unique_ptr<istream> is, const string &fileName, const string &mediaType)
@@ -177,14 +177,14 @@ void ASiContainer::addDataFile(unique_ptr<istream> is, const string &fileName, c
177177 d->documents .push_back (new DataFilePrivate (std::move (is), fileName, mediaType));
178178}
179179
180- void ASiContainer::addDataFileChecks (const string & fileName, const string &mediaType)
180+ void ASiContainer::addDataFileChecks (string_view fileName, const string &mediaType)
181181{
182182 if (!d->signatures .empty ())
183183 THROW (" Can not add document to container which has signatures, remove all signatures before adding new document." );
184184 if (fileName == " mimetype" )
185185 THROW (" mimetype is reserved file." );
186186 if (any_of (d->documents .cbegin (), d->documents .cend (), [&](DataFile *file) { return fileName == file->fileName (); }))
187- THROW (" Document with same file name '%s' already exists." , fileName. c_str ( ));
187+ THROW (" Document with same file name '%.* s' already exists." , STR_VIEW_FMT (fileName ));
188188 if (mediaType.find (' /' ) == string::npos)
189189 THROW (" MediaType does not meet format requirements (RFC2045, section 5.1) '%s'." , mediaType.c_str ());
190190}
0 commit comments