Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2007-09

ExtractFilePath and GetAppConfigDir issues

5 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Graeme Geldenhuys

Hi,

I find the following inconsistent and have to constantly check for ending path delimiters because I am never sure which functions include them and which doesn't.

Both the following functions returns a path, yet one includes a trailing path delimiter and the other doesn't! Why can't all functions that return a path include or exclude the trailing path delimiter. A mix of the two is just plain annoying!

GetAppConfigDir(False)
returns: /home/graemeg/.config

ExtractFilePath('/home/graemeg/.config/testing.xml') returns: /home/graemeg/.config/

Why does one have a trailing '/' and the other not? They are both paths!

Regards,
- Graeme -

Reply by email

Graeme Geldenhuys
to Graeme Geldenhuys

Oh, and here is another one!

ExtractFileDir which to me does the exact same thing as ExtractFilePath, but this one has NO ending directory separator.

Graeme.

Graeme Geldenhuys wrote 26 lines
Hi, I find the following inconsistent and have to constantly check for ending path delimiters because I am never sure which functions include them and which doesn't. Both the following functions returns a path, yet one includes a trailing path delimiter and the other doesn't! Why can't all functions that return a path include or exclude the trailing path delimiter. A mix of the two is just plain annoying! GetAppConfigDir(False) returns: /home/graemeg/.config ExtractFilePath('/home/graemeg/.config/testing.xml') returns: /home/graemeg/.config/ Why does one have a trailing '/' and the other not? They are both paths! Regards, - Graeme -

Reply by email

Graeme Geldenhuys
to Graeme Geldenhuys

Umm... This makes me think. Is there maybe some undocumented (I haven't found anything yet) feature that says all functions that end in *Dir will return a directory _without_ a ending directory separator. And all functions that end in *Path will return a directory _with_ a directory separator. :)

Either way I still think - Always include the separator or never include the separator!

Graeme.

Graeme Geldenhuys wrote 37 lines
Oh, and here is another one! ExtractFileDir which to me does the exact same thing as ExtractFilePath, but this one has NO ending directory separator. Graeme. On 12/09/2007, Graeme Geldenhuys wrote: > Hi, > > I find the following inconsistent and have to constantly check for > ending path delimiters because I am never sure which functions include > them and which doesn't. > > > Both the following functions returns a path, yet one includes a > trailing path delimiter and the other doesn't! Why can't all > functions that return a path include or exclude the trailing path > delimiter. A mix of the two is just plain annoying! > > > GetAppConfigDir(False) > returns: /home/graemeg/.config > > ExtractFilePath('/home/graemeg/.config/testing.xml') > returns: /home/graemeg/.config/ > > > Why does one have a trailing '/' and the other not? They are both paths! > > > Regards, > - Graeme - >

Reply by email

Tiziano_mk
to Graeme Geldenhuys
Graeme Geldenhuys wrote
>> >> Why does one have a trailing '/' and the other not? They are both paths! >>

I see it in this way:

dir = the name of a specific directory;
path = the (partial) indication of the road to reach a specific place;

In this way I always know what kind of result I'm working with.

I think this comes from some non documented guideline of Delphi...

tiziano

Reply by email

Graeme Geldenhuys
to Tiziano_mk
Tiziano_mk wrote 8 lines
I see it in this way: dir = the name of a specific directory; path = the (partial) indication of the road to reach a specific place; In this way I always know what kind of result I'm working with.

This is still a bit confusing I think.... :-)

Regards,
- Graeme -

Reply by email