MCPcopy Index your code
hub / github.com/ddev/ddev / FgrepStringInFile

Function FgrepStringInFile

pkg/fileutil/files.go:225–232  ·  view source on GitHub ↗

FgrepStringInFile is a small hammer for looking for a literal string in a file. It should only be used against very modest sized files, as the entire file is read into a string.

(fullPath string, needle string)

Source from the content-addressed store, hash-verified

223// It should only be used against very modest sized files, as the entire file is read
224// into a string.
225func FgrepStringInFile(fullPath string, needle string) (bool, error) {
226 fullFileBytes, err := os.ReadFile(fullPath)
227 if err != nil {
228 return false, err
229 }
230 fullFileString := string(fullFileBytes)
231 return strings.Contains(fullFileString, needle), nil
232}
233
234// GrepStringInFile is a small hammer for looking for a regex in a file.
235// It should only be used against very modest sized files, as the entire file is read

Callers 15

TestDdevImportDBFunction · 0.92
TestDdevExportDBFunction · 0.92
createTypo3SettingsFileFunction · 0.92
CreateGitIgnoreFunction · 0.92
TestWriteSettingsFunction · 0.92
TestWriteDrushConfigFunction · 0.92

Calls

no outgoing calls