while(dirBuf.name[actSize] != 0 && dirBuf.name[actSize] != 87 && dirBuf.name[actSize] != 32) {
87? What the hell is 87? Wouldn't
while(dirBuf.name[actSize] != 0 && dirBuf.name[actSize] != 'W' && dirBuf.name[actSize] != ' ') {
make more sense?
if(actSize > 0) {
actFilename = (char*) malloc(actSize * sizeof(char));
}
free(actFilename);
Conditionally allocate some memory. Unconditionally free it. Not the best idea you've had today.
The whole jerking around with actSize confuses me. You CAN call malloc() and use actSize+1 as the size argument, and quit f***ing with actSize.
So I suppose something is wrong with my actFilename?
What's wrong is that you keep allocating and freeing memory as though you had several terrabytes to waste. Use a FIXED size array for actFilename. See what that does to your problems.