Thread overview | ||||||||
---|---|---|---|---|---|---|---|---|
|
July 14, 2009 [filesystem::basic_path] How Do I Extract the Folder Name? | ||||
---|---|---|---|---|
| ||||
Hi, Is there a way to get the folder name of a given path? Obviously, if I know that the path is a file name I can just pop(), but if it is a folder name then pop() gives me the folder above it. I think a get_folder() (and is_folder()) is a missing complement to get_ext() and get_file(). Thanks, Adi |
July 14, 2009 Re: [filesystem::basic_path] How Do I Extract the Folder Name? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Adi | "Adi" <adishavit__without_this_part__+web-news@gmail.com> wrote in message news:h3i5e7$2rjr$1@digitalmars.com... > Hi, > > Is there a way to get the folder name of a given path? > Obviously, if I know that the path is a file name I can just pop(), yes >but if it is a folder name then pop() gives me the folder above it. But isn't that appropriate? The folder containing c:\abc\def is c:\abc? Or am I misunderstanding you? > I think a get_folder() (and is_folder()) is a missing complement to get_ext() and get_file(). If it makes sense, I'll happily add it. Just a trifle confused by what you require. (It's early, and I've just done a hard workout, so brain probably not functioning at top speed ;-) |
July 15, 2009 Re: [filesystem::basic_path] How Do I Extract the Folder Name? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Matthew Wilson | Thanks for the prompt reply. Let me rephrase my Q: pop_sep() and pop_ext() do nothing if there is no separator or file extension resp. -- they are idempotent. In the same manner, I'd like a "pop_filename()" that will leave only the folder/directory name. If there was a filename it will be removed, if there wasn't the result will stay the same. This function will also be idempotent. Thanks, Adi Matthew Wilson Wrote: > > "Adi" <adishavit__without_this_part__+web-news@gmail.com> wrote in message news:h3i5e7$2rjr$1@digitalmars.com... > > Hi, > > > > Is there a way to get the folder name of a given path? > > Obviously, if I know that the path is a file name I can just pop(), > > yes > > >but if it is a folder name then pop() gives me the folder above it. > > But isn't that appropriate? The folder containing c:\abc\def is c:\abc? > > Or am I misunderstanding you? > > > I think a get_folder() (and is_folder()) is a missing complement to get_ext() and get_file(). > > If it makes sense, I'll happily add it. Just a trifle confused by what you require. (It's early, and I've just done a hard workout, > so brain probably not functioning at top speed ;-) > > |
July 15, 2009 Re: [filesystem::basic_path] How Do I Extract the Folder Name? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Adi | Adi Wrote:
> Thanks for the prompt reply.
> Let me rephrase my Q:
>
> pop_sep() and pop_ext() do nothing if there is no separator or file extension resp. -- they are idempotent.
>
> In the same manner, I'd like a "pop_filename()" that will leave only the folder/directory name. If there was a filename it will be removed, if there wasn't the result will stay the same. This function will also be idempotent.
Makes sense. I'll check it out
|
July 20, 2009 Re: [filesystem::basic_path] How Do I Extract the Folder Name? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Matt Wilson | Thanks!
Matt Wilson Wrote:
<... snip>
> Makes sense. I'll check it out
|
August 11, 2009 Re: [filesystem::basic_path] How Do I Extract the Folder Name? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Adi | This is now available in the latest beta (alpha 12) of STLSoft 1.10, in the platformstl::basic_path class Let me know how you go Matt "Adi" <adishavit__without_this_part__+web-news@gmail.com> wrote in message news:h41lc6$21ka$1@digitalmars.com... > Thanks! > > Matt Wilson Wrote: > > <... snip> > > > Makes sense. I'll check it out > |
Copyright © 1999-2021 by the D Language Foundation