| 170 | |
| 171 | |
| 172 | Future<string> sha512(const Path& input) |
| 173 | { |
| 174 | #ifdef __linux__ |
| 175 | const string cmd = "sha512sum"; |
| 176 | vector<string> argv = { |
| 177 | cmd, |
| 178 | input // Input file to compute shasum. |
| 179 | }; |
| 180 | #else |
| 181 | const string cmd = "shasum"; |
| 182 | vector<string> argv = { |
| 183 | cmd, |
| 184 | "-a", "512", // Shasum type. |
| 185 | input // Input file to compute shasum. |
| 186 | }; |
| 187 | #endif // __linux__ |
| 188 | |
| 189 | return launch(cmd, argv) |
| 190 | .then([cmd](const string& output) -> Future<string> { |
| 191 | vector<string> tokens = strings::tokenize(output, " "); |
| 192 | if (tokens.size() < 2) { |
| 193 | return Failure( |
| 194 | "Failed to parse '" + output + "' from '" + cmd + "' command"); |
| 195 | } |
| 196 | |
| 197 | // TODO(jojy): Check the size of tokens[0]. |
| 198 | |
| 199 | return tokens[0]; |
| 200 | }); |
| 201 | } |
| 202 | |
| 203 | |
| 204 | Future<Nothing> gzip(const Path& input) |