I am working on a cygwin compiled C program (GCC) that calls robocopy using the system() call function. Everything is working fine, except the return codes from the system call of the robocopy command have me confused.
Code:
sprintf(robocopyCallStr, "robocopy %s %s %s %s ", soureStr, DestStr,
optionsStr, excludeStr);
returnValue = system(robocopyCallStr);
if (returnValue.......
According to robocopy documentation (ROBOCOPY Exit Codes), the return from robocopy is a bitmap with second least significant bit (0x2) being set for extra files. When I test this functionality by forcing an "extra files" condition, it returns 512 - the 10th least significant bit. This appears to be the bitmap shifted left by 8 bits, or one byte.
The documented return for "some files copied" should be the least significant bit set to 1 (0x1). When I test this functionality by forcing a "some files copied" condition, it returns 256 - the 9th least significant bit. Again, this appears to be the bitmap shifted left by 8 bits, or one byte.
Testing for "some files copied" and "extra files" returns 768 - the 9th and 10th least significant bits. Again, this appears to be the bitmap shifted left by 8 bits, or one byte.
While I guess I could just code for the 256, 512, etc., I would really like to understand what is happening to be sure I am not hiding a problem down the road.
Can anyone please enlighten me on what is happening here?