4 Original GPL release version 4.12
5 Copyright 1993-2000 Jonathan Potter
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 as published by the Free Software Foundation; either version 2
10 of the License, or (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 All users of Directory Opus 4 (including versions distributed
22 under the GPL) are entitled to upgrade to the latest version of
23 Directory Opus version 5 at a reduced price. Please see
24 http://www.gpsoft.com.au for more information.
26 The release of Directory Opus 4 under the GPL in NO WAY affects
27 the existing commercial status of Directory Opus 5.
31 #include <dos/filehandler.h>
39 void setupchangestate(void)
42 struct IOStdReq
*diskreq
;
45 if (diskreq
=(struct IOStdReq
*)LCreateExtIO(general_port
,sizeof(struct IOStdReq
))) {
46 for (unit
=0;unit
<4;unit
++) {
47 if (!(OpenDevice("trackdisk.device",unit
,(struct IORequest
*)diskreq
,0))) {
48 diskreq
->io_Command
=TD_CHANGESTATE
;
49 DoIO((struct IORequest
*)diskreq
);
50 if (!diskreq
->io_Actual
) disk_change_state
|=1<<unit
;
51 CloseDevice((struct IORequest
*)diskreq
);
54 LDeleteExtIO((struct IORequest
*)diskreq
);
72 STR_DISKINFO_FILESYSTEM
};
77 struct InfoData __aligned infodata
;
78 struct RastPort
*dirp
;
85 int b
,c
,isd
=-1,cx
,cy
,fail
=0,xoffset
,yoffset
,titwidth
;
86 static char disktxt
[11][60],buf
[256],formstr
[80],diskname
[256],dname
[10],buf1
[40];
90 struct Gadget contgad
;
91 char *gad_gads
[2], *uscore
,cont_key
;
93 UBYTE old_change_state
;
96 struct DOpusRemember
*key
=NULL
;
98 if (!path
|| !path
[0]) return;
100 cx
=scr_font
[FONT_REQUEST
]->tf_XSize
;
101 cy
=scr_font
[FONT_REQUEST
]->tf_YSize
;
103 for (i
=0;i
<ITEM_NUM
;i
++) {
107 main_proc
->pr_WindowPtr
=(APTR
)-1;
109 strcpy(diskname
,path
);
110 if (getroot(diskname
,&ds
)) {
111 strcat(diskname
,":");
112 if ((prt
=(struct MsgPort
*)DeviceProc(diskname
))) {
113 if (lock
=Lock(diskname
,ACCESS_READ
)) {
115 get_device_task(lock
,disktxt
[0],prt
);
118 lsprintf(dname
,"DF%ld:",i
);
119 if (Stricmp(disktxt
[0],dname
)==0) {
125 Info(lock
,&infodata
);
127 switch (infodata
.id_DiskType
) {
128 case ID_UNREADABLE_DISK
:
129 strcpy(disktxt
[1],globstring
[STR_UNREADABLE_DISK
]);
131 case ID_NOT_REALLY_DOS
:
132 strcpy(disktxt
[1],globstring
[STR_NOT_A_DOS_DISK
]);
134 case ID_KICKSTART_DISK
:
135 strcpy(disktxt
[1],globstring
[STR_KICKSTART_DISK
]);
139 strcpy(disktxt
[1],diskname
);
140 disktxt
[1][(strlen(disktxt
[1])-1)]=0;
142 a
= i64_uumul( infodata
.id_NumBlocks
, infodata
.id_BytesPerBlock
);
143 i64_itoa( a
, buf1
, 40 );
145 a
=((long long)infodata
.id_NumBlocks
)*infodata
.id_BytesPerBlock
;
146 sprintf(buf1
,"%qd",a
);
149 lsprintf(buf
,"%ld",infodata
.id_NumBlocks
);
150 lsprintf(formstr
,"%%%lds %s; %%%ldld %s; %%s",
151 b
,globstring
[STR_DISKINFO_BYTES
],
152 strlen(buf
),globstring
[STR_DISKINFO_BLOCKS
]);
153 getsizestring(buf
,a
);
154 lsprintf(disktxt
[2],formstr
,buf1
,infodata
.id_NumBlocks
,buf
);
156 a
= i64_uumul( infodata
.id_NumBlocksUsed
, infodata
.id_BytesPerBlock
);
157 getsizestring(buf
,a
);
158 i64_itoa( a
, buf1
, 40 );
160 a
=((long long)infodata
.id_NumBlocksUsed
)*infodata
.id_BytesPerBlock
;
161 getsizestring(buf
,a
);
162 sprintf(buf1
,"%qd",a
);
164 lsprintf(disktxt
[3],formstr
,buf1
,infodata
.id_NumBlocksUsed
,buf
);
166 a
= i64_uumul( ( infodata
.id_NumBlocks
-infodata
.id_NumBlocksUsed
), infodata
.id_BytesPerBlock
);
167 getsizestring(buf
,a
);
168 i64_itoa( a
, buf1
, 40 );
170 a
=(infodata
.id_NumBlocks
-infodata
.id_NumBlocksUsed
)*((long long)infodata
.id_BytesPerBlock
);
171 getsizestring(buf
,a
);
172 sprintf(buf1
,"%qd",a
);
174 lsprintf(disktxt
[4],formstr
,buf1
,(infodata
.id_NumBlocks
-infodata
.id_NumBlocksUsed
),buf
);
176 if (infodata
.id_NumBlocks
) f
= ((infodata
.id_NumBlocksUsed
*100.0)/infodata
.id_NumBlocks
);
178 sprintf(buf
,"%.1f",f
); sprintf(buf1
,"%.1f",100.0-f
);
179 lsprintf(disktxt
[5],"%s%% %s; %s%% %s",
180 buf
,globstring
[STR_DISKINFO_FULL
],
181 buf1
,globstring
[STR_DISKINFO_SFREE
]);
182 lsprintf(disktxt
[6],"%ld %s",
183 infodata
.id_BytesPerBlock
,
184 globstring
[STR_DISKINFO_BYTESPERBLOCK
]);
185 lsprintf(disktxt
[7],"%ld",infodata
.id_NumSoftErrors
);
186 switch (infodata
.id_DiskState
) {
188 strcpy(disktxt
[8],globstring
[STR_VALIDATING
]);
190 case ID_WRITE_PROTECTED
:
191 strcpy(disktxt
[8],globstring
[STR_WRITE_PROTECTED
]);
194 strcpy(disktxt
[8],globstring
[STR_READ_WRITE
]);
197 seedate(&ds
,disktxt
[9],0);
202 struct FileSysStartupMsg
*fssm
;
206 if (dl
= LockDosList(LDF_DEVICES
| LDF_READ
))
208 strcpy(buf
,disktxt
[0]);
209 buf
[strlen(buf
)-1] = 0;
210 if (dl
= FindDosEntry(dl
,buf
,LDF_DEVICES
))
212 if (fssm
= BADDR(((struct DeviceNode
*)dl
)->dn_Startup
))
214 if (de
= BADDR(fssm
->fssm_Environ
)) infodata
.id_DiskType
= de
->de_DosType
;
216 // else infodata.id_DiskType = 0x3F3F3F3F;
218 UnLockDosList(LDF_DEVICES
| LDF_READ
);
225 disktxt[10][0]=(char)((infodata.id_DiskType>>24)&0xff);
226 disktxt[10][1]=(char)((infodata.id_DiskType>>16)&0xff);
227 disktxt[10][2]=(char)((infodata.id_DiskType>>8)&0xff);
228 disktxt[10][3]=(char)(infodata.id_DiskType&0xff)+'0';
231 *((ULONG
*)disktxt
[10]) = infodata
.id_DiskType
;
232 if (disktxt
[10][3] < 32) disktxt
[10][3] += '0';
235 disktxt
[10][0]=(char)((infodata
.id_DiskType
>>24)&0xff);
236 disktxt
[10][1]=(char)((infodata
.id_DiskType
>>16)&0xff);
237 disktxt
[10][2]=(char)((infodata
.id_DiskType
>>8)&0xff);
238 disktxt
[10][3]=(char)(infodata
.id_DiskType
&0xff);
239 if (disktxt
[10][3] < 32) disktxt
[10][3] += '0';
242 switch (infodata
.id_DiskType
) {
244 strcat(disktxt
[10]," (OFS)");
247 strcat(disktxt
[10]," (FFS)");
249 case ID_INTER_DOS_DISK
:
250 strcat(disktxt
[10]," (I-OFS)");
252 case ID_INTER_FFS_DISK
:
253 strcat(disktxt
[10]," (I-FFS)");
255 case ID_FASTDIR_DOS_DISK
:
256 strcat(disktxt
[10]," (DC-OFS)");
258 case ID_FASTDIR_FFS_DISK
:
259 strcat(disktxt
[10]," (DC-FFS)");
262 strcat(disktxt
[10]," (MS-DOS)");
265 strcat(disktxt
[10]," (SFS)");
268 case AROS_MAKE_ID('F','A','T',0):
269 strcat(disktxt
[10]," (FAT)");
280 case ERROR_DEVICE_NOT_MOUNTED
:
281 strcpy(disktxt
[1],globstring
[STR_DEVICE_NOT_MOUNTED
]);
283 case ERROR_NOT_A_DOS_DISK
:
284 strcpy(disktxt
[1],globstring
[STR_NOT_A_DOS_DISK
]);
287 strcpy(disktxt
[1],globstring
[STR_NO_DISK_IN_DRIVE
]);
290 lsprintf(disktxt
[1],globstring
[STR_DOS_ERROR_CODE
],a
);
299 if (config
->errorflags
&ERROR_ENABLE_DOS
) main_proc
->pr_WindowPtr
=(APTR
)Window
;
306 for (i
=0;i
<ITEM_NUM
;i
++) {
307 if ((c
=strlen(disktxt
[i
]))>b
) b
=c
;
308 if ((c
=strlen(globstring
[diskinfo_heads
[i
]]))>titwidth
) titwidth
=c
;
311 disk_win
.Width
=((b
+titwidth
+3)*cx
)+16;
312 disk_win
.Height
=(ITEM_NUM
*(cy
+1))+19;
313 if (config
->generalscreenflags
&SCR_GENERAL_REQDRAG
) {
314 disk_win
.Flags
=WFLG_RMBTRAP
|WFLG_ACTIVATE
|WFLG_DRAGBAR
|WFLG_DEPTHGADGET
;
315 xoffset
=Window
->WScreen
->WBorLeft
;
316 yoffset
=Window
->WScreen
->WBorTop
+Window
->WScreen
->Font
->ta_YSize
+1;
317 disk_win
.Width
+=xoffset
+Window
->WScreen
->WBorRight
;
318 disk_win
.Height
+=yoffset
+Window
->WScreen
->WBorBottom
;
319 disk_win
.Title
="DiskInfo";
322 disk_win
.Flags
=WFLG_BORDERLESS
|WFLG_RMBTRAP
|WFLG_ACTIVATE
;
329 centerwindow(&disk_win
);
331 contgad
.NextGadget
=NULL
;
332 contgad
.Width
=(strlen(globstring
[STR_CONTINUE
])+4)*cx
;
334 contgad
.LeftEdge
=(disk_win
.Width
-contgad
.Width
)/2;
335 contgad
.TopEdge
=disk_win
.Height
-cy
-10;
336 contgad
.Flags
=GFLG_GADGHCOMP
;
337 contgad
.Activation
=GACT_RELVERIFY
;
338 contgad
.GadgetType
=GTYP_BOOLGADGET
;
339 contgad
.GadgetRender
=NULL
;
340 contgad
.SelectRender
=NULL
;
341 contgad
.GadgetText
=NULL
;
342 contgad
.MutualExclude
=0;
343 contgad
.SpecialInfo
=NULL
;
346 // StrCombine(buf,"_",globstring[STR_CONTINUE],256);
347 gad_gads
[0]=globstring
[STR_CONTINUE
]/*buf*/;
350 if (!(fontwindow
=OpenWindow(&disk_win
))) return;
352 dirp
=fontwindow
->RPort
;
353 setupwindreq(fontwindow
);
354 SetFont(dirp
,scr_font
[FONT_REQUEST
]);
355 for (i
=0;i
<ITEM_NUM
;i
++) {
356 Move(dirp
,xoffset
+8,yoffset
+5+(i
*cy
)+scr_font
[FONT_REQUEST
]->tf_Baseline
);
357 Text(dirp
,globstring
[diskinfo_heads
[i
]],strlen(globstring
[diskinfo_heads
[i
]]));
358 Move(dirp
,xoffset
+8+(titwidth
*cx
),yoffset
+5+(i
*cy
)+scr_font
[FONT_REQUEST
]->tf_Baseline
);
360 Text(dirp
,disktxt
[i
],strlen(disktxt
[i
]));
362 AddGadgetBorders(&key
,
364 screen_pens
[config
->gadgettopcol
].pen
,screen_pens
[config
->gadgetbotcol
].pen
);
365 AddGadgets(fontwindow
,
369 screen_pens
[config
->gadgettopcol
].pen
,
370 screen_pens
[config
->gadgetbotcol
].pen
,1);
373 if (uscore
= strchr(globstring
[STR_CONTINUE
],'_')) cont_key
= uscore
[1];
374 else cont_key
= globstring
[STR_CONTINUE
][0];
375 cont_key
= ToLower(cont_key
);
378 while (IMsg
=(struct IntuiMessage
*)GetMsg(fontwindow
->UserPort
)) {
379 class=IMsg
->Class
; code
=IMsg
->Code
;
380 ReplyMsg((struct Message
*)IMsg
);
382 case IDCMP_DISKREMOVED
:
385 case IDCMP_DISKINSERTED
:
387 old_change_state
=disk_change_state
;
389 if ((old_change_state
&(1<<isd
))!=(disk_change_state
&(1<<isd
))) {
395 case IDCMP_VANILLAKEY
:
396 if (code
!='\r' && ToLower(code
)!=cont_key
)
398 SelectGadget(fontwindow
,&contgad
);
405 Wait(1<<fontwindow
->UserPort
->mp_SigBit
);
407 CloseWindow(fontwindow
);
410 if (i
==2) goto getnewdisk
;
413 void get_device_task(lock
,buffer
,port
)
416 struct MsgPort
*port
;
418 struct DeviceList
*devlist
,*dl
;
419 struct RootNode
*rootnode
;
420 struct DosInfo
*dosinfo
;
421 struct FileLock
*lock2
;
423 rootnode
=(struct RootNode
*) DOSBase
->dl_Root
;
424 dosinfo
=(struct DosInfo
*) BADDR(rootnode
->rn_Info
);
425 devlist
=(struct DeviceList
*) BADDR(dosinfo
->di_DevInfo
);
426 lock2
=(struct FileLock
*)BADDR(lock
);
427 dl
=(struct DeviceList
*)BADDR(lock2
->fl_Volume
);
430 if (devlist
->dl_Type
==DLT_DEVICE
&& devlist
->dl_Task
==dl
->dl_Task
) break;
431 devlist
=(struct DeviceList
*) BADDR(devlist
->dl_Next
);
433 if (devlist
) BtoCStr((BPTR
)devlist
->dl_Name
,buffer
,31);
434 else strcpy(buffer
,((struct Task
*)port
->mp_SigTask
)->tc_Node
.ln_Name
);
439 void getsizestring(buf
,a
)
443 bigint temp1
, temp2
, temp3
, quot
, rema
;
445 temp1
= i64_atoi( "1024" );
446 i64_udiv( a
, temp1
, "
, &rema
);
450 temp1
= i64_atoi( "1073741824" );
451 temp2
= i64_atoi( "1048576" );
452 temp3
= i64_atoi( "1024" );
454 if ( i64_cmp( quot
, temp1
) == I64_GREATER
)
456 lsprintf( buf
, "HUGE" );
458 else if ( i64_cmp( quot
, temp2
) == I64_GREATER
)
460 i64_udiv( a
, temp2
, "
, &rema
);
462 sprintf(buf
,"%.1fG", (double)quot
.lo
+ ( (double)rema
.lo
/ 1048576 ));
464 else if ( i64_cmp( quot
, temp3
) == I64_GREATER
)
466 i64_udiv( a
, temp3
, "
, &rema
);
468 sprintf(buf
,"%.1fM", (double)quot
.lo
+ ( (double)rema
.lo
/ 1024 ));
470 else lsprintf( buf
, "%ldK", (long)a
.lo
);
473 void getsizestring(buf
,a
)
475 unsigned long long a
;
478 if (a
>1073741824) lsprintf(buf
,"HUGE");
479 else if (a
>1048576) sprintf(buf
,"%.1fG",(double)((double)a
/1048576));
480 else if (a
>1024) sprintf(buf
,"%.1fM",(double)((double)a
/1024));
481 else lsprintf(buf
,"%ldK",(long)a
);
485 void getfloatstr(f,buf)
499 lsprintf(buf1,"%ld",c); buf1[1]=0;
500 lsprintf(buf,"%ld.%s",a,buf1);