aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2020-07-04 20:21:45 +0200
committerdec05eba <dec05eba@protonmail.com>2020-07-06 07:39:58 +0200
commitf1c219b6322427fd2d5d97df17fe684fbfe45afa (patch)
tree379da26a9a06144cbe054dd21a465a39f3f17e9c /src/main.cpp
parent444b5725b125e5154a571a1542cbb5a7ca58e29b (diff)
Return a string for a getFileData
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 3d11fd5..0cb55e5 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -793,26 +793,24 @@ static Result<ExecResult> gitInitProject(const FileString &projectPath)
static bool gitIgnoreContainsSibs(const FileString &gitIgnoreFilePath)
{
- Result<StringView> fileContentResult = getFileContent(gitIgnoreFilePath.c_str());
+ Result<std::string> fileContentResult = getFileContent(gitIgnoreFilePath.c_str());
if(!fileContentResult) return false;
- StringView fileContent = fileContentResult.unwrap();
- const char *fileContentEnd = fileContent.data + fileContent.size;
- auto it = std::search(fileContent.data, fileContentEnd, SIBS_GITIGNORE_HEADER.begin(), SIBS_GITIGNORE_HEADER.end());
+ const std::string &fileContent = fileContentResult.unwrap();
+ const char *fileContentEnd = fileContent.data() + fileContent.size();
+ auto it = std::search(fileContent.data(), fileContentEnd, SIBS_GITIGNORE_HEADER.begin(), SIBS_GITIGNORE_HEADER.end());
bool containsSibs = it != fileContentEnd;
- free((void*)fileContent.data);
return containsSibs;
}
static void gitIgnoreAppendSibs(const FileString &gitIgnoreFilePath)
{
- Result<StringView> fileContentResult = getFileContent(gitIgnoreFilePath.c_str());
+ Result<std::string> fileContentResult = getFileContent(gitIgnoreFilePath.c_str());
string fileContentNew;
if(fileContentResult)
{
- StringView fileContent = fileContentResult.unwrap();
- fileContentNew.append(fileContent.data, fileContent.data + fileContent.size);
+ const std::string &fileContent = fileContentResult.unwrap();
+ fileContentNew += fileContent;
fileContentNew += "\n\n";
- free((void*)fileContent.data);
}
fileContentNew += SIBS_GITIGNORE_HEADER;
fileContentNew += "\n";