| 50 | } |
| 51 | |
| 52 | std::string cmFileLockResult::GetOutputMessage() const |
| 53 | { |
| 54 | switch (this->Type) { |
| 55 | case OK: |
| 56 | return "0"; |
| 57 | case SYSTEM: |
| 58 | #if defined(_WIN32) |
| 59 | { |
| 60 | # define WINMSG_BUF_LEN (1024) |
| 61 | char winmsg[WINMSG_BUF_LEN]; |
| 62 | DWORD flags = FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS; |
| 63 | if (FormatMessageA(flags, nullptr, this->ErrorValue, |
| 64 | MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), |
| 65 | (LPSTR)winmsg, WINMSG_BUF_LEN, nullptr)) { |
| 66 | std::string const message = winmsg; |
| 67 | return message; |
| 68 | } else { |
| 69 | return "Internal error (FormatMessageA failed)"; |
| 70 | } |
| 71 | } |
| 72 | #else |
| 73 | return strerror(this->ErrorValue); |
| 74 | #endif |
| 75 | case TIMEOUT: |
| 76 | return "Timeout reached"; |
| 77 | case ALREADY_LOCKED: |
| 78 | return "File already locked"; |
| 79 | case NO_FUNCTION: |
| 80 | return "'GUARD FUNCTION' not used in function definition"; |
| 81 | case INTERNAL: |
| 82 | default: |
| 83 | return "Internal error"; |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | cmFileLockResult::cmFileLockResult(ErrorType typeValue, Error errorValue) |
| 88 | : Type(typeValue) |
no outgoing calls
no test coverage detected