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 ! -).
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.
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).
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.
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 .
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?
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.).
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.
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.