IOException (2) at TextInputStream.Open

and I do not know what to do…

I have 21 text files and this one I just add minutes ago. It looks nice, I am able to read it with TextEdit / look at it with QuickView.

The project runs fine when I remove it, generate an exception when I move the file back.

There is nothing like an error list in the documentation. The file was plain text, but was meant to have html tags, so I add them, but Xojo only open the file, read its contents and put it in the html data it generate… and this happens before read…

I quit TextEdit, run the project (in case that file is set to Read / owned by TextEdit, but same crash…

Incredible… I removed some characters from the file name and now it stop crashing ! (nothing fancy, only ASCII characters, and below the max # of characters - of course ! -).

I do not get it !

Apparently, any file using the name (below) crash with the IOException:

Mandrake 420r (Chrono 66) (029) - 03b - Resume.txt

The project scans a folder holding 18,816 items (from a master folder).

I moved what was the offending text file, and replaced with one that “works” fine (I copy it from the same master folder, but different origin) and changed its name to the above.

NB: all files in that folder have the same “Prefix”: <Mandrake 420r (Chrono 66) (029) - > and are followed with a page number (é digits, etc. until the file extension (the text after the page number are valid information stored in the file names).

The offending file is a text file. The code to open it is:


Dim Resume_FI  As FolderItem
Dim Resume_TIS As TextInputStream
Dim Resume_Str As String

Try
  Resume_TIS          = TextInputStream.Open(Resume_FI) // IOException
  Resume_TIS.Encoding = Encodings.UTF8
  Resume_Str          = Resume_TIS.ReadAll
  
Catch e As IOException
  MessageBox("Error accessing file " + Resume_FI.Name + ".")
End Try
Resume_TIS.Close

Xojo 2021r2.1
Ventura 13.2.1
MacBook Pro m1

When I set anything as the file name (like <Foo 124 - 03b - Resume.txt>), the process works fine excepted the data are not located at the awaited place (the line after “03 <description_text>”).

Because of the was macOS is nowadays, I seort alphabetically the items found in the folder and so without the proper name, items are displayed in the wrong order.

If this is the code you are really using, you are not setting Resume_FI to anything
So you are opening a nil object

It is related to the file name, but I do not understand why. I renamed the files from that folder (removed what is in parents), run the project and all is correct.

Incredible.

I even checked the file name string value as binary, and everything is ASCII (character values are all below 126; 1 Byte).

Solar Winds ?
Black Magic ?

Works here with 2022r4.1, Catalina. I get I/O error 2 if the file does not exist, otherwise it opens and reads an empty file called:

Mandrake 420r (Chrono 66) (029) - 03b - Resume.txt

on the desktop.

The FolderItem for the file is not Nil, the array used to sort the 40 files is correctly filed with the items names, etc.

As I wrote earlier, the text file can be read, modified, renamed, moved…

External Samsung SSD checked with Disk Util, etc. I even shut down the computer, wait a bit, reboot fire Xojo ONLY, run and get the crash.

I will continue to work on these data and let this folder as is until something else comes or the error clears itself.

Real code and valid Reference (checked in the debugger).

That file holds an information text (explanation about the previous entry, thus the b after the page number).

THe project creates a Table of Contents list with cover (and more images) for each magazine issue.

I have 3 different text files (different file names) loaded using 3 different code base for 3 different uses (add an image on the left pane, and add a larger information after the Table of Contents).

I have another master folder with 29,827 Items, so the number of items (files and folders) does not matters.

When you get the crash, does the File.Exists property tells “true”? Also check IsReadable. Then check all properties of the debugger, in case there’s something you’d not expect. An odd property would lead to understanding the actual problem.

1 Like

INCREDIBLE: File Exists is FALSE !

And I can see the file: it is in front of me.

I renamed the file to and removing “()”…:
Mandrake 420r Chrono 66 029 far larger test - HELL - 03b - Resume.txt
and this works.
() and () in file name are faultive: I removed, add more characters and no crash !

That’s not incredible yet, we may find an explanation later :smiling_face:.

Is the native path as you’d expect?
If you take the native path minus the file name and extension (i.e. the parent folder’s path), go to the Finder, choose “Go to…” (Command-Shift-G) and paste there, does the Finder recognize and go to the folder?

A native path might be too long. How many characters take the native path, including the file?

How are you constructing the FolderItem in the first place?

Iterative using an index (read the whole folder (directory) contents.)

Ok, so the path won’t have a typo. What about the other questions I asked?

The size of the path does not matter since I shortened the file names and it worked + I added far more characters and it works too.

May I suggest there is a defined length that gives the error ?…

Not a fixed one. It could be longer than a given number, but not an exact faulty number.

Can you share the native path here?

Also, the volume where this file is on may have a role (e.g. some file systems won’t support some characters, lengths, etc.).

Mandrake 420r (Chrono 66) (029) - 03b - Resume.txt // crash
Mandrake 420r C hrono 6 6 0 2 9 - 03b - Resume.txt // no crash

Native path:

/Volumes/Samsung Portable SSD T5 Media/Mandrake/Mandrake 420r (Chrono 66) (029) - Les jumeaux de Karana - 2,50 F - 1974-07 - 52 pages - Éditions des Remparts - JJA - Manque 11 pages - /Mandrake 420r (Chrono 66) (029) - Les jumeaux de Karana - 2,50 F - 1974-07 - 52 pages - JJA - Manque 11 pages-/Mandrake 420r (Chrono 66) (029) - 03b - Resume.txt

But it does not crash with a file name far longer than that.

I also checked, I have only one TextInputStream in this Method and I closed it as soon as I read the text file.

What if you replace parenthesis by [ and ]?
Then try replacing them by a natural character (“a”).
With these tests, we’d see whether a filename with the same length and small changes also produce the problem.

I reproduced that path here, and it works (hoping the forum software hasn’t mangled the path you pasted). What format does the file system of the SSD have?

Well, since your issue happens only with a specific file, it’s not something in your code that makes the issue.

Does the Finder says something special about that file, using Get Info? (different permissions than the items around? etc.).

It is not the file that is faultive. I moved it, replaced it with an old one, set the correct name and get the same trouble.

May it be that the file name is blackbooled by the OS ?

The offending file have been created today. most of the of the other files were created earlier… 1 year to 13 years ago…

The project runs fine with these names:

The external SSD is running since… I get the MBP M1 (last year or so).
The file names are entered from the MBP m1 (when renamed; they forgot what the original names were in 2009 for the jpg files; the txt file was created today).

I use MacOS Rename built-in utility (no Copy/Paste multiple times)

Permission do not auto-change (do not change by themselves between two runs IMHO).

Xojo read the file contents (and place it where I want) when it does not crash on the file name.

image

Just wanted to rule out multiple symptoms for this result, that I can’t try here.

Very unlikely. First because Mac OS doesn’t have a list of forbidden names (unlike on Windows: LPT1, CON1, …), second because I can’t find a pattern in your file name that would mean anything problematic.

So, what if you temporarily move one of these other files out and re-create one today with the same name and content? Does it also fail?

Ok, so I’ve the same setup…

I’d still would suggest you to make further tests with the problematic filename. Like removing just one arbitrary character, replacing one character only (03c instead of 03b), replace all digits by a letter, replace “(”, “)” and “-” by a letter etc. and check when Xojo fails/succeeds with the changes.

May sound painful, but it’s not so. The result would lead to when/when it fails.

The troublesome part is before the page number (here “ - 03b”).

These names are OK too:
Mandrake 420 - 03b - Resume.txt
Mandrake 420r [Chrono 66] [029] - 03b - Resume.txt