TempleOSCDV4.12.ISO

This commit is contained in:
Terry A. Davis authored and minexew committed 2018-09-08 21:47:56 +02:00
1 parent 93ca216483
commit b84bbff6db
381 files changed
+18356 -18798

No files matched your search

+36 -36
View File
@@ -94,7 +94,7 @@ U0 ATARepEntry(I64 base0,I64 base1,I64 unit,I64 irq,U8 *msg,
I64 type;
base0&=-8;
base1&=-4;
CATARep *tempha;
CATARep *tmpha;
if (type=ATAProbe(base0,base1,unit)) {
*num_hints+=1;
"\n\n$$PURPLE$$ $$BT+X,\"%d\",LM=\"%d\\n\"$$$$FG$$$$LM,4$$",*num_hints,*num_hints;
@@ -105,14 +105,14 @@ U0 ATARepEntry(I64 base0,I64 base1,I64 unit,I64 irq,U8 *msg,
"%s$$FG$$\nBase0:0x%04X Base1:0x%04X\nIrq:0x%02X Unit:%d$$LM,0$$\n",
msg,base0,base1,irq,unit;
if (_head) {
tempha=CAlloc(sizeof(CATARep));
tempha->next=*_head;
*_head=tempha;
tempha->num=*num_hints;
tempha->type=type;
tempha->base0=base0;
tempha->base1=base1;
tempha->unit=unit;
tmpha=CAlloc(sizeof(CATARep));
tmpha->next=*_head;
*_head=tmpha;
tmpha->num=*num_hints;
tmpha->type=type;
tmpha->base0=base0;
tmpha->base1=base1;
tmpha->unit=unit;
}
}
}
@@ -204,32 +204,32 @@ CATARep *ATARepFind(CATARep *haystack_head,I64 needle_num)
CATARep *ATAIDDrvs(CATARep *head,CATARep **_ata_drv,CATARep **_atapi_drv)
{//This is for when trying to sort-out main hard drives and CD/DVD drives.
CATARep *res=NULL,*tempha=head,*ata_drv=NULL,*atapi_drv=NULL;
CATARep *res=NULL,*tmpha=head,*ata_drv=NULL,*atapi_drv=NULL;
CBlkDev *bd;
Bool was_silent=Silent;
bd=Let2BlkDev(':',FALSE);
Silent(was_silent);
while (tempha) {
if (!res && bd && bd->type==tempha->type) {
while (tmpha) {
if (!res && bd && bd->type==tmpha->type) {
if (bd->type==BDT_ATAPI &&
bd->base0==tempha->base0 && bd->unit==tempha->unit)
res=atapi_drv=tempha;
else if (bd->type==BDT_ATA && bd->base0==tempha->base0 &&
bd->base1==tempha->base1 && bd->unit==tempha->unit)
res=ata_drv=tempha;
bd->base0==tmpha->base0 && bd->unit==tmpha->unit)
res=atapi_drv=tmpha;
else if (bd->type==BDT_ATA && bd->base0==tmpha->base0 &&
bd->base1==tmpha->base1 && bd->unit==tmpha->unit)
res=ata_drv=tmpha;
}
if (!res || res->type!=tempha->type) {
if (tempha->type==BDT_ATA) {
if (!ata_drv || tempha->unit<ata_drv->unit ||
tempha->unit==ata_drv->unit && tempha->num<ata_drv->num)
ata_drv=tempha;
} else if (tempha->type==BDT_ATAPI) {
if (!atapi_drv || tempha->unit<atapi_drv->unit ||
tempha->unit==atapi_drv->unit && tempha->num<atapi_drv->num)
atapi_drv=tempha;
if (!res || res->type!=tmpha->type) {
if (tmpha->type==BDT_ATA) {
if (!ata_drv || tmpha->unit<ata_drv->unit ||
tmpha->unit==ata_drv->unit && tmpha->num<ata_drv->num)
ata_drv=tmpha;
} else if (tmpha->type==BDT_ATAPI) {
if (!atapi_drv || tmpha->unit<atapi_drv->unit ||
tmpha->unit==atapi_drv->unit && tmpha->num<atapi_drv->num)
atapi_drv=tmpha;
}
}
tempha=tempha->next;
tmpha=tmpha->next;
}
if (_ata_drv) *_ata_drv =ata_drv;
if (_atapi_drv) *_atapi_drv=atapi_drv;
@@ -256,7 +256,7 @@ I64 AutoMountIDE()
//It uses 'C' and 'T' as first drive letters or whatever you set
//in config when compiling Kernel.BIN.
I64 res=0;
CATARep *head=NULL,*ata_drv=NULL,*atapi_drv=NULL,*tempha;
CATARep *head=NULL,*ata_drv=NULL,*atapi_drv=NULL,*tmpha;
ATARep(FALSE,TRUE,&head);
ATAIDDrvs(head,&ata_drv,&atapi_drv);
if (ata_drv && ATAMount(blkdev.first_hd_drv_let,BDT_ATA,
@@ -265,18 +265,18 @@ I64 AutoMountIDE()
if (atapi_drv && ATAMount(blkdev.first_dvd_drv_let,BDT_ATAPI,
atapi_drv->base0,atapi_drv->base1,atapi_drv->unit))
res++;
tempha=head;
while (tempha) {
if (tempha!=ata_drv && tempha!=atapi_drv) {
if (tempha->type==BDT_ATA && ATAMount(blkdev.first_hd_drv_let,BDT_ATA,
tempha->base0,tempha->base1,tempha->unit))
tmpha=head;
while (tmpha) {
if (tmpha!=ata_drv && tmpha!=atapi_drv) {
if (tmpha->type==BDT_ATA && ATAMount(blkdev.first_hd_drv_let,BDT_ATA,
tmpha->base0,tmpha->base1,tmpha->unit))
res++;
else if (tempha->type==BDT_ATAPI &&
else if (tmpha->type==BDT_ATAPI &&
ATAMount(blkdev.first_dvd_drv_let,BDT_ATAPI,
tempha->base0,tempha->base1,tempha->unit))
tmpha->base0,tmpha->base1,tmpha->unit))
res++;
}
tempha=tempha->next;
tmpha=tmpha->next;
}
LinkedLstDel(head);
blkdev.auto_mount_ide_cnt=res;
+50 -50
View File
@@ -1,6 +1,6 @@
U0 DskCacheInit(I64 size_in_U8s)
{
CCacheBlk *tempc;
CCacheBlk *tmpc;
I64 i,cnt;
while (LBts(&sys_semas[SYS_SEMA_DSK_CACHE],0))
@@ -20,18 +20,18 @@ U0 DskCacheInit(I64 size_in_U8s)
cnt=MSize(blkdev.cache_base)/sizeof(CCacheBlk);
blkdev.cache_size=cnt*BLK_SIZE;
for (i=0;i<cnt;i++) {
tempc=blkdev.cache_base+i;
QueIns(tempc,blkdev.cache_ctrl->last_lru);
tempc->next_hash=tempc->last_hash=tempc;
tempc->dv=NULL;
tempc->blk=0;
tmpc=blkdev.cache_base+i;
QueIns(tmpc,blkdev.cache_ctrl->last_lru);
tmpc->next_hash=tmpc->last_hash=tmpc;
tmpc->dv=NULL;
tmpc->blk=0;
}
blkdev.cache_hash_table=AMAlloc(DSK_CACHE_HASH_SIZE*sizeof(U8 *)*2);
for (i=0;i<DSK_CACHE_HASH_SIZE;i++) {
tempc=blkdev.cache_hash_table(U8 *)+i*sizeof(U8 *)*2
tmpc=blkdev.cache_hash_table(U8 *)+i*sizeof(U8 *)*2
-offset(CCacheBlk.next_hash);
tempc->next_hash=tempc->last_hash=tempc;
tmpc->next_hash=tmpc->last_hash=tmpc;
}
}
LBtr(&sys_semas[SYS_SEMA_DSK_CACHE],0);
@@ -43,50 +43,50 @@ I64 DskCacheHash(I64 blk)
return blkdev.cache_hash_table(U8 *)+i<<4-offset(CCacheBlk.next_hash);
}
U0 DskCacheQueRem(CCacheBlk *tempc)
U0 DskCacheQueRem(CCacheBlk *tmpc)
{
QueRem(tempc);
tempc->next_hash->last_hash=tempc->last_hash;
tempc->last_hash->next_hash=tempc->next_hash;
QueRem(tmpc);
tmpc->next_hash->last_hash=tmpc->last_hash;
tmpc->last_hash->next_hash=tmpc->next_hash;
}
U0 DskCacheQueIns(CCacheBlk *tempc)
U0 DskCacheQueIns(CCacheBlk *tmpc)
{
CCacheBlk *temp_n,*temp_l;
QueIns(tempc,blkdev.cache_ctrl->last_lru);
temp_l=DskCacheHash(tempc->blk);
temp_n=temp_l->next_hash;
tempc->last_hash=temp_l;
tempc->next_hash=temp_n;
temp_l->next_hash=temp_n->last_hash=tempc;
CCacheBlk *tmp_n,*tmp_l;
QueIns(tmpc,blkdev.cache_ctrl->last_lru);
tmp_l=DskCacheHash(tmpc->blk);
tmp_n=tmp_l->next_hash;
tmpc->last_hash=tmp_l;
tmpc->next_hash=tmp_n;
tmp_l->next_hash=tmp_n->last_hash=tmpc;
}
CCacheBlk *DskCacheFind(CDrv *dv,I64 blk)
{
CCacheBlk *tempc,*tempc1=DskCacheHash(blk);
tempc=tempc1->next_hash;
while (tempc!=tempc1) {
if (tempc->dv==dv && tempc->blk==blk)
return tempc;
tempc=tempc->next_hash;
CCacheBlk *tmpc,*tmpc1=DskCacheHash(blk);
tmpc=tmpc1->next_hash;
while (tmpc!=tmpc1) {
if (tmpc->dv==dv && tmpc->blk==blk)
return tmpc;
tmpc=tmpc->next_hash;
}
return NULL;
}
U0 DskCacheAdd(CDrv *dv,U8 *buf, I64 blk, I64 cnt)
{
CCacheBlk *tempc;
CCacheBlk *tmpc;
if (blkdev.cache_base) {
while (LBts(&sys_semas[SYS_SEMA_DSK_CACHE],0))
Yield;
while (cnt-->0) {
if (!(tempc=DskCacheFind(dv,blk)))
tempc=blkdev.cache_ctrl->next_lru;
DskCacheQueRem(tempc);
MemCpy(&tempc->body,buf,BLK_SIZE);
tempc->dv=dv;
tempc->blk=blk;
DskCacheQueIns(tempc);
if (!(tmpc=DskCacheFind(dv,blk)))
tmpc=blkdev.cache_ctrl->next_lru;
DskCacheQueRem(tmpc);
MemCpy(&tmpc->body,buf,BLK_SIZE);
tmpc->dv=dv;
tmpc->blk=blk;
DskCacheQueIns(tmpc);
blk++;
buf+=BLK_SIZE;
}
@@ -96,21 +96,21 @@ U0 DskCacheAdd(CDrv *dv,U8 *buf, I64 blk, I64 cnt)
U0 DskCacheInvalidate2(CDrv *dv)
{
CCacheBlk *tempc,*tempc1;
CCacheBlk *tmpc,*tmpc1;
if (blkdev.cache_base) {
while (LBts(&sys_semas[SYS_SEMA_DSK_CACHE],0))
Yield;
tempc=blkdev.cache_ctrl->last_lru;
while (tempc!=blkdev.cache_ctrl) {
tempc1=tempc->last_lru;
if (tempc->dv==dv) {
DskCacheQueRem(tempc);
tempc->dv=NULL;
tempc->blk=0;
tempc->next_hash=tempc->last_hash=tempc;
QueIns(tempc,blkdev.cache_ctrl->last_lru);
tmpc=blkdev.cache_ctrl->last_lru;
while (tmpc!=blkdev.cache_ctrl) {
tmpc1=tmpc->last_lru;
if (tmpc->dv==dv) {
DskCacheQueRem(tmpc);
tmpc->dv=NULL;
tmpc->blk=0;
tmpc->next_hash=tmpc->last_hash=tmpc;
QueIns(tmpc,blkdev.cache_ctrl->last_lru);
}
tempc=tempc1;
tmpc=tmpc1;
}
LBtr(&sys_semas[SYS_SEMA_DSK_CACHE],0);
}
@@ -118,14 +118,14 @@ U0 DskCacheInvalidate2(CDrv *dv)
U0 RCache(CDrv *dv,U8 **_buf, I64 *_blk, I64 *_cnt)
{
CCacheBlk *tempc;
CCacheBlk *tmpc;
if (blkdev.cache_base) {
while (LBts(&sys_semas[SYS_SEMA_DSK_CACHE],0))
Yield;
//fetch leading blks from cache
while (*_cnt>0) {
if (tempc=DskCacheFind(dv,*_blk)) {
MemCpy(*_buf,&tempc->body,BLK_SIZE);
if (tmpc=DskCacheFind(dv,*_blk)) {
MemCpy(*_buf,&tmpc->body,BLK_SIZE);
*_cnt-=1;
*_buf+=BLK_SIZE;
*_blk+=1;
@@ -134,8 +134,8 @@ U0 RCache(CDrv *dv,U8 **_buf, I64 *_blk, I64 *_cnt)
}
//fetch trailing blks from cache
while (*_cnt>0) {
if (tempc=DskCacheFind(dv,*_blk+*_cnt-1)) {
MemCpy(*_buf+(*_cnt-1)<<BLK_SIZE_BITS,&tempc->body,BLK_SIZE);
if (tmpc=DskCacheFind(dv,*_blk+*_cnt-1)) {
MemCpy(*_buf+(*_cnt-1)<<BLK_SIZE_BITS,&tmpc->body,BLK_SIZE);
*_cnt-=1;
} else
break;
+61 -61
View File
@@ -1,10 +1,10 @@
Bool DirNew(CDrv *dv,U8 *cur_dir,CDirEntry *tempde,Bool free_old_chain=TRUE)
Bool DirNew(CDrv *dv,U8 *cur_dir,CDirEntry *tmpde,Bool free_old_chain=TRUE)
{//Makes a directory entry in the directory from a $LK,"CDirEntry",A="MN:CDirEntry"$ node.
switch (dv->fs_type) {
case FSt_REDSEA:
return RedSeaDirNew(dv,cur_dir,tempde,free_old_chain);
return RedSeaDirNew(dv,cur_dir,tmpde,free_old_chain);
case FSt_FAT32:
return FAT32DirNew(dv,cur_dir,tempde,free_old_chain);
return FAT32DirNew(dv,cur_dir,tmpde,free_old_chain);
case FSt_ISO9660:
PrintErr("Not Writable\n");
return FALSE;
@@ -14,48 +14,48 @@ Bool DirNew(CDrv *dv,U8 *cur_dir,CDirEntry *tempde,Bool free_old_chain=TRUE)
}
}
U0 DirEntryDel(CDirEntry *tempde)
U0 DirEntryDel(CDirEntry *tmpde)
{//Free node returned from $LK,"FilesFind",A="MN:FilesFind"$(). Doesn't Free user_data.
//Does not change the directory on disk.
if (tempde) {
Free(tempde->full_name);
Free(tempde);
if (tmpde) {
Free(tmpde->full_name);
Free(tmpde);
}
}
U0 DirEntryDel2(CDirEntry *tempde)
U0 DirEntryDel2(CDirEntry *tmpde)
{//Free node returned from $LK,"FilesFind",A="MN:FilesFind"$(). Frees user_data
//Does not change the directory on disk.
if (tempde) {
Free(tempde->full_name);
Free(tempde->user_data);
Free(tempde);
if (tmpde) {
Free(tmpde->full_name);
Free(tmpde->user_data);
Free(tmpde);
}
}
U0 DirTreeDel(CDirEntry *tempde)
U0 DirTreeDel(CDirEntry *tmpde)
{//Free tree returned from $LK,"FilesFind",A="MN:FilesFind"$(). Doesn't Free user_data.
//Does not change the directory on disk.
CDirEntry *tempde2;
while (tempde) {
tempde2=tempde->next;
if (tempde->sub)
DirTreeDel(tempde->sub);
DirEntryDel(tempde);
tempde=tempde2;
CDirEntry *tmpde2;
while (tmpde) {
tmpde2=tmpde->next;
if (tmpde->sub)
DirTreeDel(tmpde->sub);
DirEntryDel(tmpde);
tmpde=tmpde2;
}
}
U0 DirTreeDel2(CDirEntry *tempde)
U0 DirTreeDel2(CDirEntry *tmpde)
{//Free tree returned from $LK,"FilesFind",A="MN:FilesFind"$(). Frees user_data
//Does not change the directory on disk.
CDirEntry *tempde2;
while (tempde) {
tempde2=tempde->next;
if (tempde->sub)
DirTreeDel2(tempde->sub);
DirEntryDel2(tempde);
tempde=tempde2;
CDirEntry *tmpde2;
while (tmpde) {
tmpde2=tmpde->next;
if (tmpde->sub)
DirTreeDel2(tmpde->sub);
DirEntryDel2(tmpde);
tmpde=tmpde2;
}
}
@@ -89,19 +89,19 @@ I64 DirEntryCompareCluster(CDirEntry *e1,CDirEntry *e2)
#define SK_NAME 0
#define SK_CLUSTER 1
U0 DirFilesSort(CDirEntry **_tempde,I64 key)
U0 DirFilesSort(CDirEntry **_tmpde,I64 key)
{
I64 i,cnt;
CDirEntry *tempde=*_tempde,*tempde1,**sort_buf;
if (tempde) {
cnt=LinkedLstCnt(tempde);
CDirEntry *tmpde=*_tmpde,*tmpde1,**sort_buf;
if (tmpde) {
cnt=LinkedLstCnt(tmpde);
if (cnt>1) {
sort_buf=MAlloc(cnt*sizeof(U8 *));
i=0;
tempde1=tempde;
while (tempde1) {
sort_buf[i++]=tempde1;
tempde1=tempde1->next;
tmpde1=tmpde;
while (tmpde1) {
sort_buf[i++]=tmpde1;
tmpde1=tmpde1->next;
}
switch [key] {
case SK_NAME:
@@ -111,48 +111,48 @@ U0 DirFilesSort(CDirEntry **_tempde,I64 key)
QSortI64(sort_buf,cnt,&DirEntryCompareCluster);
break;
}
tempde=sort_buf[0];
*_tempde=tempde;
tmpde=sort_buf[0];
*_tmpde=tmpde;
for (i=0;i<cnt-1;i++) {
tempde1=sort_buf[i];
tempde1->next=sort_buf[i+1];
tmpde1=sort_buf[i];
tmpde1->next=sort_buf[i+1];
}
tempde1=sort_buf[i];
tempde1->next=NULL;
tmpde1=sort_buf[i];
tmpde1->next=NULL;
Free(sort_buf);
tempde1=tempde;
while (tempde1) {
if (tempde1->sub)
DirFilesSort(&tempde1->sub,key);
tempde1=tempde1->next;
tmpde1=tmpde;
while (tmpde1) {
if (tmpde1->sub)
DirFilesSort(&tmpde1->sub,key);
tmpde1=tmpde1->next;
}
} else
if (tempde->sub)
DirFilesSort(&tempde->sub,key);
if (tmpde->sub)
DirFilesSort(&tmpde->sub,key);
}
}
CDirEntry *DirFilesFlatten(CDirEntry *tempde,CDirEntry **_res,I64 fuf_flags)
CDirEntry *DirFilesFlatten(CDirEntry *tmpde,CDirEntry **_res,I64 fuf_flags)
{//Returns last node
CDirEntry *tempde1;
CDirEntry *tmpde1;
Bool del;
if (tempde)
if (tmpde)
while (TRUE) {
tempde1=tempde->next;
if (!(tempde->attr&RS_ATTR_DIR)||!(fuf_flags&FUF_JUST_FILES)) {
_res=*_res=tempde;
tmpde1=tmpde->next;
if (!(tmpde->attr&RS_ATTR_DIR)||!(fuf_flags&FUF_JUST_FILES)) {
_res=*_res=tmpde;
del=FALSE;
} else
del=TRUE;
if (tempde->sub) {
_res=DirFilesFlatten(tempde->sub,_res,fuf_flags);
tempde->sub=NULL;
if (tmpde->sub) {
_res=DirFilesFlatten(tmpde->sub,_res,fuf_flags);
tmpde->sub=NULL;
}
if (del)
DirEntryDel(tempde);
if (tempde1)
tempde=tempde1;
DirEntryDel(tmpde);
if (tmpde1)
tmpde=tmpde1;
else
break;
}
+22 -22
View File
@@ -104,28 +104,28 @@ Bool IsDir(U8 *dir_name)
I64 Dir(U8 *files_find_mask,Bool full)
{//List directory.
CDirEntry *tempde1=NULL,*tempde2;
CDirEntry *tmpde1=NULL,*tmpde2;
U8 *st;
CDateStruct ds;
I64 csize=0xFFFF,c=0xFFFF,res=0;
tempde1=FilesFind(files_find_mask);
tmpde1=FilesFind(files_find_mask);
if (!(st=CurDir))
PrintErr("Invalid Drive\n");
else {
if (tempde1) {
if (tmpde1) {
Free(st);
st=MAllocIdent(tempde1->full_name);
st=MAllocIdent(tmpde1->full_name);
StrLastRem(st,"/");
if (!st[2])
StrCpy(st+2,"/");
//Find max columns
tempde2=tempde1;
while (tempde2) {
if (tempde2->size>csize)
csize=tempde2->size;
if (tempde2->cluster>c)
c=tempde2->cluster;
tempde2=tempde2->next;
tmpde2=tmpde1;
while (tmpde2) {
if (tmpde2->size>csize)
csize=tmpde2->size;
if (tmpde2->cluster>c)
c=tmpde2->cluster;
tmpde2=tmpde2->next;
}
csize=Bsr(csize)/4+1;
c=Bsr(c)/4+1;
@@ -136,24 +136,24 @@ I64 Dir(U8 *files_find_mask,Bool full)
csize,"SIZE",c,"CLUSTER";
else
"DATE_ TIME_ %*ts\n",csize,"SIZE";
while (tempde1) {
tempde2=tempde1->next;
while (tmpde1) {
tmpde2=tmpde1->next;
res++;
if (full)
"%D %T %0*tX %0*tX ",tempde1->datetime,tempde1->datetime,
csize,tempde1->size,c,tempde1->cluster;
"%D %T %0*tX %0*tX ",tmpde1->datetime,tmpde1->datetime,
csize,tmpde1->size,c,tmpde1->cluster;
else {
Date2Struct(&ds,tempde1->datetime+local_time_offset);
Date2Struct(&ds,tmpde1->datetime+local_time_offset);
"%02d/%02d %02d:%02d %0*tX ",ds.mon,ds.day_of_mon,ds.hour,ds.min,
csize,tempde1->size;
csize,tmpde1->size;
}
if (tempde1->attr & RS_ATTR_DIR)
PutDirLink(tempde1->name,tempde1->full_name);
if (tmpde1->attr & RS_ATTR_DIR)
PutDirLink(tmpde1->name,tmpde1->full_name);
else
PutFileLink(tempde1->name,tempde1->full_name);
PutFileLink(tmpde1->name,tmpde1->full_name);
'\n';
DirEntryDel(tempde1);
tempde1=tempde2;
DirEntryDel(tmpde1);
tmpde1=tmpde2;
}
} else
"No matching entries\n";
+15 -13
View File
@@ -1,17 +1,19 @@
U0 DirContextDel(CDirContext *dirc)
U0 DirContextDel(CDirContext *dirc,Bool restore=TRUE)
{//Change back to old cur_dir and drv.
CBlkDev *bd;
if (!dirc) return;
bd=dirc->old_dv->bd;
if (!(bd->flags & BDF_INIT_IN_PROGRESS)) {
if (dirc->old_dir) {
Drv(Drv2Let(dirc->old_dv));
Cd(dirc->old_dir);
if (restore) {
bd=dirc->old_dv->bd;
if (!(bd->flags & BDF_INIT_IN_PROGRESS)) {
if (dirc->old_dir) {
Drv(Drv2Let(dirc->old_dv));
Cd(dirc->old_dir);
}
} else {
Fs->cur_dv=dirc->old_dv;
Free(Fs->cur_dir);
Fs->cur_dir=StrNew("/");
}
} else {
Fs->cur_dv=dirc->old_dv;
Free(Fs->cur_dir);
Fs->cur_dir=StrNew("/");
}
Free(dirc->old_dir);
Free(dirc->mask);
@@ -23,12 +25,12 @@ CDirContext *DirContextNew(U8 *_mask,Bool make_mask=FALSE,
{//Save cur_dir and drv. Change to new dir.
Bool valid=TRUE,old_silent;
I64 mask_len=StrLen(_mask);
U8 *buf,*mask,*temp_mask,*semicolon_mask;
U8 *buf,*mask,*tmp_mask,*semicolon_mask;
CDirContext *dirc=CAlloc(sizeof(CDirContext));
dirc->old_dir=StrNew(Fs->cur_dir);
dirc->old_dv=Fs->cur_dv;
mask=MStrUtil(_mask,SUF_REM_LEADING|SUF_REM_TRAILING|SUF_REM_CTRL_CHARS);
temp_mask=mask;
tmp_mask=mask;
if (*mask && mask[1]==':') {
if (Fs->cur_dv!=Let2Drv(*mask) && !Drv(*mask))
valid=FALSE;
@@ -76,7 +78,7 @@ CDirContext *DirContextNew(U8 *_mask,Bool make_mask=FALSE,
}
}
Free(buf);
Free(temp_mask);
Free(tmp_mask);
if (!valid) {
DirContextDel(dirc);
dirc=NULL;
+12 -12
View File
@@ -1,19 +1,19 @@
U8 *FileRead(U8 *filename,I64 *_size=NULL,I64 *_attr=NULL)
{//Read whole file from disk.
CHashGeneric *temph;
CHashGeneric *tmph;
U8 *absname,*altname,*curname,*res=NULL;
I64 i,size=0,attr=0;
CDirContext *dirc;
CArcCompress *arc;
absname=FileNameAbs(filename);
altname=ToggleZorNotZ(absname);
if ((temph=HashFind(absname,adam_task->hash_table,HTT_FILE))||
(temph=HashFind(altname,adam_task->hash_table,HTT_FILE))) {
size=temph->user_data1;
if ((tmph=HashFind(absname,adam_task->hash_table,HTT_FILE))||
(tmph=HashFind(altname,adam_task->hash_table,HTT_FILE))) {
size=tmph->user_data1;
res=MAlloc(size+1);
MemCpy(res,temph->user_data0,size);
MemCpy(res,tmph->user_data0,size);
res[size]=0; //Terminate
attr=FileAttr(temph->str,attr);
attr=FileAttr(tmph->str,attr);
} else {
for (i=0;i<2 && !res;i++) {//Try name, then altname
if (!i)
@@ -87,7 +87,7 @@ U8 *FileRead(U8 *filename,I64 *_size=NULL,I64 *_attr=NULL)
I64 FileWrite(U8 *filename,U8 *fbuf,I64 size,CDate cdt=0,I64 attr=0)
{//Write whole file to disk.
I64 c=0;
CHashGeneric *temph;
CHashGeneric *tmph;
CDirContext *dirc;
U8 *fbuf2,*absname=FileNameAbs(filename);
if (dirc=DirContextNew(filename,FALSE,TRUE)) {
@@ -112,13 +112,13 @@ I64 FileWrite(U8 *filename,U8 *fbuf,I64 size,CDate cdt=0,I64 attr=0)
default:
PrintErr("File System Not Supported\n");
}
if (temph=HashFind(absname,adam_task->hash_table,HTT_FILE)) {
if (tmph=HashFind(absname,adam_task->hash_table,HTT_FILE)) {
if (attr & RS_ATTR_RESIDENT) {
Free(temph->user_data0);
temph->user_data0=AMAllocIdent(fbuf);
temph->user_data1=size;
Free(tmph->user_data0);
tmph->user_data0=AMAllocIdent(fbuf);
tmph->user_data1=size;
} else
HashRemDel(temph,adam_task->hash_table);
HashRemDel(tmph,adam_task->hash_table);
} else if (attr & RS_ATTR_RESIDENT)
HashGenericAdd(absname,HTT_FILE,AMAllocIdent(fbuf),size,0,adam_task);
Free(fbuf2);
+17 -13
View File
@@ -71,6 +71,10 @@ Bool FilesFindMatch(U8 *_test_name,U8 *files_find_mask,I64 fuf_flags=0)
!FilesFindMatch(_test_name,FILEMASK_TXT)) {
res=FALSE;
break;
} else if (Bt(&fuf_flags,FUf_JUST_DD) &&
!FilesFindMatch(_test_name,FILEMASK_DD)) {
res=FALSE;
break;
} else if (Bt(&fuf_flags,FUf_JUST_SRC) &&
!FilesFindMatch(_test_name,FILEMASK_SRC)) {
res=FALSE;
@@ -83,8 +87,8 @@ Bool FilesFindMatch(U8 *_test_name,U8 *files_find_mask,I64 fuf_flags=0)
!FilesFindMatch(_test_name,FILEMASK_JIT)) {
res=FALSE;
break;
} else if (Bt(&fuf_flags,FUf_JUST_GRA) &&
!FilesFindMatch(_test_name,FILEMASK_GRA)) {
} else if (Bt(&fuf_flags,FUf_JUST_GR) &&
!FilesFindMatch(_test_name,FILEMASK_GR)) {
res=FALSE;
break;
} else
@@ -214,19 +218,19 @@ U8 *DftExt(U8 *filename,U8 *extension)
return res;
}
CDirEntry *Cd2DirEntry(CDirEntry *tempde,U8 *abs_name)
CDirEntry *Cd2DirEntry(CDirEntry *tmpde,U8 *abs_name)
{
I64 i;
while (tempde) {
i=StrLen(tempde->full_name);
if (StrNCmp(tempde->full_name,abs_name,i)||
i && tempde->full_name[i-1]!='/' && abs_name[i] && abs_name[i]!='/')
tempde=tempde->next;
while (tmpde) {
i=StrLen(tmpde->full_name);
if (StrNCmp(tmpde->full_name,abs_name,i)||
i && tmpde->full_name[i-1]!='/' && abs_name[i] && abs_name[i]!='/')
tmpde=tmpde->next;
else
if (StrLen(abs_name)==i)
return tempde;
return tmpde;
else
return Cd2DirEntry(tempde->sub,abs_name);
return Cd2DirEntry(tmpde->sub,abs_name);
}
return NULL;
}
@@ -269,9 +273,9 @@ U8 *ToggleZorNotZ(U8 *name)
return res;
}
U8 *FileNameTempTxt()
{//Make pretty-safe temp filename in home dir.
return MStrPrint("~/SysTemp%X.DD.Z",GetTSC>>8&0xFFFFFFFF);
U8 *FileNameTmpTxt()
{//Make pretty-safe tmp filename in home dir.
return MStrPrint("~/SysTmp%X.DD.Z",GetTSC>>8&0xFFFFFFFF);
}
U8 *CurDir(CTask *task=NULL,CTask *mem_task=NULL)
+56 -56
View File
@@ -196,50 +196,50 @@ U8 fat_long_name_map[13]={
offset(CFAT32DirEntryLong.name3)+2
};
Bool DirLongNameFill(CDirEntry *tempde,CFAT32DirEntryLong *de,I64 *xsum)
Bool DirLongNameFill(CDirEntry *tmpde,CFAT32DirEntryLong *de,I64 *xsum)
{
I64 i;
U8 *ptr=de;
if (de->ord&0x40) {
MemSet(tempde,0,sizeof(CDirEntry));
MemSet(tmpde,0,sizeof(CDirEntry));
*xsum=de->xsum;
} else if (de->type || de->zero || de->xsum!=*xsum) {
MemSet(tempde,0,sizeof(CDirEntry));
MemSet(tmpde,0,sizeof(CDirEntry));
*xsum=0;
return FALSE;
}
switch (de->ord&0x3F) {
case 1:
for (i=0;i<13;i++)
if (!(tempde->name[i]=ptr[fat_long_name_map[i]]))
if (!(tmpde->name[i]=ptr[fat_long_name_map[i]]))
return TRUE;
break;
case 2:
for (i=0;i<12;i++)
if (!(tempde->name[i+13]=ptr[fat_long_name_map[i]]))
if (!(tmpde->name[i+13]=ptr[fat_long_name_map[i]]))
return TRUE;
break;
}
return TRUE;
}
Bool FAT32CDirFill(CDirEntry *tempde,
Bool FAT32CDirFill(CDirEntry *tmpde,
CFAT32DirEntry *de,CDate _local_time_offset)
{
Bool res;
if (*tempde->name)
if (*tmpde->name)
res=TRUE;
else
res=FATFromName(tempde->name,de->name);
tempde->cluster=de->cluster_lo+de->cluster_hi<<16;
tempde->size=de->size;
tempde->attr=de->attr;
tempde->datetime=Dos2CDate(de->WrtTime,de->WrtDate)-_local_time_offset;
res=FATFromName(tmpde->name,de->name);
tmpde->cluster=de->cluster_lo+de->cluster_hi<<16;
tmpde->size=de->size;
tmpde->attr=de->attr;
tmpde->datetime=Dos2CDate(de->WrtTime,de->WrtDate)-_local_time_offset;
return res;
}
Bool FAT32DirFill(CFAT32DirEntry *de,
CDirEntry *tempde,I64 *_de_cnt,CDate _local_time_offset)
CDirEntry *tmpde,I64 *_de_cnt,CDate _local_time_offset)
{//Fill up to 3 entries and store cnt of entries.
I64 de_cnt=0,i,l,xsum,ord;
U8 *ptr,dname[16];
@@ -247,19 +247,19 @@ Bool FAT32DirFill(CFAT32DirEntry *de,
Bool res;
MemSet(de,0,sizeof(CFAT32DirEntry));
res=FATNameTo(de->name,tempde->name);
res=FATNameTo(de->name,tmpde->name);
FATFromName(dname,de->name);
if (StrCmp(dname,tempde->name)) {
if (StrCmp(dname,tmpde->name)) {
ord=0x41;
xsum=FATNameXSum(de->name);
if ((l=StrLen(tempde->name))>13) {
if ((l=StrLen(tmpde->name))>13) {
ptr=&ld[de_cnt];
MemSet(ptr,0,sizeof(CFAT32DirEntryLong));
ld[de_cnt].attr=RS_ATTR_LONG_NAME;
ld[de_cnt].xsum=xsum;
ld[de_cnt].ord=0x42;
for (i=13;i<l;i++)
ptr[fat_long_name_map[i-13]]=tempde->name[i];
ptr[fat_long_name_map[i-13]]=tmpde->name[i];
i++;
for (;i<26;i++)
ptr[fat_long_name_map[i-13]](U16)=0xFFFF;
@@ -273,23 +273,23 @@ Bool FAT32DirFill(CFAT32DirEntry *de,
ld[de_cnt].xsum=xsum;
ld[de_cnt].ord=ord;
for (i=0;i<l;i++)
ptr[fat_long_name_map[i]]=tempde->name[i];
ptr[fat_long_name_map[i]]=tmpde->name[i];
i++;
for (;i<13;i++)
ptr[fat_long_name_map[i]](U16)=0xFFFF;
de_cnt++;
MemSet(&de[de_cnt],0,sizeof(CFAT32DirEntry));
res=FATNameTo(de[de_cnt].name,tempde->name);
res=FATNameTo(de[de_cnt].name,tmpde->name);
}
de[de_cnt].cluster_lo=tempde->cluster.u16[0];
de[de_cnt].cluster_hi=tempde->cluster.u16[1];
if (!(tempde->attr&RS_ATTR_DIR))
de[de_cnt].size=tempde->size;
de[de_cnt].attr=tempde->attr;
if (!tempde->datetime)
tempde->datetime=Now;
de[de_cnt].cluster_lo=tmpde->cluster.u16[0];
de[de_cnt].cluster_hi=tmpde->cluster.u16[1];
if (!(tmpde->attr&RS_ATTR_DIR))
de[de_cnt].size=tmpde->size;
de[de_cnt].attr=tmpde->attr;
if (!tmpde->datetime)
tmpde->datetime=Now;
CDate2Dos(&de[de_cnt].WrtTime,&de[de_cnt].WrtDate,
tempde->datetime+_local_time_offset);
tmpde->datetime+_local_time_offset);
if (_de_cnt)
*_de_cnt=de_cnt+1;
return res;
@@ -573,17 +573,17 @@ I64 FAT32AllocContiguousClusters(CDrv *dv,I64 cnt)
return first;
}
Bool FAT32DirNew(CDrv *dv,U8 *cur_dir,CDirEntry *tempde,Bool free_old_chain)
Bool FAT32DirNew(CDrv *dv,U8 *cur_dir,CDirEntry *tmpde,Bool free_old_chain)
{
//See $LK,"::/Doc/CutCorners.DD"$.
CFAT32DirEntry *buf,*last_buf,*temp_buf,de[3];
CFAT32DirEntry *buf,*last_buf,*tmp_buf,de[3];
I64 i,attr,avail_cnt,de_cnt,c,
cur_dir_entry,entries_per_cluster,
cur_dir_cluster,xsum=0,last_dir_cluster=INVALID_CLUSTER;
U8 ch;
Bool written=FALSE,unlock,unlock_break;
CDirEntry long_name;
FAT32DirFill(&de,tempde,&de_cnt,dv->fat32_local_time_offset);
FAT32DirFill(&de,tmpde,&de_cnt,dv->fat32_local_time_offset);
MemSet(&long_name,0,sizeof(CDirEntry));
try {
unlock_break=BreakLock;
@@ -620,7 +620,7 @@ Bool FAT32DirNew(CDrv *dv,U8 *cur_dir,CDirEntry *tempde,Bool free_old_chain)
if (!*long_name.name)
FATFromName(long_name.name,buf[cur_dir_entry].name);
//Del old entry with same name
if (!StrCmp(long_name.name,tempde->name)) {
if (!StrCmp(long_name.name,tmpde->name)) {
if (free_old_chain)
FAT32FreeClusters(dv,buf[cur_dir_entry].cluster_lo+
buf[cur_dir_entry].cluster_hi<<16);
@@ -662,7 +662,7 @@ Bool FAT32DirNew(CDrv *dv,U8 *cur_dir,CDirEntry *tempde,Bool free_old_chain)
}
if (++cur_dir_entry==entries_per_cluster) {
last_dir_cluster=cur_dir_cluster;
temp_buf=buf; buf=last_buf; last_buf=temp_buf;
tmp_buf=buf; buf=last_buf; last_buf=tmp_buf;
c=ClusterNumNext(dv,cur_dir_cluster);
if (!(0<c<0x0FFFFFF8)) {
c=ClustersAlloc(dv,cur_dir_cluster,1,FALSE);
@@ -685,7 +685,7 @@ Bool FAT32DirNew(CDrv *dv,U8 *cur_dir,CDirEntry *tempde,Bool free_old_chain)
cur_dir_entry+=avail_cnt;
if (cur_dir_entry==entries_per_cluster) {
last_dir_cluster=cur_dir_cluster;
temp_buf=buf; buf=last_buf; last_buf=temp_buf;
tmp_buf=buf; buf=last_buf; last_buf=tmp_buf;
cur_dir_cluster=ClustersAlloc(dv,cur_dir_cluster,1);
cur_dir_entry=0;
MemSet(buf,0,BLK_SIZE*dv->spc);
@@ -726,7 +726,7 @@ Bool FAT32DirNew(CDrv *dv,U8 *cur_dir,CDirEntry *tempde,Bool free_old_chain)
I64 FAT32FilesDel(CDrv *dv,U8 *cur_dir,U8 *files_find_mask,I64 fuf_flags,
Bool del_dir,Bool print_msg)
{
CFAT32DirEntry *buf,*last_buf,*temp_buf;
CFAT32DirEntry *buf,*last_buf,*tmp_buf;
I64 i,res=0,attr,xsum=0,last_dir_cluster=INVALID_CLUSTER,
cur_dir_entry,entries_per_cluster,cur_dir_cluster;
U8 ch;
@@ -792,7 +792,7 @@ I64 FAT32FilesDel(CDrv *dv,U8 *cur_dir,U8 *files_find_mask,I64 fuf_flags,
if (++cur_dir_entry==entries_per_cluster) {
last_dir_cluster=cur_dir_cluster;
cur_dir_cluster=ClusterNumNext(dv,cur_dir_cluster,1);
temp_buf=buf; buf=last_buf; last_buf=temp_buf;
tmp_buf=buf; buf=last_buf; last_buf=tmp_buf;
RClusters(dv,buf,cur_dir_cluster,1);
cur_dir_entry=0;
}
@@ -851,7 +851,7 @@ CDirEntry *FAT32FilesFind(U8 *files_find_mask,
I64 attr,xsum=0,dir_size=0,sub_dir_size,
cur_dir_cluster,cur_dir_entry,entries_per_cluster;
U8 ch;
CDirEntry *res=NULL,*tempde,long_name;
CDirEntry *res=NULL,*tmpde,long_name;
if (fuf_flags&~FUG_FILES_FIND)
throw('FUF');
try {
@@ -870,41 +870,41 @@ CDirEntry *FAT32FilesFind(U8 *files_find_mask,
DirLongNameFill(&long_name,&buf[cur_dir_entry],&xsum);
else {
if (!(attr&RS_ATTR_VOL_ID)) {
tempde=MAlloc(sizeof(CDirEntry));
tmpde=MAlloc(sizeof(CDirEntry));
if (xsum==FATNameXSum(buf[cur_dir_entry].name))
MemCpy(tempde,&long_name,sizeof(CDirEntry));
MemCpy(tmpde,&long_name,sizeof(CDirEntry));
else
MemSet(tempde,0,sizeof(CDirEntry));
if (FAT32CDirFill(tempde,&buf[cur_dir_entry],
MemSet(tmpde,0,sizeof(CDirEntry));
if (FAT32CDirFill(tmpde,&buf[cur_dir_entry],
dv->fat32_local_time_offset)) {
tempde->parent=parent;
tmpde->parent=parent;
if (Bt(&fuf_flags,FUf_RECURSE) && attr&RS_ATTR_DIR &&
*tempde->name!='.') {
tempde->next=res;
res=tempde;
tempde->full_name=DirNameAbs(tempde->name);
*tmpde->name!='.') {
tmpde->next=res;
res=tmpde;
tmpde->full_name=DirNameAbs(tmpde->name);
DrvUnlock(dv);
if (Cd(tempde->name)) {
tempde->sub=FAT32FilesFind(files_find_mask,fuf_flags,
tempde,&sub_dir_size);
tempde->size=sub_dir_size;
if (Cd(tmpde->name)) {
tmpde->sub=FAT32FilesFind(files_find_mask,fuf_flags,
tmpde,&sub_dir_size);
tmpde->size=sub_dir_size;
Cd("..");
}
DrvLock(dv);
} else {
tempde->full_name=FileNameAbs(tempde->name);
tmpde->full_name=FileNameAbs(tmpde->name);
if ((attr&RS_ATTR_DIR || !Bt(&fuf_flags,FUf_JUST_DIRS)) &&
!(Bt(&fuf_flags,FUf_RECURSE) &&
*tempde->name=='.' && attr&RS_ATTR_DIR) &&
FilesFindMatch(tempde->full_name,files_find_mask,
*tmpde->name=='.' && attr&RS_ATTR_DIR) &&
FilesFindMatch(tmpde->full_name,files_find_mask,
fuf_flags)) {
tempde->next=res;
res=tempde;
tmpde->next=res;
res=tmpde;
} else
DirEntryDel(tempde);
DirEntryDel(tmpde);
}
} else
DirEntryDel(tempde);
DirEntryDel(tmpde);
}
MemSet(&long_name,0,sizeof(CDirEntry));
}
+27 -27
View File
@@ -53,17 +53,17 @@ Bool ISO1FromName(U8 *dst,U8 *src)
return FileNameChk(dst);
}
Bool ISO1CDirFill(CDirEntry *tempde,CISO1DirEntry *de)
Bool ISO1CDirFill(CDirEntry *tmpde,CISO1DirEntry *de)
{
Bool res;
MemSet(tempde,0,sizeof(CDirEntry));
res=ISO1FromName(tempde->name,&de->name_len);
tempde->cluster=de->loc.little;
tempde->size=de->size.little;
tempde->attr=FileAttr(tempde->name);
MemSet(tmpde,0,sizeof(CDirEntry));
res=ISO1FromName(tmpde->name,&de->name_len);
tmpde->cluster=de->loc.little;
tmpde->size=de->size.little;
tmpde->attr=FileAttr(tmpde->name);
if (de->flags & ISO1_ATTR_DIR)
tempde->attr|=RS_ATTR_DIR;
tempde->datetime=ISO1DateStruct2CDate(&de->date);
tmpde->attr|=RS_ATTR_DIR;
tmpde->datetime=ISO1DateStruct2CDate(&de->date);
return res;
}
@@ -176,7 +176,7 @@ CDirEntry *ISO1FilesFind(U8 *files_find_mask,
CDrv *dv=Fs->cur_dv;
CISO1DirEntry *buf,*buf2,*isoptr;
I64 i,cur_dir_cluster=Name2DirCluster(dv,Fs->cur_dir);
CDirEntry *res=NULL,*tempde;
CDirEntry *res=NULL,*tmpde;
if (fuf_flags&~FUG_FILES_FIND)
throw('FUF');
isoptr=MAlloc(dv->spc<<BLK_SIZE_BITS);
@@ -197,32 +197,32 @@ CDirEntry *ISO1FilesFind(U8 *files_find_mask,
buf(U8 *)++;
i--;
} else {
tempde=MAlloc(sizeof(CDirEntry));
if (ISO1CDirFill(tempde,buf)) {
tempde->parent=parent;
if (Bt(&fuf_flags,FUf_RECURSE) && tempde->attr&RS_ATTR_DIR &&
*tempde->name!='.') {
tempde->next=res;
res=tempde;
tempde->full_name=DirNameAbs(tempde->name);
if (Cd(tempde->name)) {
tempde->sub=ISO1FilesFind(files_find_mask,fuf_flags,tempde);
tmpde=MAlloc(sizeof(CDirEntry));
if (ISO1CDirFill(tmpde,buf)) {
tmpde->parent=parent;
if (Bt(&fuf_flags,FUf_RECURSE) && tmpde->attr&RS_ATTR_DIR &&
*tmpde->name!='.') {
tmpde->next=res;
res=tmpde;
tmpde->full_name=DirNameAbs(tmpde->name);
if (Cd(tmpde->name)) {
tmpde->sub=ISO1FilesFind(files_find_mask,fuf_flags,tmpde);
Cd("..");
}
} else {
tempde->full_name=FileNameAbs(tempde->name);
if ((tempde->attr & RS_ATTR_DIR ||
tmpde->full_name=FileNameAbs(tmpde->name);
if ((tmpde->attr & RS_ATTR_DIR ||
!Bt(&fuf_flags,FUf_JUST_DIRS)) &&
!(Bt(&fuf_flags,FUf_RECURSE) &&
*tempde->name=='.' && tempde->attr&RS_ATTR_DIR) &&
FilesFindMatch(tempde->full_name,files_find_mask,fuf_flags)) {
tempde->next=res;
res=tempde;
*tmpde->name=='.' && tmpde->attr&RS_ATTR_DIR) &&
FilesFindMatch(tmpde->full_name,files_find_mask,fuf_flags)) {
tmpde->next=res;
res=tmpde;
} else
DirEntryDel(tempde);
DirEntryDel(tmpde);
}
} else
DirEntryDel(tempde);
DirEntryDel(tmpde);
i-=buf->len;
buf(U8 *)+=buf->len;
}
+62 -62
View File
@@ -2,15 +2,15 @@
U0 RedSeaFreeFreeLst(CDrv *dv)
{
CFreeLst *tempf,*tempf1;
CFreeLst *tmpf,*tmpf1;
Bool unlock;
try {
unlock=DrvLock(dv);
if (tempf=dv->next_free) {
while (tempf!=&dv->next_free) {
tempf1=tempf->next;
Free(tempf);
tempf=tempf1;
if (tmpf=dv->next_free) {
while (tmpf!=&dv->next_free) {
tmpf1=tmpf->next;
Free(tmpf);
tmpf=tmpf1;
}
}
dv->next_free=NULL;
@@ -24,7 +24,7 @@ U0 RedSeaFreeFreeLst(CDrv *dv)
U0 RedSeaFreeLstBuild(CDrv *dv)
{
Bool unlock;
CFreeLst *tempf;
CFreeLst *tmpf;
I64 i,first=dv->data_area,max_blk=dv->size+dv->drv_offset;
try {
unlock=DrvLock(dv);
@@ -41,10 +41,10 @@ U0 RedSeaFreeLstBuild(CDrv *dv)
i++;
}
if (i) {
tempf=AMAlloc(sizeof(CFreeLst));
tempf->size=i;
tempf->start=first;
QueIns(tempf,dv->last_free);
tmpf=AMAlloc(sizeof(CFreeLst));
tmpf->size=i;
tmpf->start=first;
QueIns(tmpf,dv->last_free);
}
first+=i+1;
}
@@ -249,7 +249,7 @@ Bool RedSeaCd(U8 *name,I64 cur_dir_cluster)
U0 RedSeaFreeClusters(CDrv *dv,I64 c,I64 cnt)
{
CFreeLst *tempf;
CFreeLst *tmpf;
Bool found=FALSE,unlock,unlock_break;
DrvChk(dv);
if (!c) return;
@@ -261,23 +261,23 @@ U0 RedSeaFreeClusters(CDrv *dv,I64 c,I64 cnt)
unlock=DrvLock(dv);
if (!dv->next_free)
RedSeaFreeLstBuild(dv);
tempf=dv->next_free;
while (!found && tempf!=&dv->next_free) {
if (tempf->start+tempf->size==c) {
tempf->size+=cnt;
tmpf=dv->next_free;
while (!found && tmpf!=&dv->next_free) {
if (tmpf->start+tmpf->size==c) {
tmpf->size+=cnt;
found=TRUE;
} else if (c+cnt==tempf->start) {
tempf->size+=cnt;
tempf->start=c;
} else if (c+cnt==tmpf->start) {
tmpf->size+=cnt;
tmpf->start=c;
found=TRUE;
}
tempf=tempf->next;
tmpf=tmpf->next;
}
if (!found) {
tempf=AMAlloc(sizeof(CFreeLst));
tempf->size=cnt;
tempf->start=c;
QueIns(tempf,dv->last_free);
tmpf=AMAlloc(sizeof(CFreeLst));
tmpf->size=cnt;
tmpf->start=c;
QueIns(tmpf,dv->last_free);
}
while (cnt-->0) {
DrvFATBlkSet(dv,c);
@@ -301,7 +301,7 @@ U0 RedSeaFreeClusters(CDrv *dv,I64 c,I64 cnt)
I64 RedSeaAllocClusters(CDrv *dv,I64 cnt)
{
CFreeLst *tempf,*best_free=NULL;
CFreeLst *tmpf,*best_free=NULL;
I64 i,first,best_size=MAX_I64;
Bool unlock,unlock_break;
if (cnt<=0)
@@ -311,15 +311,15 @@ I64 RedSeaAllocClusters(CDrv *dv,I64 cnt)
unlock=DrvLock(dv);
if (!dv->next_free)
RedSeaFreeLstBuild(dv);
tempf=dv->next_free;
while (tempf!=&dv->next_free) {
if (tempf->size>=cnt && tempf->size<best_size) {
best_free=tempf;
best_size=tempf->size;
if (tempf->size==cnt)
tmpf=dv->next_free;
while (tmpf!=&dv->next_free) {
if (tmpf->size>=cnt && tmpf->size<best_size) {
best_free=tmpf;
best_size=tmpf->size;
if (tmpf->size==cnt)
break;
}
tempf=tempf->next;
tmpf=tmpf->next;
}
if (!best_free)
throw('Drv');
@@ -349,16 +349,16 @@ I64 RedSeaAllocClusters(CDrv *dv,I64 cnt)
return first;
}
Bool RedSeaDirNew(CDrv *dv,U8 *cur_dir,CDirEntry *tempde,Bool free_old_chain)
Bool RedSeaDirNew(CDrv *dv,U8 *cur_dir,CDirEntry *tmpde,Bool free_old_chain)
{
CDirEntry *buf,*buf2,*ptr,de2;
CRedSeaBoot *br;
I64 c,ch,i=1,j=0,n=BLK_SIZE/CDIR_SIZE,dir_size,cur_dir_cluster;
Bool written=FALSE,unlock,unlock_break;
U8 *temp,*parent_dir;
U8 *tmp,*parent_dir;
try {
unlock_break=BreakLock;
tempde->attr|=RS_ATTR_CONTIGUOUS;
tmpde->attr|=RS_ATTR_CONTIGUOUS;
unlock=DrvLock(dv);
cur_dir_cluster=Name2DirCluster(dv,cur_dir);
buf2=MAlloc(BLK_SIZE);
@@ -374,7 +374,7 @@ Bool RedSeaDirNew(CDrv *dv,U8 *cur_dir,CDirEntry *tempde,Bool free_old_chain)
while (TRUE) {
if (!(ch=*ptr->name)) {
if (!written)
MemCpy(&ptr->start,&tempde->start,CDIR_SIZE);
MemCpy(&ptr->start,&tmpde->start,CDIR_SIZE);
if ((i+1)*CDIR_SIZE+j<<BLK_SIZE_BITS<dir_size)
WBlks(dv,buf(U8 *)+j<<BLK_SIZE_BITS,cur_dir_cluster+j,1);
else {
@@ -397,38 +397,38 @@ Bool RedSeaDirNew(CDrv *dv,U8 *cur_dir,CDirEntry *tempde,Bool free_old_chain)
Free(br);
dv->root_cluster=c;
} else {
temp=StrNew(cur_dir);
tmp=StrNew(cur_dir);
parent_dir=StrNew(cur_dir);
StrLastRem(parent_dir,"/",temp);
StrLastRem(parent_dir,"/",tmp);
if (!*parent_dir) {
Free(parent_dir);
parent_dir=StrNew("/");
}
if (RedSeaFileFind(dv,Name2DirCluster(dv,parent_dir),
temp,&de2,FUF_JUST_DIRS)) {
tmp,&de2,FUF_JUST_DIRS)) {
de2.cluster=c;
de2.size=dir_size;
RedSeaDirNew(dv,parent_dir,&de2,FALSE);
} else
throw('Drv');
Free(temp);
Free(tmp);
Free(parent_dir);
}
}
break;
} else if (ptr->attr & RS_ATTR_DELETED) {
if (!written) {
MemCpy(&ptr->start,&tempde->start,CDIR_SIZE);
MemCpy(&ptr->start,&tmpde->start,CDIR_SIZE);
WBlks(dv,buf(U8 *)+j<<BLK_SIZE_BITS,cur_dir_cluster+j,1);
written=TRUE;
}
} else {
if (!StrCmp(tempde->name,ptr->name)) {
if (!StrCmp(tmpde->name,ptr->name)) {
if (free_old_chain)
RedSeaFreeClusters(dv,ptr->cluster,
(ptr->size+BLK_SIZE-1)>>BLK_SIZE_BITS);
if (!written)
MemCpy(&ptr->start,&tempde->start,CDIR_SIZE);
MemCpy(&ptr->start,&tmpde->start,CDIR_SIZE);
else
ptr->attr|=RS_ATTR_DELETED;
WBlks(dv,buf(U8 *)+j<<BLK_SIZE_BITS,cur_dir_cluster+j,1);
@@ -540,7 +540,7 @@ CDirEntry *RedSeaFilesFind(U8 *files_find_mask,I64 fuf_flags,
CDirEntry *parent=NULL)
{
CDrv *dv=Fs->cur_dv;
CDirEntry *buf,*buf2,*ptr,*res=NULL,*tempde;
CDirEntry *buf,*buf2,*ptr,*res=NULL,*tmpde;
I64 ch,cur_dir_cluster;
if (fuf_flags&~FUG_FILES_FIND)
throw('FUF');
@@ -565,31 +565,31 @@ CDirEntry *RedSeaFilesFind(U8 *files_find_mask,I64 fuf_flags,
if (!(ch=*ptr->name))
break;
else if (!(ptr->attr & RS_ATTR_DELETED)) {
tempde=CAlloc(sizeof(CDirEntry));
MemCpy(&tempde->start,&ptr->start,CDIR_SIZE);
tempde->parent=parent;
if (Bt(&fuf_flags,FUf_RECURSE) && tempde->attr&RS_ATTR_DIR &&
*tempde->name!='.') {
tempde->next=res;
res=tempde;
tempde->full_name=DirNameAbs(tempde->name);
tmpde=CAlloc(sizeof(CDirEntry));
MemCpy(&tmpde->start,&ptr->start,CDIR_SIZE);
tmpde->parent=parent;
if (Bt(&fuf_flags,FUf_RECURSE) && tmpde->attr&RS_ATTR_DIR &&
*tmpde->name!='.') {
tmpde->next=res;
res=tmpde;
tmpde->full_name=DirNameAbs(tmpde->name);
DrvUnlock(dv);
if (Cd(tempde->name)) {
tempde->sub=RedSeaFilesFind(files_find_mask,fuf_flags,tempde);
if (Cd(tmpde->name)) {
tmpde->sub=RedSeaFilesFind(files_find_mask,fuf_flags,tmpde);
Cd("..");
}
DrvLock(dv);
} else {
tempde->full_name=FileNameAbs(tempde->name);
if ((tempde->attr&RS_ATTR_DIR ||
tmpde->full_name=FileNameAbs(tmpde->name);
if ((tmpde->attr&RS_ATTR_DIR ||
!Bt(&fuf_flags,FUf_JUST_DIRS)) &&
!(Bt(&fuf_flags,FUf_RECURSE) && *tempde->name=='.' &&
tempde->attr&RS_ATTR_DIR) &&
FilesFindMatch(tempde->full_name,files_find_mask,fuf_flags)) {
tempde->next=res;
res=tempde;
!(Bt(&fuf_flags,FUf_RECURSE) && *tmpde->name=='.' &&
tmpde->attr&RS_ATTR_DIR) &&
FilesFindMatch(tmpde->full_name,files_find_mask,fuf_flags)) {
tmpde->next=res;
res=tmpde;
} else
DirEntryDel(tempde);
DirEntryDel(tmpde);
}
}
ptr(U8 *)+=CDIR_SIZE;