EDIT: In the orignal version of my post, i wrote about zero-terminated strings with a zero byte being the zero/NUL terminator. Considering we are dealing with wchar_t here, this is entirely incorrect. Instead of "zero byte", i should have more accurately said "NUL character" (because one NUL character in wchar_t type is actually two zero bytes in itself, not just a single zero byte).
First, check the return value of the function. It should hopefully give you some clues about the problem.
Aside from that, i see at least two problems with your code (each of which might or might not contribute to the issue you are having).
1. Pay attention to the documentation in the wcx / packer plug-in guide, especially what it says about the AddList parameter. Note that AddList is a
list of file names. It is not just a single zero/NUL-terminated string, but a sequence of zero/NUL-terminated strings, with the end of the list indicated by an additional NUL character. In other words, the AddList parameter needs to end with two NUL characters, not just with a single NUL character. Simply using string copy functions like you did will _only_ make sure that a single NUL character is terminating the AddList parameter. Unless you fully initialize the array used for addList with zero bytes / NUL characters, you will have to "manually" add the second, final NUL character to the addList parameter. (You might also have had pure luck during your tries and debugging session where the array was always filled with zero bytes no matter what, and there is still another cause for your problem somewhere. But hey, do you like to rely on chance in your programming endeavors?)
Fortunately, initializing this array fully with zero bytes / NUL characters is rather easy. I don't know why you are trying to initialize the arrays with ".\", but this does not enforce the rest of the array being fully zero-byte initialized (all array positions behind the ".\" with NUL character could remain uninitialized or initialized with a byte pattern different from NUL charactgers, depending on compiler and/or C++ runtime behavior, and other system/environmental factors). Unless you are using a compiler from the iron age, try to initialize it like this (empty-bracket aggregate initializer):
Code: Select all
static wchar_t addList[MAX_PATH] = { };
2. I assume the full path of the file you are trying to pack is "C:\list.txt", and i am not sure using "C:" instead of "C:\" for SrcPath will work reliably. "C:" normally does NOT specify the root directory of C:. It specifies the current working directory last active for this drive with respect to the current process (which may or may not happen to be the root directory). But how this parameter is actually processed and interpreted here probably depends to a great deal on the packer plug-in itself, so it might or it might not be a problem with the specific packer-plugin you are testing with. But all bets are off how other packer plug-ins (or a different version of the same packer plug-in) will treat a srcPath like "C:"...