MCPcopy Create free account
hub / github.com/comaps/comaps / ApplyDiff

Function ApplyDiff

libs/mwm_diff/diff.cpp:128–156  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

126}
127
128DiffApplicationResult ApplyDiff(std::string const & oldMwmPath, std::string const & newMwmPath,
129 std::string const & diffPath, base::Cancellable const & cancellable)
130{
131 try
132 {
133 FileReader oldReader(oldMwmPath);
134 BufferedFileWriter newWriter(newMwmPath);
135 FileReader diffFileReader(diffPath);
136
137 ReaderSource<FileReader> diffFileSource(diffFileReader);
138 auto const version = ReadPrimitiveFromSource<uint32_t>(diffFileSource);
139
140 switch (version)
141 {
142 case VERSION_V0: return ApplyDiffVersion0(oldReader, newWriter, diffFileSource, cancellable);
143 default: LOG(LERROR, ("Unknown version format of mwm diff:", version)); return DiffApplicationResult::Failed;
144 }
145 }
146 catch (Reader::Exception const & e)
147 {
148 LOG(LERROR, ("Could not open file for reading when applying a patch:", e.Msg()));
149 }
150 catch (Writer::Exception const & e)
151 {
152 LOG(LERROR, ("Could not open file for writing when applying a patch:", e.Msg()));
153 }
154
155 return cancellable.IsCancelled() ? DiffApplicationResult::Cancelled : DiffApplicationResult::Failed;
156}
157
158std::string DebugPrint(DiffApplicationResult const & result)
159{

Callers 2

UNIT_TESTFunction · 0.50
mainFunction · 0.50

Calls 2

ApplyDiffVersion0Function · 0.85
IsCancelledMethod · 0.45

Tested by 1

UNIT_TESTFunction · 0.40