Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > Blocks free on Disk
2011-10-30 20:51
lA-sTYLe

Registered: Sep 2003
Posts: 63
Blocks free on Disk

I am searching for a way to detect the free Blocks on a Disk.

Since i need to get that value everytime before i start saving it might happen that this routine needs to be executed 30 times in a save process. So loading the Directory and Parsing for the last line and calculating the Blocks free is way to slow.

Or detecting if there are atleast x Blocks free would help aswell.

Anybody knows a decent way to get the wanted Result ?

Cheers,
Mario

 
... 1 post hidden. Click here to view all posts....
 
2011-10-30 21:39
lA-sTYLe

Registered: Sep 2003
Posts: 63
Quote: load track 18:0 and check the BAM ... will only work on 1541 ofcourse.

however, i would just start saving and add proper error checking after that, you can see "disk full". any imagineable way to find out the number of free blocks is doomed to fail on non 1541 drives or screws up on simple directory manipulations.


thats exactly the problem, i want to be drive independant but still use kernal routines.

I have already installed error checking and could check for error #72 but hope that somebody has an idea to check the free blocks in a decent way.

2011-10-30 23:36
Sorex
Account closed

Registered: Nov 2003
Posts: 43
Like Groepaz wrote, the BAM keeps track of which blocks are being used or not.

But you can mess around with the BAM, and dir file structure.

You could do a verify which rebuilds the BAM based on what's left in the directory or scan/count file blocks but if you have hidden files or non standard file structures files on that disk you will risk overwriting that data.

What's the purpose of this anyway?

why not just prompt with a "insert next disk" when you bump into a "Disk is full" error?

I know it a timeloss if you just wrote 200 blocks at kernal speed and need to do it again because you only had 195 left but it's the easiest method.

You could also start with a fresh 1581 disk ;)
that's 3000-something bytes which should be enough for most "common" tasks
2011-10-31 09:16
Krill

Registered: Apr 2002
Posts: 2839
Just do what Groepaz said. Using plain KERNAL calls is only useful for modern drives which usually have enough space available anyways (it's just too slow on 1541 et al.). You can then detect supported drives and run custom-made fast routines on them.
2011-10-31 10:35
Graham
Account closed

Registered: Dec 2002
Posts: 990
You could read the directory with a filename which is not on the disk, this way you will only get the header/id and the blocks free message.
2011-10-31 13:57
Mace

Registered: May 2002
Posts: 1799
Or you could parse the free blocks once and then calculate and keep tracks of used blocks inside your program.
This, of course, only works when you don't change the floppy between saves.
2011-10-31 15:55
chatGPZ

Registered: Dec 2001
Posts: 11114
"You could read the directory with a filename which is not on the disk, this way you will only get the header/id and the blocks free message."
wont be much faster though... on a 1541 anyway
2011-10-31 17:05
MagerValp

Registered: Dec 2001
Posts: 1055
Quoting Graham
You could read the directory with a filename which is not on the disk, this way you will only get the header/id and the blocks free message.

This is nice, simple, and portable, thumbs up.
2011-10-31 17:20
MagerValp

Registered: Dec 2001
Posts: 1055
Quoting Groepaz
Quoting Graham
You could read the directory with a filename which is not on the disk, this way you will only get the header/id and the blocks free message.

wont be much faster though... on a 1541 anyway

With 144 files in the directory:
@$:flarghleblargh     4.9 seconds
@$                   16.2 seconds

With 8 files in the directory:
@$:flarghleblargh     1.0 seconds
@$                    1.5 seconds

2011-11-01 01:56
chatGPZ

Registered: Dec 2001
Posts: 11114
and now, if you are saving those 30 files at kernal speed, how much of the total time would these 16 seconds be so that it matters ? =P
2011-11-01 02:29
iAN CooG

Registered: May 2002
Posts: 3132
sorry if i sneak in, but load"$:",8 is enough, no need to specify a non existant name =) ":" is already a non existant name/pattern
Previous - 1 | 2 - Next
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
bonefish
tlr
jmin
Guests online: 139
Top Demos
1 Next Level  (9.8)
2 Mojo  (9.7)
3 Coma Light 13  (9.7)
4 Edge of Disgrace  (9.6)
5 Comaland 100%  (9.6)
6 No Bounds  (9.6)
7 Uncensored  (9.6)
8 Wonderland XIV  (9.6)
9 Memento Mori  (9.6)
10 Bromance  (9.5)
Top onefile Demos
1 It's More Fun to Com..  (9.7)
2 Party Elk 2  (9.7)
3 Cubic Dream  (9.6)
4 Copper Booze  (9.5)
5 TRSAC, Gabber & Pebe..  (9.5)
6 Rainbow Connection  (9.5)
7 Onscreen 5k  (9.5)
8 Wafer Demo  (9.5)
9 Dawnfall V1.1  (9.5)
10 Quadrants  (9.5)
Top Groups
1 Oxyron  (9.3)
2 Nostalgia  (9.3)
3 Booze Design  (9.3)
4 Censor Design  (9.3)
5 Crest  (9.3)
Top Coders
1 Axis  (9.8)
2 Graham  (9.8)
3 Lft  (9.8)
4 Crossbow  (9.8)
5 HCL  (9.8)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.063 sec.