@@ -146,7 +146,7 @@ vector<Signature *> ASiContainer::signatures() const
146146 */
147147void ASiContainer::addDataFile (const string &path, const string &mediaType)
148148{
149- string fileName = File::fileName (path);
149+ auto fileName = File::fileName (path);
150150 addDataFileChecks (fileName, mediaType);
151151 auto nativePath = File::encodeName (path);
152152 auto size = File::fileSize (nativePath);
@@ -162,8 +162,8 @@ void ASiContainer::addDataFile(const string &path, const string &mediaType)
162162 *data << is->rdbuf ();
163163 is = std::move (data);
164164 }
165- d->properties [fileName] = { appInfo (), File::modifiedTime (path), size };
166- d->documents .push_back (new DataFilePrivate (std::move (is), std::move (fileName), mediaType));
165+ d->properties [string ( fileName) ] = { appInfo (), File::modifiedTime (path), size };
166+ d->documents .push_back (new DataFilePrivate (std::move (is), string (fileName), mediaType));
167167}
168168
169169void ASiContainer::addDataFile (unique_ptr<istream> is, const string &fileName, const string &mediaType)
@@ -197,15 +197,15 @@ void ASiContainer::validateDataFilePath(string_view fileName)
197197 }
198198}
199199
200- void ASiContainer::addDataFileChecks (const string & fileName, const string &mediaType)
200+ void ASiContainer::addDataFileChecks (string_view fileName, const string &mediaType)
201201{
202202 if (!d->signatures .empty ())
203203 THROW (" Can not add document to container which has signatures, remove all signatures before adding new document." );
204204 if (fileName == " mimetype" )
205205 THROW (" mimetype is reserved file." );
206206 validateDataFileName (fileName);
207207 if (any_of (d->documents .cbegin (), d->documents .cend (), [&](DataFile *file) { return fileName == file->fileName (); }))
208- THROW (" Document with same file name '%s' already exists." , fileName. c_str ( ));
208+ THROW (" Document with same file name '%.* s' already exists." , STR_VIEW_FMT (fileName ));
209209 if (mediaType.find (' /' ) == string::npos)
210210 THROW (" MediaType does not meet format requirements (RFC2045, section 5.1) '%s'." , mediaType.c_str ());
211211}
0 commit comments