TempleOSTS_140317.ISO

This commit is contained in:
Terry A. Davis authored and minexew committed 2018-09-08 21:46:02 +02:00
1 parent 2d2a65d572
commit 7ef616a20e
1416 files changed
+223873 -53917

No files matched your search

+232
View File
@@ -0,0 +1,232 @@
#help_index "Info;File/Cmd Line (Typically);Cmd Line (Typically)"
Bool ChkDskConfirm(Bool *_fix,Bool *_confirm)
{
if (*_fix && *_confirm) {
"Fix ";
if (!YorN)
*_fix=FALSE;
*_confirm=FALSE;
}
return *_fix;
}
I64 RedSeaFSChkDskLst(CDirEntry *tempde1,U8 *bits,U8 *bits2,I64 size,I64 bpc)
{
CDirEntry *tempde2;
I64 i,j,errs=0;
while (tempde1) {
tempde2=tempde1->next;
if (tempde1->attr & _ATTR_DIR) {
if (tempde1->sub)
errs+=RedSeaFSChkDskLst(tempde1->sub,bits,bits2,size,bpc);
}
j=(tempde1->size+bpc-1)/bpc;
for (i=0;i<j;i++) {
if (i+tempde1->cluster>size) {
PrintErr("Invalid Cluster:%s Cluster:%X\n",tempde1->full_name,
i+tempde1->cluster);
errs++;
break;
}
if (LBts(bits,i+tempde1->cluster)) {
PrintErr("Dbl Alloc:%s Cluster:%X\n",tempde1->full_name,
i+tempde1->cluster);
errs++;
}
if (!LBtr(bits2,i+tempde1->cluster)) {
PrintErr("UnAlloc:%s Cluster:%X\n",tempde1->full_name,
i+tempde1->cluster);
errs++;
}
}
DirEntryDel(tempde1);
tempde1=tempde2;
}
return errs;
}
I64 RedSeaFSChkDsk(U8 drv_let,Bool *_fix,Bool *_confirm)
{
I64 i,j,bpc,size,errs=0;
CPrt *p=Drv2Prt(drv_let),*old_prt=Fs->cur_prt;
U8 *files_find_mask=MPrint("%c:/*",Prt2Drv(p)),
*old_dir=StrNew(Fs->cur_dir),
*bits,*bits2;
CDirEntry *ptr,*ptr2;
Drv(drv_let);
"Scanning...\n";
size=(p->size-(p->data-p->offset))/p->spc;
bpc=p->spc<<BLK_SIZE_BITS;
bits=CAlloc((size+7)>>3);
bits2=CAlloc((size+7)>>3+BLK_SIZE);
RBlks(p,bits2,p->map1,((size+7)>>3+BLK_SIZE-1)>>BLK_SIZE_BITS);
//Get Root Dir size
ptr2=MAlloc(bpc);
RClusters(p,ptr2,p->root_cluster,1);
ptr=ptr2(U8 *)-offset(CDirEntry.start);
j=(ptr->size+bpc-1)/bpc;
Free(ptr2);
for (i=0;i<j;i++) {
if (i+p->root_cluster>size) {
PrintErr("Invalid Cluster: RootDir Cluster:%X\n",i+p->root_cluster);
errs++;
break;
}
if (LBts(bits,i+p->root_cluster)) {
PrintErr("Dbl Alloc: RootDir Cluster:%X\n",i+p->root_cluster);
errs++;
}
if (!LBtr(bits2,i+p->root_cluster)) {
PrintErr("UnAlloc: RootDir Cluster:%X\n",i+p->root_cluster);
errs++;
}
}
errs+=RedSeaFSChkDskLst(FilesFind(files_find_mask,FUF_RECURSE),bits,bits2,size,bpc);
for (i=1;i<size;i++)
if (Bt(bits2,i)) {
PrintWarn("Shouldn't Alloc Cluster:%0X\n",i);
errs++;
if (ChkDskConfirm(_fix,_confirm))
RedSeaFSFreeClusters(p,i,1);
}
Free(files_find_mask);
Free(bits);
Free(bits2);
Drv(Prt2Drv(old_prt));
Cd(old_dir);
Free(old_dir);
return errs;
}
I64 FAT32ChkDskLst(CPrt *p,CDirEntry *tempde1,U8 *bits,U32 *bits2,I64 size,I64 bpc)
{
CDirEntry *tempde2;
I64 i,c,errs=0;
while (tempde1) {
tempde2=tempde1->next;
if (tempde1->attr & _ATTR_DIR) {
if (tempde1->sub)
errs+=FAT32ChkDskLst(p,tempde1->sub,bits,bits2,size,bpc);
}
i=0;
c=tempde1->cluster;
while (0<c<0x0FFFFFF8) {
if (c>size) {
PrintErr("Invalid Cluster:%s Cluster:%X\n",tempde1->full_name,c);
errs++;
break;
}
if (LBts(bits,c)) {
PrintErr("Dbl Alloc:%s Cluster:%X\n",tempde1->full_name,c);
errs++;
}
if (!bits2[c]) {
PrintErr("UnAlloc:%s Cluster:%X\n",tempde1->full_name,c);
errs++;
} else
bits2[c]=0;
c=ClusterNumNext(p,c);
i++;
}
if (!(tempde1->attr & _ATTR_DIR)) {
i*=bpc;
if (tempde1->size>i) {
PrintErr("Allocated File Too Short:%s\n",tempde1->full_name);
errs++;
}
if (i>tempde1->size+bpc-1) {
PrintWarn("Allocated File Too Long:%s\n",tempde1->full_name);
errs++;
}
}
DirEntryDel(tempde1);
tempde1=tempde2;
}
return errs;
}
I64 FAT32ChkDsk(U8 drv_let,Bool *_fix,Bool *_confirm)
{
I64 i,bpc,size,c,errs=0;
CPrt *p=Drv2Prt(drv_let),*old_prt=Fs->cur_prt;
U8 *files_find_mask=MPrint("%c:/*",Prt2Drv(p)),
*old_dir=StrNew(Fs->cur_dir),
*bits;
U32 *bits2;
Drv(drv_let);
"Scanning...\n";
size=(p->size-(p->data-p->offset))/p->spc;
bpc=p->spc<<BLK_SIZE_BITS;
bits=CAlloc((size+7)>>3);
bits2=CAlloc(size*4+BLK_SIZE);
RBlks(p,bits2,p->map1,(size*4+BLK_SIZE-1)>>BLK_SIZE_BITS);
c=p->root_cluster;
while (0<c<0x0FFFFFF8) {
if (c>size) {
PrintErr("Invalid Cluster: RootDir Cluster:%X\n",c);
errs++;
break;
}
if (LBts(bits,c)) {
PrintErr("Dbl Alloc: RootDir Cluster:%X\n",c);
errs++;
}
if (!bits2[c]) {
PrintErr("UnAlloc: RootDir Cluster:%X\n",c);
errs++;
} else
bits2[c]=0;
c=ClusterNumNext(p,c);
}
errs+=FAT32ChkDskLst(p,FilesFind(files_find_mask,FUF_RECURSE),bits,bits2,size,bpc);
bits2[1]=0; //See $LK,"FAT32Fmt",A="MN:FAT32Fmt"$()
for (i=1;i<size;i++)
if (bits2[i]) {
PrintWarn("Shouldn't Alloc Cluster:%0X\n",i);
errs++;
if (ChkDskConfirm(_fix,_confirm))
FAT32FreeClusters(p,i);
}
Free(files_find_mask);
Free(bits);
Free(bits2);
Drv(Prt2Drv(old_prt));
Cd(old_dir);
Free(old_dir);
return errs;
}
public I64 ChkDsk(U8 drv_let=0,Bool fix=FALSE,Bool confirm=TRUE)
{ //Check for allocation errors.
I64 errs=0;
CPrt *p=Drv2Prt(drv_let);
switch (p->type) {
case PT_REDSEA:
errs=RedSeaFSChkDsk(drv_let,&fix,&confirm);
break;
case PT_FAT32:
errs=FAT32ChkDsk(drv_let,&fix,&confirm);
break;
default:
PrintErr("File System Not Supported\n");
}
if (errs) {
if (fix)
"It might be a little better. ";
"Copy files to another partition or CD-ROM, "
"reformat, and copy back. "
"Or, copy from a back-up.\n";
}
return errs;
}
#help_index ""
+4
View File
@@ -0,0 +1,4 @@
#include "Dsk2a"
#include "Dsk2b"
#include "ChkDsk"
#include "FileMgr"
+380
View File
@@ -0,0 +1,380 @@
#help_index "File/Cmd Line (Typically);Cmd Line (Typically)"
public U8 *DBlk(I64 blk,Bool write=FALSE)
{//Dump Disk Blk.
//If you set write to TRUE, it will be written when you press <ESC>.
//See $LK,"::/Demo/Dsk/DskRaw.CPP"$.
U8 *buf=MAlloc(BLK_SIZE);
RBlks(Fs->cur_prt,buf,blk,1);
DocD(buf,BLK_SIZE);
if (write) {
"Edit and press <ESC> to write or <SHIFT-ESC>\n";
if (View) {
"Write\n";
WBlks(Fs->cur_prt,buf,blk,1);
}
}
return buf;
}
public U8 *DCluster(I64 c,Bool write=FALSE,I64 num=0)
{//Dump Disk Cluster.
//If you set write to TRUE, it will be written when you press <ESC>.
//See $LK,"::/Demo/Dsk/DskRaw.CPP"$.
//Do $LK,"Dir",A="MN:Dir"$("*",TRUE); to get cluster numbers of files.
U8 *buf=MAlloc(Fs->cur_prt->spc<<BLK_SIZE_BITS);
c=ClusterNumNext(Fs->cur_prt,c,num);
RClusters(Fs->cur_prt,buf,c,1);
"Cluster:%X\n",c;
DocD(buf,Fs->cur_prt->spc<<BLK_SIZE_BITS);
if (write) {
"Edit and press <ESC> to write or <SHIFT-ESC>\n";
if (View) {
"Write\n";
WClusters(Fs->cur_prt,buf,c,1);
}
}
return buf;
}
#help_index "File/Program Routines"
U0 FOFlatten(CDirEntry *tempde,CDirEntry **a,I64 *i)
{
CDirEntry *tempde1;
while (tempde) {
tempde1=tempde->next;
if (tempde->attr&_ATTR_DIR) {
FOFlatten(tempde->sub,a,i);
DirEntryDel(tempde);
} else {
a[*i]=tempde;
*i=*i+1;
}
tempde=tempde1;
}
}
public I64 FileCnt(CDirEntry *tempde)
{
I64 cnt=0;
while (tempde) {
if (tempde->attr&_ATTR_DIR)
cnt+=FileCnt(tempde->sub);
else
cnt++;
tempde=tempde->next;
}
return cnt;
}
#help_index "File/Cmd Line (Typically);Cmd Line (Typically)"
public Bool Copy(U8 *src_files_find_mask,U8 *dst_files_find_mask=".")
{
Bool result=TRUE;
CFileAccess *fa;
CDirEntry *tempde,*tempde1;
U8 *st;
if (!(tempde=FilesFind(src_files_find_mask,FUF_CLUSTER_ORDER)))
return FALSE;
if (IsDir(dst_files_find_mask)) {
if (fa=FileAccessNew(dst_files_find_mask,TRUE)) {
while (tempde) {
tempde1=tempde->next;
if (!(tempde->attr & _ATTR_DIR)) {
st=FileNameAbs(tempde->name);
if (!CopySingle(tempde->full_name,st))
result=FALSE;
Free(st);
}
DirEntryDel(tempde);
tempde=tempde1;
}
FileAccessDel(fa);
}
return result;
} else
return CopySingle(src_files_find_mask,dst_files_find_mask);
}
public Bool Move(U8 *f1,U8 *f2)
{
if (Copy(f1,f2)) {
Del(f1);
return TRUE;
}
return FALSE;
}
I64 CopyTree2(CDirEntry *tempde,I64 src_dir_len,I64 dst_dir_len,U8 *dst_dir)
{
U8 *st;
I64 result=1;
while (tempde) {
st=MAlloc(StrLen(tempde->full_name)+dst_dir_len+2);
MemCpy(st,dst_dir,dst_dir_len);
StrCpy(st+dst_dir_len,tempde->full_name+src_dir_len);
if (tempde->attr & _ATTR_DIR) {
MkDir(st);
result+=CopyTree2(tempde->sub,src_dir_len,dst_dir_len,dst_dir);
} else
if (CopySingle(tempde->full_name,st))
result++;
Free(st);
tempde=tempde->next;
}
return result;
}
public I64 CopyTree(U8 *src_files_find_mask,U8 *dst_files_find_mask,Bool no_mask=TRUE)
{ //returns count of copied files (not dirs)
CFileAccess *fa;
CDirEntry *tempde=NULL;
I64 result=0,i1,i2;
U8 *st1,*st2;
st1=DirNameAbs(src_files_find_mask);
st2=DirNameAbs(dst_files_find_mask);
i1=StrLen(st1);
if (!StrNCmp(st1,st2,i1) && (st2[i1]=='/' || !st2[i1]) ) {
Free(st1);
Free(st2);
return 0;
}
Free(st1);
Free(st2);
if (fa=FileAccessNew(src_files_find_mask,TRUE,,no_mask)) {
tempde=SysFilesFind(fa->mask,FUF_RECURSE);
st1=CurDir;
FileAccessDel(fa);
i1=StrLen(st1);
if (i1==3) i1--;
if (fa=FileAccessNew(dst_files_find_mask,TRUE,TRUE)) {
st2=CurDir;
i2=StrLen(st2);
if (i2==3) i2--;
result=CopyTree2(tempde,i1,i2,st2);
FileAccessDel(fa);
Free(st2);
}
DirLstDel(tempde);
Free(st1);
}
return result;
}
I64 DelTreeDirs(CDirEntry *tempde1)
{
I64 result=0;
CDirEntry *tempde2;
while (tempde1) {
tempde2=tempde1->next;
if (tempde1->attr & _ATTR_DIR) {
if (tempde1->sub)
result+=DelTreeDirs(tempde1->sub);
result+=SysDel(tempde1->full_name,TRUE);
}
DirEntryDel(tempde1);
tempde1=tempde2;
}
return result;
}
I64 DelTreeFiles(CDirEntry *tempde1)
{
I64 result=0;
CDirEntry *tempde2;
while (tempde1) {
tempde2=tempde1->next;
if (tempde1->attr & _ATTR_DIR) {
if (tempde1->sub)
result+=DelTreeFiles(tempde1->sub);
} else
result+=SysDel(tempde1->full_name,FALSE);
DirEntryDel(tempde1);
tempde1=tempde2;
}
return result;
}
public I64 DelTree(U8 *files_find_mask,U8 *fu_flags=NULL)
{
I64 result=0,fuf_flags=0;
ScanFlags(&fuf_flags,Define("ST_FILE_UTIL_FLAGS"),"+r");
ScanFlags(&fuf_flags,Define("ST_FILE_UTIL_FLAGS"),fu_flags);
if (IsDir(files_find_mask)) {
result=DelTreeDirs(FilesFind(files_find_mask,fuf_flags));
result+=SysDel(files_find_mask,TRUE);
result+=SysDel(files_find_mask,FALSE);
} else
result=DelTreeFiles(FilesFind(files_find_mask,fuf_flags));
return result;
}
U0 TouchFile(U8 *filename,U8 *attr,CDate cdt=MIN_I64)
{
CPrt *p=Drv2Prt(*filename);
CDirEntry de;
U8 *cur_dir=StrNew(filename),
buf[136];
if (FileFind(filename,&de,FUF_JUST_FILES)) {
Free(de.full_name);
if (!StrCmp(attr,"+?"))
"%-48ts %s\n",filename,SPrintFlags(buf,Define("ST_FILE_ATTRS"),de.attr);
else {
StrFirstRem(cur_dir,":");
StrLastRem(cur_dir,"/");
if (!*cur_dir)
StrCpy(cur_dir,"/");
ScanFlags(&de.attr,Define("ST_FILE_ATTRS"),attr);
if (cdt==MIN_I64)
de.datetime=Now;
else
de.datetime=cdt;
DirNew(p,cur_dir,&de,FALSE);
}
} else
PrintErr("File not found.\n");
}
public U0 Touch(U8 *files_find_mask,U8 *attr="+?",U8 *fu_flags=NULL,CDate cdt=MIN_I64)
{
//Attr "+?" =show
// "+T" =resident
//To Set Date
// Touch(filename,"",,datetime);
I64 fuf_flags=0;
CDirEntry *tempde,*tempde1;
ScanFlags(&fuf_flags,Define("ST_FILE_UTIL_FLAGS"),"+f+F");
ScanFlags(&fuf_flags,Define("ST_FILE_UTIL_FLAGS"),fu_flags);
tempde=tempde1=FilesFind(files_find_mask,fuf_flags);
while (tempde) {
TouchFile(tempde->full_name,attr,cdt);
tempde=tempde->next;
}
DirLstDel(tempde1);
}
public I64 FF(U8 *files_find_mask,U8 *fu_flags=NULL)
//Files Find
{
I64 cnt=0,fuf_flags=0;
CDirEntry *tempde,*tempde1;
ScanFlags(&fuf_flags,Define("ST_FILE_UTIL_FLAGS"),"+r+f+F");
ScanFlags(&fuf_flags,Define("ST_FILE_UTIL_FLAGS"),fu_flags);
tempde=tempde1=FilesFind(files_find_mask,fuf_flags);
while (tempde) {
PutFileLink(tempde->full_name);
NewLine;
cnt++;
tempde=tempde->next;
}
DirLstDel(tempde1);
return cnt;
}
public U0 SetDrvTextAttr(U8 drv_let,U8 attr)
{ //This is to color the border text according to the current drive
CPrt *p;
try {
p=Drv2Prt(drv_let);
p->text_attr=attr;
} catch
Fs->catch_except=TRUE;
}
I64 RedSeaFSUnusedDrvSpace(U8 drv_let=0)
{
CPrt *p=Drv2Prt(drv_let);
I64 result=0,i,l;
U8 *bitmap;
try {
l=(p->size+p->spc-1)/p->spc;
i=((l+7)>>3+BLK_SIZE-1)>>BLK_SIZE_BITS;
bitmap=MAlloc(i<<BLK_SIZE_BITS);
RBlks(p,bitmap,p->map1,i);
for (i=0;i<l;i++)
if (!Bt(bitmap,i))
result++;
Free(bitmap);
} catch
PrtUnlock(p);
return result*BLK_SIZE*p->spc;
}
I64 FAT32UnusedDrvSpace(U8 drv_let=0)
{
CPrt *p=Drv2Prt(drv_let);
I64 result=0,i,l;
U32 *bitmap;
try {
l=(p->size+p->spc-1)/p->spc;
i=(l*4+BLK_SIZE-1)>>BLK_SIZE_BITS;
bitmap=MAlloc(i<<BLK_SIZE_BITS);
RBlks(p,bitmap,p->map1,i);
for (i=0;i<l;i++)
if (!bitmap[i])
result++;
Free(bitmap);
} catch
PrtUnlock(p);
return result*BLK_SIZE*p->spc;
}
public I64 UnusedDrvSpace(U8 drv_let=0)
{ //returns size in bytes
CPrt *p=Drv2Prt(drv_let),*p_old=Fs->cur_prt;
U8 *old_dir=StrNew(Fs->cur_dir);
I64 result=0;
Drv(drv_let);
switch (p->type) {
case PT_REDSEA:
result=RedSeaFSUnusedDrvSpace(drv_let);
break;
case PT_FAT32:
result=FAT32UnusedDrvSpace(drv_let);
break;
default:
PrintErr("File System Not Supported\n");
}
Drv(Prt2Drv(p_old));
Cd(old_dir);
Free(old_dir);
return result;
}
#help_index "File/Program Routines"
I64 Size1(CDirEntry *tempde,I64 *_fuf_flags,I64 round_to)
{
U8 buf[BLK_SIZE];
I64 result=0,i;
CPrt *p;
while (tempde) {
if ((i=tempde->size) && Bt(_fuf_flags,FUf_EXPAND) &&
!(tempde->attr&_ATTR_DIR) && FileAttr(tempde->name)&_ATTR_COMPRESSED) {
p=Drv2Prt(*tempde->full_name);
RBlks(p,buf,Cluster2Blk(p,tempde->cluster),1);
i=(&buf)(CArcCompress *)->expanded_size;
}
if (round_to)
i=CeilU64(tempde->size,round_to);
if (tempde->attr&_ATTR_DIR)
i+=Size1(tempde->sub,_fuf_flags,round_to);
tempde->user_data=i;
result+=i;
tempde=tempde->next;
}
return result;
}
public I64 Size(U8 *files_find_mask="/*",U8 *fu_flags=NULL,I64 round_to=0)
{
//"+x" for expanded size.
//Does not include directory size of base directory, but
//does include size of sub directories.
I64 fuf_flags=0,result=0;
CDirEntry *tempde1=NULL;
ScanFlags(&fuf_flags,Define("ST_FILE_UTIL_FLAGS"),"+r");
ScanFlags(&fuf_flags,Define("ST_FILE_UTIL_FLAGS"),fu_flags);
if (tempde1=FilesFind(files_find_mask,fuf_flags&FUG_FILES_FIND)) {
fuf_flags&=FUF_EXPAND;
result=Size1(tempde1,&fuf_flags,round_to);
DirLstDel(tempde1);
}
return result;
}
#help_index ""
+405
View File
@@ -0,0 +1,405 @@
#help_index "File/Program Routines/Utils"
I64 DirTreeFlattenSize(CDirEntry *tempde)
{
I64 result=0;
while (tempde) {
result+=CDIR_SIZE+1;
if (tempde->attr & _ATTR_DIR)
result+=DirTreeFlattenSize(tempde->sub);
tempde=tempde->next;
}
return result+1;
}
I64 DirTreeFlattenFill(CDirEntry *tempde,U8 *dst)
{
I64 result=0,i;
while (tempde) {
*dst++=1;
result++;
i=CDIR_SIZE;
MemCpy(dst,&tempde->start,i);
dst+=i;
result+=i;
if (tempde->attr & _ATTR_DIR) {
i=DirTreeFlattenFill(tempde->sub,dst);
dst+=i;
result+=i;
}
tempde=tempde->next;
}
*dst=0;
return result+1;
}
public U8 *DirTreeFlatten(CDirEntry *tempde,I64 *_size=NULL)
{
I64 size=DirTreeFlattenSize(tempde);
U8 *buf=MAlloc(size);
DirTreeFlattenFill(tempde,buf);
if (_size) *_size=size;
return buf;
}
U8 *DirTreeDoUnflatten(U8 *src,CDirEntry **tempde)
{
I64 i;
CDirEntry *tempde1;
if (*src++) {
tempde1=CAlloc(sizeof(CDirEntry));
*tempde=tempde1;
i=CDIR_SIZE;
MemCpy(&tempde1->start,src,i);
src+=i;
if (tempde1->attr & _ATTR_DIR)
src=DirTreeDoUnflatten(src,&tempde1->sub);
src=DirTreeDoUnflatten(src,&tempde1->next);
} else
*tempde=NULL;
return src;
}
public CDirEntry *DirTreeUnflatten(U8 *src)
{
CDirEntry *tempde=NULL;
DirTreeDoUnflatten(src,&tempde);
return tempde;
}
#help_index "Install;File/Cmd Line (Typically);Cmd Line (Typically)"
#define ROUND_PRT_TO (63*255)
#define PRT_HEADER 63
class CPlannedPrt
{
CPlannedPrt *next,*last;
I64 size;
Bool pri;
};
//This is available to assist in writing scripts.
I64 prt_dsk_dsk_size;
public U0 PrtDsk(U8 drv_let=0)
//Partition Disk containing partition drv_let.
//or drv_let=0 means add new drv that is not already mounted.
{
CBlkDev *bdev;
CPlannedPrt root,*temppp;
CMasterBoot mbr;
Bool pri=TRUE;
I64 ext_base,drv_let2,pri_cnt=0,
i,start_offset,offset,remaining;
"This command does not play well\n"
"with other operating systems.\n"
"You really should use another\n"
"operating system's partitioner.\n"
"If you use this, it may, in fact,\n"
"make your hard drive impossible\n"
"to repartition with other operating\n"
"until you set block zero to zero\n"
"with $$LK,\"MasterBootZero\",\"MN:MasterBootZero\"$$()\n\n\n"
"Continue";
if (!YorN) return;
if (drv_let)
try
Drv2BlkDev(drv_let);
catch {
drv_let=0;
Fs->catch_except=TRUE;
}
if (!drv_let) {
Mount(TRUE);
return;
}
bdev=Drv2BlkDev(drv_let);
if (!bdev || bdev->type!=BDT_ATA)
return;
prt_dsk_dsk_size=bdev->max_blk+1;
QueInit(&root);
drv_let2=bdev->first_drv_let;
remaining=FloorU64(bdev->max_blk+1,ROUND_PRT_TO);
while (FloorU64(remaining,ROUND_PRT_TO)>=ROUND_PRT_TO) {
temppp=MAlloc(sizeof(CPlannedPrt));
do {
"$$RED$$Partition %C$$FG$$\n",drv_let2;
temppp->pri=FALSE;
if (pri) {
"Primary Partition";
if (YorN) {
pri_cnt++;
temppp->pri=TRUE;
if (pri_cnt==3)
pri=FALSE;
} else
pri=FALSE;
}
"Blocks Remaining:%d (0x%X)\n",
remaining-PRT_HEADER,remaining-PRT_HEADER;
temppp->size=CeilU64(PmtI64("Size in Blocks :",
remaining-PRT_HEADER)+PRT_HEADER,ROUND_PRT_TO);
} while (!(ROUND_PRT_TO<=temppp->size<=FloorU64(remaining,ROUND_PRT_TO)));
QueIns(temppp,root.last);
remaining-=temppp->size;
drv_let2++;
}
"\n\n!!! Repartition Drive !!!\n\n";
temppp=root.next;
drv_let2=bdev->first_drv_let;
while (temppp!=&root) {
"Drive %C:%08X ",drv_let2,temppp->size;
if (temppp->pri)
"Primary\n";
else
"Logical\n";
temppp=temppp->next;
drv_let2++;
}
if (!AreYouSure)
goto pd_done;
remaining=FloorU64(bdev->max_blk+1,ROUND_PRT_TO)-ROUND_PRT_TO;
temppp=root.next;
MemSet(&mbr,0,BLK_SIZE);
mbr.signature=0xAA55;
offset=0;
for (i=0;i<pri_cnt;i++) {
mbr.p[i].active=0x80;
mbr.p[i].start_head=0;
mbr.p[i].start_cyl=0x101;
mbr.p[i].type=1; //Will get set different.
mbr.p[i].end_head=0xFE;
mbr.p[i].end_cyl=0xFFFF;
mbr.p[i].offset=PRT_HEADER+offset;
mbr.p[i].size=temppp->size-PRT_HEADER;
offset+=temppp->size;
remaining-=temppp->size;
temppp=temppp->next;
}
if (!i) i++;
if (temppp!=&root) {
mbr.p[i].active=0x80;
mbr.p[i].start_head=0;
mbr.p[i].start_cyl=0x101;
mbr.p[i].type=0xF;
mbr.p[i].end_head=0xFE;
mbr.p[i].end_cyl=0xFFFF;
mbr.p[i].offset=offset;
mbr.p[i].size=remaining;
ext_base=offset;
}
ATAWriteBlks(bdev,&mbr,0,1);
while (temppp!=&root) {
start_offset=offset;
MemSet(&mbr,0,BLK_SIZE);
mbr.signature=0xAA55;
mbr.p[0].active=0x80;
mbr.p[0].start_head=1;
mbr.p[0].start_cyl=0x101;
mbr.p[0].type=1; //Will get set different.
mbr.p[0].end_head=0xFE;
mbr.p[0].end_cyl=0xFFFF;
mbr.p[0].offset=PRT_HEADER;
mbr.p[0].size=temppp->size-PRT_HEADER;
offset+=temppp->size;
temppp=temppp->next;
if (temppp!=&root) {
mbr.p[1].active=0x80;
mbr.p[1].start_head=0;
mbr.p[1].start_cyl=0x101;
mbr.p[1].type=5;
mbr.p[1].end_head=0xFE;
mbr.p[1].end_cyl=0xFFFF;
mbr.p[1].offset=offset-ext_base;
mbr.p[1].size=temppp->size;
}
ATAWriteBlks(bdev,&mbr,start_offset,1);
}
bdev->flags&=~(BDF_INITIALIZED | BDF_INIT_IN_PROGRESS);
BlkDevAdd(bdev,FALSE,TRUE);
for (i=bdev->first_drv_let;i<drv_let2;i++)
Fmt(i,,FALSE);
pd_done:
while (root.next!=&root) {
temppp=root.next;
QueRem(temppp);
Free(temppp);
}
}
#help_index "Info;File/Cmd Line (Typically);Cmd Line (Typically)"
U0 RedSeaFSDrvView(U8 drv_let=0)
{
CPrt *p=Drv2Prt(drv_let);
I64 lohi,c1,i,x,y,l,s;
U8 *bitmap;
CDC *dc=DCAlias;
l=(GR_HEIGHT-3*FONT_HEIGHT)*(GR_WIDTH-FONT_WIDTH<<1),
s=(p->size+p->spc-1)/p->spc;
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
WinMax;
DocCursor;
DocClear;
DCFill;
try {
i=((s+7)>>3+BLK_SIZE-1)>>BLK_SIZE_BITS;
bitmap=MAlloc(i<<BLK_SIZE_BITS);
RBlks(p,bitmap,p->map1,i);
i=0;
for (y=0;y<GR_HEIGHT-3*FONT_HEIGHT;y++) {
if (ScanKey)
break;
for (x=0;x<GR_WIDTH-FONT_WIDTH<<1;x++) {
lohi=i*s;
c1=lohi/l;
if (Bt(bitmap,c1))
dc->color=ROP_XOR+BLUE^COLOR_TRANSPARENT;
else
dc->color=ROP_XOR+WHITE^COLOR_TRANSPARENT;
GrPlot(dc,x,y);
i++;
}
}
Free(bitmap);
} catch
PrtUnlock(p);
GetChar;
SettingsPop;
DCFill;
DCDel(dc);
}
U0 FAT32DrvView(U8 drv_let=0)
{
CPrt *p=Drv2Prt(drv_let);
I64 lohi,c1,i,x,y,l,s;
U32 *bitmap;
CDC *dc=DCAlias;
l=(GR_HEIGHT-3*FONT_HEIGHT)*(GR_WIDTH-FONT_WIDTH<<1),
s=(p->size+p->spc-1)/p->spc;
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
WinMax;
DocCursor;
DocClear;
DCFill;
try {
i=(s*4+BLK_SIZE-1)>>BLK_SIZE_BITS;
bitmap=MAlloc(i<<BLK_SIZE_BITS);
RBlks(p,bitmap,p->map1,i);
i=0;
for (y=0;y<GR_HEIGHT-3*FONT_HEIGHT;y++) {
if (ScanKey)
break;
for (x=0;x<GR_WIDTH-FONT_WIDTH<<1;x++) {
lohi=i*s;
c1=lohi/l;
if (bitmap[c1])
dc->color=ROP_XOR+BLUE^COLOR_TRANSPARENT;
else
dc->color=ROP_XOR+WHITE^COLOR_TRANSPARENT;
GrPlot(dc,x,y);
i++;
}
}
Free(bitmap);
} catch
PrtUnlock(p);
GetChar;
SettingsPop;
DCFill;
DCDel(dc);
}
public U0 DrvView(U8 drv_let=0)
{
CPrt *p=Drv2Prt(drv_let),*p_old=Fs->cur_prt;
Drv(drv_let);
switch (p->type) {
case PT_REDSEA:
RedSeaFSDrvView(drv_let);
break;
case PT_FAT32:
FAT32DrvView(drv_let);
break;
default:
PrintErr("File System Not Supported\n");
}
Drv(Prt2Drv(p_old));
}
public U0 DskView(U8 drv_let=0)
{
I64 i,j,
h=Fs->pix_width,
v=Fs->pix_height,
radius;
CPrt *p;
CBlkDev *bdev=Drv2BlkDev(drv_let);
CDC *dc=DCAlias;
F64 sect_start,sect_end;
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
DocCursor;
DocClear;
DCFill;
if (h<v)
radius=0.4*h;
else
radius=0.4*v;
dc->color=BLACK;
GrCircle(dc,h>>1,v>>1,radius);
j=1;
for (i=0;i<NUM_PRTS;i++) {
p=&sys_prts[i];
if (bdev==p->bdev && p->type) {
sect_start=-(p->offset*2*ã/(bdev->max_blk+1));
sect_end =-((p->offset+p->size)*2*ã/(bdev->max_blk+1));
dc->color=BLACK;
GrLine(dc,h>>1,v>>1,
h>>1+radius*Cos(sect_start),
v>>1+radius*Sin(sect_start));
GrLine(dc,h>>1,v>>1,
h>>1+radius*Cos(sect_end),
v>>1+radius*Sin(sect_end));
dc->color=j;
GrPrint(dc,0,v-FONT_HEIGHT*j,"%C %-8Z",Prt2Drv(p),
p->type.u16[0],"ST_PRT_TYPES");
GrFloodFill(dc,
h>>1+(radius-4)*Cos((sect_start+sect_end)/2),
v>>1+(radius-4)*Sin((sect_start+sect_end)/2),FALSE);
j++;
}
}
GetChar(,FALSE);
SettingsPop;
DCFill;
DCDel(dc);
}
#help_index "Info;File/Cmd Line (Typically);Cmd Line (Typically);Install"
public U0 BlkDevRep()
{
I64 i;
for (i=0;i<NUM_BLKDEVS;i++)
if (sys_blkdevs[i].bd_signature==BD_SIGNATURE_VAL)
ClassRep(&sys_blkdevs[i]);
}
#help_index ""
+755
View File
@@ -0,0 +1,755 @@
#help_index "Doc/Output"
U0 DirFileDoc(CDoc *doc,CDirEntry *tempde)
{
CDocEntry *doc_e;
while (tempde) {
if (tempde->attr & _ATTR_DIR) {
doc_e=DocPrint(doc,"$$TR,\"%s\"$$",tempde->name);
doc_e->user_data=tempde;
tempde->user_data=doc_e;
DocPrint(doc,"\n$$ID,+2$$");
if (tempde->sub)
DirFileDoc(doc,tempde->sub);
DocPrint(doc,"$$ID,-2$$");
} else {
doc_e=DocPrint(doc,"$$MU,\"%s\"$$",
tempde->name);
doc_e->user_data=tempde;
tempde->user_data=doc_e;
DocPrint(doc,"\n");
}
tempde=tempde->next;
}
}
#help_index "File/Cmd Line (Typically);Cmd Line (Typically)"
class CFMUncollapsedLst
{
CFMUncollapsedLst *next;
U8 *name;
};
CFMUncollapsedLst *FMCollectUncollapsedLst(CDoc *doc)
{
CDocEntry *doc_e=doc->root.next;
CFMUncollapsedLst *result=NULL,*tempc;
CDirEntry *tempde;
while (doc_e!=doc) {
if (doc_e->type_u8==DOCT_TREE) {
if (!(doc_e->flags1&DOCEF1_CHECKED_COLLAPSED)) {
if (tempde=doc_e->user_data) {
tempc=MAlloc(sizeof(CFMUncollapsedLst));
tempc->next=result;
result=tempc;
tempc->name=StrNew(tempde->full_name);
}
}
}
doc_e=doc_e->next;
}
return result;
}
U0 FMMarkUncollapsed(CDoc *doc,CFMUncollapsedLst *tempc,U8 *cur_entry,U8 *next_entry)
{
CDocEntry *doc_e=doc->root.next;
CFMUncollapsedLst *tempc1;
CDirEntry *tempde;
while (doc_e!=doc) {
if (doc_e->type_u8==DOCT_TREE) {
tempde=doc_e->user_data;
tempc1=tempc;
while (tempc1) {
if (!StrCmp(tempc1->name,tempde->full_name)) {
doc_e->flags1&=~DOCEF1_CHECKED_COLLAPSED;
break;
}
tempc1=tempc1->next;
}
if (cur_entry) {
if (!StrNCmp(cur_entry,tempde->full_name,StrLen(tempde->full_name))) {
doc->cur_entry=doc_e;
if (StrLen(tempde->full_name)==StrLen(cur_entry))
cur_entry=NULL;
} else if (next_entry) {
if (!StrNCmp(next_entry,tempde->full_name,StrLen(tempde->full_name))) {
doc->cur_entry=doc_e;
if (StrLen(tempde->full_name)==StrLen(next_entry))
cur_entry=NULL;
}
}
}
} else if (doc_e->type_u8==DOCT_MENU_VAL) {
tempde=doc_e->user_data;
if (cur_entry) {
if (!StrNCmp(cur_entry,tempde->full_name,StrLen(tempde->full_name))) {
doc->cur_entry=doc_e;
if (StrLen(tempde->full_name)==StrLen(cur_entry))
cur_entry=NULL;
} else if (next_entry) {
if (!StrNCmp(next_entry,tempde->full_name,StrLen(tempde->full_name))) {
doc->cur_entry=doc_e;
if (StrLen(tempde->full_name)==StrLen(next_entry))
cur_entry=NULL;
}
}
}
}
doc_e=doc_e->next;
}
}
U0 FMDelUncollapsedLst(CFMUncollapsedLst *tempc)
{
CFMUncollapsedLst *tempc1;
while (tempc) {
tempc1=tempc->next;
Free(tempc->name);
Free(tempc);
tempc=tempc1;
}
}
CDirEntry *FMRebuildDocDrv(U8 drv_let,CDoc *doc,CDirEntry **_root,Bool init)
{
CDocEntry *doc_e;
CDirEntry *tempde,*tempde1;
U8 *st;
tempde=CAlloc(sizeof(CDirEntry));
tempde->full_name=MPrint("%C:/",drv_let);
tempde->attr=_ATTR_DIR;
st=MPrint("%c:/*",drv_let);
if (init)
tempde->sub=tempde1=FilesFind(st,FUF_RECURSE);
else
tempde1=NULL;
Free(st);
doc_e=DocPrint(doc,"$$TR,\"%s\"$$",tempde->full_name);
doc_e->user_data=tempde;
tempde->user_data=doc_e;
tempde->next=*_root;
*_root=tempde;
DocPrint(doc,"\n$$ID,+2$$");
DocBottom(doc);
if (init) {
DirFileDoc(doc,tempde1);
while (tempde1) {
tempde1->parent=tempde;
tempde1=tempde1->next;
}
}
DocPrint(doc,"$$ID,-2$$");
return tempde;
}
U0 FMRebuildDoc(CDoc **_doc,CDirEntry **_root,I64 mode)
{
CPrt *p;
I64 i;
CDoc *doc=*_doc,*doc2=sys_clipboard_doc,*parent_doc;
CFMUncollapsedLst *tempc=NULL;
U8 *cur_entry=NULL,*next_entry=NULL;
CDocEntry *doc_ce;
CDirEntry *tempde,*tempde1,*cur_tree_entry;
if (!doc)
parent_doc=DocPut;
else {
parent_doc=doc->parent_doc;
Fs->put_doc=Fs->display_doc=NULL;
DocUnlock(doc);
WinMgrSync;
DocLock(doc);
cur_tree_entry=NULL;
doc_ce=doc->cur_entry;
if (doc_ce->type_u8==DOCT_TREE || doc_ce->type_u8==DOCT_MENU_VAL)
cur_tree_entry=doc_ce->user_data;
if (cur_tree_entry)
cur_entry=StrNew(cur_tree_entry->full_name);
tempde=NULL;
if (doc_ce!=doc)
doc_ce=doc_ce->next;
while (doc_ce!=doc) {
if (doc_ce->type_u8==DOCT_TREE || doc_ce->type_u8==DOCT_MENU_VAL)
tempde=doc_ce->user_data;
else
tempde=NULL;
if (tempde) {
tempde1=tempde->parent;
while (tempde1) {
if (tempde1==cur_tree_entry) {
tempde=NULL;
break;
} else
tempde1=tempde1->parent;
}
if (tempde)
break;
}
doc_ce=doc_ce->next;
}
if (tempde)
next_entry=StrNew(tempde->full_name);
tempc=FMCollectUncollapsedLst(doc);
DocDel(doc);
}
if (*_root) {
DirLstDel(*_root);
*_root=NULL;
}
doc=DocNew;
StrCpy(doc->desc,"FileMan");
doc->parent_doc=parent_doc;
doc->flags|=DOCF_FORM;
switch (mode) {
case FM_NORMAL:
DocPrint(doc,"$$PURPLE$$File Manager\n\n$$LK,\"Click for Help\",\"FI:::/Doc/FileMgr.TXT\"$$\n\n");
break;
case FM_PICK_FILE:
DocPrint(doc,"$$PURPLE$$Pick file and press <ESC>\n\n");
doc->flags|=DOCF_MIN_SIZE;
break;
case FM_PICK_DIR:
DocPrint(doc,"$$PURPLE$$Pick directory and press <ESC>\n\n");
doc->flags|=DOCF_MIN_SIZE;
break;
}
DocPrint(doc,"$$LTBLUE$$");
for (i=0;i<NUM_PRTS;i++) {
p=&sys_prts[i];
if (p->type==PT_REDSEA||p->type==PT_FAT32)
FMRebuildDocDrv(Prt2Drv(p),doc,_root,TRUE);
else if (p->type==PT_ISO9660) {
if (p->bdev->flags&BDF_INITIALIZED)
tempde=FMRebuildDocDrv(Prt2Drv(p),doc,_root,TRUE);
else {
tempde=FMRebuildDocDrv(Prt2Drv(p),doc,_root,FALSE);
tempde->flags|=DEF_NOT_INITIALIZED;
}
tempde->flags|=DEF_REMOVABLE;
}
}
DocHome(doc);
FMMarkUncollapsed(doc,tempc,cur_entry,next_entry);
DocCenter(doc);
DocRst(doc2,TRUE);
FMDelUncollapsedLst(tempc);
Free(cur_entry);
Free(next_entry);
*_doc=doc;
DocLock(doc);
Fs->put_doc=Fs->display_doc=doc;
}
U0 FMRename(CDoc *doc)
{
CEdFileName fn;
CDocEntry *doc_e=doc->cur_entry;
CDirEntry *tempde=NULL,*parent;
if (doc_e->type_u8==DOCT_MENU_VAL) {
tempde=doc_e->user_data;
if (parent=tempde->parent) {
Cd(parent->full_name);
StrCpy(fn.name,tempde->name);
if (DocFormDo(&fn)) {
Silent(ON);
Move(tempde->name,fn.name);
Silent(OFF);
}
}
} else if (doc_e->type_u8==DOCT_TREE) {
tempde=doc_e->user_data;
if (parent=tempde->parent) {
Cd(parent->full_name);
StrCpy(fn.name,tempde->name);
if (DocFormDo(&fn)) {
if (StrCmp(tempde->name,fn.name)) {
Silent(ON);
if (CopyTree(tempde->name,fn.name))
DelTree(tempde->name);
Silent(OFF);
}
}
}
}
}
U0 FMMkDir(CDoc *doc)
{
CEdFileName fn;
CDocEntry *doc_e=doc->cur_entry;
CDirEntry *tempde=NULL,*parent;
*fn.name=0;
if (doc_e->type_u8==DOCT_MENU_VAL) {
tempde=doc_e->user_data;
if (parent=tempde->parent) {
Cd(parent->full_name);
if (DocFormDo(&fn)) {
Silent(ON);
MkDir(fn.name);
Silent(OFF);
}
}
} else if (doc_e->type_u8==DOCT_TREE) {
tempde=doc_e->user_data;
Cd(tempde->full_name);
if (DocFormDo(&fn)) {
Silent(ON);
MkDir(fn.name);
Silent(OFF);
}
}
}
U0 FMDelete(CDoc *doc)
{
U8 *st;
CDocEntry *doc_ce=doc->cur_entry;
CDirEntry *tempde;
if (doc_ce->type_u8==DOCT_MENU_VAL) {
tempde=doc_ce->user_data;
Silent(ON);
st=MPrint("Delete: %s",tempde->full_name);
if (PopUpCancelOk(st))
Del(tempde->full_name);
Free(st);
Silent(OFF);
} else if (doc_ce->type_u8==DOCT_TREE) {
tempde=doc_ce->user_data;
Silent(ON);
st=MPrint("Delete: %s",tempde->full_name);
if (PopUpCancelOk(st))
DelTree(tempde->full_name);
Free(st);
Silent(OFF);
}
}
U0 FMMount(CDoc *doc)
{
CDocEntry *doc_ce=doc->cur_entry;
CDirEntry *tempde;
if (doc_ce->type_u8==DOCT_TREE || doc_ce->type_u8==DOCT_MENU_VAL)
tempde=doc_ce->user_data;
else
tempde=NULL;
if (tempde) {
while (tempde->parent)
tempde=tempde->parent;
Silent(ON);
ChgDsk(*tempde->full_name);
Silent(OFF);
}
}
U0 FMFmtDrv(CDoc *doc)
{
CDocEntry *doc_ce=doc->cur_entry;
CDirEntry *tempde;
U8 *st=NULL;
if (doc_ce->type_u8==DOCT_TREE || doc_ce->type_u8==DOCT_MENU_VAL)
tempde=doc_ce->user_data;
else
tempde=NULL;
if (tempde) {
while (tempde->parent)
tempde=tempde->parent;
st=MPrint("Format Drive '%c'?\nAre You Sure?\n",*tempde->full_name);
if (PopUpCancelOk(st)) {
Silent(ON);
Fmt(*tempde->full_name,,FALSE);
Silent(OFF);
}
}
Free(st);
}
U0 FMMakeISO(CDoc *doc)
{
CDocEntry *doc_ce=doc->cur_entry;
CDirEntry *tempde;
U8 *st;
if (doc_ce->type_u8==DOCT_TREE || doc_ce->type_u8==DOCT_MENU_VAL)
tempde=doc_ce->user_data;
else
tempde=NULL;
if (tempde) {
if (doc_ce->type_u8==DOCT_MENU_VAL)
tempde=tempde->parent;
if (tempde && *tempde->full_name) {
Silent(ON);
if (tempde->full_name[StrLen(tempde->full_name)-1]=='/')
st=MPrint("%s*",tempde->full_name);
else
st=MPrint("%s/*",tempde->full_name);
CDFileCreate(,st);
Free(st);
Silent(OFF);
}
}
}
U0 FMBurnISO(CDoc *doc)
{
CDocEntry *doc_ce=doc->cur_entry;
CDirEntry *tempde;
if (doc_ce->type_u8==DOCT_TREE || doc_ce->type_u8==DOCT_MENU_VAL)
tempde=doc_ce->user_data;
else
tempde=NULL;
if (tempde) {
while (tempde->parent)
tempde=tempde->parent;
Silent(ON);
CDImageWrite(*tempde->full_name);
Silent(OFF);
}
}
U0 FMCopy(CDoc *doc)
{
CDoc *doc2=sys_clipboard_doc;
U8 *st;
CDocEntry *doc_ce=doc->cur_entry,*doc_e;
CDirEntry *tempde,*tempde1=NULL,*tempde2;
Bool unlock_doc2=DocLock(doc2);
doc_e=doc2->root.next;
tempde1=doc_ce->user_data;
if (doc_ce->type_u8==DOCT_MENU_VAL)
tempde1=tempde1->parent;
else if (doc_ce->type_u8!=DOCT_TREE)
tempde1=NULL;
if (tempde1) {
while (doc_e!=doc2) {
if (doc_e->type_u8==DOCT_MENU_VAL) {
tempde=doc_e->user_data;
tempde->flags|=DEF_PROCESSED;
tempde2=tempde->parent;
if (!tempde2 || !(tempde2->flags&DEF_PROCESSED)) {
Silent(ON);
Copy(tempde->full_name,tempde1->full_name);
Silent(OFF);
}
} else if (doc_e->type_u8==DOCT_TREE) {
tempde=doc_e->user_data;
tempde->flags|=DEF_PROCESSED;
tempde2=tempde->parent;
if (!tempde2 || !(tempde2->flags&DEF_PROCESSED)) {
Silent(ON);
if (*tempde1->name)
st=MPrint("%s/%s",tempde1->full_name,tempde->name);
else
st=MPrint("%s%s",tempde1->full_name,tempde->name);
CopyTree(tempde->full_name,st);
Free(st);
Silent(OFF);
}
}
doc_e=doc_e->next;
}
}
if (unlock_doc2)
DocUnlock(doc2);
}
#define FMR_INCLUDE 0
#define FMR_ADAM_INCLUDE 1
#define FMR_DELETE 2
#define FMR_RENAME 3
#define FMR_MKDIR 4
#define FMR_PLAIN 5
#define FMR_PASTE 6
#define FMR_CHG_DSK 7
#define FMR_FORMAT 8
#define FMR_MAKE_ISO 9
#define FMR_BURN_ISO 10
#define FMR_HELP 11
I64 PopUpFMRight(U8 *header=NULL,U8 *footer=NULL)
{
I64 i;
CDoc *doc=DocNew;
if (header) DocPrint(doc,"%s",header);
DocPrint(doc,"$$CM+LX,1,1 $$$$BT,\"INCLUDE \",LE=FMR_INCLUDE$$"
"$$CM+LX,27,0$$$$BT,\"ADAM INCLUDE \",LE=FMR_ADAM_INCLUDE$$"
"$$CM+LX,1,3 $$$$BT,\"DELETE \",LE=FMR_DELETE$$"
"$$CM+LX,27,0$$$$BT,\"RENAME \",LE=FMR_RENAME$$"
"$$CM+LX,1,3 $$$$BT,\"MAKE DIRECTORY \",LE=FMR_MKDIR$$"
"$$CM+LX,27,0$$$$BT,\"PLAIN-TEXT EDIT \",LE=FMR_PLAIN$$"
"$$CM+LX,1,3 $$$$BT,\"PASTE CLIPBOARD FILES \",LE=FMR_PASTE$$"
"$$CM+LX,27,0$$$$BT,\"CHANGE DISK(MOUNT IT) \",LE=FMR_CHG_DSK$$"
"$$CM+LX,1,3 $$$$BT,\"FORMAT \",LE=FMR_FORMAT$$"
"$$CM+LX,1,3 $$$$BT,\"MAKE ISO (CD-ROM) FILE\",LE=FMR_MAKE_ISO$$"
"$$CM+LX,27,0$$$$BT,\"BURN ISO (CD-ROM) FILE\",LE=FMR_BURN_ISO$$"
"$$CM+LX,1,3 $$$$BT,\"HELP \",LE=FMR_HELP$$"
"$$CM+LX,27,0$$$$BT,\"CANCEL \",LE=DOCM_CANCEL$$\n");
if (footer) DocPrint(doc,"%s",footer);
i=PopUpMenu(doc);
DocDel(doc);
return i;
}
U0 FMRightClick()
{
switch (PopUpFMRight) {
case FMR_INCLUDE:
Msg(MSG_KEY_DOWN,0,0x3F0000003F);
break;
case FMR_ADAM_INCLUDE:
Msg(MSG_KEY_DOWN,0,0x23F0000023F);
break;
case FMR_DELETE:
Msg(MSG_KEY_DOWN,CH_CTRLY,0);
break;
case FMR_RENAME:
Msg(MSG_KEY_DOWN,'r',0);
break;
case FMR_MKDIR:
Msg(MSG_KEY_DOWN,'d',0);
break;
case FMR_PLAIN:
Msg(MSG_KEY_DOWN,CH_SHIFT_SPACE,0);
break;
case FMR_PASTE:
Msg(MSG_KEY_DOWN,0,SC_INS+SCF_SHIFT);
break;
case FMR_CHG_DSK:
Msg(MSG_KEY_DOWN,'m',0);
break;
case FMR_FORMAT:
Msg(MSG_KEY_DOWN,'f',0);
break;
case FMR_MAKE_ISO:
Msg(MSG_KEY_DOWN,'M',0);
break;
case FMR_BURN_ISO:
Msg(MSG_KEY_DOWN,'B',0);
break;
case FMR_HELP:
Msg(MSG_KEY_DOWN,CH_CTRLM,0x43200000432);
break;
}
}
U8 *fm_ip_str=NULL;
U0 (*fp_old_final_screen_update)(CDC *dc);
U0 FMFinalScreenUpdate(CDC *dc)
{
if (fm_ip_str) {
dc->color=LTRED;
GrPrint(dc,ipx,ipy,"%s",fm_ip_str);
}
(*fp_old_final_screen_update)(dc);
}
public U8 *FileMgr(I64 mode=FM_NORMAL,CTask *mem_task=NULL)
{
CDirEntry *root=NULL,*tempde,*tempde1,*tempde2;
I64 sc,ch,p1,p2,msg_code;
CDoc *doc=NULL,*old_put_doc=DocPut,*old_display_doc=DocDisplay;
U8 *result=NULL,*st,*st2,*old_cur_dir=CurDir;
CDocEntry *doc_ce=NULL,*doc_e;
Bool okay;
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
fp_old_final_screen_update=fp_final_screen_update;
MenuFilePush("::/Doc/FileMgrPullDown.TXT");
FMRebuildDoc(&doc,&root,mode);
if (tempde1=Cd2DirEntry(root,old_cur_dir))
doc->cur_entry=tempde1->user_data;
while (tempde1) {
if (tempde1->attr&_ATTR_DIR)
tempde1->user_data(CDocEntry *)->flags1&=~DOCEF1_CHECKED_COLLAPSED;
tempde1=tempde1->parent;
}
do {
DocUnlock(doc);
do msg_code=GetMsg(&p1,&p2,
1<<MSG_KEY_DOWN|1<<MSG_IP_L_DOWN|1<<MSG_IP_L_UP|
1<<MSG_IP_R_UP);
while (Fs!=sys_focus_task);
DocLock(doc);
switch (msg_code) {
case MSG_IP_R_UP:
DocUnlock(doc);
FMRightClick;
DocLock(doc);
break;
case MSG_IP_L_DOWN:
doc_ce=doc->cur_entry;
fm_ip_str=doc_ce->tag;
fp_final_screen_update=&FMFinalScreenUpdate;
break;
case MSG_IP_L_UP:
if (doc_ce) {
fp_final_screen_update=fp_old_final_screen_update;
if (SetCursorPos(Fs,p1/FONT_WIDTH+Fs->win_left+Fs->scroll_x/FONT_WIDTH,p2/FONT_HEIGHT+Fs->win_top+Fs->scroll_y/FONT_HEIGHT,TRUE)) {
doc_e=doc->cur_entry;
if (doc_e!=doc_ce) {
st2=NULL;
if (doc_e->type_u8==DOCT_MENU_VAL) {
tempde1=doc_e->user_data;
if (tempde1=tempde1->parent)
st2=StrNew(tempde1->full_name);
} else if (doc_e->type_u8==DOCT_TREE) {
tempde1=doc_e->user_data;
st2=StrNew(tempde1->full_name);
}
if (st2 && doc_ce->type_u8==DOCT_MENU_VAL) {
tempde=doc_ce->user_data;
Silent(ON);
Move(tempde->full_name,st2);
Silent(OFF);
FMRebuildDoc(&doc,&root,mode);
} else if (st2 && doc_ce->type_u8==DOCT_TREE) {
tempde=doc_ce->user_data;
okay=TRUE;
tempde2=tempde1;
while (tempde2) {
if (tempde2!=tempde)
tempde2=tempde2->parent;
else {
okay=FALSE;
break;
}
}
if (okay) {
if (*tempde1->name)
st=MPrint("%s/%s",tempde1->full_name,tempde->name);
else
st=MPrint("%s%s",tempde1->full_name,tempde->name);
if (StrCmp(tempde->full_name,st)) {
Silent(ON);
CopyTree(tempde->full_name,st);
DelTree(tempde->full_name);
Silent(OFF);
FMRebuildDoc(&doc,&root,mode);
}
Free(st);
}
}
Free(st2);
FlushMsgs;
} else
if (doc_e->type_u8==DOCT_MENU_VAL) {
DocUnlock(doc);
Ed(doc_e->user_data(CDirEntry *)->full_name);
DocLock(doc);
}
doc_ce=NULL;
}
}
break;
case MSG_KEY_DOWN:
doc_ce=NULL;
ch=p1; sc=p2;
if (sc.u8[0]==SC_DELETE && !(sc&(SCF_SHIFT|SCF_CTRL)))
ch=CH_CTRLY;
if (ch && sc&SCF_ALT) goto regular_key;
switch (ch) {
case '\n':
DocUnlock(doc);
FMRightClick;
DocLock(doc);
break;
sub_switch_start:
DocUnlock(doc);
case CH_CTRLV:
FMCopy(doc);
break;
case 'r':
FMRename(doc);
break;
case 'd':
FMMkDir(doc);
break;
case CH_CTRLY:
FMDelete(doc);
break;
case 'm':
FMMount(doc);
break;
case 'M':
FMMakeISO(doc);
break;
case 'B':
FMBurnISO(doc);
break;
case 'f':
FMFmtDrv(doc);
break;
sub_switch_end:
FMRebuildDoc(&doc,&root,mode);
break;
case CH_SHIFT_ESC:
break;
case CH_SPACE:
if (doc->cur_entry->type_u8==DOCT_MENU_VAL) {
DocUnlock(doc);
Ed(doc->cur_entry->user_data(CDirEntry *)->full_name);
DocLock(doc);
} else
goto regular_key;
break;
case CH_SHIFT_SPACE:
if (doc->cur_entry->type_u8==DOCT_MENU_VAL) {
DocUnlock(doc);
Plain(doc->cur_entry->user_data(CDirEntry *)->full_name);
DocLock(doc);
} else
goto regular_key;
break;
case CH_ESC:
doc_ce=doc->cur_entry;
tempde=doc_ce->user_data;
if (mode==FM_PICK_FILE && doc_ce->type_u8==DOCT_MENU_VAL)
result=StrNew(tempde->full_name,mem_task);
else if (mode==FM_PICK_DIR) {
if (doc_ce->type_u8==DOCT_TREE)
result=StrNew(tempde->full_name,mem_task);
else if (doc_ce->type_u8==DOCT_MENU_VAL && (tempde=tempde->parent))
result=StrNew(tempde->full_name,mem_task);
}
break;
default:
if (sc.u8[0]==SC_INS && sc&SCF_SHIFT && !(sc&SCF_CTRL)) {
FMCopy(doc);
FMRebuildDoc(&doc,&root,mode);
} else if (sc.u8[0]==SC_F5) {
if (doc->cur_entry->type_u8==DOCT_MENU_VAL) {
tempde=doc->cur_entry->user_data;
DocUnlock(doc);
if (sc&SCF_SHIFT)
AdamFile(tempde->full_name);
else
PopUpFile(tempde->full_name);
DocLock(doc);
}
} else {
regular_key:
DocUnlock(doc);
PutKey(ch,sc);
DocLock(doc);
}
}
break;
}
} while (ch!=CH_ESC && ch!=CH_SHIFT_ESC);
fp_final_screen_update=fp_old_final_screen_update;
Fs->put_doc =old_put_doc;
Fs->display_doc=old_display_doc;
SettingsPop;
DocDel(doc);
DirLstDel(root);
Cd(old_cur_dir);
Free(old_cur_dir);
if (mode!=FM_NORMAL && !result)
result=StrNew("",mem_task);
MenuPop;
return result;
}
#help_index ""