TempleOSTS_130707.ISO

This commit is contained in:
Terry A. Davis authored and minexew committed 2018-09-08 21:45:45 +02:00
1 parent 17b71f1a2d
commit 1343005a29
617 files changed
+14399 -25130

No files matched your search

+7 -7
View File
@@ -11,7 +11,7 @@ Bool ChkDskConfirm(Bool *_fix,Bool *_confirm)
return *_fix;
}
I64 NativeFSChkDskLst(CDirEntry *tempm1,U8 *bits,U8 *bits2,I64 size,I64 bpc)
I64 RedSeaFSChkDskLst(CDirEntry *tempm1,U8 *bits,U8 *bits2,I64 size,I64 bpc)
{
CDirEntry *tempm2;
I64 i,j,errs=0;
@@ -19,7 +19,7 @@ I64 NativeFSChkDskLst(CDirEntry *tempm1,U8 *bits,U8 *bits2,I64 size,I64 bpc)
tempm2=tempm1->next;
if (tempm1->attr & _ATTR_DIR) {
if (tempm1->sub)
errs+=NativeFSChkDskLst(tempm1->sub,bits,bits2,size,bpc);
errs+=RedSeaFSChkDskLst(tempm1->sub,bits,bits2,size,bpc);
}
j=(tempm1->size+bpc-1)/bpc;
for (i=0;i<j;i++) {
@@ -46,7 +46,7 @@ I64 NativeFSChkDskLst(CDirEntry *tempm1,U8 *bits,U8 *bits2,I64 size,I64 bpc)
return errs;
}
I64 NativeFSChkDsk(U8 drv_let,Bool *_fix,Bool *_confirm)
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;
@@ -86,13 +86,13 @@ I64 NativeFSChkDsk(U8 drv_let,Bool *_fix,Bool *_confirm)
}
}
errs+=NativeFSChkDskLst(FilesFind(files_find_mask,FUF_RECURSE),bits,bits2,size,bpc);
errs+=RedSeaFSChkDskLst(FilesFind(files_find_mask,FUF_RECURSE),bits,bits2,size,bpc);
for (i=1;i<size;i++)
if (Bt(bits2,i)) {
PrintFWarn("Shouldn't Alloc Cluster:%0X\n",i);
errs++;
if (ChkDskConfirm(_fix,_confirm))
NativeFSFreeClusters(p,i,1);
RedSeaFSFreeClusters(p,i,1);
}
Free(files_find_mask);
@@ -210,8 +210,8 @@ public I64 ChkDsk(U8 drv_let=0,Bool fix=FALSE,Bool confirm=TRUE)
I64 errs=0;
CPrt *p=Drv2Prt(drv_let);
switch (p->type) {
case PT_NATIVE:
errs=NativeFSChkDsk(drv_let,&fix,&confirm);
case PT_REDSEA:
errs=RedSeaFSChkDsk(drv_let,&fix,&confirm);
break;
case PT_FAT32:
errs=FAT32ChkDsk(drv_let,&fix,&confirm);
-1
View File
@@ -1,5 +1,4 @@
#include "Dsk2a"
#include "Dsk2b"
#include "DskCDDVD"
#include "ChkDsk"
#include "FileMgr"
+12 -20
View File
@@ -230,7 +230,7 @@ public I64 DelTree(U8 *files_find_mask,U8 *fu_flags=NULL)
return result;
}
U0 TouchFile(U8 *filename,U8 *attr,CDate spdt=0) //Just one file
U0 TouchFile(U8 *filename,U8 *attr,CDate cdt=0) //Just one file
{
CPrt *p=Drv2Prt(*filename);
CDirEntry de;
@@ -246,16 +246,16 @@ U0 TouchFile(U8 *filename,U8 *attr,CDate spdt=0) //Just one file
if (!*cur_dir)
StrCpy(cur_dir,"/");
GetFFlags(&de.attr,Define("ST_FILE_ATTRS"),attr);
if (spdt)
de.datetime=spdt;
if (cdt)
de.datetime=cdt;
else
de.datetime=GetCurTimeCDate;
de.datetime=GetCurTimeDate;
CDirNew(p,cur_dir,&de,FALSE);
}
} else PutDefineErr("ST_FILE_NOT_FOUND");
}
U0 TouchLst(CDirEntry *tempm1,U8 *attr,CDate spdt=0)
U0 TouchLst(CDirEntry *tempm1,U8 *attr,CDate cdt=0)
{
CDirEntry *tempm2;
while (tempm1) {
@@ -263,16 +263,16 @@ U0 TouchLst(CDirEntry *tempm1,U8 *attr,CDate spdt=0)
if (tempm1->attr & _ATTR_DIR) {
if (tempm1->sub) {
"%S%s\n","ST_SCANNING_DIR",tempm1->full_name;
TouchLst(tempm1->sub,attr,spdt);
TouchLst(tempm1->sub,attr,cdt);
}
} else
TouchFile(tempm1->full_name,attr,spdt);
TouchFile(tempm1->full_name,attr,cdt);
CDirEntryDel(tempm1);
tempm1=tempm2;
}
}
public U0 Touch(U8 *files_find_mask,U8 *attr="+?",U8 *fu_flags=NULL,CDate spdt=0)
public U0 Touch(U8 *files_find_mask,U8 *attr="+?",U8 *fu_flags=NULL,CDate cdt=0)
{
//Attr "+?" =show
// "+T" =resident
@@ -280,7 +280,7 @@ public U0 Touch(U8 *files_find_mask,U8 *attr="+?",U8 *fu_flags=NULL,CDate spdt=0
// Touch(filename,"",,datetime);
I64 fuf_flags=0;
GetFFlags(&fuf_flags,Define("ST_FILE_UTIL_FLAGS"),fu_flags);
TouchLst(FilesFind(files_find_mask,fuf_flags),attr,spdt);
TouchLst(FilesFind(files_find_mask,fuf_flags),attr,cdt);
}
I64 FFLst(CDirEntry *tempm1)
@@ -324,15 +324,7 @@ public U0 SetDrvTextAttr(U8 drv_let,U8 attr)
Fs->catch_except=TRUE;
}
U0 PrintFDrvTextAttr(U8 drv_let=0)
{
CPrt *p=Drv2Prt(drv_let);
U8 fg=p->text_attr&0xF,bg=p->text_attr>>4;
if (fg!=bg)
"$$FG,%d$$$$BG,%d$$",fg,bg;
}
I64 NativeFSUnusedDrvSpace(U8 drv_let=0)
I64 RedSeaFSUnusedDrvSpace(U8 drv_let=0)
{
CPrt *p=Drv2Prt(drv_let);
I64 result=0,i,l;
@@ -377,8 +369,8 @@ public I64 UnusedDrvSpace(U8 drv_let=0)
I64 result=0;
Drv(drv_let);
switch (p->type) {
case PT_NATIVE:
result=NativeFSUnusedDrvSpace(drv_let);
case PT_REDSEA:
result=RedSeaFSUnusedDrvSpace(drv_let);
break;
case PT_FAT32:
result=FAT32UnusedDrvSpace(drv_let);
+16 -14
View File
@@ -67,8 +67,7 @@ public CDirEntry *CDirTreeUnflatten(U8 *src)
return tempm;
}
#help_index "Install;File/Install Related"
#help_file "::/TempleOS/Doc/Install"
#help_index "Install;File/Cmd Line (Typically);Cmd Line (Typically)"
#define ROUND_PRT_TO (63*255)
#define PRT_HEADER 63
@@ -157,8 +156,11 @@ public U0 PrtDsk(U8 drv_let=0)
temppp=root.next;
drv_let2=bdev->first_drv_let;
while (temppp!=&root) {
"Drive %C:%08X %s\n",drv_let2,temppp->size,
temppp->pri ? "Primary":"Logical";
"Drive %C:%08X ",drv_let2,temppp->size;
if (temppp->pri)
"Primary\n";
else
"Logical\n";
temppp=temppp->next;
drv_let2++;
}
@@ -174,7 +176,7 @@ public U0 PrtDsk(U8 drv_let=0)
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 to MBR_PT_NATIVE
mbr.p[i].type=1; //Will get set to MBR_PT_REDSEA
mbr.p[i].end_head=0xFE;
mbr.p[i].end_cyl=0xFFFF;
mbr.p[i].offset=PRT_HEADER+offset;
@@ -205,7 +207,7 @@ public U0 PrtDsk(U8 drv_let=0)
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 to MBR_PT_NATIVE
mbr.p[0].type=1; //Will get set to MBR_PT_REDSEA
mbr.p[0].end_head=0xFE;
mbr.p[0].end_cyl=0xFFFF;
mbr.p[0].offset=PRT_HEADER;
@@ -241,7 +243,7 @@ pd_done:
#help_index "Info;File/Cmd Line (Typically);Cmd Line (Typically)"
U0 NativeFSDrvView(U8 drv_let=0)
U0 RedSeaFSDrvView(U8 drv_let=0)
{
CPrt *p=Drv2Prt(drv_let);
I64 lohi,c1,i,x,y,l,s;
@@ -335,8 +337,8 @@ 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_NATIVE:
NativeFSDrvView(drv_let);
case PT_REDSEA:
RedSeaFSDrvView(drv_let);
break;
case PT_FAT32:
FAT32DrvView(drv_let);
@@ -366,7 +368,7 @@ public U0 DskView(U8 drv_let=0)
radius=0.4*h;
else
radius=0.4*v;
dc->color=ROP_EQU+BLACK;
dc->color=BLACK;
GrCircle(dc,h>>1,v>>1,radius);
j=1;
@@ -375,7 +377,7 @@ public U0 DskView(U8 drv_let=0)
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=ROP_EQU+BLACK;
dc->color=BLACK;
GrLine(dc,h>>1,v>>1,
h>>1+radius*Cos(sect_start),
v>>1+radius*Sin(sect_start));
@@ -383,7 +385,7 @@ public U0 DskView(U8 drv_let=0)
h>>1+radius*Cos(sect_end),
v>>1+radius*Sin(sect_end));
dc->color=ROP_EQU+j;
dc->color=j;
GrPrintF(dc,0,v-FONT_HEIGHT*j,"%C %-8Z",Prt2Drv(p),
p->type.u16[0],"ST_PRT_TYPES");
GrFloodFill(dc,
@@ -393,13 +395,13 @@ public U0 DskView(U8 drv_let=0)
}
}
GetChar(NULL,FALSE);
GetChar(,FALSE);
SettingsPop;
DCFill;
DCDel(dc);
}
#help_index "Info;File/Cmd Line (Typically);Cmd Line (Typically);File/Install Related;Install"
#help_index "Info;File/Cmd Line (Typically);Cmd Line (Typically);Install"
public U0 BlkDevRep()
{
I64 i;
-549
View File
@@ -1,549 +0,0 @@
#help_index "File/CD DVD"
U0 FillU16Palindrome(CPalindromeU16 *dst,U16 w)
{
dst->big=EndianU16(w);
dst->little=w;
}
U0 FillU32Palindrome(CPalindromeU32 *dst,I64 d)
{
dst->big=EndianU32(d);
dst->little=d;
}
class CCCDUserData //Create CD
{
I64 loc,path_entry_num,
short_dir_blks,long_dir_blks;
};
I64 CDFileCreate2(CFile *out_file,CDirEntry *tempm,
CISO1DirEntry *tempi,CISO1DirEntry *tempi2,
I64 *_cur_blk,
CDirEntry *parent,Bool write)
{
CCCDUserData *tempc;
CDirEntry *tempm1,*tempm2;
CFile *in_file;
U8 *buf=MAlloc(CD_BLK_SIZE),*ptr1,*ptr2;
CISO1DirEntry *dir_blk_buf =CAlloc(CD_BLK_SIZE*128),
*de =dir_blk_buf, *de1,
*dir_blk_buf2=CAlloc(CD_BLK_SIZE*128),
*de2=dir_blk_buf2,*de12;
I64 i,n;
tempc=parent->user_data;
de->len=sizeof(CISO1DirEntry)-1;
de->ext_attr_len=0;
FillU16Palindrome(&de->vol_seq_num,1);
CDate2ISO1(&de->date,tempm->datetime);
de->flags=ISO1_ATTR_DIR;
de->name_len=1;
de->name=0;
de->len+=de->name_len;
de(U8 *)+=de->len;
de->len=sizeof(CISO1DirEntry)-1;
de->ext_attr_len=0;
FillU32Palindrome(&de->loc,tempc->loc);
FillU32Palindrome(&de->size,tempc->short_dir_blks*CD_BLK_SIZE);
FillU16Palindrome(&de->vol_seq_num,1);
CDate2ISO1(&de->date,parent->datetime);
de->flags=ISO1_ATTR_DIR;
de->name_len=1;
de->name=1;
de->len+=de->name_len;
de(U8 *)+=de->len;
de2->len=sizeof(CISO1DirEntry)-1;
de2->ext_attr_len=0;
FillU16Palindrome(&de2->vol_seq_num,1);
CDate2ISO1(&de2->date,tempm->datetime);
de2->flags=ISO1_ATTR_DIR;
de2->name_len=1;
de2->name=0;
de2->len=de2->len+de2->name_len;
de2(U8 *)+=de2->len;
de2->len=sizeof(CISO1DirEntry)-1;
de2->ext_attr_len=0;
FillU32Palindrome(&de2->loc,tempc->loc+tempc->short_dir_blks);
FillU32Palindrome(&de2->size,tempc->long_dir_blks*CD_BLK_SIZE);
FillU16Palindrome(&de2->vol_seq_num,1);
CDate2ISO1(&de2->date,parent->datetime);
de2->flags=ISO1_ATTR_DIR;
de2->name_len=1;
de2->name=1;
de2->len+=de2->name_len;
de2(U8 *)+=de2->len;
tempm1=tempm->sub;
while (tempm1) {
tempm2=tempm1->next;
if (!write) tempm1->user_data=CAlloc(sizeof(CCCDUserData));
de1=de;
de12=de2;
if (tempm1->attr & _ATTR_DIR) {
n=CDFileCreate2(out_file,tempm1,de,de2,_cur_blk,tempm,write);
de(U8 *)+=sizeof(CISO1DirEntry)-1+n;
de2(U8 *)+=sizeof(CISO1DirEntry)-1+n<<1;
} else {
tempc=tempm1->user_data;
de->len=sizeof(CISO1DirEntry)-1;
de->ext_attr_len=0;
FillU32Palindrome(&de->loc,*_cur_blk);
tempc->loc=*_cur_blk;
if (write)
"%X:%s\n",*_cur_blk,tempm1->full_name;
FillU32Palindrome(&de->size,tempm1->size);
FillU16Palindrome(&de->vol_seq_num,1);
CDate2ISO1(&de->date,tempm1->datetime);
de->flags=0;
de->name_len=StrLen(tempm1->name);
StrCpy(&de->name,tempm1->name);
de->len=de->len+de->name_len;
de(U8 *)+=de->len;
de2->len=sizeof(CISO1DirEntry)-1;
de2->ext_attr_len=0;
FillU32Palindrome(&de2->loc,*_cur_blk);
FillU32Palindrome(&de2->size,tempm1->size);
FillU16Palindrome(&de2->vol_seq_num,1);
CDate2ISO1(&de2->date,tempm1->datetime);
de2->flags=0;
de2->name_len=StrLen(tempm1->name)<<1;
ptr1=&de2->name;
ptr2=&tempm1->name;
for (i=0;i<de2->name_len;i=i+2) {
ptr1++;
*ptr1++=*ptr2++;
}
de2->len+=de2->name_len;
de2(U8 *)+=de2->len;
in_file=FOpen(tempm1->full_name,"r");
for (i=0;i<(FSize(in_file)+CD_BLK_SIZE-1)/CD_BLK_SIZE;i++) {
n=4;
if ((i+1)<<2>(FSize(in_file)+BLK_SIZE-1)>>BLK_SIZE_BITS) {
n=(FSize(in_file)+BLK_SIZE-1)>>BLK_SIZE_BITS&3;
MemSet(buf,0,CD_BLK_SIZE);
}
if (write) {
FRBlks(in_file,buf,i<<2,n);
FWBlks(out_file,buf,*_cur_blk<<2,n);
}
*_cur_blk+=1;
}
FClose(in_file);
}
if ((de1(U8 *)-dir_blk_buf(U8 *))/CD_BLK_SIZE!=
(de(U8 *) -dir_blk_buf(U8 *))/CD_BLK_SIZE) {
i=de1->len;
MemCpy(buf,de1,i);
MemSet(de1,0,i);
de=dir_blk_buf(U8 *)+(de(U8 *)-dir_blk_buf(U8 *))/CD_BLK_SIZE*CD_BLK_SIZE;
MemCpy(de,buf,i);
de(U8 *)+=i;
}
if ((de12(U8 *)-dir_blk_buf2(U8 *))/CD_BLK_SIZE!=
(de2(U8 *) -dir_blk_buf2(U8 *))/CD_BLK_SIZE) {
i=de12->len;
MemCpy(buf,de12,i);
MemSet(de12,0,i);
de2(U8 *)=dir_blk_buf2(U8 *)+(de2(U8 *)-dir_blk_buf2(U8 *))/CD_BLK_SIZE*CD_BLK_SIZE;
MemCpy(de2,buf,i);
de2(U8 *)+=i;
}
tempm1=tempm2;
}
tempc=tempm->user_data;
tempi->len=sizeof(CISO1DirEntry)-1;
tempi->ext_attr_len=0;
tempi->flags=ISO1_ATTR_DIR;
if (!tempm->name[0]) {
tempi->name_len=1;
tempi->name=1;
} else {
tempi->name_len=StrLen(tempm->name);
StrCpy(&tempi->name,tempm->name);
}
tempi->len+=tempi->name_len;
n=de(U8 *)+1-dir_blk_buf(U8 *);
n=(n+CD_BLK_SIZE-1)/CD_BLK_SIZE;
FillU32Palindrome(&tempi->size,n*CD_BLK_SIZE);
FillU32Palindrome(&tempi->loc,*_cur_blk);
tempc->short_dir_blks=n;
tempc->loc=*_cur_blk;
FillU32Palindrome(&dir_blk_buf->size,n*CD_BLK_SIZE);
FillU32Palindrome(&dir_blk_buf->loc,*_cur_blk);
FillU16Palindrome(&tempi->vol_seq_num,1);
CDate2ISO1(&tempi->date,tempm->datetime);
if (write)
"%X:%s\n",*_cur_blk,tempm->full_name;
if (write)
FWBlks(out_file,dir_blk_buf,*_cur_blk<<2,n<<2);
*_cur_blk+=n;
tempi2->len=sizeof(CISO1DirEntry)-1;
tempi2->ext_attr_len=0;
tempi2->flags=ISO1_ATTR_DIR;
if (!tempm->name[0]) {
tempi2->name_len=1;
tempi->name=1;
} else {
tempi2->name_len=StrLen(tempm->name)<<1;
ptr1=&tempi2->name;
ptr2=&tempm->name;
for (i=0;i<tempi2->name_len;i=i+2) {
ptr1++;
*ptr1++=*ptr2++;
}
}
tempi2->len+=tempi2->name_len;
n=de2(U8 *)+1-dir_blk_buf2(U8 *);
n=(n+CD_BLK_SIZE-1)/CD_BLK_SIZE;
FillU32Palindrome(&tempi2->size,n*CD_BLK_SIZE);
FillU32Palindrome(&tempi2->loc,*_cur_blk);
tempc->long_dir_blks=n;
FillU32Palindrome(&dir_blk_buf2->size,n*CD_BLK_SIZE);
FillU32Palindrome(&dir_blk_buf2->loc,*_cur_blk);
FillU16Palindrome(&tempi2->vol_seq_num,1);
CDate2ISO1(&tempi2->date,tempm->datetime);
if (write)
"%X:%s\n",*_cur_blk,tempm->full_name;
if (write)
FWBlks(out_file,dir_blk_buf2,*_cur_blk<<2,n<<2);
*_cur_blk+=n;
Free(dir_blk_buf);
Free(dir_blk_buf2);
Free(buf);
return tempi->name_len;
}
I64 CDTableLen(CDirEntry *tempm,I64 *size1,I64 *size2,I64 cur_depth)
//returns depth
{
CDirEntry *tempm1=tempm->sub;
I64 max_depth=cur_depth,i;
while (tempm1) {
if (tempm1->attr & _ATTR_DIR) {
*size1+=sizeof(CISO1PathEntry)-2+ (StrLen(tempm1->name)+1)&-0x2;
*size2+=sizeof(CISO1PathEntry)-2+StrLen(tempm1->name)<<1;
i=CDTableLen(tempm1,size1,size2,cur_depth+1);
if (i>max_depth) max_depth=i;
}
tempm1=tempm1->next;
}
return max_depth;
}
U0 CDFillPathTable(CDirEntry *tempm,
CISO1PathEntry **_itabbuf,CISO1PathEntry **_itabbuf2,
I64 parent_entry_num,Bool big_endian,I64 *first_free,I64 cur_level,I64 output_level)
{
U8 *ptr1,*ptr2;
I64 i;
CISO1PathEntry *tabbuf =*_itabbuf,
*tabbuf2=*_itabbuf2;
CDirEntry *tempm1=tempm->sub,*tempm2;
CCCDUserData *tempc;
if (cur_level==output_level) {
while (tempm1) {
if (tempm1->attr & _ATTR_DIR) {
tempc=tempm1->user_data;
tempc->path_entry_num=*first_free;
tabbuf->name_len=StrLen(tempm1->name);
if (big_endian) {
tabbuf->blk=EndianU32(tempc->loc);
tabbuf->parent_entry_num=EndianU16(parent_entry_num);
} else {
tabbuf->blk=tempc->loc;
tabbuf->parent_entry_num=parent_entry_num;
}
StrCpy(&tabbuf->name,tempm1->name);
tabbuf(U8 *)+=sizeof(CISO1PathEntry)-2+
(StrLen(tempm1->name)+1) & -0x2;
tabbuf2->name_len=StrLen(tempm1->name)<<1;
if (big_endian) {
tabbuf2->blk=EndianU32(tempc->loc+tempc->short_dir_blks);
tabbuf2->parent_entry_num=EndianU16(parent_entry_num);
} else {
tabbuf2->blk=tempc->loc+tempc->short_dir_blks;
tabbuf2->parent_entry_num=parent_entry_num;
}
ptr1=&tabbuf2->name;
ptr2=&tempm1->name;
for (i=0;i<tabbuf2->name_len;i=i+2) {
ptr1++;
*ptr1++=*ptr2++;
}
tabbuf2(U8 *)+=sizeof(CISO1PathEntry)-2+
StrLen(tempm1->name)<<1;
*first_free+=1;
}
tempm1=tempm1->next;
}
*_itabbuf=tabbuf;
*_itabbuf2=tabbuf2;
}
tempm1=tempm->sub;
while (tempm1) {
tempm2=tempm1->next;
if (tempm1->attr & _ATTR_DIR) {
tempc=tempm1->user_data;
CDFillPathTable(tempm1,_itabbuf,_itabbuf2,tempc->path_entry_num,
big_endian,first_free,cur_level+1,output_level);
}
tempm1=tempm2;
}
}
class CElTorito
{
U16 w[16];
U8 bootable; //88=bootable 00=not bootable
U8 media_type; //0=no emulation 4=hard disk
U16 load_seg; //0000->07C0
U8 sys_type;
U8 zero;
U16 sect_cnt;
U32 load_rba; //start addr of virtual disk
U8 zero2[20];
};
public I64 CDFileCreate(U8 *filename=NULL,U8 *src_files_find_mask,U8 *fu_flags=NULL,
U8 *bootfile=NULL,I64 emulation=0)
//See $LK-A,"::/TempleOS/Demo/MakeDistro.CPP.Z"$
//NULL filename uses sys_dft_iso_name.
//See the above sample code
//0=no emu 2=1.44meg 4=hard drive
//Use "C:/*" if you want all files on the C: drive.
//Default flags are "+r" recurse.
{
CISO1PriDesc *iso =CAlloc(CD_BLK_SIZE),
*iso1=CAlloc(CD_BLK_SIZE),
*iso2=CAlloc(CD_BLK_SIZE),
*iso3=CAlloc(CD_BLK_SIZE);
CDirEntry *rootdir=CAlloc(sizeof(CDirEntry));
I64 i,j,
cur_blk=0,bootfile_cd_blks=0,tabsize,tabsize2,first_free,max_depth,
fuf_flags=0;
U32 *d;
CElTorito *et=CAlloc(CD_BLK_SIZE);
U8 *filename2,
*zero_buf=CAlloc(CD_BLK_SIZE),
*bootfile_buf=NULL;
CISO1PathEntry *tabbuf=NULL,*tabbuf2=NULL,*itabbuf,*itabbuf2;
Bool okay=TRUE;
CFile *out_file=NULL;
CISO1DirEntry *tempi;
CCCDUserData *tempc;
GetFFlags(&fuf_flags,Define("ST_FILE_UTIL_FLAGS"),"+r");
GetFFlags(&fuf_flags,Define("ST_FILE_UTIL_FLAGS"),fu_flags);
if (!filename)
filename=sys_dft_iso_name;
filename2=DftExt(filename,"ISO");
if (bootfile) {
bootfile_buf=FileRead(bootfile,&bootfile_cd_blks);
if (bootfile_cd_blks>CD_BLK_SIZE*4) {
ST_ERR_ST "Boot files limited to 0x2000 bytes\n";
goto done1;
}
bootfile_cd_blks=(bootfile_cd_blks+CD_BLK_SIZE-1)/CD_BLK_SIZE;
}
rootdir->attr=_ATTR_DIR;
rootdir->sub=FilesFind(src_files_find_mask,fuf_flags);
rootdir->datetime=GetCurTimeCDate;
rootdir->user_data=CAlloc(sizeof(CCCDUserData));
tempc=rootdir->user_data;
tempc->path_entry_num=1;
if (okay) {
cur_blk=CD_FILE_OFFSET>>2;
if (bootfile_buf)
//preboot and bootloader
cur_blk+=1+bootfile_cd_blks;
CDFileCreate2(out_file,rootdir,
&iso->root_dir_record,
&iso2->root_dir_record,
&cur_blk,rootdir,FALSE);
tabsize=sizeof(CISO1PathEntry);
tabsize2=sizeof(CISO1PathEntry);
max_depth=CDTableLen(rootdir,&tabsize,&tabsize2,1);
FillU32Palindrome(&iso->path_table_size,tabsize);
FillU32Palindrome(&iso2->path_table_size,tabsize2);
tabsize=(tabsize+CD_BLK_SIZE-1)/CD_BLK_SIZE;
cur_blk+=tabsize<<1;
tabsize2=(tabsize2+CD_BLK_SIZE-1)/CD_BLK_SIZE;
cur_blk+=tabsize2<<1;
}
if (okay) {
if (FileAttr(filename2) & _ATTR_CONTIGUOUS)
out_file=FOpen(filename2,"wc",cur_blk<<2);
else
out_file=FOpen(filename2,"w",cur_blk<<2);
if (!out_file)
okay=FALSE;
}
if (okay) {
cur_blk=0;
while (cur_blk<CD_FILE_OFFSET>>2) {
FWBlks(out_file,zero_buf,cur_blk<<2,4);
cur_blk++;
}
iso->type=ISO1T_PRI_VOL_DESC;
StrCpy(iso->id,"CD001");
iso->version=1;
FillU16Palindrome(&iso->vol_set_size,1);
FillU16Palindrome(&iso->vol_seq_num,1);
FillU16Palindrome(&iso->log_block_size,CD_BLK_SIZE);
iso->file_structure_version=1;
iso2->type=ISO1T_SUPPLEMENTARY_DESC;
StrCpy(iso2->id,"CD001");
iso2->version=1;
FillU16Palindrome(&iso2->vol_set_size,1);
FillU16Palindrome(&iso2->vol_seq_num,1);
FillU16Palindrome(&iso2->log_block_size,CD_BLK_SIZE);
iso2->file_structure_version=1;
iso1->type=ISO1T_BOOT_RECORD;
StrCpy(iso1->id,"CD001");
iso1->version=1;
StrCpy(iso1(U8 *)+7,"EL TORITO SPECIFICATION");
cur_blk=CD_FILE_OFFSET>>2;
if (bootfile_buf) {
d=iso1(U8 *)+0x47;
*d=cur_blk;
et->w[0]=1;
StrCpy(&et->w[2],"TempleOS");
et->w[15]=0xAA55;
j=0;
for (i=0;i<16;i++) //Checksum
j+=et->w[i];
et->w[14]=-j;
if (bootfile_buf)
et->bootable=0x88;
//0=no emu 2=1.44meg 4=hard drive
et->media_type=emulation;
et->sect_cnt=4; //5 seems like the limit, 4 is safer
et->load_rba=cur_blk+1;
//$AN,"CDBOOT","CDBOOT"$ See $LK,"CDBootFileCreate","MN:CDBootFileCreate"$
//See $LK,"BootCdProbe","MN:BootCdProbe"$().
"%X: Pre Boot Blk\n",cur_blk;
FWBlks(out_file,et,cur_blk<<2,4);
cur_blk++;
"%X: Boot Loader Blks\n",cur_blk;
FWBlks(out_file,bootfile_buf,cur_blk<<2,bootfile_cd_blks<<2);
cur_blk+=bootfile_cd_blks;
}
CDFileCreate2(out_file,rootdir,
&iso->root_dir_record,
&iso2->root_dir_record,
&cur_blk,rootdir,TRUE);
tabbuf=CAlloc(tabsize*CD_BLK_SIZE);
iso->type_l_path_table=cur_blk;
tabbuf->name_len=2; //Fill-in adam entry
tempi=&iso->root_dir_record;
tabbuf->blk=tempi->loc.little;
tabbuf->parent_entry_num=1;
tabbuf2=CAlloc(tabsize2*CD_BLK_SIZE);
iso2->type_l_path_table=cur_blk+tabsize;
tabbuf2->name_len=2; //Fill-in adam entry
tempi=&iso2->root_dir_record;
tabbuf2->blk=tempi->loc.little;
tabbuf2->parent_entry_num=1;
itabbuf=tabbuf+1;
itabbuf2=tabbuf2+1;
first_free=2;
for (i=1;i<=max_depth;i++)
CDFillPathTable(rootdir,&itabbuf,&itabbuf2,
1,FALSE,&first_free,1,i);
"%X: Path Table 0\n",cur_blk;
FWBlks(out_file,tabbuf,cur_blk<<2,tabsize<<2);
cur_blk+=tabsize;
"%X: Path Table 1\n",cur_blk;
FWBlks(out_file,tabbuf2,cur_blk<<2,tabsize2<<2);
cur_blk+=tabsize2;
MemSet(tabbuf,0,tabsize*CD_BLK_SIZE);
iso->type_m_path_table=EndianU32(cur_blk);
tabbuf->name_len=2; //Fill-in adam entry
tempi=&iso->root_dir_record;
tabbuf->blk=tempi->loc.big;
tabbuf->parent_entry_num=EndianU16(1);
MemSet(tabbuf2,0,tabsize2*CD_BLK_SIZE);
iso2->type_m_path_table=EndianU32(cur_blk+tabsize);
tabbuf2->name_len=2; //Fill-in adam entry
tempi=&iso2->root_dir_record;
tabbuf2->blk=tempi->loc.big;
tabbuf2->parent_entry_num=EndianU16(1);
itabbuf=tabbuf+1;
itabbuf2=tabbuf2+1;
first_free=2;
for (i=1;i<=max_depth;i++)
CDFillPathTable(rootdir,&itabbuf,&itabbuf2,
1,TRUE,&first_free,1,i);
"%X: Path Table 2\n",cur_blk;
FWBlks(out_file,tabbuf,cur_blk<<2,tabsize<<2);
cur_blk+=tabsize;
"%X: Path Table 3\n",cur_blk;
FWBlks(out_file,tabbuf2,cur_blk<<2,tabsize2<<2);
cur_blk+=tabsize2;
CDirLstDel2(rootdir);
FillU32Palindrome(&iso->vol_space_size,cur_blk);
FillU32Palindrome(&iso2->vol_space_size,cur_blk);
FWBlks(out_file,iso,16<<2,4);
iso3->type=ISO1T_TERMINATOR;
StrCpy(iso3->id,"CD001");
iso3->version=1;
if (bootfile_buf) {
FWBlks(out_file,iso1,17<<2,4);
FWBlks(out_file,iso2,18<<2,4);
FWBlks(out_file,iso3,19<<2,4);
} else {
FWBlks(out_file,iso2,17<<2,4);
FWBlks(out_file,iso3,18<<2,4);
}
} else
cur_blk=0;
FClose(out_file);
Free(tabbuf);
Free(tabbuf2);
done1:
Free(bootfile_buf);
Free(filename2);
Free(et);
Free(zero_buf);
Free(iso);
Free(iso1);
Free(iso2);
Free(iso3);
return cur_blk;
}
#help_index ""
+12 -12
View File
@@ -153,10 +153,10 @@ U0 FMRebuildDoc(CDoc **_doc,CDirEntry **_root,I64 mode)
CDocEntry *doc_ce;
CDirEntry *tempm,*tempm1,*cur_tree_entry;
if (!doc)
parent_doc=DocCur;
parent_doc=DocPut;
else {
parent_doc=doc->parent_doc;
DocQueRem(doc);
Fs->put_doc=Fs->display_doc=NULL;
DocUnlock(doc);
WinMgrSync;
DocLock(doc);
@@ -204,20 +204,21 @@ U0 FMRebuildDoc(CDoc **_doc,CDirEntry **_root,I64 mode)
doc->flags|=DOCF_FORM;
switch (mode) {
case FM_NORMAL:
DocPutS(doc,"$$FG,PURPLE$$File Manager$$FG$$\n\n$$LK,\"Click for Help\",\"FI:::/TempleOS/Doc/FileMgr.TXT\"$$\n\n");
DocPutS(doc,"$$FG,PURPLE$$File Manager\n\n$$LK,\"Click for Help\",\"FI:::/TempleOS/Doc/FileMgr.TXT\"$$\n\n");
break;
case FM_PICK_FILE:
DocPutS(doc,"$$FG,PURPLE$$Pick file and press <ESC>$$FG$$\n\n");
DocPutS(doc,"$$FG,PURPLE$$Pick file and press <ESC>\n\n");
doc->flags|=DOCF_MIN_SIZE;
break;
case FM_PICK_DIR:
DocPutS(doc,"$$FG,PURPLE$$Pick directory and press <ESC>$$FG$$\n\n");
DocPutS(doc,"$$FG,PURPLE$$Pick directory and press <ESC>\n\n");
doc->flags|=DOCF_MIN_SIZE;
break;
}
DocPutS(doc,"$$FG,LTBLUE$$");
for (i=0;i<NUM_PRTS;i++) {
p=&sys_prts[i];
if (p->type==PT_NATIVE||p->type==PT_FAT32)
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)
@@ -238,8 +239,7 @@ U0 FMRebuildDoc(CDoc **_doc,CDirEntry **_root,I64 mode)
Free(next_entry);
*_doc=doc;
DocLock(doc);
DocQueRem(DocCur);
DocQueIns(doc,Fs->last_doc);
Fs->put_doc=Fs->display_doc=doc;
}
U0 FMRename(CDoc *doc)
@@ -550,7 +550,7 @@ public U8 *FileMgr(I64 mode=FM_NORMAL,CTask *mem_task=NULL)
{
CDirEntry *root=NULL,*tempm,*tempm1,*tempm2;
I64 sc,ch,p1,p2,msg_code;
CDoc *doc=NULL,*old_doc=DocCur;
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;
@@ -559,7 +559,7 @@ public U8 *FileMgr(I64 mode=FM_NORMAL,CTask *mem_task=NULL)
fp_old_final_screen_update=fp_final_screen_update;
MenuFilePush("::/TempleOS/Doc/FileMgrPullDown.TXT");
FMRebuildDoc(&doc,&root,mode);
if (tempm1=CdDir(root,old_cur_dir))
if (tempm1=Cd2DirEntry(root,old_cur_dir))
doc->cur_entry=tempm1->user_data;
while (tempm1) {
if (tempm1->attr&_ATTR_DIR)
@@ -750,8 +750,8 @@ regular_key:
}
} while (ch!=CH_ESC && ch!=CH_SHIFT_ESC);
fp_final_screen_update=fp_old_final_screen_update;
DocQueRem(doc);
DocQueIns(old_doc,Fs->last_doc);
Fs->put_doc =old_put_doc;
Fs->display_doc=old_display_doc;
SettingsPop;
DocDel(doc);
CDirLstDel(root);