Path: utzoo!attcan!uunet!wuarchive!usc!ucsd!sdd.hp.com!apollo!apollo.hp.com!geiser From: geiser@apollo.HP.COM (Wayne Geiser) Newsgroups: comp.sys.ibm.pc.programmer Subject: Re: splitting up filename components Keywords: FSplit Message-ID: <4ab39622.20b6d@apollo.HP.COM> Date: 30 May 90 13:19:00 GMT References: <4173@uwm.edu> Sender: root@apollo.HP.COM Reply-To: geiser@apollo.HP.COM (Wayne Geiser) Distribution: na Organization: Hewlett-Packard Apollo Division - Chelmsford, MA Lines: 32 In article <4173@uwm.edu>, chad@csd4.csd.uwm.edu (D. Chadwick Gibbons) writes: |> |> Take, for example, the problem of a program which accepts |> a file specification as one of its parameters. The file specification |> does not necessarally have to include the current directory. If |> so, using DOS's find-first/next routines will determine if file |> exists, but does not give a true file name. |> |> In Turbo Pascal, the FSplit takes as an argument a file |> path and will return the three components of this path: the |> directory, file name, and file extension. Does such a routine |> exist in MSC? The run-time library routines do not appear to have |> such a routine. What about a built-in DOS function? Again, I have |> checked several sources of documentation, and none appeared to have |> such a routine listed. I'm sure I could easily scan the path string |> for the arguments I need and build my own routine, but I would |> prefer to use any existing routines, in order to keep my code size |> down to a minimum. The runtime library does, indeed, have such a beast (At least my version 5.0 library does). The function that will do what you want is _splitpath and its signature is: void _splitpath(char *path, char *drive, char *dir, char *fname, char *ext) See your Microsoft documentation for more information. Wayne Geiser Apollo Computer, Inc. - A subsidiary of Hewlett Packard geiser@apollo.hp.com