Hi all,
gpc("\Stücklistenpflege\test.txt", "parent"); //-> "Stücklistenpflege" - expected
gpc("Stücklistenpflege\test.txt", "parent"); //-> "Stücklistenpflege" - expected
gpc("\test.txt", "parent"); //-> "" - expected
gpc("test.txt", "parent"); //-> "test.txt" - ???
Is this a bug? I would think so...
Regards, S.
getpathcomponent parent and partial paths
-
autocart
- Posts: 1391
- Joined: 26 Sep 2013 15:22
getpathcomponent parent and partial paths
[AHK] redirecting Windows Explorer to XY, [XYS] Mini Tree with open tabs (cur loc expanded, tab folders highlighted), [AHK] customInlineRenameKeys, [AHK] clipboardHelper_and_XYEscToList
-
admin
- Site Admin
- Posts: 66679
- Joined: 22 May 2004 16:48
- Location: Win8.1, Win10, Win11, all @100%
- Contact:
Re: getpathcomponent parent and partial paths
You would expect ""?
BTW, what would you expect here?
echo gpc("C:", "parent"); //-> ???
echo gpc("C:\", "parent"); //-> ???
BTW, what would you expect here?
echo gpc("C:", "parent"); //-> ???
echo gpc("C:\", "parent"); //-> ???
FAQ | XY News RSS | XY X
-
autocart
- Posts: 1391
- Joined: 26 Sep 2013 15:22
Re: getpathcomponent parent and partial paths
Hi Don,
thx for this good question.
in both cases I would expect
""
as a result.
(As I see, when trying it out with the current version, I do get "C:" in both cases, though.)
thx for this good question.
in both cases I would expect
""
as a result.
(As I see, when trying it out with the current version, I do get "C:" in both cases, though.)
[AHK] redirecting Windows Explorer to XY, [XYS] Mini Tree with open tabs (cur loc expanded, tab folders highlighted), [AHK] customInlineRenameKeys, [AHK] clipboardHelper_and_XYEscToList
-
admin
- Site Admin
- Posts: 66679
- Joined: 22 May 2004 16:48
- Location: Win8.1, Win10, Win11, all @100%
- Contact:
Re: getpathcomponent parent and partial paths
I think both ways could be argued for. But, when I change it now, I would break old code. So IMO it's best to leave it as it is.
FAQ | XY News RSS | XY X
-
LittleBiG
- Posts: 1848
- Joined: 08 Apr 2011 12:57
- Location: Win10x64
Re: getpathcomponent parent and partial paths
So it means "no parent" can be checked only by gpc($path, "parent") == $path instead of gpc($path, "parent") == "". It is strange enough to be worth to mention in the help file in my opinion.

I would be very curious how can be argued for the current way of working, save for breaking old codes.admin wrote:I think both ways could be argued for.
-
admin
- Site Admin
- Posts: 66679
- Joined: 22 May 2004 16:48
- Location: Win8.1, Win10, Win11, all @100%
- Contact:
Re: getpathcomponent parent and partial paths
My idea of parent was to return the next available upper path. If there is none then the item itself is the upmost path and is returned.
(Okay, I'm not convinced myself...)
(Okay, I'm not convinced myself...)
FAQ | XY News RSS | XY X
-
Filehero
- Posts: 2734
- Joined: 27 Feb 2012 18:50
- Location: Windows 11@100%
Re: getpathcomponent parent and partial paths
Yes, by common definition a node without a parent is the root node of any given tree-like structure, isn't it? Hence, I would expect "null" >(aka "") there as well.admin wrote:(Okay, I'm not convinced myself...)
-
admin
- Site Admin
- Posts: 66679
- Joined: 22 May 2004 16:48
- Location: Win8.1, Win10, Win11, all @100%
- Contact:
Re: getpathcomponent parent and partial paths
Convinced. Actually I now see it as a bug that has to be fixed.
FAQ | XY News RSS | XY X
XYplorer Beta Club