mirror of
https://github.com/NixOS/nix.git
synced 2025-11-16 15:32:43 +01:00
string2Int(): Return std::optional
This commit is contained in:
parent
29a445840a
commit
6548b89cc4
17 changed files with 82 additions and 69 deletions
|
|
@ -66,8 +66,10 @@ int getSchema(Path schemaPath)
|
|||
int curSchema = 0;
|
||||
if (pathExists(schemaPath)) {
|
||||
string s = readFile(schemaPath);
|
||||
if (!string2Int(s, curSchema))
|
||||
auto n = string2Int<int>(s);
|
||||
if (!n)
|
||||
throw Error("'%1%' is corrupt", schemaPath);
|
||||
curSchema = *n;
|
||||
}
|
||||
return curSchema;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue