Browse Source

TempleOSCDV4.11.ISO

v6
Terry A. Davis 5 years ago
committed by minexew
parent
commit
93ca216483
  1. BIN
      0000Boot/0000Kernel.BIN.C
  2. 252
      Adam/ABlkDev/ADskA.CPP
  3. 252
      Adam/ABlkDev/ADskA.HC
  4. 0
      Adam/ABlkDev/ADskB.HC
  5. 0
      Adam/ABlkDev/ChkDsk.HC
  6. 793
      Adam/ABlkDev/FileMgr.CPP
  7. 793
      Adam/ABlkDev/FileMgr.HC
  8. 0
      Adam/ABlkDev/MakeABlkDev.HC
  9. 148
      Adam/ABlkDev/Mount.CPP
  10. 148
      Adam/ABlkDev/Mount.HC
  11. 0
      Adam/ABlkDev/PrtDsk.HC
  12. 270
      Adam/ADbg.CPP
  13. 270
      Adam/ADbg.HC
  14. 39
      Adam/ADefine.CPP
  15. 39
      Adam/ADefine.HC
  16. 98
      Adam/AExts.CPP
  17. 98
      Adam/AExts.HC
  18. 433
      Adam/AHash.CPP
  19. 433
      Adam/AHash.HC
  20. BIN
      Adam/AInputPointer.CPP
  21. BIN
      Adam/AInputPointer.HC
  22. 0
      Adam/AMath.HC
  23. 609
      Adam/AMathODE.CPP
  24. 609
      Adam/AMathODE.HC
  25. 0
      Adam/AMem.HC
  26. 106
      Adam/ARegistry.CPP
  27. 106
      Adam/ARegistry.HC
  28. 263
      Adam/AutoComplete/ACDictGen.CPP
  29. 263
      Adam/AutoComplete/ACDictGen.HC
  30. 0
      Adam/AutoComplete/ACFill.HC
  31. 0
      Adam/AutoComplete/ACInit.HC
  32. 285
      Adam/AutoComplete/ACTask.CPP
  33. 284
      Adam/AutoComplete/ACTask.HC
  34. 6
      Adam/AutoComplete/MakeAC.CPP
  35. 6
      Adam/AutoComplete/MakeAC.HC
  36. 139
      Adam/AutoFile.CPP
  37. 139
      Adam/AutoFile.HC
  38. 388
      Adam/Ctrls/CtrlsA.CPP
  39. 388
      Adam/Ctrls/CtrlsA.HC
  40. 91
      Adam/Ctrls/CtrlsButton.CPP
  41. 91
      Adam/Ctrls/CtrlsButton.HC
  42. 0
      Adam/Ctrls/CtrlsSlider.HC
  43. 0
      Adam/Ctrls/MakeCtrls.HC
  44. 207
      Adam/DevInfo.CPP
  45. 274
      Adam/DevInfo.HC
  46. 0
      Adam/DolDoc/DocBin.HC
  47. 652
      Adam/DolDoc/DocChar.CPP
  48. 652
      Adam/DolDoc/DocChar.HC
  49. 0
      Adam/DolDoc/DocClipBoard.HC
  50. 658
      Adam/DolDoc/DocCodeTools.CPP
  51. 658
      Adam/DolDoc/DocCodeTools.HC
  52. 108
      Adam/DolDoc/DocDblBuf.CPP
  53. 108
      Adam/DolDoc/DocDblBuf.HC
  54. 250
      Adam/DolDoc/DocEd.CPP
  55. 250
      Adam/DolDoc/DocEd.HC
  56. 0
      Adam/DolDoc/DocExt.HC
  57. 0
      Adam/DolDoc/DocFile.HC
  58. 0
      Adam/DolDoc/DocFind.HC
  59. 344
      Adam/DolDoc/DocForm.CPP
  60. 344
      Adam/DolDoc/DocForm.HC
  61. 0
      Adam/DolDoc/DocGet.HC
  62. 0
      Adam/DolDoc/DocGr.HC
  63. 155
      Adam/DolDoc/DocHighlight.CPP
  64. 155
      Adam/DolDoc/DocHighlight.HC
  65. 0
      Adam/DolDoc/DocInit.HC
  66. 0
      Adam/DolDoc/DocLink.HC
  67. 0
      Adam/DolDoc/DocMacro.HC
  68. 385
      Adam/DolDoc/DocNew.CPP
  69. 385
      Adam/DolDoc/DocNew.HC
  70. 117
      Adam/DolDoc/DocOpt.CPP
  71. 117
      Adam/DolDoc/DocOpt.HC
  72. 0
      Adam/DolDoc/DocPlain.HC
  73. 323
      Adam/DolDoc/DocPopUp.CPP
  74. 323
      Adam/DolDoc/DocPopUp.HC
  75. 726
      Adam/DolDoc/DocPutKey.CPP
  76. 726
      Adam/DolDoc/DocPutKey.HC
  77. 0
      Adam/DolDoc/DocPutS.HC
  78. 1334
      Adam/DolDoc/DocRecalc.CPP
  79. 1334
      Adam/DolDoc/DocRecalc.HC
  80. 213
      Adam/DolDoc/DocRecalcLib.CPP
  81. 213
      Adam/DolDoc/DocRecalcLib.HC
  82. 0
      Adam/DolDoc/DocRun.HC
  83. 207
      Adam/DolDoc/DocTerm.CPP
  84. 207
      Adam/DolDoc/DocTerm.HC
  85. 0
      Adam/DolDoc/DocTree.HC
  86. 1163
      Adam/DolDoc/DocWidgetWiz.CPP
  87. 1163
      Adam/DolDoc/DocWidgetWiz.HC
  88. 70
      Adam/DolDoc/MakeDoc.CPP
  89. 70
      Adam/DolDoc/MakeDoc.HC
  90. 0
      Adam/God/GodBible.HC
  91. 188
      Adam/God/GodDoodle.CPP
  92. 188
      Adam/God/GodDoodle.HC
  93. 24
      Adam/God/GodExt.CPP
  94. 26
      Adam/God/GodExt.HC
  95. 164
      Adam/God/GodSong.CPP
  96. 164
      Adam/God/GodSong.HC
  97. 218
      Adam/God/HSNotes.DD
  98. 217
      Adam/God/HSNotes.TXT
  99. 146
      Adam/God/HolySpirit.CPP
  100. 158
      Adam/God/HolySpirit.HC

BIN
0000Boot/0000Kernel.BIN.C

Binary file not shown.

252
Adam/ABlkDev/ADskA.CPP

@ -1,252 +0,0 @@
#help_index "File/Cmd Line (Typically);Cmd Line (Typically)"
public U8 *DBlk(I64 blk,Bool write=FALSE)
{//Dump disk block. Optionally, write.
//If you set write to TRUE, the block will
//be written when you press <ESC>.
//See $LK,"::/Demo/Dsk/DskRaw.CPP"$.
U8 *buf=MAlloc(BLK_SIZE);
RBlks(Fs->cur_dv,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_dv,buf,blk,1);
}
}
return buf;
}
public U8 *DCluster(I64 c,Bool write=FALSE,I64 num=0)
{//Dump disk cluster. Optionally, write.
//If you set write to TRUE, the cluster 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_dv->spc<<BLK_SIZE_BITS);
c=ClusterNumNext(Fs->cur_dv,c,num);
RClusters(Fs->cur_dv,buf,c,1);
"Cluster:%X\n",c;
DocD(buf,Fs->cur_dv->spc<<BLK_SIZE_BITS);
if (write) {
"Edit and press <ESC> to write or <SHIFT-ESC>\n";
if (View) {
"Write\n";
WClusters(Fs->cur_dv,buf,c,1);
}
}
return buf;
}
public U8 *Dump(U8 *filename,Bool write=FALSE)
{//Dump file. Optionally, write.
//If you set write to TRUE, the file will
//be written when you press <ESC>.
U8 *buf;
I64 size;
if (buf=FileRead(filename,&size)) {
DocD(buf,size);
if (write) {
"Edit and press <ESC> to write or <SHIFT-ESC>\n";
if (View) {
"Write\n";
FileWrite(filename,buf,size);
}
}
}
return buf;
}
public Bool Copy(U8 *src_files_find_mask,U8 *dst_files_find_mask=".")
{//Copy files.
//If the name ends in ".Z", it will
//be stored compressed. If not ".Z"
//it will be stored uncompressed.
Bool res=TRUE;
CDirContext *dirc;
CDirEntry *tempde,*tempde1;
U8 *st;
if (!(tempde1=FilesFind(src_files_find_mask,FUF_CLUSTER_ORDER)))
return FALSE;
if (IsDir(dst_files_find_mask)) {
if (dirc=DirContextNew(dst_files_find_mask,TRUE)) {
tempde=tempde1;
while (tempde) {
if (!(tempde->attr & RS_ATTR_DIR)) {
st=FileNameAbs(tempde->name);
if (!CopySingle(tempde->full_name,st))
res=FALSE;
Free(st);
}
tempde=tempde->next;
}
DirContextDel(dirc);
}
DirTreeDel(tempde1);
return res;
} else {
DirTreeDel(tempde1);
return CopySingle(src_files_find_mask,dst_files_find_mask);
}
}
public Bool Move(U8 *f1,U8 *f2)
{//Move files from one location to another or rename.
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 res=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 & RS_ATTR_DIR) {
MkDir(st,LinkedLstCnt(tempde->sub));
res+=CopyTree2(tempde->sub,src_dir_len,dst_dir_len,dst_dir);
} else
if (CopySingle(tempde->full_name,st))
res++;
Free(st);
tempde=tempde->next;
}
return res;
}
public I64 CopyTree(U8 *src_files_find_mask,U8 *dst_files_find_mask,
Bool no_mask=TRUE)
{//Copy directory tree.
//Returns the count of copied files (not dirs).
CDirContext *dirc;
CDirEntry *tempde=NULL;
I64 res=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 (dirc=DirContextNew(src_files_find_mask,TRUE,,no_mask)) {
tempde=FilesFind(dirc->mask,FUF_RECURSE);
st1=CurDir;
DirContextDel(dirc);
i1=StrLen(st1);
if (i1==3) i1--;
if (dirc=DirContextNew(dst_files_find_mask,TRUE,TRUE)) {
st2=CurDir;
i2=StrLen(st2);
if (i2==3) i2--;
res=CopyTree2(tempde,i1,i2,st2);
DirContextDel(dirc);
Free(st2);
}
DirTreeDel(tempde);
Free(st1);
}
return res;
}
I64 DelTreeDirs(CDirEntry *tempde1)
{
I64 res=0;
CDirEntry *tempde2;
while (tempde1) {
tempde2=tempde1->next;
if (tempde1->attr & RS_ATTR_DIR) {
if (tempde1->sub)
res+=DelTreeDirs(tempde1->sub);
res+=Del(tempde1->full_name,TRUE,TRUE);
}
DirEntryDel(tempde1);
tempde1=tempde2;
}
return res;
}
I64 DelTreeFiles(CDirEntry *tempde1)
{
I64 res=0;
CDirEntry *tempde2;
while (tempde1) {
tempde2=tempde1->next;
if (tempde1->attr & RS_ATTR_DIR) {
if (tempde1->sub)
res+=DelTreeFiles(tempde1->sub);
} else
res+=Del(tempde1->full_name,FALSE,TRUE);
DirEntryDel(tempde1);
tempde1=tempde2;
}
return res;
}
public I64 DelTree(U8 *files_find_mask,U8 *fu_flags=NULL)
{//Delete directory tree.
I64 res=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)) {
res=DelTreeDirs(FilesFind(files_find_mask,fuf_flags));
res+=Del(files_find_mask,TRUE,TRUE);
res+=Del(files_find_mask,FALSE,TRUE);
} else
res=DelTreeFiles(FilesFind(files_find_mask,fuf_flags));
return res;
}
U0 TouchFile(U8 *filename,U8 *attr,CDate cdt=MIN_I64)
{
CDrv *dv=Let2Drv(*filename);
CDirEntry de;
U8 *cur_dir=StrNew(filename),buf[STR_LEN];
if (FileFind(filename,&de,FUF_JUST_FILES)) {
Free(de.full_name);
if (!StrCmp(attr,"+?"))
"%-48ts %s\n",filename,StrPrintFlags(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(dv,cur_dir,&de,FALSE);
}
} else
PrintErr("File not found.\n");
Free(cur_dir);
}
public U0 Touch(U8 *files_find_mask="*",U8 *attr="+?",
U8 *fu_flags=NULL,CDate cdt=MIN_I64)
{/*Touch file attributes and DateTime.
Default lists attributes.
attr: "+?" =show current
"+T" =resident
$LK,"RS_ATTR_READ_ONLY",A="MN:RS_ATTR_READ_ONLY"$ $LK,"ST_FILE_ATTRS",A="MN:ST_FILE_ATTRS"$
To Set DateL:
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;
}
DirTreeDel(tempde1);
}

252
Adam/ABlkDev/ADskA.HC

@ -0,0 +1,252 @@
#help_index "File/Cmd Line (Typically);Cmd Line (Typically)"
public U8 *DBlk(I64 blk,Bool write=FALSE)
{//Dump disk block. Optionally, write.
//If you set write to TRUE, the block will
//be written when you press <ESC>.
//See $LK,"::/Demo/Dsk/DskRaw.HC"$.
U8 *buf=MAlloc(BLK_SIZE);
RBlks(Fs->cur_dv,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_dv,buf,blk,1);
}
}
return buf;
}
public U8 *DCluster(I64 c,Bool write=FALSE,I64 num=0)
{//Dump disk cluster. Optionally, write.
//If you set write to TRUE, the cluster will
//be written when you press <ESC>.
//See $LK,"::/Demo/Dsk/DskRaw.HC"$.
//Do $LK,"Dir",A="MN:Dir"$("*",TRUE); to get cluster numbers of files.
U8 *buf=MAlloc(Fs->cur_dv->spc<<BLK_SIZE_BITS);
c=ClusterNumNext(Fs->cur_dv,c,num);
RClusters(Fs->cur_dv,buf,c,1);
"Cluster:%X\n",c;
DocD(buf,Fs->cur_dv->spc<<BLK_SIZE_BITS);
if (write) {
"Edit and press <ESC> to write or <SHIFT-ESC>\n";
if (View) {
"Write\n";
WClusters(Fs->cur_dv,buf,c,1);
}
}
return buf;
}
public U8 *Dump(U8 *filename,Bool write=FALSE)
{//Dump file. Optionally, write.
//If you set write to TRUE, the file will
//be written when you press <ESC>.
U8 *buf;
I64 size;
if (buf=FileRead(filename,&size)) {
DocD(buf,size);
if (write) {
"Edit and press <ESC> to write or <SHIFT-ESC>\n";
if (View) {
"Write\n";
FileWrite(filename,buf,size);
}
}
}
return buf;
}
public Bool Copy(U8 *src_files_find_mask,U8 *dst_files_find_mask=".")
{//Copy files.
//If the name ends in ".Z", it will
//be stored compressed. If not ".Z"
//it will be stored uncompressed.
Bool res=TRUE;
CDirContext *dirc;
CDirEntry *tempde,*tempde1;
U8 *st;
if (!(tempde1=FilesFind(src_files_find_mask,FUF_CLUSTER_ORDER)))
return FALSE;
if (IsDir(dst_files_find_mask)) {
if (dirc=DirContextNew(dst_files_find_mask,TRUE)) {
tempde=tempde1;
while (tempde) {
if (!(tempde->attr & RS_ATTR_DIR)) {
st=FileNameAbs(tempde->name);
if (!CopySingle(tempde->full_name,st))
res=FALSE;
Free(st);
}
tempde=tempde->next;
}
DirContextDel(dirc);
}
DirTreeDel(tempde1);
return res;
} else {
DirTreeDel(tempde1);
return CopySingle(src_files_find_mask,dst_files_find_mask);
}
}
public Bool Move(U8 *f1,U8 *f2)
{//Move files from one location to another or rename.
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 res=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 & RS_ATTR_DIR) {
MkDir(st,LinkedLstCnt(tempde->sub));
res+=CopyTree2(tempde->sub,src_dir_len,dst_dir_len,dst_dir);
} else
if (CopySingle(tempde->full_name,st))
res++;
Free(st);
tempde=tempde->next;
}
return res;
}
public I64 CopyTree(U8 *src_files_find_mask,U8 *dst_files_find_mask,
Bool no_mask=TRUE)
{//Copy directory tree.
//Returns the count of copied files (not dirs).
CDirContext *dirc;
CDirEntry *tempde=NULL;
I64 res=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 (dirc=DirContextNew(src_files_find_mask,TRUE,,no_mask)) {
tempde=FilesFind(dirc->mask,FUF_RECURSE);
st1=CurDir;
DirContextDel(dirc);
i1=StrLen(st1);
if (i1==3) i1--;
if (dirc=DirContextNew(dst_files_find_mask,TRUE,TRUE)) {
st2=CurDir;
i2=StrLen(st2);
if (i2==3) i2--;
res=CopyTree2(tempde,i1,i2,st2);
DirContextDel(dirc);
Free(st2);
}
DirTreeDel(tempde);
Free(st1);
}
return res;
}
I64 DelTreeDirs(CDirEntry *tempde1)
{
I64 res=0;
CDirEntry *tempde2;
while (tempde1) {
tempde2=tempde1->next;
if (tempde1->attr & RS_ATTR_DIR) {
if (tempde1->sub)
res+=DelTreeDirs(tempde1->sub);
res+=Del(tempde1->full_name,TRUE,TRUE);
}
DirEntryDel(tempde1);
tempde1=tempde2;
}
return res;
}
I64 DelTreeFiles(CDirEntry *tempde1)
{
I64 res=0;
CDirEntry *tempde2;
while (tempde1) {
tempde2=tempde1->next;
if (tempde1->attr & RS_ATTR_DIR) {
if (tempde1->sub)
res+=DelTreeFiles(tempde1->sub);
} else
res+=Del(tempde1->full_name,FALSE,TRUE);
DirEntryDel(tempde1);
tempde1=tempde2;
}
return res;
}
public I64 DelTree(U8 *files_find_mask,U8 *fu_flags=NULL)
{//Delete directory tree.
I64 res=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)) {
res=DelTreeDirs(FilesFind(files_find_mask,fuf_flags));
res+=Del(files_find_mask,TRUE,TRUE);
res+=Del(files_find_mask,FALSE,TRUE);
} else
res=DelTreeFiles(FilesFind(files_find_mask,fuf_flags));
return res;
}
U0 TouchFile(U8 *filename,U8 *attr,CDate cdt=MIN_I64)
{
CDrv *dv=Let2Drv(*filename);
CDirEntry de;
U8 *cur_dir=StrNew(filename),buf[STR_LEN];
if (FileFind(filename,&de,FUF_JUST_FILES)) {
Free(de.full_name);
if (!StrCmp(attr,"+?"))
"%-48ts %s\n",filename,StrPrintFlags(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(dv,cur_dir,&de,FALSE);
}
} else
PrintErr("File not found.\n");
Free(cur_dir);
}
public U0 Touch(U8 *files_find_mask="*",U8 *attr="+?",
U8 *fu_flags=NULL,CDate cdt=MIN_I64)
{/*Touch file attributes and DateTime.
Default lists attributes.
attr: "+?" =show current
"+T" =resident
$LK,"RS_ATTR_READ_ONLY",A="MN:RS_ATTR_READ_ONLY"$ $LK,"ST_FILE_ATTRS",A="MN:ST_FILE_ATTRS"$
To Set DateL:
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;
}
DirTreeDel(tempde1);
}

0
Adam/ABlkDev/ADskB.CPP → Adam/ABlkDev/ADskB.HC

0
Adam/ABlkDev/ChkDsk.CPP → Adam/ABlkDev/ChkDsk.HC

793
Adam/ABlkDev/FileMgr.CPP

@ -1,793 +0,0 @@
#help_index "DolDoc/Output;StdOut/DolDoc"
U0 DirFileDoc(CDoc *doc,CDirEntry *tempde)
{
while (tempde) {
if (tempde->attr & RS_ATTR_DIR) {
tempde->user_data=DocPrint(doc,"$$TR,\"%s\",U=0x%X$$",tempde->name,tempde);
DocPrint(doc,"\n$$ID,+2$$");
if (tempde->sub)
DirFileDoc(doc,tempde->sub);
DocPrint(doc,"$$ID,-2$$");
} else {
tempde->user_data=DocPrint(doc,"$$MU,\"%s\",U=0x%X$$",tempde->name,tempde);
DocPrint(doc,"\n");
}
tempde=tempde->next;
}
}
#help_index "File/Cmd Line (Typically);Cmd Line (Typically)"
#define FM_NORMAL 0
#define FM_PICK_FILE 1
#define FM_PICK_DIR 2
class CFMUncollapsedLst
{
CFMUncollapsedLst *next;
U8 *name;
};
CFMUncollapsedLst *FMCollectUncollapsedLst(CDoc *doc)
{
CDocEntry *doc_e=doc->head.next;
CFMUncollapsedLst *res=NULL,*tempc;
CDirEntry *tempde;
while (doc_e!=doc) {
if (doc_e->type_u8==DOCT_TREE) {
if (!(doc_e->de_flags&DOCEF_CHECKED_COLLAPSED)) {
if (tempde=doc_e->user_data) {
tempc=MAlloc(sizeof(CFMUncollapsedLst));
tempc->next=res;
res=tempc;
tempc->name=StrNew(tempde->full_name);
}
}
}
doc_e=doc_e->next;
}
return res;
}
U0 FMMarkUncollapsed(CDoc *doc,CFMUncollapsedLst *tempc,
U8 *cur_entry,U8 *next_entry)
{
CDocEntry *doc_e=doc->head.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->de_flags&=~DOCEF_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 **_head,Bool init)
{
CDirEntry *tempde,*tempde1;
U8 *st;
tempde=CAlloc(sizeof(CDirEntry));
tempde->full_name=MStrPrint("%C:/",drv_let);
tempde->attr=RS_ATTR_DIR;
st=MStrPrint("%c:/*",drv_let);
if (init)
tempde->sub=tempde1=FilesFind(st,FUF_RECURSE);
else
tempde1=NULL;
Free(st);
tempde->user_data=DocPrint(doc,"$$TR,\"%s\",U=0x%X$$",tempde->full_name,tempde);
tempde->next=*_head;
*_head=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 **_head,I64 mode)
{
CDrv *dv;
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 (*_head) {
DirTreeDel(*_head);
*_head=NULL;
}
doc=DocNew;
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\",A=\"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_DRVS;i++) {
dv=&blkdev.drvs[i];
if (dv->bd->type==BDT_ATAPI) {
if (dv->bd->flags&BDF_INITIALIZED)
tempde=FMRebuildDocDrv(Drv2Let(dv),doc,_head,TRUE);
else {
tempde=FMRebuildDocDrv(Drv2Let(dv),doc,_head,FALSE);
tempde->flags|=DEF_NOT_INITIALIZED;
}
} else if (dv->fs_type==FSt_REDSEA || dv->fs_type==FSt_FAT32)
FMRebuildDocDrv(Drv2Let(dv),doc,_head,TRUE);
}
DocTop(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 (DocForm(&fn)) {
Silent;
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 (DocForm(&fn)) {
if (StrCmp(tempde->name,fn.name)) {
Silent;
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 (DocForm(&fn)) {
Silent;
MkDir(fn.name);
Silent(OFF);
}
}
} else if (doc_e->type_u8==DOCT_TREE) {
tempde=doc_e->user_data;
Cd(tempde->full_name);
if (DocForm(&fn)) {
Silent;
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;
st=MStrPrint("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;
st=MStrPrint("Delete: %s",tempde->full_name);
if (PopUpCancelOk(st))
DelTree(tempde->full_name);
Free(st);
Silent(OFF);
}
}
U0 FMChgDsk(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;
ChgDsk(*tempde->full_name);
Silent(OFF);
}
}
U0 FMMountISO(CDoc *doc)
{
CDocEntry *doc_ce=doc->cur_entry;
CDirEntry *tempde;
if (doc_ce->type_u8==DOCT_MENU_VAL && (tempde=doc_ce->user_data))
MountFile(tempde->full_name);
}
U0 FMUnmount(CDoc *doc)
{
CDocEntry *doc_ce=doc->cur_entry;
CDirEntry *tempde;
I64 drv_let;
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;
drv_let=*tempde->full_name;
if (Let2BlkDev(drv_let)!=Let2BlkDev(':'))
Unmount(drv_let);
}
}
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=MStrPrint("Format Drive '%c'?\nAre You Sure?\n",*tempde->full_name);
if (PopUpCancelOk(st)) {
Silent;
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;
if (tempde->full_name[StrLen(tempde->full_name)-1]=='/')
st=MStrPrint("%s*",tempde->full_name);
else
st=MStrPrint("%s/*",tempde->full_name);
ISO9660ISO(,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;
DVDImageWrite(*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->head.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;
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;
if (*tempde1->name)
st=MStrPrint("%s/%s",tempde1->full_name,tempde->name);
else
st=MStrPrint("%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_MOUNT_ISO 9
#define FMR_UNMOUNT 10
#define FMR_MAKE_ISO 11
#define FMR_BURN_ISO 12
#define FMR_HELP 13
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,\"MOUNT ISO.C FILE \",LE=FMR_MOUNT_ISO$$"
"$$CM+LX,27,0$$$$BT,\"UNMOUNT \",LE=FMR_UNMOUNT$$"
"$$CM+LX,1,3 $$$$BT,\"MAKE ISO (CD/DVD) FILE\",LE=FMR_MAKE_ISO$$"
"$$CM+LX,27,0$$$$BT,\"BURN ISO (CD/DVD) 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_MOUNT_ISO:
Msg(MSG_KEY_DOWN,'i',0);
break;
case FMR_UNMOUNT:
Msg(MSG_KEY_DOWN,'u',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,ip.pos.x,ip.pos.y,"%s",fm_ip_str);
}
(*fp_old_final_screen_update)(dc);
}
public U8 *FileMgr(I64 mode=FM_NORMAL,CTask *mem_task=NULL)
{//File manager. Also, used to choose files and dirs.
CDirEntry *head=NULL,*tempde,*tempde1,*tempde2;
I64 sc,ch,a1,a2,msg_code;
CDoc *doc=NULL,*old_put_doc=DocPut,*old_display_doc=DocDisplay;
U8 *res=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=gr.fp_final_screen_update;
MenuFilePush("::/Doc/FileMgrPullDown.TXT");
FMRebuildDoc(&doc,&head,mode);
if (tempde1=Cd2DirEntry(head,old_cur_dir))
doc->cur_entry=tempde1->user_data;
while (tempde1) {
if (tempde1->attr&RS_ATTR_DIR)
tempde1->user_data(CDocEntry *)->de_flags&=~DOCEF_CHECKED_COLLAPSED;
tempde1=tempde1->parent;
}
do {
DocUnlock(doc);
do msg_code=GetMsg(&a1,&a2,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;
gr.fp_final_screen_update=&FMFinalScreenUpdate;
break;
case MSG_IP_L_UP:
if (doc_ce) {
gr.fp_final_screen_update=fp_old_final_screen_update;
if (WinCursorPosSet(Fs,a1+Fs->pix_left+Fs->scroll_x,
a2+Fs->pix_top+Fs->scroll_y,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;
Move(tempde->full_name,st2);
Silent(OFF);
FMRebuildDoc(&doc,&head,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=MStrPrint("%s/%s",tempde1->full_name,tempde->name);
else
st=MStrPrint("%s%s",tempde1->full_name,tempde->name);
if (StrCmp(tempde->full_name,st)) {
Silent;
CopyTree(tempde->full_name,st);
DelTree(tempde->full_name);
Silent(OFF);
FMRebuildDoc(&doc,&head,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=a1; sc=a2;
if (sc.u8[0]==SC_DELETE && !(sc&(SCF_SHIFT|SCF_CTRL)))
ch=CH_CTRLY;
if (ch && sc&SCF_ALT) goto fm_regular_key;
switch (ch) {
case '\n':
DocUnlock(doc);
FMRightClick;
DocLock(doc);
break;
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':
FMChgDsk(doc);
break;
case 'i':
FMMountISO(doc);
break;
case 'u':
FMUnmount(doc);
break;
case 'M':
FMMakeISO(doc);
break;
case 'B':
FMBurnISO(doc);
break;
case 'f':
FMFmtDrv(doc);
break;
end:
FMRebuildDoc(&doc,&head,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 fm_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 fm_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)
res=StrNew(tempde->full_name,mem_task);
else if (mode==FM_PICK_DIR) {
if (doc_ce->type_u8==DOCT_TREE)
res=StrNew(tempde->full_name,mem_task);
else if (doc_ce->type_u8==DOCT_MENU_VAL &&
(tempde=tempde->parent))
res=StrNew(tempde->full_name,mem_task);
}
break;
default:
if (sc.u8[0]==SC_INS && sc&SCF_SHIFT && !(sc&SCF_CTRL)) {
FMCopy(doc);
FMRebuildDoc(&doc,&head,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 {
fm_regular_key:
DocUnlock(doc);
PutKey(ch,sc);
DocLock(doc);
}
}
break;
}
} while (ch!=CH_ESC && ch!=CH_SHIFT_ESC);
gr.fp_final_screen_update=fp_old_final_screen_update;
Fs->put_doc =old_put_doc;
Fs->display_doc=old_display_doc;
SettingsPop;
DocDel(doc);
DirTreeDel(head);
Cd(old_cur_dir);
Free(old_cur_dir);
if (mode!=FM_NORMAL && !res)
res=StrNew("",mem_task);
MenuPop;
return res;
}

793
Adam/ABlkDev/FileMgr.HC

@ -0,0 +1,793 @@
#help_index "DolDoc/Output;StdOut/DolDoc"
U0 DirFileDoc(CDoc *doc,CDirEntry *tempde)
{
while (tempde) {
if (tempde->attr & RS_ATTR_DIR) {
tempde->user_data=DocPrint(doc,"$$TR,\"%s\",U=0x%X$$",tempde->name,tempde);
DocPrint(doc,"\n$$ID,+2$$");
if (tempde->sub)
DirFileDoc(doc,tempde->sub);
DocPrint(doc,"$$ID,-2$$");
} else {
tempde->user_data=DocPrint(doc,"$$MU,\"%s\",U=0x%X$$",tempde->name,tempde);
DocPrint(doc,"\n");
}
tempde=tempde->next;
}
}
#help_index "File/Cmd Line (Typically);Cmd Line (Typically)"
#define FM_NORMAL 0
#define FM_PICK_FILE 1
#define FM_PICK_DIR 2
class CFMUncollapsedLst
{
CFMUncollapsedLst *next;
U8 *name;
};
CFMUncollapsedLst *FMCollectUncollapsedLst(CDoc *doc)
{
CDocEntry *doc_e=doc->head.next;
CFMUncollapsedLst *res=NULL,*tempc;
CDirEntry *tempde;
while (doc_e!=doc) {
if (doc_e->type_u8==DOCT_TREE) {
if (!(doc_e->de_flags&DOCEF_CHECKED_COLLAPSED)) {
if (tempde=doc_e->user_data) {
tempc=MAlloc(sizeof(CFMUncollapsedLst));
tempc->next=res;
res=tempc;
tempc->name=StrNew(tempde->full_name);
}
}
}
doc_e=doc_e->next;
}
return res;
}
U0 FMMarkUncollapsed(CDoc *doc,CFMUncollapsedLst *tempc,
U8 *cur_entry,U8 *next_entry)
{
CDocEntry *doc_e=doc->head.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->de_flags&=~DOCEF_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 **_head,Bool init)
{
CDirEntry *tempde,*tempde1;
U8 *st;
tempde=CAlloc(sizeof(CDirEntry));
tempde->full_name=MStrPrint("%C:/",drv_let);
tempde->attr=RS_ATTR_DIR;
st=MStrPrint("%c:/*",drv_let);
if (init)
tempde->sub=tempde1=FilesFind(st,FUF_RECURSE);
else
tempde1=NULL;
Free(st);
tempde->user_data=DocPrint(doc,"$$TR,\"%s\",U=0x%X$$",tempde->full_name,tempde);
tempde->next=*_head;
*_head=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 **_head,I64 mode)
{
CDrv *dv;
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 (*_head) {
DirTreeDel(*_head);
*_head=NULL;
}
doc=DocNew;
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\",A=\"FI:::/Doc/FileMgr.DD\"$$\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_DRVS;i++) {
dv=&blkdev.drvs[i];
if (dv->bd->type==BDT_ATAPI) {
if (dv->bd->flags&BDF_INITIALIZED)
tempde=FMRebuildDocDrv(Drv2Let(dv),doc,_head,TRUE);
else {
tempde=FMRebuildDocDrv(Drv2Let(dv),doc,_head,FALSE);
tempde->flags|=DEF_NOT_INITIALIZED;
}
} else if (dv->fs_type==FSt_REDSEA || dv->fs_type==FSt_FAT32)
FMRebuildDocDrv(Drv2Let(dv),doc,_head,TRUE);
}
DocTop(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 (DocForm(&fn)) {
Silent;
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 (DocForm(&fn)) {
if (StrCmp(tempde->name,fn.name)) {
Silent;
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) {