Is there a Windows or C++ library function to break down a Filepath?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ramon F Herrera

    Is there a Windows or C++ library function to break down a Filepath?


    My application receives a filepath as an argument. Obviously, it can
    come in several formats, such as:

    filename.ext

    ..\filename.ext

    ...\..\filename .ext

    this\is_a\relat ive\path\finall y.ext

    C:\fully\qualif ied\path\filena me.ext

    ....and so on.

    In Unix there is a function which will do the right thing in every
    case, splitting the path into a base and a filename.

    Is there such thing, something equivalent in Windows programming?

    TIA,

    -Ramon

  • Ramon F Herrera

    #2
    Re: Is there a Windows or C++ library function to break down a Filepath?

    On Oct 22, 1:38 am, "Alf P. Steinbach" <al...@start.no wrote:
    * Ramon F Herrera:
    >
    >
    >
    My application receives a filepath as an argument. Obviously, it can
    come in several formats, such as:
    >
    filename.ext
    >
    .\filename.ext
    >
    ..\..\filename. ext
    >
    this\is_a\relat ive\path\finall y.ext
    >
    C:\fully\qualif ied\path\filena me.ext
    >
    ...and so on.
    >
    In Unix there is a function which will do the right thing in every
    case, splitting the path into a base and a filename.
    >
    Is there such thing, something equivalent in Windows programming?
    >
    Windows programming is off-topic in clc++.
    >
    Check out the Boost library's general file handling.
    >

    Ooops, I went trigger happy, shot from the hip and didn't even realize
    you actually gave some useful info, Alf.

    Thanks!

    For the record: I am not too fond of the Windows crowd, their ways and
    means, and have tried my best to stay on the side of standards,
    interoperabilit y (i.e., non-Microsoft), IETF, OSS, etc.

    -Ramon


    Comment

    • Andrew

      #3
      Re: Is there a Windows or C++ library function to break down a Filepath?

      On Oct 22, 8:32 am, Ramon F Herrera <ra...@conexus. netwrote:
      My application receives a filepath as an argument. Obviously, it can
      come in several formats, such as:
      >
      filename.ext
      >
      .\filename.ext
      >
      ..\..\filename. ext
      >
      this\is_a\relat ive\path\finall y.ext
      >
      C:\fully\qualif ied\path\filena me.ext
      >
      ...and so on.
      >
      In Unix there is a function which will do the right thing in every
      case, splitting the path into a base and a filename.
      >
      Is there such thing, something equivalent in Windows programming?
      >
      TIA,
      >
      -Ramon

      Look to the Shell Path functions in MSDN.
      One of them is PathFindFileNam e which takes a path and returns the
      filename


      Comment

      • jtorjo2007@yahoo.com

        #4
        Re: Is there a Windows or C++ library function to break down a Filepath?

        On 22 Oct, 08:32, Ramon F Herrera <ra...@conexus. netwrote:
        My application receives a filepath as an argument. Obviously, it can
        come in several formats
        Why don't you use boost::filesyst em library? It's cross-platform.


        Best
        John



        --
        http://John.Torjo.com -- C++ expert
        .... call me only if you want things done right


        Comment

        Working...