home *** CD-ROM | disk | FTP | other *** search
/ Enigma Amiga Life 113 / EnigmaAmiga113CD.iso / software / sviluppo / fm2000 / diskinfo.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-02-04  |  4.2 KB  |  159 lines

  1. /*
  2.      Filemaster - Multitasking directory utility.
  3.      Copyright (C) 2000  Toni Wilen
  4.      
  5.      This program is free software; you can redistribute it and/or
  6.      modify it under the terms of the GNU General Public License
  7.      as published by the Free Software Foundation; either version 2
  8.      of the License, or (at your option) any later version.
  9.      
  10.      This program is distributed in the hope that it will be useful,
  11.      but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.      GNU General Public License for more details.
  14.      
  15.      You should have received a copy of the GNU General Public License
  16.      along with this program; if not, write to the Free Software
  17.      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  18. */
  19.  
  20. #include <proto/all.h>
  21. #include <exec/types.h>
  22. #include <exec/memory.h>
  23. #include <intuition/intuition.h>
  24. #include <dos/dosextens.h>
  25. #include <dos/filehandler.h>
  26. #include <stdio.h>
  27. #include <string.h>
  28. #include "fmnode.h"
  29. #include "child.h"
  30. #include "fmdos.h"
  31. #include "fmlocale.h"
  32. #include "fmgui.h"
  33.  
  34. WORD finddevice(BPTR lock,struct DosList**,struct DosList**);
  35.  
  36. void __saveds diskinfo(void)
  37. {
  38. struct ProcMsg *pm;
  39. BPTR lock=0;
  40. struct DosList *doslist;
  41. struct DosList *vollist;
  42. struct FMList *list;
  43. struct FMNode *node;
  44. struct FileSysStartupMsg *fssm;
  45. struct InfoData *id;
  46. struct DosEnvec *de;
  47. UBYTE text[1000];
  48. UBYTE *ptr1,*ptr2;
  49. UBYTE volname[32];
  50. UBYTE devname[32];
  51. UBYTE disktype[32];
  52. ULONG dtype;
  53. UBYTE cdate[32];
  54. ULONG tsecs;
  55. WORD apu1,apu2,apu3;
  56.  
  57. extern struct FMMain fmmain;
  58.  
  59. pm=sinitproc();
  60. priority(pm->cmc);
  61. list=fmmain.sourcedir;
  62. fmmain.wincnt++;
  63. if (!(setalloc(list,1))) {
  64.     initproc(0,0);
  65.     goto endi;
  66. }
  67. initproc(list,pm->cmc->label);
  68.  
  69. if (!(id=allocmem(sizeof(struct InfoData)))) goto diend;
  70. ptr2=list->path;
  71. if (!(list->flags&LDIRLIST)) {
  72.     node=findselnodeall(list);
  73.     if (node) {
  74.         ptr2=NDFILE(node);
  75.         node->flags&=~NSELECTED;
  76.         outputlistline(list,node);
  77.     } else {
  78.         strcpymsg(list->fmmessage1,MSG_MAIN_NOSOURCEFILE);
  79.         fmmessage(list);
  80.         goto diend;
  81.     }
  82. }
  83. if (lock=fmlock(list,ptr2)) {
  84.     if (Info(lock,id)) {
  85.         doslist=LockDosList(LDF_VOLUMES|LDF_DEVICES|LDF_READ);
  86.         if(finddevice(lock,&doslist,&vollist)) {
  87.             fssm=(struct FileSysStartupMsg*)(doslist->dol_misc.dol_handler.dol_Startup<<2);
  88.             de=(struct DosEnvec*)(fssm->fssm_Environ<<2);
  89.             if (fssm) {
  90.                 switch(id->id_DiskState)
  91.                 {
  92.                 case ID_WRITE_PROTECTED:
  93.                 ptr1=getstring(MSG_DISKINFO_WPROT);
  94.                 break;
  95.                 case ID_VALIDATING:
  96.                 ptr1=getstring(MSG_DISKINFO_VALIDATING);
  97.                 break;
  98.                 case ID_VALIDATED:
  99.                 ptr1=getstring(MSG_DISKINFO_VALIDATED);
  100.                 break;
  101.                 default:
  102.                 ptr1=getstring(MSG_DISKINFO_UNKNOWN);
  103.                 break;
  104.                 }
  105.                 siirrabstr((UBYTE*)(vollist->dol_Name<<2),volname);
  106.                 siirrabstr((UBYTE*)(doslist->dol_Name<<2),devname);
  107.                 tsecs=de->de_BlocksPerTrack;
  108.                 longtodatestring(cdate,dstolong(&vollist->dol_misc.dol_volume.dol_VolumeDate));
  109.                 dtype=de->de_DosType;
  110.                 ptr2=disktype;
  111.                 apu2=24;
  112.                 for(apu1=0;apu1<4;apu1++) {
  113.                     apu3=(dtype>>apu2)&0xff;
  114.                     if(apu3>=32) {
  115.                         *ptr2++=apu3;
  116.                     } else {
  117.                         sformat(ptr2,"\\\%ld",apu3);
  118.                         ptr2+=strlen(ptr2);
  119.                     }
  120.                     apu2-=8;
  121.                 }
  122.                 *ptr2=0;
  123.                 sformatmsg(text,MSG_DISKINFO,id->id_NumSoftErrors,fssm->fssm_Unit,ptr1,id->id_NumBlocks,id->id_NumBlocksUsed,id->id_BytesPerBlock,dtype,disktype,volname,devname,cdate,(fssm->fssm_Device<<2)+1,de->de_Surfaces,tsecs,de->de_Reserved+de->de_PreAlloc,de->de_LowCyl,de->de_HighCyl,de->de_NumBuffers,de->de_BufMemType,de->de_MaxTransfer,de->de_Mask);
  124.                 UnLockDosList(LDF_VOLUMES|LDF_DEVICES|LDF_READ);
  125.                 endproc(list);    
  126.                 reqinfowindow(pm->cmc->label,text,guiLEFT,MSG_OK,1,0);
  127.                 goto diend;
  128.                 }
  129.         }
  130.         UnLockDosList(LDF_VOLUMES|LDF_DEVICES|LDF_READ);
  131.     }
  132. }
  133. diend:
  134. if (lock) UnLock(lock);
  135. freemem(id);
  136. endproc(list);
  137. endi:
  138. fmmain.wincnt--;
  139. deinitproc(pm);
  140. }
  141.  
  142.  
  143. WORD finddevice(BPTR lock,struct DosList **dl,struct DosList **vl)
  144. {
  145. struct DosList *doslist;
  146. struct DosList *vollist;
  147.  
  148. doslist=*dl;
  149. vollist=(struct DosList*)((((struct FileLock*)(lock<<2))->fl_Volume)<<2);
  150. while(doslist=NextDosEntry(doslist,LDF_DEVICES)) {
  151.     if (doslist->dol_Task==vollist->dol_Task) {
  152.         *dl=doslist;
  153.         *vl=vollist;
  154.         return(1);
  155.     }
  156. }
  157. return(0);
  158. }
  159.