File pointers in CC65!

Chat about anything CX16 related that doesn't fit elsewhere
rje
Posts: 1263
Joined: Mon Apr 27, 2020 10:00 pm
Location: Dallas Area

File pointers in CC65!

Post by rje »


So for some reason I only now started playing with CC65's file i/o.

And... it looks like it just works.  I haven't tried *real* things yet, but this opens up my horizons.

 

ZeroByte
Posts: 714
Joined: Wed Feb 10, 2021 2:40 pm

File pointers in CC65!

Post by ZeroByte »


R38? SD image or host FS?

I suspect either 38 or 39 will work if using SD.... I'll be dealing with file IO fairly soon myself and any advice you have will be most helpful.

rje
Posts: 1263
Joined: Mon Apr 27, 2020 10:00 pm
Location: Dallas Area

File pointers in CC65!

Post by rje »


R38 appears to work with an SD image.

I'm going to try opendir() to read directory contents next.  

ZeroByte
Posts: 714
Joined: Wed Feb 10, 2021 2:40 pm

File pointers in CC65!

Post by ZeroByte »


I'm going to need to either read a file byte by byte or else just pull pieces in at a time, so if cc65's fread () works right out of the box, that will be quite nice. I presume this code fails when using the host FS?

Greg King
Posts: 162
Joined: Wed Jul 08, 2020 1:14 pm

File pointers in CC65!

Post by Greg King »


Yes, only the load and save functions work on the emulator's filesystem.

Standard I/O and POSIX I/O work on the SD filesystem as the standards say that they should.  However, subdirectories don't exist in CBM DOS.  Therefore, those functions might not work in CMNDR DOS as you would expect.

rje
Posts: 1263
Joined: Mon Apr 27, 2020 10:00 pm
Location: Dallas Area

File pointers in CC65!

Post by rje »


R38

I've just attempted to write a file to the SD image... and I think it works.

Yes, it works.  Just don't mount the image on your computers file system at the same time you're running code on the X16 to modify that image.

 

rje
Posts: 1263
Joined: Mon Apr 27, 2020 10:00 pm
Location: Dallas Area

File pointers in CC65!

Post by rje »



4 hours ago, Greg King said:




Yes, only the load and save functions work on the emulator's filesystem.



Standard I/O and POSIX I/O work on the SD filesystem as the standards say that they should.  However, subdirectories don't exist in CBM DOS.  Therefore, those functions might not work in CMNDR DOS as you would expect.



I will be attempting directory reads next, so I'll find out what happens. 

I know it's no guarantee, but 16DOS knows to at least acknowledge the existence of dirs.

Screen Shot 2021-08-10 at 8.50.05 AM.png

rje
Posts: 1263
Joined: Mon Apr 27, 2020 10:00 pm
Location: Dallas Area

File pointers in CC65!

Post by rje »


How many files can a directory have?  Is it typical for the image filesystem?

I'll go check.

"CBM-DOS for FAT32 SD cards"

Well let's see what FAT32 can handle first.  (268 million files for 32kb clusters).

And now to see if we have any limitations on that.

Scott Robison
Posts: 952
Joined: Fri Mar 19, 2021 9:06 pm

File pointers in CC65!

Post by Scott Robison »


FAT32 has a limit of 65536 files in a given directory, but!

Two are already used for the current and parent (. & ..) entries in subdirectories but not the root.

If a file has a simple 8.3 file name, then it only takes one entry. If a file has a long file name, it takes a variable number of entries (one extra entry per 13 characters in the LFN).

rje
Posts: 1263
Joined: Mon Apr 27, 2020 10:00 pm
Location: Dallas Area

File pointers in CC65!

Post by rje »



45 minutes ago, Scott Robison said:




FAT32 has a limit of 65536 files in a given directory, but!



Two are already used for the current and parent (. & ..) entries in subdirectories but not the root.



If a file has a simple 8.3 file name, then it only takes one entry. If a file has a long file name, it takes a variable number of entries (one extra entry per 13 characters in the LFN).



Thank you for ALL of that.  The 8.3 AND the 2^16 - 3 limits.  That helps me plan.

So let's see.  The filenames I want to use will be larger than 8.3.  Call it two entries.

Maximum files per directory is therefore around 32,700.

Not a problem at all.

Post Reply