Check suffix_len
this should be the correct version
Move newfilename_len to top
remove unused variable
check wchar.h
finally found the terrible bug...