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

2011-10-30 21:20
chatGPZ

Registered: Dec 2001
Posts: 11386
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.
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: 2980
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: 11386
"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: 1078
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: 1078
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: 11386
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: 3194
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
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
rexbeng
Jetboy/Elysium
Jason/Antic
krissz
REBEL 1/HF
Retroluzzer/Quantum
zscs
Act-Otl/Outlaws
Guests online: 94
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Mojo  (9.7)
4 Coma Light 13  (9.6)
5 Edge of Disgrace  (9.6)
6 What Is The Matrix 2  (9.6)
7 The Demo Coder  (9.6)
8 Uncensored  (9.6)
9 Comaland 100%  (9.6)
10 Wonderland XIV  (9.6)
Top onefile Demos
1 No Listen  (9.6)
2 Layers  (9.6)
3 Cubic Dream  (9.6)
4 Party Elk 2  (9.6)
5 Copper Booze  (9.6)
6 Dawnfall V1.1  (9.5)
7 Rainbow Connection  (9.5)
8 Onscreen 5k  (9.5)
9 Morph  (9.5)
10 Libertongo  (9.5)
Top Groups
1 Performers  (9.3)
2 Booze Design  (9.3)
3 Oxyron  (9.3)
4 Triad  (9.3)
5 Censor Design  (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.068 sec.