Re: filenames with spaces

Discussion in 'C++' started by Francesco S. Carta, Aug 30, 2010.

  1. Paul <>, on 30/08/2010 17:06:53, wrote:

    > Hello everyone!
    > I am creating a utility program that loops through a directory and
    > removes files using the c++ remove() function.
    > Now the problem is SOME files contain spaces in their names
    > ie: Lance Armstrong-JTM-020837.jpg
    > So how can i escape the names so remove() will work correctly.


    The std::remove algorithm has nothing to do with your problem.

    Post your code and point out exactly what the issue is. With the amount
    of information you have given it takes a lucky wild guesser or a genius
    to give you a sensible answer - and I am neither of these :)

    --
    FSC - http://userscripts.org/scripts/show/59948
    http://fscode.altervista.org - http://sardinias.com
     
    Francesco S. Carta, Aug 30, 2010
    #1
    1. Advertising

  2. Sherm Pendley <>, on 30/08/2010 13:21:13, wrote:

    > "Francesco S. Carta"<> writes:
    >
    >> Paul<>, on 30/08/2010 17:06:53, wrote:
    >>
    >>> Hello everyone!
    >>> I am creating a utility program that loops through a directory and
    >>> removes files using the c++ remove() function.
    >>> Now the problem is SOME files contain spaces in their names
    >>> ie: Lance Armstrong-JTM-020837.jpg
    >>> So how can i escape the names so remove() will work correctly.

    >>
    >> The std::remove algorithm has nothing to do with your problem.

    >
    > Then why bring it up?
    >
    >> Post your code and point out exactly what the issue is. With the
    >> amount of information you have given it takes a lucky wild guesser or
    >> a genius

    >
    > ... or someone who's also familiar with C functions, and isn't afraid
    > to call them from C++. :)


    Ouch... I just forgot there is a remove() function that deletes files in
    the C heritage... OK, never mind, thanks for the reminder :-(

    --
    FSC - http://userscripts.org/scripts/show/59948
    http://fscode.altervista.org - http://sardinias.com
     
    Francesco S. Carta, Aug 30, 2010
    #2
    1. Advertising

  3. Francesco S. Carta

    Jorgen Grahn Guest

    On Mon, 2010-08-30, Francesco S. Carta wrote:
    > Sherm Pendley <>, on 30/08/2010 13:21:13, wrote:
    >
    >> "Francesco S. Carta"<> writes:
    >>
    >>> Paul<>, on 30/08/2010 17:06:53, wrote:
    >>>
    >>>> Hello everyone!
    >>>> I am creating a utility program that loops through a directory and
    >>>> removes files using the c++ remove() function.
    >>>> Now the problem is SOME files contain spaces in their names
    >>>> ie: Lance Armstrong-JTM-020837.jpg
    >>>> So how can i escape the names so remove() will work correctly.
    >>>
    >>> The std::remove algorithm has nothing to do with your problem.

    >>
    >> Then why bring it up?
    >>
    >>> Post your code and point out exactly what the issue is. With the
    >>> amount of information you have given it takes a lucky wild guesser or
    >>> a genius

    >>
    >> ... or someone who's also familiar with C functions, and isn't afraid
    >> to call them from C++. :)

    >
    > Ouch... I just forgot there is a remove() function that deletes files in
    > the C heritage... OK, never mind, thanks for the reminder :-(


    It was complete news for me too, even though it has been in C since
    C89 at least!

    I think many of us go "oh, that area isn't well covered by the
    standard library" and immediately reach for the OS-specific functions.
    In this case, I'd have used Unix's unlink(2).

    /Jorgen

    --
    // Jorgen Grahn <grahn@ Oo o. . .
    \X/ snipabacken.se> O o .
     
    Jorgen Grahn, Aug 31, 2010
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Scott Allen
    Replies:
    3
    Views:
    2,621
    Scott Allen
    Aug 23, 2004
  2. Edison Carter
    Replies:
    1
    Views:
    468
    brucie
    Sep 30, 2003
  3. B.J.
    Replies:
    4
    Views:
    767
    Toby Inkster
    Apr 23, 2005
  4. hokiegal99
    Replies:
    9
    Views:
    568
    Bengt Richter
    Jul 14, 2003
  5. tubby tudor
    Replies:
    0
    Views:
    390
    tubby tudor
    Jul 13, 2003
Loading...

Share This Page