How to pass filenames to system( ) ?
How to pass filenames to system( ) ?
- Subject: How to pass filenames to system( ) ?
- From: Patrick Stadelmann <email@hidden>
- Date: Wed, 03 Mar 2010 09:33:22 +0100
Hi,
I have a question regarding handling of filenames when passing them
to a command using the system() call in a plain old C CLI program.
If I retrieve a filename from the argv list, I can e.g. add a prefix
using sprintf, and pass the new string to fopen( ) to create a new
file. This works even when the filename contains / ` ' \ and non-roman
Unicode characters. I use filename completion in Terminal.app when
running the program to input the path.
Now, the proble is that I need to pass the new name to another CLI tool,
which also handles filenames without problem when used directly. However,
if I simply use sprintf to construct the parameter to pass to system(),
it works for simple filenames, but fails if the name contains spaces,
quotes, etc...
What do I need to do ? Is there a function I need to call to escape
problematic characters in the filename ? Or a doc explaining how to
write such function ?
Thanks,
Patrick
--
Patrick Stadelmann <email@hidden>
--
Patrick Stadelmann <email@hidden>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Filesystem-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden