| 82 | } |
| 83 | |
| 84 | void TarHeader::set_checksum() |
| 85 | // Calculate and store checksum. The method is: |
| 86 | // Set the 8 checksum bytes to spaces |
| 87 | // Sum the 512 bytes of the header, treating each byte as a uint. |
| 88 | // Store the size in the format "000000\0 " where the 0's represent the |
| 89 | // checksum as a zero padded six digit octal number. |
| 90 | { |
| 91 | memset(m_head.h.checksum, ' ', sizeof(m_head.h.checksum)); |
| 92 | unsigned int sum = 0; |
| 93 | for(int ii = 0; ii < sizeof(m_head.c); ii++) { |
| 94 | sum += m_head.c[ii]; |
| 95 | } |
| 96 | snprintf(m_head.h.checksum, sizeof(m_head.h.checksum) - 1, "%06o", sum); |
| 97 | } |
no outgoing calls
no test coverage detected