* Writes a string to the ED2KLinks file. * * If errors are detected, it will terminate the program. */
| 261 | * If errors are detected, it will terminate the program. |
| 262 | */ |
| 263 | static void writeLink( const string& uri, const string& config_dir ) |
| 264 | { |
| 265 | // Attempt to lock the ED2KLinks file |
| 266 | static CFileLock lock(GetLinksFilePath(config_dir)); |
| 267 | static std::ofstream file; |
| 268 | |
| 269 | if (!file.is_open()) { |
| 270 | string path = GetLinksFilePath(config_dir); |
| 271 | file.open( path.c_str(), std::ofstream::out | std::ofstream::app ); |
| 272 | |
| 273 | if (!file.is_open()) { |
| 274 | std::cout << "ERROR! Failed to open " << path << " for writing!" << std::endl; |
| 275 | exit(1); |
| 276 | } |
| 277 | } |
| 278 | |
| 279 | file << uri << std::endl; |
| 280 | |
| 281 | std::cout << "Link successfully queued." << std::endl; |
| 282 | } |
| 283 | |
| 284 | |
| 285 | /** |
no test coverage detected