• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
How to pass filenames to system( ) ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: How to pass filenames to system( ) ?
      • From: Quinn <email@hidden>
  • Next by Date: Re: How to pass filenames to system( ) ?
  • Next by thread: Re: How to pass filenames to system( ) ?
  • Index(es):
    • Date
    • Thread