[fpc-pascal] Writing to a drive which may be spun down

James Richters james at productionautomation.net
Fri Nov 22 14:38:19 CET 2019

I thought there was a way to figure out if the drive was spun down, perhaps with a S.M.A.R.T command?

I like the idea of using the ioResult, but I would put in a way to exit the loop for ioReults of errors not caused by a spun down drive would report right away and a timeout in case some other condition causes the same error as being spun down, so it's not caught in an infinite loop for errors not caused by the spindown.  Something like this... (Untested):

           A_Day = 1;
         An_Hour = A_Day/24;
        A_Minute = An_Hour/60;
        A_Second = A_Minute/60;

rewrite (txt); 
writeln (txt,'I''m so tired ...'); 
io := ioResult; 
// showMessage ('--> '+IntToStr(io)); 
until (io=NoSuchFileErrorCode) or (StartTime+(30*A_Second)<Now);
If io<>0 Then

It seems strange that this would be an issue at all,  I would think the drive itself would cache any data written to it for long enough to get the drive spun up... seems very short sighted on hard drive design for this to be an issue at all, and even if the drive didn't do this,  it seems like the operating system should take care of it for you.  


-----Original Message-----
From: fpc-pascal <fpc-pascal-bounces at lists.freepascal.org> On Behalf Of Brian
Sent: Thursday, November 21, 2019 8:55 PM
To: FPC-Pascal users discussions <fpc-pascal at lists.freepascal.org>
Subject: Re: [fpc-pascal] Writing to a drive which may be spun down

On 11/21/19 2:38 PM, Winfried Bartnick wrote:


> writeln (txt,'I''m so tired ...');
> closeFile(txt);
> io := ioResult;

Thanks Winni, that sounds the sort of idea I'm looking for...

fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

More information about the fpc-pascal mailing list