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):

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

StartTime:=now;
assignFile(txt,'/mnt/test.txt'); 
{$I-} 
rewrite (txt); 
repeat 
application.processmessages; 
writeln (txt,'I''m so tired ...'); 
io := ioResult; 
// showMessage ('--> '+IntToStr(io)); 
until (io=NoSuchFileErrorCode) or (StartTime+(30*A_Second)<Now);
{$I+}
closeFile(txt);
If io<>0 Then
   DoSomethingAboutError;

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.  


James 

-----Original Message-----
From: fpc-pascal <fpc-pascal-boun...@lists.freepascal.org> On Behalf Of Brian
Sent: Thursday, November 21, 2019 8:55 PM
To: FPC-Pascal users discussions <fpc-pascal@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...

Brian.
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org 
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to