In the console "defaults -currentHost read com.apple.screensaver modulePath" produces "/System/Library/Screen Savers/Cosmos.slideSaver" but this code only produces "/System/Library/Screen", cutting off at the space. I can't figure out why this is happening.
Anyone?

That's weird, I copied and pasted you code (everything but the NSString stuff, since it was quicker to just use C and compile via command line), and I got a full result:
/Library/Screen Savers/Fluid.saver

Besides, fgets is supposed to read up to a newline or when it runs out of buffer. You can try first getting rid of the NSString and using printf to make sure it's getting the C string correctly. Afterwards, you might want to try a different constructor. (perhaps try UTF8String rather than CString) If it still doesn't work, try calling printf by getting the C string (via UTF8String) from the NSString to make sure it's being stored correctly.