| 937 | |
| 938 | // |
| 939 | std::string |
| 940 | FormatFileName(const std::string & TempDirectory, |
| 941 | const std::string & name, |
| 942 | const std::string & extension, |
| 943 | const int tagID) |
| 944 | { |
| 945 | std::string TempFile = TempDirectory; |
| 946 | |
| 947 | #ifdef _WIN32 |
| 948 | int pid = _getpid(); |
| 949 | #else |
| 950 | int pid = getpid(); |
| 951 | #endif |
| 952 | |
| 953 | std::ostringstream tmp; |
| 954 | |
| 955 | if (!name.empty()) |
| 956 | { |
| 957 | std::string n = name; |
| 958 | // remove invalid characters |
| 959 | n.erase(std::remove_if(n.begin(), n.end(), &IsBadCharacter), n.end()); |
| 960 | |
| 961 | tmp << n << "-" << pid << "-" << tagID; |
| 962 | TempFile = TempFile + tmp.str() + extension; |
| 963 | } |
| 964 | else |
| 965 | { |
| 966 | tmp << "TempFile-" << pid << "-" << tagID; |
| 967 | TempFile = TempFile + tmp.str() + extension; |
| 968 | } |
| 969 | return TempFile; |
| 970 | } |
| 971 | |
| 972 | #if defined(_WIN32) |
| 973 | // |