Introduce readText and make stripUTF8BOM private
1 parent 7541430 commit fc93c40c07774884670b9e4ee19b4531a2180b63
@Mathias Lang Mathias Lang authored on 18 Feb 2024
Mathias LANG committed on 22 Feb 2024
Showing 5 changed files
View
2
■■■
source/dub/generators/build.d
const dbPath = pkgCacheDir ~ jsonFileName;
const dbPathStr = dbPath.toNativeString();
Json db;
if (exists(dbPathStr)) {
const text = stripUTF8Bom(cast(string)readFile(dbPath));
const text = readText(dbPath);
db = parseJsonString(text, dbPathStr);
enforce(db.type == Json.Type.array, "Expected a JSON array in " ~ dbPathStr);
}
else {
View
4
source/dub/internal/utils.d
}
 
Json jsonFromFile(NativePath file, bool silent_fail = false) {
if( silent_fail && !existsFile(file) ) return Json.emptyObject;
auto text = stripUTF8Bom(cast(string)readFile(file));
auto text = readText(file);
return parseJsonString(text, file.toNativeString());
}
 
/**
conn.handle.set(CurlOption.netrc, CURL_NETRC_OPTIONAL);
}
}
 
string stripUTF8Bom(string str)
private string stripUTF8Bom(string str)
{
if( str.length >= 3 && str[0 .. 3] == [0xEF, 0xBB, 0xBF] )
return str[3 ..$];
return str;
View
source/dub/internal/vibecompat/core/file.d
View
source/dub/recipe/io.d
View
source/dub/test/base.d