Shellpath vs FolderItem.PathTypeShell

The plugin is using fopen to open a FILE. In Xojo the following is done:

dim f, g as FolderItem
f  = GetFolderItem("/Users/anvh/Documents/samples-basic/yard/start.bas", FolderItem.PathTypeShell)

so far so good, the folderitem exists and is not nil. But then getting the shell path from the folderitem:

dim s as string = f.ShellPath

the string returns “/Users/anvh/Documents/samples\-basic/yard/start.bas”. See the difference? This path is incorrect for fopen, which fails to open the file. It is true that

f  = GetFolderItem("/Users/anvh/Documents/samples\\-basic/yard/start.bas", FolderItem.PathTypeShell)

also provides for a non nil folderitem. I am just wondering why f.ShellPath produces escapes for “-” or “&” to name a few; the escape “” is used for " " only, based on my understanding.

The ambiguity is when calling GetFoderItem that can take Shellpaths with or without the escape for non-identifiers, while the returning ShellPath is producing, in my view, escapes for the non-identifiers, which makes fopen to return a nil pointer.

why not use native path?

Yes, I know, it’s the ambiguity of

GetFolderItem("/Users/anvh/Documents/samples\\-basic/yard/start.bas", FolderItem.PathTypeShell)
GetFolderItem("/Users/anvh/Documents/samples-basic/yard/start.bas", FolderItem.PathTypeShell)

The second line is not a ShellPath and yet it gives a valid folderItem. If however

GetFolderItem("/Users/anvh/Documents/samples\\-basic/yard/start.bas", FolderItem.PathTypeNative)
GetFolderItem("/Users/anvh/Documents/samples-basic/yard/start.bas", FolderItem.PathTypeNative)

then the first line here fails, not the second.

It had trip me off, that’s all, chasing an apparent bug that led to this.

One must be wrong
Do you see the difference?

/Users/anvh/Documents/samples\-basic/yard/start.bas (foldername is ‘samples\-basic’)
/Users/anvh/Documents/samples-basic/yard/start.bas (foldername is ‘samples-basic’)

If there are no spaces, shellpath and nativepath are identical

[quote=311201:@Axel Schneider]One must be wrong
Do you see the difference?

/Users/anvh/Documents/samples\-basic/yard/start.bas (foldername is ‘samples\-basic’)
/Users/anvh/Documents/samples-basic/yard/start.bas (foldername is ‘samples-basic’)

If there are no spaces, shellpath and nativepath are identical[/quote]

You haven’t tried it and get it. Changing the folder name to “samples basic” and call

f  = GetFolderItem("/Users/anvh/Documents/samples basic/yard/start.bas", FolderItem.PathTypeShell)		

It is not a shell path. It is a native path, yet the call gives a valid folder item named “start.bas”. The ambiguity is clear, I would think. It holds for a space, it holds for all non-identifiers. If PathTypeNative then there is no ambiguity.

[quote=311204:@Alfred Van Hoek]f = GetFolderItem("/Users/anvh/Documents/samples basic/yard/start.bas", FolderItem.PathTypeShell)

It is not a shell path. It is a native path, yet the call gives a valid folder item named “start.bas”. The ambiguity is clear, I would think. It holds for a space, it holds for all non-identifiers. If PathTypeNative then there is no ambiguity.[/quote]

“/Users/anvh/Documents/samples basic/yard/start.bas” is nativepath

You can show the path

Create a new project

in Window1.Open:

me.AcceptFileDrop("")

in Window1.DropObject:

if obj.FolderItemAvailable then MsgBox (obj.FolderItem.NativePath + EndOfLine + obj.FolderItem.ShellPath) end if

Then drop the file start.bas to the window.