MCPcopy Create free account
hub / github.com/SpartanJ/eepp / replaceInFile

Function replaceInFile

src/tools/ecode/globalsearchcontroller.cpp:17–34  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15}
16
17static bool replaceInFile( const std::string& path, const std::string& replaceText,
18 const std::vector<std::pair<Int64, Int64>>& replacements ) {
19 std::string data;
20 if ( !FileSystem::fileGet( path, data ) )
21 return false;
22
23 Int64 diff = 0;
24
25 for ( const auto& range : replacements ) {
26 data.replace( range.first + diff, range.second - range.first, replaceText );
27 diff += replaceText.size() - ( range.second - range.first );
28 }
29
30 if ( !FileSystem::fileWrite( path, (const Uint8*)data.c_str(), data.size() ) )
31 return false;
32
33 return true;
34}
35
36static bool replaceInFile( const std::string& path, const std::vector<std::string>& replaceTexts,
37 const std::vector<std::pair<Int64, Int64>>& replacements ) {

Callers 1

replaceInFilesMethod · 0.85

Calls 3

c_strMethod · 0.80
replaceMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected