| 657 | } |
| 658 | |
| 659 | std::string Path_ReadTextFile( const std::string &strFilename ) |
| 660 | { |
| 661 | // doing it this way seems backwards, but I don't |
| 662 | // see an easy way to do this with C/C++ style IO |
| 663 | // that isn't worse... |
| 664 | int size; |
| 665 | unsigned char* buf = Path_ReadBinaryFile( strFilename, &size ); |
| 666 | if (!buf) |
| 667 | return ""; |
| 668 | |
| 669 | // convert CRLF -> LF |
| 670 | size_t outsize = 1; |
| 671 | for (int i=1; i < size; i++) |
| 672 | { |
| 673 | if (buf[i] == '\n' && buf[i-1] == '\r') // CRLF |
| 674 | buf[outsize-1] = '\n'; // ->LF |
| 675 | else |
| 676 | buf[outsize++] = buf[i]; // just copy |
| 677 | } |
| 678 | |
| 679 | std::string ret((char *)buf, outsize); |
| 680 | delete[] buf; |
| 681 | return ret; |
| 682 | } |
| 683 | |
| 684 | |
| 685 | bool Path_WriteStringToTextFile( const std::string &strFilename, const char *pchData ) |
nothing calls this directly
no test coverage detected