Preparing for 2019r2 new folderitem fails if path contains ":"

macOS 10.11.6, Xojo 2018r3. I am updating an existing application and thought I’d prepare it for 2019r2 while doing so (I am not using 2019r2, because if there’s a problem I read that I can no longer use that project in a previous version).

So I replaced GetFolderItem and GetTrueFolderItem with “new folderitem( path, pathType )”; but was running into multiple problems. One of them was it fails when a path contains a “:” character. It’s a valid path and the file name appears (In Finder) as “Failed / messed up”. However the path shows the name as “Failed : messed up”. With GetTrueFolderItem it works, but I get an UnsupportedFormatException with New Folderitem.

Is this still true of 2019r2 or does it handle these paths better? Like I say, I am reluctant to try it because if I save, my project may not be usable in a previous version.

Yes, this works better in 2019r2. I ran into that because a user had a file with a : in the name. I had a workaround in place for 2019r1 which I had to take out for r2.

Hello, just out of curiosity because I will not move anything to 2019 R2 because I already have too much trouble to start this, but how would my code below to work in 2019 R2 ?

I have to change something because these changes are not becoming clear to me

[code]Dim F as FolderItem

F = getfolderitem("").child(“Data”).child(“Image01.png”)[/code]

I think it would look like this:

[code]Var F As FolderItem

F = ("/Applications/MyApp/Data/“Image01.png”)[/code]

If I am wrong, I would appreciate any suggestions. Tanks !

I suppose you have already tried Folderitem.pathModes.Shell so you could escape the colon with backslash ?

@Michel Bujardet: no, don’t do that. The : makes very odd things. The file really has a : but the Finder shows it with a /. You have to talk to the file with the : and not the /. See <>.

This is relevant:

See the end of the thread.

I verified that while it is possible at the Unix level to create paths and filenames with a colon in them, the Finder does display an error when attempting to validate a name containing a colon.

It is easy to create a file with : in it’s name from the command line, but Finder will display it with a “/” instead. Could be related to AbsolutePath where colon is the path separator.

[code]#This creates a file with colon in it’s name
echo “this is some text” > one:two.txt

#This creates a folder with a colon in its name
mkdir three:four[/code]

The best way to proceed would be to list the folder content to detect filenames and folders with colon in them:

dim s as new shell s.execute "/Mydir/ls" //Use s.result, parse, check for colons

Then use mv to rename either file or folder with a semi colon instead of the colon:

dim s as new shell s.execute("mv ~/three:four ~three;four")

That way you can process from Xojo. Eventually put things back afterward.

[quote=458402:@Michel Bujardet]dim s as new shell
s.execute(“mv ~/three:four ~three;four”)[/quote]

Of course, I typed too fast.

Here is the right code, with the path for both file name:

dim s as new shell s.execute("mv ~/three:four ~/three;four")

Sorry for any confusion here, the file appears as “Myfile / others” in the Finder. In the terminal and nativePath, it shows as " Myfile : others". When I get the name of the folderitem in Xojo it also shows as the Finder.

I was concerned because it appeared that the newer function didn’t work as expected on 2018r3, and wanted to clarify it for 2019r2. @Beatrix Willius says that it does work correctly. So that’s one less thing to worry about when the time comes to move to 2019r2.