TempleOSCD_140715.ISO
This commit is contained in:
1 parent
7ef616a20e
commit
64f679eeb9
1095 files changed
+24814
-221011
No files matched your search
@@ -1,31 +0,0 @@
|
||||
//See $LK,"::/Doc/Acknowledgements.TXT"$.
|
||||
|
||||
#define ATA_NOP 0x00
|
||||
#define ATA_DEV_RST 0x08
|
||||
#define ATA_PACKET 0xA0
|
||||
#define ATA_READ_NATIVE_MAX 0xF8
|
||||
#define ATA_READ_NATIVE_MAX_EXT 0x27
|
||||
#define ATA_SET_MAX 0xF9
|
||||
#define ATA_SET_MAX_EXT 0x37
|
||||
#define ATA_READ_MULTI 0xC4
|
||||
#define ATA_READ_MULTI_EXT 0x29
|
||||
#define ATA_WRITE_MULTI 0xC5
|
||||
#define ATA_WRITE_MULTI_EXT 0x39
|
||||
#define ATA_ID_DEV 0xEC
|
||||
|
||||
#define ATAS_ERR 0x01
|
||||
#define ATAS_DRQ 0x08
|
||||
#define ATAS_DF 0x20
|
||||
#define ATAS_DRDY 0x40
|
||||
#define ATAS_BSY 0x80
|
||||
|
||||
#define ATAR0_DATA 0
|
||||
#define ATAR0_FEAT 1
|
||||
#define ATAR0_NSECT 2
|
||||
#define ATAR0_SECT 3
|
||||
#define ATAR0_LCYL 4
|
||||
#define ATAR0_HCYL 5
|
||||
#define ATAR0_SELECT 6
|
||||
#define ATAR0_STAT 7
|
||||
#define ATAR0_CMD 7
|
||||
#define ATAR1_CTRL 2
|
||||
+36
-41
@@ -1,5 +1,5 @@
|
||||
Bool BlkDevLock(CBlkDev *bdev)
|
||||
{
|
||||
{//Make this task have exclusive access to BlkDev.
|
||||
BlkDevChk(bdev);
|
||||
while (bdev->lock_fwding)
|
||||
bdev=bdev->lock_fwding;
|
||||
@@ -13,7 +13,7 @@ Bool BlkDevLock(CBlkDev *bdev)
|
||||
}
|
||||
|
||||
Bool PrtLock(CPrt *p)
|
||||
{
|
||||
{//Make this task have exclusive access to Prt & BlkDev.
|
||||
PrtChk(p);
|
||||
BlkDevLock(p->bdev);
|
||||
if (!Bt(&p->locked_flags,Plf_LOCKED) || p->owning_task!=Fs) {
|
||||
@@ -26,7 +26,7 @@ Bool PrtLock(CPrt *p)
|
||||
}
|
||||
|
||||
Bool BlkDevUnlock(CBlkDev *bdev,Bool rst=FALSE)
|
||||
{
|
||||
{//Release exclusive lock on access to BlkDev.
|
||||
BlkDevChk(bdev);
|
||||
while (bdev->lock_fwding)
|
||||
bdev=bdev->lock_fwding;
|
||||
@@ -42,7 +42,7 @@ Bool BlkDevUnlock(CBlkDev *bdev,Bool rst=FALSE)
|
||||
}
|
||||
|
||||
Bool PrtUnlock(CPrt *p,Bool rst=FALSE)
|
||||
{
|
||||
{//Release exclusive lock on access to Prt & BlkDev.
|
||||
PrtChk(p);
|
||||
if (Bt(&p->locked_flags,Plf_LOCKED) && p->owning_task==Fs) {
|
||||
BlkDevUnlock(p->bdev,rst);
|
||||
@@ -84,8 +84,8 @@ Bool BlkDevInit(CBlkDev *bdev)
|
||||
//0xFFFF*4 is too big for my taste
|
||||
bdev->max_reads=0x800*4;
|
||||
//max of maybe a quarter of disk cache
|
||||
if (bdev->max_reads>sys_dsk_cache_size/BLK_SIZE/4)
|
||||
bdev->max_reads=sys_dsk_cache_size/BLK_SIZE/4 & ~3;
|
||||
if (bdev->max_reads>dsk.cache_size/BLK_SIZE/4)
|
||||
bdev->max_reads=dsk.cache_size/BLK_SIZE/4 & ~3;
|
||||
if (bdev->max_reads<128)
|
||||
bdev->max_reads=128;
|
||||
bdev->max_writes=0xFFFF*4;
|
||||
@@ -103,46 +103,48 @@ Bool BlkDevInit(CBlkDev *bdev)
|
||||
}
|
||||
|
||||
U0 BlkDevsRelease()
|
||||
{
|
||||
{//When task dies, release all owned BlkDevs.
|
||||
I64 i;
|
||||
CBlkDev *bdev;
|
||||
for (i=0;i<NUM_BLKDEVS;i++) {
|
||||
bdev=&sys_blkdevs[i];
|
||||
bdev=&dsk.blkdevs[i];
|
||||
if (bdev->owning_task==Fs && bdev->bd_signature==BD_SIGNATURE_VAL)
|
||||
BlkDevUnlock(bdev,TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
U0 PrtsRelease()
|
||||
{
|
||||
{//When task dies, release all owned Prts.
|
||||
I64 i;
|
||||
CPrt *p;
|
||||
for (i=0;i<NUM_PRTS;i++) {
|
||||
p=&sys_prts[i];
|
||||
p=&dsk.prts[i];
|
||||
if (p->owning_task==Fs && p->pt_signature==PRT_SIGNATURE_VAL)
|
||||
PrtUnlock(p,TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
CPrt *PrtMakeFree(U8 drv_let)
|
||||
{//!!! drv is not a remapped prt.
|
||||
{//Make a slot free for a new partition, like during $LK,"Mount",A="MN:Mount"$().
|
||||
//!!! drv_let is not a $LK,"remapped",A="MN:MapDrv"$ prt.
|
||||
I64 i=ToUpper(drv_let)-'A';
|
||||
CPrt *result;
|
||||
if (!(0<=i<NUM_PRTS))
|
||||
throw('Prt');
|
||||
result=&sys_prts[i];
|
||||
result=&dsk.prts[i];
|
||||
MemSet(result,0,sizeof(CPrt));
|
||||
result->drv_let='A'+i;
|
||||
return result;
|
||||
}
|
||||
|
||||
CPrt *PrtNextFree(U8 first_drv_let='C')
|
||||
{//!!! first_drv_let is not a remapped prt.
|
||||
{//Locate free slot for new partition, like during $LK,"Mount",A="MN:Mount"$().
|
||||
//!!! first_drv_let is not a $LK,"remapped",A="MN:MapDrv"$ prt.
|
||||
I64 i=ToUpper(first_drv_let)-'A';
|
||||
if (!(0<=i<NUM_PRTS))
|
||||
throw('Prt');
|
||||
do
|
||||
if (sys_prts[i].pt_signature!=PRT_SIGNATURE_VAL)
|
||||
if (dsk.prts[i].pt_signature!=PRT_SIGNATURE_VAL)
|
||||
return PrtMakeFree(i+'A');
|
||||
while (++i<NUM_PRTS);
|
||||
throw('Prt');
|
||||
@@ -150,11 +152,11 @@ CPrt *PrtNextFree(U8 first_drv_let='C')
|
||||
}
|
||||
|
||||
CBlkDev *BlkDevNextFree(U8 first_drv_let,I64 type)
|
||||
{
|
||||
{//Locate free slot for new BlkDev, like during $LK,"Mount",A="MN:Mount"$().
|
||||
I64 i=0;
|
||||
CBlkDev *result;
|
||||
do {
|
||||
result=&sys_blkdevs[i];
|
||||
result=&dsk.blkdevs[i];
|
||||
if (result->bd_signature!=BD_SIGNATURE_VAL) {
|
||||
MemSet(result,0,sizeof(CBlkDev));
|
||||
result->first_drv_let=first_drv_let;
|
||||
@@ -192,7 +194,6 @@ U0 MapBufAlloc(CPrt *p,I64 num_blks)
|
||||
RBlks(p,p->cur_map_blk,p->map1,p->num_buffered_map_blks);
|
||||
}
|
||||
|
||||
|
||||
U0 CleanMAPBuf(CPrt *p,I64 MAP_select=-1)
|
||||
{
|
||||
I64 i;
|
||||
@@ -227,7 +228,7 @@ U0 SetFSBuf(CPrt *p,I64 c,I64 map_select=-1)
|
||||
|
||||
#define ZERO_BUF_SIZE 2048
|
||||
U0 WZeroBlks(CPrt *p,I64 blk,I64 cnt)
|
||||
{
|
||||
{//Fill blk cnt with zeros in Prt.
|
||||
I64 n;
|
||||
U8 *z=CAlloc(ZERO_BUF_SIZE<<BLK_SIZE_BITS);
|
||||
Bool show_progress;
|
||||
@@ -255,9 +256,8 @@ U0 WZeroBlks(CPrt *p,I64 blk,I64 cnt)
|
||||
}
|
||||
}
|
||||
|
||||
//Very dangerous
|
||||
Bool SetDrvType(U8 drv_let,I64 type=PT_REDSEA)
|
||||
{
|
||||
{//Very dangerous
|
||||
I64 i,j,ext_base,prt_num,offset,cur_type;
|
||||
CMasterBoot mbr;
|
||||
CBlkDev *bdev=Drv2BlkDev(drv_let);
|
||||
@@ -309,7 +309,7 @@ Bool SetDrvType(U8 drv_let,I64 type=PT_REDSEA)
|
||||
}
|
||||
|
||||
Bool RBlks(CPrt *p,U8 *buf, I64 blk, I64 cnt)
|
||||
{
|
||||
{//Read blk cnt from Prt to buf.
|
||||
Bool result=TRUE,unlock;
|
||||
CBlkDev *bdev=p->bdev;
|
||||
if (cnt<=0) return TRUE;
|
||||
@@ -319,7 +319,6 @@ Bool RBlks(CPrt *p,U8 *buf, I64 blk, I64 cnt)
|
||||
BlkDevInit(bdev);
|
||||
if (p->offset && blk<p->offset || blk+cnt>p->offset+p->size)
|
||||
throw('Prt');
|
||||
blk+=bdev->offset;
|
||||
|
||||
if (bdev->flags & BDF_READ_CACHE)
|
||||
RCache(p,&buf,&blk,&cnt);
|
||||
@@ -346,7 +345,7 @@ Bool RBlks(CPrt *p,U8 *buf, I64 blk, I64 cnt)
|
||||
}
|
||||
|
||||
Bool WBlks(CPrt *p,U8 *buf, I64 blk, I64 cnt)
|
||||
{
|
||||
{//Write blk cnt from buf to Prt.
|
||||
Bool result=TRUE,unlock;
|
||||
CBlkDev *bdev=p->bdev;
|
||||
if (cnt<=0) return TRUE;
|
||||
@@ -359,7 +358,6 @@ Bool WBlks(CPrt *p,U8 *buf, I64 blk, I64 cnt)
|
||||
throw('BlkDev');
|
||||
if (p->offset && blk<p->offset || blk+cnt>p->offset+p->size)
|
||||
throw('Prt');
|
||||
blk+=bdev->offset;
|
||||
if (cnt>0) {
|
||||
switch (bdev->type) {
|
||||
case BDT_RAM:
|
||||
@@ -382,9 +380,8 @@ Bool WBlks(CPrt *p,U8 *buf, I64 blk, I64 cnt)
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
U0 DskCacheInvalidate(CPrt *p)
|
||||
{
|
||||
{//Needed for removable media. Called by $LK,"ChgDsk",A="MN:ChgDsk"$().
|
||||
Bool unlock;
|
||||
CBlkDev *bdev=p->bdev;
|
||||
PrtChk(p);
|
||||
@@ -406,7 +403,7 @@ U0 DskCacheInvalidate(CPrt *p)
|
||||
}
|
||||
|
||||
U0 ChgDsk(U8 drv_let=0)
|
||||
{ //This is needed for removable media
|
||||
{//Change disk. (Needed for removable media.)
|
||||
CPrt *p=Drv2Prt(drv_let);
|
||||
CBlkDev *bdev=p->bdev;
|
||||
Bool old_preempt=Preempt(OFF);
|
||||
@@ -420,7 +417,7 @@ U0 ChgDsk(U8 drv_let=0)
|
||||
}
|
||||
|
||||
U8 *DrvSerialNum(U8 drv_let=0)
|
||||
{ //20 bytes max.
|
||||
{//20 bytes max.
|
||||
CBlkDev *bdev=Drv2BlkDev(drv_let);
|
||||
U16 *st,*result=NULL;
|
||||
I64 i;
|
||||
@@ -435,7 +432,7 @@ U8 *DrvSerialNum(U8 drv_let=0)
|
||||
}
|
||||
|
||||
U8 *DrvModelNum(U8 drv_let=0)
|
||||
{ //40 bytes max.
|
||||
{//40 bytes max.
|
||||
CBlkDev *bdev=Drv2BlkDev(drv_let);
|
||||
U16 *st,*result=NULL;
|
||||
I64 i;
|
||||
@@ -450,13 +447,13 @@ U8 *DrvModelNum(U8 drv_let=0)
|
||||
}
|
||||
|
||||
U0 PrtRep()
|
||||
{ //Partition report
|
||||
{//Partition report.
|
||||
CPrt *p;
|
||||
CBlkDev *bdev;
|
||||
I64 i,drv_let;
|
||||
U8 *st;
|
||||
"\nDefined Partitions:\n\n";
|
||||
for (i=0,p=sys_prts;i<NUM_PRTS;i++,p++) {
|
||||
for (i=0,p=dsk.prts;i<NUM_PRTS;i++,p++) {
|
||||
if (p->pt_signature==PRT_SIGNATURE_VAL) {
|
||||
bdev=p->bdev;
|
||||
drv_let=Prt2Drv(p);
|
||||
@@ -485,7 +482,7 @@ U0 PrtRep()
|
||||
}
|
||||
|
||||
I64 ClusterNumNext(CPrt *p,I64 c,I64 cnt=1)
|
||||
{
|
||||
{//Return next cnt'th cluster in chain.
|
||||
Bool unlock;
|
||||
PrtChk(p);
|
||||
if (cnt<=0) return c;
|
||||
@@ -515,15 +512,14 @@ I64 ClusterNumNext(CPrt *p,I64 c,I64 cnt=1)
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
I64 Cluster2Blk(CPrt *p,I64 c)
|
||||
{
|
||||
{//Prt cluster num to blk num.
|
||||
PrtChk(p);
|
||||
return p->data+c*p->spc;
|
||||
}
|
||||
|
||||
I64 RClustersBlks(CPrt *p,U8 *buf,I64 c,I64 blks)
|
||||
{ //This accepts blk count, so padding on last cluster is not read.
|
||||
{//Accepts blk count, so padding on last cluster is not read.
|
||||
I64 i;
|
||||
Bool unlock;
|
||||
PrtChk(p);
|
||||
@@ -561,7 +557,7 @@ I64 RClustersBlks(CPrt *p,U8 *buf,I64 c,I64 blks)
|
||||
}
|
||||
|
||||
I64 RClusters(CPrt *p,U8 *buf,I64 c,I64 cnt)
|
||||
{
|
||||
{//Read cluster cnt from Prt to buf.
|
||||
return RClustersBlks(p,buf,c,cnt*p->spc);
|
||||
}
|
||||
|
||||
@@ -663,9 +659,8 @@ I64 Name2ParentDirCluster(CPrt *p,U8 *dirname)
|
||||
return cur_dir_cluster2;
|
||||
}
|
||||
|
||||
|
||||
I64 WClustersBlks(CPrt *p,U8 *buf,I64 c,I64 blks)
|
||||
{ //This accepts blk count, so padding on last cluster is not written.
|
||||
{//Accepts blk count, so padding on last cluster is not written.
|
||||
I64 i;
|
||||
Bool unlock;
|
||||
PrtChk(p);
|
||||
@@ -702,13 +697,13 @@ I64 WClustersBlks(CPrt *p,U8 *buf,I64 c,I64 blks)
|
||||
}
|
||||
|
||||
I64 WClusters(CPrt *p,U8 *buf,I64 c,I64 cnt)
|
||||
{
|
||||
{//Write cluster cnt from buf to Prt.
|
||||
return WClustersBlks(p,buf,c,cnt*p->spc);
|
||||
}
|
||||
|
||||
//c=0 means first cluster in chain
|
||||
I64 ClustersAlloc(CPrt *p,I64 c=0,I64 cnt=1,Bool contiguous=FALSE)
|
||||
{
|
||||
{//Alloc cluster cnt into chain.
|
||||
//c=0 means first cluster in chain
|
||||
PrtChk(p);
|
||||
if (cnt<=0) return c;
|
||||
switch (p->type) {
|
||||
|
||||
+27
-37
@@ -1,8 +1,8 @@
|
||||
Bool MapDrv(U8 drv_let,CPrt *p)
|
||||
{
|
||||
{//Make drive letter map to another.
|
||||
drv_let=ToUpper(drv_let);
|
||||
if ('A'<=drv_let<='Z') {
|
||||
drv_to_prt[drv_let-'A']=p;
|
||||
dsk.drv_to_prt[drv_let-'A']=p;
|
||||
p->drv_let=drv_let;
|
||||
return TRUE;
|
||||
} else
|
||||
@@ -10,7 +10,7 @@ Bool MapDrv(U8 drv_let,CPrt *p)
|
||||
}
|
||||
|
||||
Bool Drv(U8 drv_let)
|
||||
{
|
||||
{//Set drive. You can set drive with $LK,"Cd",A="MN:Cd"$() as well.
|
||||
CPrt *p=Drv2Prt(drv_let);
|
||||
CBlkDev *bdev=p->bdev;
|
||||
BlkDevChk(bdev);
|
||||
@@ -35,7 +35,7 @@ Bool Drv(U8 drv_let)
|
||||
}
|
||||
|
||||
Bool Cd(U8 *dirname,Bool make_dirs=FALSE)
|
||||
{//Optionally, will create the directories if they don't exist.
|
||||
{//Change directory. Optionally, make directories, too.
|
||||
I64 maxlen,cur_dir_cluster=0;
|
||||
U8 *chg_to_buf,*new_cur_dir,*buf;
|
||||
CPrt *p;
|
||||
@@ -114,7 +114,7 @@ Bool Cd(U8 *dirname,Bool make_dirs=FALSE)
|
||||
}
|
||||
|
||||
U0 FileAccessDel(CFileAccess *fa)
|
||||
{
|
||||
{//Change back to old cur_dir and prt.
|
||||
CBlkDev *bdev;
|
||||
if (!fa) return;
|
||||
bdev=fa->old_prt->bdev;
|
||||
@@ -134,7 +134,7 @@ U0 FileAccessDel(CFileAccess *fa)
|
||||
}
|
||||
|
||||
CFileAccess *FileAccessNew(U8 *_mask,Bool make_mask=FALSE,Bool make_dirs=FALSE,Bool no_mask=FALSE)
|
||||
{
|
||||
{//Save cur_dir and prt. Change to new dir.
|
||||
Bool valid=TRUE,old_silent;
|
||||
U8 *buf,*mask,*temp_mask;
|
||||
CFileAccess *fa=CAlloc(sizeof(CFileAccess));
|
||||
@@ -190,22 +190,13 @@ CFileAccess *FileAccessNew(U8 *_mask,Bool make_mask=FALSE,Bool make_dirs=FALSE,B
|
||||
}
|
||||
|
||||
CDirEntry *FilesFind(U8 *files_find_mask,I64 fuf_flags=0)
|
||||
{
|
||||
/*
|
||||
Flags:
|
||||
$LK,"FUF_RECURSE",A="MN:FUF_RECURSE"$ +r Recurse
|
||||
$LK,"FUF_SINGLE",A="MN:FUF_SINGLE"$ +s Single File (Optimization for one file in mask.)
|
||||
$LK,"FUF_FLATTEN_TREE",A="MN:FUF_FLATTEN_TREE"$ +f $BK,1$use with '+F'$BK,0$. Just use +F, probably.
|
||||
$LK,"FUF_JUST_DIRS",A="MN:FUF_JUST_DIRS"$ +D just directories
|
||||
$LK,"FUF_JUST_FILES",A="MN:FUF_JUST_FILES"$ +F just files (Flattens trees)
|
||||
$LK,"FUF_CLUSTER_ORDER",A="MN:FUF_CLUSTER_ORDER"$ +O sort by cluster (move head one direction)
|
||||
$LK,"FUF_JUST_TXT",A="MN:FUF_JUST_TXT"$ +T just text files : $LK,"FILEMASK_TXT",A="MN:FILEMASK_TXT"$
|
||||
$LK,"FUF_JUST_SRC",A="MN:FUF_JUST_SRC"$ +S just src files : $LK,"FILEMASK_SRC",A="MN:FILEMASK_SRC"$
|
||||
$LK,"FUF_JUST_AOT",A="MN:FUF_JUST_AOT"$ +A just aot files : $LK,"FILEMASK_AOT",A="MN:FILEMASK_AOT"$
|
||||
$LK,"FUF_JUST_JIT",A="MN:FUF_JUST_JIT"$ +J just jit files : $LK,"FILEMASK_JIT",A="MN:FILEMASK_JIT"$
|
||||
$LK,"FUF_JUST_GRA",A="MN:FUF_JUST_GRA"$ +G just graphic files : $LK,"FILEMASK_GRA",A="MN:FILEMASK_GRA"$
|
||||
{/* See $LK,"::/Doc/FileUtils.TXT"$.
|
||||
|
||||
Find files and make a directory tree in memory.
|
||||
|
||||
When done, you free with $LK,"DirEntryDel",A="MN:DirEntryDel"$(),$LK,"DirEntryDel2",A="MN:DirEntryDel2"$(),
|
||||
$LK,"DirTreeDel",A="MN:DirTreeDel"$() or $LK,"DirTreeDel2",A="MN:DirTreeDel2"$().
|
||||
|
||||
See $LK,"ST_FILE_UTIL_FLAGS",A="MN:ST_FILE_UTIL_FLAGS"$ when used in calling program taking text flags.
|
||||
*/
|
||||
CDirEntry *result;
|
||||
CFileAccess *fa;
|
||||
@@ -226,8 +217,8 @@ See $LK,"ST_FILE_UTIL_FLAGS",A="MN:ST_FILE_UTIL_FLAGS"$ when used in calling pro
|
||||
}
|
||||
|
||||
Bool IsDir(U8 *dir_name)
|
||||
{
|
||||
U8 *mask=MPrint("%s/*",dir_name);
|
||||
{//Is a str a valid, existing Dir?
|
||||
U8 *mask=MStrPrint("%s/*",dir_name);
|
||||
Bool result,old_silent=Silent(ON);
|
||||
CFileAccess *fa;
|
||||
if (fa=FileAccessNew(mask)) {
|
||||
@@ -241,7 +232,7 @@ Bool IsDir(U8 *dir_name)
|
||||
}
|
||||
|
||||
I64 Dir(U8 *files_find_mask="*",Bool full=FALSE)
|
||||
{
|
||||
{//List directory.
|
||||
I64 result;
|
||||
CFileAccess *fa;
|
||||
if (fa=FileAccessNew(files_find_mask,TRUE)) {
|
||||
@@ -252,9 +243,8 @@ I64 Dir(U8 *files_find_mask="*",Bool full=FALSE)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
I64 Del(U8 *files_find_mask,Bool print_msg=TRUE)
|
||||
{
|
||||
{//Delete files.
|
||||
I64 result=0;
|
||||
CFileAccess *fa;
|
||||
if (fa=FileAccessNew(files_find_mask)) {
|
||||
@@ -277,7 +267,7 @@ I64 Del(U8 *files_find_mask,Bool print_msg=TRUE)
|
||||
}
|
||||
|
||||
U8 *FileRead(U8 *filename,I64 *_size=NULL,I64 *_attr=NULL,Bool raw=FALSE)
|
||||
{
|
||||
{//Read whole file from disk.
|
||||
CHashGeneric *temph;
|
||||
U8 *absname,*altname,*curname,*result=NULL;
|
||||
I64 i,size=0,attr=0;
|
||||
@@ -346,10 +336,10 @@ U8 *FileRead(U8 *filename,I64 *_size=NULL,I64 *_attr=NULL,Bool raw=FALSE)
|
||||
"%s ",filename;
|
||||
PrintErr("File not found.\n");
|
||||
}
|
||||
if (result && !raw && attr & _ATTR_RESIDENT)
|
||||
if (result && !raw && attr & RS_ATTR_RESIDENT)
|
||||
HashGenericAdd(curname,HTT_FILE,AMAllocIdentical(result),size,0,adam_task);
|
||||
}
|
||||
if (result && !raw && attr & _ATTR_COMPRESSED) {
|
||||
if (result && !raw && attr & RS_ATTR_COMPRESSED) {
|
||||
ac=result;
|
||||
size=ac->expanded_size;
|
||||
result=ExpandBuf(ac);
|
||||
@@ -363,8 +353,8 @@ U8 *FileRead(U8 *filename,I64 *_size=NULL,I64 *_attr=NULL,Bool raw=FALSE)
|
||||
}
|
||||
|
||||
Bool FileFind(U8 *filename,CDirEntry *_de=NULL,I64 fuf_flags=0)
|
||||
{ //$LK,"FUF_JUST_DIRS",A="MN:FUF_JUST_DIRS"$, $LK,"FUF_JUST_FILES",A="MN:FUF_JUST_FILES"$, $LK,"FUF_Z_OR_NOT_Z",A="MN:FUF_Z_OR_NOT_Z"$, $LK,"FUF_SCAN_PARENTS",A="MN:FUF_SCAN_PARENTS"$
|
||||
//If you pass _de, you must Free(_de->full_name);
|
||||
{//$LK,"FUF_JUST_DIRS",A="MN:FUF_JUST_DIRS"$, $LK,"FUF_JUST_FILES",A="MN:FUF_JUST_FILES"$, $LK,"FUF_Z_OR_NOT_Z",A="MN:FUF_Z_OR_NOT_Z"$, $LK,"FUF_SCAN_PARENTS",A="MN:FUF_SCAN_PARENTS"$
|
||||
//If you pass _de, you must Free(_de->full_name);
|
||||
I64 i,j,cur_dir_cluster;
|
||||
U8 *altname,*curname,*full_name=NULL;
|
||||
CDirEntry de;
|
||||
@@ -399,7 +389,7 @@ Bool FileFind(U8 *filename,CDirEntry *_de=NULL,I64 fuf_flags=0)
|
||||
PrintErr("File System Not Supported\n");
|
||||
}
|
||||
if (result && _de)
|
||||
full_name=MPrint("%C:%s/%s",Fs->cur_prt->drv_let,Fs->cur_dir,de.name);
|
||||
full_name=MStrPrint("%C:%s/%s",Fs->cur_prt->drv_let,Fs->cur_dir,de.name);
|
||||
FileAccessDel(fa);
|
||||
}
|
||||
}
|
||||
@@ -428,7 +418,7 @@ Bool FileFind(U8 *filename,CDirEntry *_de=NULL,I64 fuf_flags=0)
|
||||
}
|
||||
}
|
||||
if (result && _de)
|
||||
full_name=MPrint("%C:%s/%s",Fs->cur_prt->drv_let,Fs->cur_dir,de.name);
|
||||
full_name=MStrPrint("%C:%s/%s",Fs->cur_prt->drv_let,Fs->cur_dir,de.name);
|
||||
FileAccessDel(fa);
|
||||
}
|
||||
}
|
||||
@@ -445,14 +435,14 @@ Bool FileFind(U8 *filename,CDirEntry *_de=NULL,I64 fuf_flags=0)
|
||||
|
||||
I64 FileWrite(U8 *filename,U8 *fbuf,
|
||||
I64 size,CDate cdt=0,I64 attr=0,Bool raw=FALSE)
|
||||
{
|
||||
{//Write whole file to disk.
|
||||
I64 c=0;
|
||||
CHashGeneric *temph;
|
||||
CFileAccess *fa;
|
||||
U8 *fbuf2,*absname=FileNameAbs(filename);
|
||||
if (fa=FileAccessNew(filename,FALSE,TRUE)) {
|
||||
attr=FileAttr(fa->mask,attr);
|
||||
if (attr&_ATTR_COMPRESSED && !raw) {
|
||||
if (attr&RS_ATTR_COMPRESSED && !raw) {
|
||||
fbuf=CompressBuf(fbuf,size);
|
||||
size=fbuf(CArcCompress *)->compressed_size;
|
||||
fbuf2=fbuf;
|
||||
@@ -473,13 +463,13 @@ I64 FileWrite(U8 *filename,U8 *fbuf,
|
||||
PrintErr("File System Not Supported\n");
|
||||
}
|
||||
if (temph=HashFind(absname,adam_task->hash_table,HTT_FILE)) {
|
||||
if (!raw && attr & _ATTR_RESIDENT) {
|
||||
if (!raw && attr & RS_ATTR_RESIDENT) {
|
||||
Free(temph->user_data0);
|
||||
temph->user_data0=AMAllocIdentical(fbuf);
|
||||
temph->user_data1=size;
|
||||
} else
|
||||
HashRemDel(temph,adam_task->hash_table);
|
||||
} else if (!raw && attr & _ATTR_RESIDENT)
|
||||
} else if (!raw && attr & RS_ATTR_RESIDENT)
|
||||
HashGenericAdd(absname,HTT_FILE,AMAllocIdentical(fbuf),size,0,adam_task);
|
||||
Free(fbuf2);
|
||||
FileAccessDel(fa);
|
||||
|
||||
+15
-13
@@ -25,7 +25,7 @@ Bool CopySingle(U8 *f1,U8 *f2) //Just one file
|
||||
U8 *absf1=FileNameAbs(f1),*absf2=FileNameAbs(f2),*buf;
|
||||
I64 cnt,n,size,attr1=FileAttr(f1),attr2=FileAttr(f2),i,j;
|
||||
CFile *in_file=NULL,*out_file=NULL;
|
||||
if (!StrCmp(absf1,absf2)) { //onto self?
|
||||
if (!StrCmp(absf1,absf2)) {//onto self?
|
||||
Free(absf1);
|
||||
Free(absf2);
|
||||
return FALSE;
|
||||
@@ -35,14 +35,14 @@ Bool CopySingle(U8 *f1,U8 *f2) //Just one file
|
||||
if (attr1!=attr2)
|
||||
return CopySingleZ(f1,f2);
|
||||
buf=MAlloc(COPY_BUF_BLKS<<BLK_SIZE_BITS);
|
||||
if (attr1 & _ATTR_CONTIGUOUS)
|
||||
if (attr1 & RS_ATTR_CONTIGUOUS)
|
||||
in_file=FOpen(f1,"rc");
|
||||
else
|
||||
in_file=FOpen(f1,"r");
|
||||
if (in_file) {
|
||||
size=FSize(in_file);
|
||||
cnt=(size+BLK_SIZE-1)>>BLK_SIZE_BITS;
|
||||
if (attr2 & _ATTR_CONTIGUOUS)
|
||||
if (attr2 & RS_ATTR_CONTIGUOUS)
|
||||
out_file=FOpen(f2,"wc",cnt);
|
||||
else
|
||||
out_file=FOpen(f2,"w",cnt);
|
||||
@@ -80,7 +80,7 @@ Bool CopySingle(U8 *f1,U8 *f2) //Just one file
|
||||
}
|
||||
|
||||
Bool MkDir(U8 *filename)
|
||||
{
|
||||
{//Make directory. $LK,"Cd",A="MN:Cd"$() can also make directories.
|
||||
U8 *name;
|
||||
CFileAccess *fa;
|
||||
Bool result=FALSE;
|
||||
@@ -138,8 +138,12 @@ I64 SysDel(U8 *wild,Bool make_mask) //this is dangerous
|
||||
}
|
||||
|
||||
U0 Fmt(I64 drv_let,Bool quick=TRUE,Bool confirm=TRUE,I64 type=PT_FAT32)
|
||||
{//See $LK,"PT_FAT32",A="MN:PT_FAT32"$ for a lst of supported file system types.
|
||||
|
||||
{//Format hard drive or RAM drive.
|
||||
//$BK,1$Warning:$BK,0$ Destroys all previous info.
|
||||
//quick=FALSE means fill entire drive
|
||||
//with zeros.
|
||||
//Choose $LK,"PT_FAT32",A="MN:PT_FAT32"$ or $LK,"PT_REDSEA",A="MN:PT_REDSEA"$.
|
||||
//You don't format a CD-ROM with this.
|
||||
CPrt *p=Drv2Prt(drv_let);
|
||||
Bool old_silent=IsSilent;
|
||||
if (confirm && !AreYouSure)
|
||||
@@ -173,9 +177,8 @@ U0 Fmt(I64 drv_let,Bool quick=TRUE,Bool confirm=TRUE,I64 type=PT_FAT32)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
U0 CDImageRead(U8 cd_drv_let,U8 *out_name)
|
||||
{
|
||||
{//Read entire CD/DVD image into ISO file.
|
||||
CBlkDev *bdev=Drv2BlkDev(cd_drv_let);
|
||||
CPrt *p=Drv2Prt(cd_drv_let);
|
||||
U8 *buf=MAlloc(COPY_BUF_BLKS<<BLK_SIZE_BITS),
|
||||
@@ -186,7 +189,7 @@ U0 CDImageRead(U8 cd_drv_let,U8 *out_name)
|
||||
if (bdev->type!=BDT_ATAPI)
|
||||
throw('BlkDev');
|
||||
if (!out_name)
|
||||
out_name=sys_dft_iso_name;
|
||||
out_name=dsk.dft_iso_filename;
|
||||
cnt=CeilU64(p->size,spc);
|
||||
while (cnt>0) {
|
||||
if (cnt>COPY_BUF_BLKS)
|
||||
@@ -222,14 +225,13 @@ class CDualBuf
|
||||
CBlkDev *CD_bdev;
|
||||
};
|
||||
|
||||
|
||||
U0 CDImageWriteTask(CDualBuf *d)
|
||||
{
|
||||
U8 *buf;
|
||||
I64 n,blk=0,cnt=d->cnt;
|
||||
CFile *f;
|
||||
Preempt(ON);
|
||||
if (FileAttr(d->filename)&_ATTR_CONTIGUOUS)
|
||||
if (FileAttr(d->filename)&RS_ATTR_CONTIGUOUS)
|
||||
f=FOpen(d->filename,"rc");
|
||||
else
|
||||
f=FOpen(d->filename,"r");
|
||||
@@ -255,7 +257,7 @@ U0 CDImageWriteTask(CDualBuf *d)
|
||||
}
|
||||
|
||||
U0 CDImageWrite(U8 cd_drv_let,U8 *in_name=NULL,I64 media_type=MT_CD)
|
||||
{
|
||||
{//Write CD/DVD ISO file to disk.
|
||||
CDualBuf *d=CAlloc(sizeof(CDualBuf));
|
||||
U8 *buf,*in_name2,*in_name3;
|
||||
I64 i,n,spc,blk=0,cnt;
|
||||
@@ -266,7 +268,7 @@ U0 CDImageWrite(U8 cd_drv_let,U8 *in_name=NULL,I64 media_type=MT_CD)
|
||||
CFile *f;
|
||||
|
||||
if (!in_name)
|
||||
in_name=sys_dft_iso_name;
|
||||
in_name=dsk.dft_iso_filename;
|
||||
in_name3=DftExt(in_name,"ISO");
|
||||
in_name2=FileNameAbs(in_name3);
|
||||
f=FOpen(in_name2,"r");
|
||||
|
||||
+26
-26
@@ -127,7 +127,6 @@ Bool ATAPISetMaxSpeed(CBlkDev *bdev)
|
||||
return ATAWaitNotBUSY(bdev,0);
|
||||
}
|
||||
|
||||
|
||||
Bool ATAPISeek(CBlkDev *bdev,I64 native_blk)
|
||||
{
|
||||
if (bdev->flags & BDF_EXT_SIZE)
|
||||
@@ -185,7 +184,7 @@ I64 ATAGetDevId(CBlkDev *bdev,F64 timeout,U16 **_id_record)
|
||||
}
|
||||
|
||||
I64 ATAReadNativeMax(CBlkDev *bdev,F64 timeout)
|
||||
{ //returns zero on err
|
||||
{//Returns zero on err
|
||||
I64 result=0;
|
||||
Bool okay=TRUE;
|
||||
|
||||
@@ -251,7 +250,7 @@ I64 ATAReadNativeMax(CBlkDev *bdev,F64 timeout)
|
||||
}
|
||||
|
||||
I64 ATAPIReadCapacity(CBlkDev *bdev,I64 *_blk_size=NULL)
|
||||
{ //Supposedly this can return a result +/- 75 sects.
|
||||
{//Supposedly this can return a result +/- 75 sects.
|
||||
//Error might just be for music.
|
||||
Bool unlock=BlkDevLock(bdev);
|
||||
U32 buf[2];
|
||||
@@ -366,7 +365,7 @@ retry:
|
||||
throw('BlkDev');
|
||||
}
|
||||
|
||||
sys_dsk_reads+=(cnt*bdev->blk_size)>>BLK_SIZE_BITS;
|
||||
dsk.read_cnt+=(cnt*bdev->blk_size)>>BLK_SIZE_BITS;
|
||||
if (unlock) BlkDevUnlock(bdev);
|
||||
}
|
||||
|
||||
@@ -400,7 +399,7 @@ Bool ATAPIReadBlks2(CBlkDev *bdev,F64 timeout,U8 *buf, I64 native_blk, I64 cnt,B
|
||||
if (ATAPIWritePktWord(bdev,timeout,0xA800,
|
||||
native_blk.u16[1],native_blk,cnt.u16[1],cnt,0) &&
|
||||
ATAGetResult(bdev,timeout,buf,cnt*bdev->blk_size,0,FALSE)) {
|
||||
sys_dsk_reads+=(cnt*bdev->blk_size)>>BLK_SIZE_BITS;
|
||||
dsk.read_cnt+=(cnt*bdev->blk_size)>>BLK_SIZE_BITS;
|
||||
result=TRUE;
|
||||
}
|
||||
}
|
||||
@@ -457,10 +456,9 @@ Bool ATARBlks(CPrt *p,U8 *buf, I64 blk, I64 cnt)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//This is for low level disk access
|
||||
//Call WBlks() instead
|
||||
U0 ATAWriteBlks(CBlkDev *bdev,U8 *buf, I64 blk, I64 cnt)
|
||||
{
|
||||
{//For low level disk access.
|
||||
//Use WBlks() instead.
|
||||
I64 i,U32s_avail,sects_avail,retries=3;
|
||||
F64 timeout;
|
||||
Bool unlock=BlkDevLock(bdev);
|
||||
@@ -519,9 +517,8 @@ Bool ATAPISync(CBlkDev *bdev)
|
||||
}
|
||||
|
||||
U0 ATAPIClose(CBlkDev *bdev,I64 close_field=0x200,I64 track=0)
|
||||
{
|
||||
//0x200 CD/DVD part 1
|
||||
//0x300 DVD part 2
|
||||
{//0x200 CD/DVD part 1
|
||||
// 0x300 DVD part 2
|
||||
if (bdev->flags & BDF_EXT_SIZE)
|
||||
OutU8(bdev->base0+ATAR0_SELECT,0xEF|bdev->unit<<4);
|
||||
else
|
||||
@@ -571,7 +568,7 @@ U0 ATAPIWriteBlks(CBlkDev *bdev,U8 *buf, I64 native_blk, I64 cnt)
|
||||
if (U32s_avail) {
|
||||
RepOutU32(buf,U32s_avail,bdev->base0+ATAR0_DATA);
|
||||
buf+=U32s_avail<<2;
|
||||
sys_dsk_writes+=U32s_avail>>(BLK_SIZE_BITS-2);
|
||||
dsk.write_cnt+=U32s_avail>>(BLK_SIZE_BITS-2);
|
||||
}
|
||||
}
|
||||
ATAWaitNotBUSY(bdev,0);
|
||||
@@ -598,7 +595,7 @@ Bool ATAWBlks(CPrt *p,U8 *buf, I64 blk, I64 cnt)
|
||||
buf+=n<<BLK_SIZE_BITS;
|
||||
blk+=n;
|
||||
cnt-=n;
|
||||
sys_dsk_writes+=n;
|
||||
dsk.write_cnt+=n;
|
||||
}
|
||||
if (bdev->type==BDT_ATAPI) {
|
||||
ATAPISync(bdev);
|
||||
@@ -618,7 +615,7 @@ Bool BootCdProbe(CBlkDev *bdev)
|
||||
" ATAPI";
|
||||
if (ATAPIStartStop(bdev,tS+5.0,TRUE)) {
|
||||
" Started";
|
||||
for (i=0;i<2;i++) { //Retry
|
||||
for (i=0;i<2;i++) {//Retry
|
||||
if (ATAPIReadBlks2(bdev,tS+7.0,img,sys_boot_code.u16[1],1,FALSE)) {
|
||||
if (img->compile_time==sys_compile_time) {
|
||||
" Found";
|
||||
@@ -736,7 +733,7 @@ Bool ATARepExitAllApplications()
|
||||
}
|
||||
|
||||
public I64 ATARep(Bool pmt=TRUE,Bool just_ide=FALSE,CATARep **_root=NULL)
|
||||
{
|
||||
{//Report possible ATA devices by probing. Hard disks and CD/DVDs.
|
||||
I64 d1,d2,d3,i,j,k,cnt=0,unlock_flags=0,num_hints=0;
|
||||
#assert NUM_BLKDEVS<=64
|
||||
Bool old_preempt;
|
||||
@@ -748,9 +745,9 @@ public I64 ATARep(Bool pmt=TRUE,Bool just_ide=FALSE,CATARep **_root=NULL)
|
||||
|
||||
old_preempt=Preempt(OFF);
|
||||
for (i=0;i<NUM_BLKDEVS;i++)
|
||||
if (sys_blkdevs[i].bd_signature==BD_SIGNATURE_VAL)
|
||||
if (dsk.blkdevs[i].bd_signature==BD_SIGNATURE_VAL)
|
||||
BEqu(&unlock_flags,i,
|
||||
BlkDevLock(&sys_blkdevs[i]));
|
||||
BlkDevLock(&dsk.blkdevs[i]));
|
||||
|
||||
if (!just_ide)
|
||||
for (k=0;k<256;k++) {
|
||||
@@ -795,16 +792,17 @@ public I64 ATARep(Bool pmt=TRUE,Bool just_ide=FALSE,CATARep **_root=NULL)
|
||||
ATARepEntry(d1,d2,0,d3,"Secondary IDE",_root,&num_hints);
|
||||
ATARepEntry(d1,d2,1,d3,"Secondary IDE",_root,&num_hints);
|
||||
}
|
||||
NewLine(2);
|
||||
'\n\n';
|
||||
for (i=0;i<NUM_BLKDEVS;i++)
|
||||
if (Bt(&unlock_flags,i))
|
||||
BlkDevUnlock(&sys_blkdevs[i]);
|
||||
BlkDevUnlock(&dsk.blkdevs[i]);
|
||||
Preempt(old_preempt);
|
||||
return num_hints;
|
||||
}
|
||||
|
||||
CATARep *ATAIDDrvs(CATARep *root,U8 _sys_acct_drv,CATARep **_ata_drv,CATARep **_atapi_drv)
|
||||
{
|
||||
{//When trying to sort-out main hard drives
|
||||
//and CD-ROM drives, this is needed.
|
||||
CATARep *result=NULL,*tempha=root,*ata_drv=NULL,*atapi_drv=NULL;
|
||||
CBlkDev *bdev;
|
||||
Bool was_silent=Silent(ON);
|
||||
@@ -858,30 +856,32 @@ CBlkDev *ATAMount(U8 first_drv_let,I64 type,I64 base0,I64 base1,I64 unit)
|
||||
}
|
||||
|
||||
I64 AutoMountIDE()
|
||||
{
|
||||
{//Try to mount hard drive and CD/DVD, automatically. (Kernel.Cfg option).
|
||||
//It uses 'C' and 'T' as first drive letters or whatever you set
|
||||
//in config when compiling Kernel.BIN.
|
||||
I64 result=0;
|
||||
CATARep *root=NULL,*ata_drv=NULL,*atapi_drv=NULL,*tempha;
|
||||
ATARep(FALSE,TRUE,&root);
|
||||
ATAIDDrvs(root,*sys_acct,&ata_drv,&atapi_drv);
|
||||
if (ata_drv && ATAMount(sys_first_hd_drv_let,BDT_ATA,
|
||||
if (ata_drv && ATAMount(dsk.first_hd_drv_let,BDT_ATA,
|
||||
ata_drv->base0,ata_drv->base1,ata_drv->unit))
|
||||
result++;
|
||||
if (atapi_drv && ATAMount(sys_first_cd_drv_let,BDT_ATAPI,
|
||||
if (atapi_drv && ATAMount(dsk.first_cd_drv_let,BDT_ATAPI,
|
||||
atapi_drv->base0,atapi_drv->base1,atapi_drv->unit))
|
||||
result++;
|
||||
tempha=root;
|
||||
while (tempha) {
|
||||
if (tempha!=ata_drv && tempha!=atapi_drv) {
|
||||
if (tempha->type==BDT_ATA && ATAMount(sys_first_hd_drv_let,BDT_ATA,
|
||||
if (tempha->type==BDT_ATA && ATAMount(dsk.first_hd_drv_let,BDT_ATA,
|
||||
tempha->base0,tempha->base1,tempha->unit))
|
||||
result++;
|
||||
else if (tempha->type==BDT_ATAPI && ATAMount(sys_first_cd_drv_let,BDT_ATAPI,
|
||||
else if (tempha->type==BDT_ATAPI && ATAMount(dsk.first_cd_drv_let,BDT_ATAPI,
|
||||
tempha->base0,tempha->base1,tempha->unit))
|
||||
result++;
|
||||
}
|
||||
tempha=tempha->next;
|
||||
}
|
||||
LinkedLstDel(root);
|
||||
sys_auto_mount_ide_cnt=result;
|
||||
dsk.auto_mount_ide_cnt=result;
|
||||
return result;
|
||||
}
|
||||
+27
-34
@@ -8,7 +8,7 @@ U0 SetBlkDevLockFwding(CBlkDev *bdev)
|
||||
case BDT_ATA:
|
||||
case BDT_ATAPI:
|
||||
for (i=0;i<NUM_BLKDEVS;i++) {
|
||||
bdev1=&sys_blkdevs[i];
|
||||
bdev1=&dsk.blkdevs[i];
|
||||
if (bdev1->bd_signature==BD_SIGNATURE_VAL && bdev!=bdev1 &&
|
||||
(bdev1->type==BDT_ATAPI || bdev1->type==BDT_ATA) &&
|
||||
bdev1->base0==bdev->base0) {
|
||||
@@ -148,10 +148,8 @@ I64 BlkDevAdd(CBlkDev *bdev,Bool one_prt,Bool make_free)
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Bool DrvEnable(U8 drv_let,Bool val)
|
||||
{//This can be used to unmount a drive or remount,
|
||||
//but not mount the first time.
|
||||
{//Can unmount or remount, but not mount the first time.
|
||||
CPrt *p;
|
||||
Bool result=FALSE;
|
||||
try {
|
||||
@@ -173,7 +171,7 @@ CATARep *ATARepFind(CATARep *haystack_root,I64 needle_num)
|
||||
}
|
||||
|
||||
U0 Mount(Bool repartition=FALSE)
|
||||
{
|
||||
{//Mount a drive.
|
||||
CBlkDev *bdev;
|
||||
I64 first_prt_num,type,unit,num_hints;
|
||||
U8 blks_buf[128],addr_buf[128],base0_buf[128],base1_buf[128];
|
||||
@@ -190,12 +188,12 @@ U0 Mount(Bool repartition=FALSE)
|
||||
"they will be lettered in sequence.\n"
|
||||
"\nFirst Drive Letter ($$PURPLE$$<ENTER>$$FG$$ to exit):";
|
||||
first_prt_num=ToUpper(GetChar)-'A';
|
||||
NewLine;
|
||||
'\n';
|
||||
if (0<=first_prt_num<NUM_PRTS) {
|
||||
"\t$$PURPLE$$1$$FG$$=RAM\n\t$$PURPLE$$2$$FG$$=ATA(Harddisk)\n"
|
||||
"\t$$PURPLE$$3$$FG$$=ATAPI(CD-ROM)\nType:";
|
||||
type=GetChar-'0';
|
||||
NewLine;
|
||||
'\n';
|
||||
|
||||
unit=0;
|
||||
if (type==BDT_ATA || type==BDT_ATAPI) {
|
||||
@@ -207,11 +205,11 @@ U0 Mount(Bool repartition=FALSE)
|
||||
else
|
||||
"Include $$PURPLE$$0x$$FG$$ prefix.\nI/O Port Base0:\n";
|
||||
GetS(base0_buf,128);
|
||||
} while (!A2I64(base0_buf));
|
||||
if (1<=A2I64(base0_buf)<=num_hints) {
|
||||
tempha=ATARepFind(root,A2I64(base0_buf));
|
||||
SPrint(base0_buf,"0x%X",tempha->base0);
|
||||
SPrint(base1_buf,"0x%X",tempha->base1);
|
||||
} while (!Str2I64(base0_buf));
|
||||
if (1<=Str2I64(base0_buf)<=num_hints) {
|
||||
tempha=ATARepFind(root,Str2I64(base0_buf));
|
||||
StrPrint(base0_buf,"0x%X",tempha->base0);
|
||||
StrPrint(base1_buf,"0x%X",tempha->base1);
|
||||
unit=tempha->unit;
|
||||
} else {
|
||||
if (type==BDT_ATAPI)
|
||||
@@ -220,12 +218,12 @@ U0 Mount(Bool repartition=FALSE)
|
||||
do {
|
||||
"I/O Port Base1:\n";
|
||||
GetS(base1_buf,128);
|
||||
} while (!A2I64(base1_buf));
|
||||
} while (!Str2I64(base1_buf));
|
||||
do {
|
||||
"\t$$PURPLE$$0$$FG$$=Master\n\t$$PURPLE$$1$$FG$$=Slave\nUnit:";
|
||||
unit=GetChar-'0';
|
||||
} while (!(0<=unit<=1));
|
||||
NewLine;
|
||||
'\n';
|
||||
}
|
||||
LinkedLstDel(root);
|
||||
}
|
||||
@@ -241,13 +239,13 @@ U0 Mount(Bool repartition=FALSE)
|
||||
bdev->unit=unit;
|
||||
if (type==BDT_RAM) {
|
||||
if (!*addr_buf) StrCpy(addr_buf,"0");
|
||||
bdev->RAM_dsk=A2I64(addr_buf);
|
||||
bdev->max_blk=A2I64(blks_buf)-1;
|
||||
bdev->RAM_dsk=Str2I64(addr_buf);
|
||||
bdev->max_blk=Str2I64(blks_buf)-1;
|
||||
}
|
||||
if (type==BDT_ATA ||
|
||||
type==BDT_ATAPI) {
|
||||
bdev->base0=A2I64(base0_buf);
|
||||
bdev->base1=A2I64(base1_buf);
|
||||
bdev->base0=Str2I64(base0_buf);
|
||||
bdev->base1=Str2I64(base1_buf);
|
||||
}
|
||||
add=TRUE;
|
||||
if (type==BDT_ATA && repartition) {
|
||||
@@ -268,18 +266,14 @@ U0 Mount(Bool repartition=FALSE)
|
||||
} while (0<=first_prt_num<NUM_PRTS);
|
||||
}
|
||||
|
||||
I64 SysPmtI64()
|
||||
I64 SysGetI64()
|
||||
{
|
||||
U8 st[136];
|
||||
StrCpy(st,"0x");
|
||||
GetS(st+2,134,FALSE);
|
||||
if (!st[2])
|
||||
return 0;
|
||||
else
|
||||
return A2I64(st);
|
||||
GetS(st,136,FALSE);
|
||||
return Str2I64(st,16);
|
||||
}
|
||||
|
||||
Bool PmtBaseUnit(CBlkDev *bdev)
|
||||
Bool GetBaseUnit(CBlkDev *bdev)
|
||||
{
|
||||
I64 ch;
|
||||
Bool probe;
|
||||
@@ -299,7 +293,7 @@ Bool PmtBaseUnit(CBlkDev *bdev)
|
||||
"'IDE', 'ATA' or 'SATA'.\n"
|
||||
"\n\nEnter 4-digit hex I/O Port number.\n"
|
||||
"CD-ROM I/O Port Base0: 0x";
|
||||
bdev->base0=SysPmtI64;
|
||||
bdev->base0=SysGetI64;
|
||||
bdev->base1=0;
|
||||
bdev->unit =0;
|
||||
if (bdev->base0) {
|
||||
@@ -308,10 +302,10 @@ Bool PmtBaseUnit(CBlkDev *bdev)
|
||||
while (!('0'<=ch<='1'));
|
||||
'' ch;
|
||||
bdev->unit=ch-'0';
|
||||
cdrom_boot_is_good=BootCdProbe(bdev);
|
||||
dsk.cdrom_boot_is_good=BootCdProbe(bdev);
|
||||
return TRUE;
|
||||
} else {
|
||||
cdrom_boot_is_good=FALSE;
|
||||
dsk.cdrom_boot_is_good=FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
@@ -322,11 +316,11 @@ U0 BlkDevsInitAll()
|
||||
{
|
||||
CBlkDev *bdev;
|
||||
I64 i;
|
||||
sys_blkdevs=CAlloc(sizeof(CBlkDev)*NUM_BLKDEVS);
|
||||
sys_prts=CAlloc(sizeof(CPrt)*NUM_PRTS);
|
||||
dsk.blkdevs=CAlloc(sizeof(CBlkDev)*NUM_BLKDEVS);
|
||||
dsk.prts=CAlloc(sizeof(CPrt)*NUM_PRTS);
|
||||
for (i=0;i<NUM_PRTS;i++)
|
||||
drv_to_prt[i]=&sys_prts[i];
|
||||
sys_raw_col=0;
|
||||
dsk.drv_to_prt[i]=&dsk.prts[i];
|
||||
text.raw_col=0;
|
||||
#exe {
|
||||
if (kernel_cfg->opts[CFG_AUTO_MOUNT_IDE])
|
||||
StreamPrint("AutoMountIDE;");
|
||||
@@ -336,4 +330,3 @@ U0 BlkDevsInitAll()
|
||||
};
|
||||
PrtRep;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
I64 FSize(CFile *f)
|
||||
{
|
||||
{//Report size of opened file in bytes.
|
||||
if (f)
|
||||
return f->de.size;
|
||||
else
|
||||
@@ -7,8 +7,8 @@ I64 FSize(CFile *f)
|
||||
}
|
||||
|
||||
CFile *FOpen(U8 *filename,U8 *flags,I64 cnt=0)
|
||||
{ //allows flags "r","w","w+". Include a "c" for contiguous.
|
||||
//(It uses $LK,"StrOcc",A="MN:StrOcc"$() for 'w', 'r', '+', 'c')
|
||||
{//Allows flags "r","w","w+". "c" for contiguous.
|
||||
//(It uses $LK,"StrOcc",A="MN:StrOcc"$() for 'w', 'r', '+', 'c')
|
||||
CFile *f=CAlloc(sizeof(CFile));
|
||||
CFileAccess *fa;
|
||||
U8 *full_name;
|
||||
@@ -27,7 +27,7 @@ CFile *FOpen(U8 *filename,U8 *flags,I64 cnt=0)
|
||||
contiguous=TRUE;
|
||||
if (contiguous) {
|
||||
f->flags|=FF_CONTIGUOUS;
|
||||
if (f->p->type!=PT_REDSEA && !(FileAttr(filename) & _ATTR_CONTIGUOUS))
|
||||
if (f->p->type!=PT_REDSEA && !(FileAttr(filename) & RS_ATTR_CONTIGUOUS))
|
||||
throw('File');
|
||||
}
|
||||
f->cluster_buf=CAlloc(f->p->spc<<BLK_SIZE_BITS);
|
||||
@@ -46,7 +46,7 @@ CFile *FOpen(U8 *filename,U8 *flags,I64 cnt=0)
|
||||
f->flags|=FF_NEW_FILE;
|
||||
if (fa=FileAccessNew(full_name)) {
|
||||
StrCpy(f->de.name,fa->mask);
|
||||
if (cnt>0) { //We pre-alloc the whole thing.
|
||||
if (cnt>0) {//We pre-alloc the whole thing.
|
||||
f->de.cluster=ClustersAlloc(f->p,0,
|
||||
(cnt+f->p->spc-1)/f->p->spc,contiguous);
|
||||
f->de.size=cnt<<BLK_SIZE_BITS;
|
||||
@@ -71,7 +71,7 @@ CFile *FOpen(U8 *filename,U8 *flags,I64 cnt=0)
|
||||
}
|
||||
|
||||
U0 FClose(CFile *f)
|
||||
{
|
||||
{//Close CFile, updating directory.
|
||||
CFileAccess *fa;
|
||||
if (f) {
|
||||
if (f->flags & FF_BUF_DIRTY) {
|
||||
@@ -127,7 +127,7 @@ I64 FSetCluster(CFile *f,I64 c,I64 blk,Bool read)
|
||||
}
|
||||
|
||||
Bool FRBlks(CFile *f,U8 *buf,I64 blk=FFB_NEXT_BLK,I64 cnt=1)
|
||||
{
|
||||
{//Read [nth,n+cnt) blks of file.
|
||||
CPrt *p=f->p;
|
||||
I64 spc=p->spc,i,j,c=f->de.cluster;
|
||||
if (!f || !p) return FALSE;
|
||||
@@ -179,7 +179,7 @@ Bool FRBlks(CFile *f,U8 *buf,I64 blk=FFB_NEXT_BLK,I64 cnt=1)
|
||||
}
|
||||
|
||||
Bool FWBlks(CFile *f,U8 *buf,I64 blk=FFB_NEXT_BLK,I64 cnt=1)
|
||||
{
|
||||
{//Write [nth,n+cnt) blks of file.
|
||||
CPrt *p=f->p;
|
||||
I64 spc=p->spc,i,j,c=f->de.cluster,c1;
|
||||
if (!f || !p) return FALSE;
|
||||
|
||||
+24
-24
@@ -5,31 +5,31 @@ U0 DskCacheInit(I64 size_in_U8s)
|
||||
|
||||
while (LBts(&sys_semas[SYS_SEMA_DSK_CACHE],0))
|
||||
Yield;
|
||||
Free(sys_dsk_cache_ctrl);
|
||||
Free(sys_dsk_cache_base);
|
||||
Free(sys_dsk_cache_hash_table);
|
||||
Free(dsk.cache_ctrl);
|
||||
Free(dsk.cache_base);
|
||||
Free(dsk.cache_hash_table);
|
||||
if (size_in_U8s<0x2000) {
|
||||
sys_dsk_cache_ctrl=NULL;
|
||||
sys_dsk_cache_base=NULL;
|
||||
sys_dsk_cache_hash_table=NULL;
|
||||
dsk.cache_ctrl=NULL;
|
||||
dsk.cache_base=NULL;
|
||||
dsk.cache_hash_table=NULL;
|
||||
} else {
|
||||
sys_dsk_cache_ctrl=ACAlloc(offset(CCacheBlk.body));
|
||||
sys_dsk_cache_base=AMAlloc(size_in_U8s);
|
||||
QueInit(sys_dsk_cache_ctrl);
|
||||
dsk.cache_ctrl=ACAlloc(offset(CCacheBlk.body));
|
||||
dsk.cache_base=AMAlloc(size_in_U8s);
|
||||
QueInit(dsk.cache_ctrl);
|
||||
|
||||
cnt=MSize(sys_dsk_cache_base)/sizeof(CCacheBlk);
|
||||
sys_dsk_cache_size=cnt*BLK_SIZE;
|
||||
cnt=MSize(dsk.cache_base)/sizeof(CCacheBlk);
|
||||
dsk.cache_size=cnt*BLK_SIZE;
|
||||
for (i=0;i<cnt;i++) {
|
||||
tempc=sys_dsk_cache_base+i;
|
||||
QueIns(tempc,sys_dsk_cache_ctrl->last_lru);
|
||||
tempc=dsk.cache_base+i;
|
||||
QueIns(tempc,dsk.cache_ctrl->last_lru);
|
||||
tempc->next_hash=tempc->last_hash=tempc;
|
||||
tempc->p=NULL;
|
||||
tempc->blk=0;
|
||||
}
|
||||
|
||||
sys_dsk_cache_hash_table=AMAlloc(DSK_CACHE_HASH_SIZE*sizeof(U8 *)*2);
|
||||
dsk.cache_hash_table=AMAlloc(DSK_CACHE_HASH_SIZE*sizeof(U8 *)*2);
|
||||
for (i=0;i<DSK_CACHE_HASH_SIZE;i++) {
|
||||
tempc=sys_dsk_cache_hash_table(U8 *)+i*sizeof(U8 *)*2-offset(CCacheBlk.next_hash);
|
||||
tempc=dsk.cache_hash_table(U8 *)+i*sizeof(U8 *)*2-offset(CCacheBlk.next_hash);
|
||||
tempc->next_hash=tempc->last_hash=tempc;
|
||||
}
|
||||
}
|
||||
@@ -39,7 +39,7 @@ U0 DskCacheInit(I64 size_in_U8s)
|
||||
I64 DskCacheHash(I64 blk)
|
||||
{
|
||||
I64 i=blk & (DSK_CACHE_HASH_SIZE-1);
|
||||
return sys_dsk_cache_hash_table(U8 *)+i<<4-offset(CCacheBlk.next_hash);
|
||||
return dsk.cache_hash_table(U8 *)+i<<4-offset(CCacheBlk.next_hash);
|
||||
}
|
||||
|
||||
U0 DskCacheQueRem(CCacheBlk *tempc)
|
||||
@@ -52,7 +52,7 @@ U0 DskCacheQueRem(CCacheBlk *tempc)
|
||||
U0 DskCacheQueIns(CCacheBlk *tempc)
|
||||
{
|
||||
CCacheBlk *temp_n,*temp_l;
|
||||
QueIns(tempc,sys_dsk_cache_ctrl->last_lru);
|
||||
QueIns(tempc,dsk.cache_ctrl->last_lru);
|
||||
temp_l=DskCacheHash(tempc->blk);
|
||||
temp_n=temp_l->next_hash;
|
||||
tempc->last_hash=temp_l;
|
||||
@@ -75,12 +75,12 @@ CCacheBlk *DskCacheFind(CPrt *p,I64 blk)
|
||||
U0 DskCacheAdd(CPrt *p,U8 *buf, I64 blk, I64 cnt)
|
||||
{
|
||||
CCacheBlk *tempc;
|
||||
if (sys_dsk_cache_base) {
|
||||
if (dsk.cache_base) {
|
||||
while (LBts(&sys_semas[SYS_SEMA_DSK_CACHE],0))
|
||||
Yield;
|
||||
while (cnt-->0) {
|
||||
if (!(tempc=DskCacheFind(p,blk)))
|
||||
tempc=sys_dsk_cache_ctrl->next_lru;
|
||||
tempc=dsk.cache_ctrl->next_lru;
|
||||
DskCacheQueRem(tempc);
|
||||
MemCpy(&tempc->body,buf,BLK_SIZE);
|
||||
tempc->p=p;
|
||||
@@ -96,18 +96,18 @@ U0 DskCacheAdd(CPrt *p,U8 *buf, I64 blk, I64 cnt)
|
||||
U0 DskCacheInvalidate2(CPrt *p)
|
||||
{
|
||||
CCacheBlk *tempc,*tempc1;
|
||||
if (sys_dsk_cache_base) {
|
||||
if (dsk.cache_base) {
|
||||
while (LBts(&sys_semas[SYS_SEMA_DSK_CACHE],0))
|
||||
Yield;
|
||||
tempc=sys_dsk_cache_ctrl->last_lru;
|
||||
while (tempc!=sys_dsk_cache_ctrl) {
|
||||
tempc=dsk.cache_ctrl->last_lru;
|
||||
while (tempc!=dsk.cache_ctrl) {
|
||||
tempc1=tempc->last_lru;
|
||||
if (tempc->p==p) {
|
||||
DskCacheQueRem(tempc);
|
||||
tempc->p=NULL;
|
||||
tempc->blk=0;
|
||||
tempc->next_hash=tempc->last_hash=tempc;
|
||||
QueIns(tempc,sys_dsk_cache_ctrl->last_lru);
|
||||
QueIns(tempc,dsk.cache_ctrl->last_lru);
|
||||
}
|
||||
tempc=tempc1;
|
||||
}
|
||||
@@ -118,7 +118,7 @@ U0 DskCacheInvalidate2(CPrt *p)
|
||||
U0 RCache(CPrt *p,U8 **_buf, I64 *_blk, I64 *_cnt)
|
||||
{
|
||||
CCacheBlk *tempc;
|
||||
if (sys_dsk_cache_base) {
|
||||
if (dsk.cache_base) {
|
||||
while (LBts(&sys_semas[SYS_SEMA_DSK_CACHE],0))
|
||||
Yield;
|
||||
//fetch leading blks from cache
|
||||
|
||||
+44
-30
@@ -1,5 +1,5 @@
|
||||
Bool DirNew(CPrt *p,U8 *cur_dir,CDirEntry *tempde,Bool free_old_chain=TRUE)
|
||||
{
|
||||
{//Makes a directory entry in the directory from a $LK,"CDirEntry",A="MN:CDirEntry"$ node.
|
||||
switch (p->type) {
|
||||
case PT_REDSEA:
|
||||
return RedSeaFSDirNew(p,cur_dir,tempde,free_old_chain);
|
||||
@@ -15,7 +15,8 @@ Bool DirNew(CPrt *p,U8 *cur_dir,CDirEntry *tempde,Bool free_old_chain=TRUE)
|
||||
}
|
||||
|
||||
U0 DirEntryDel(CDirEntry *tempde)
|
||||
{ //Doesn't Free user_data
|
||||
{//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);
|
||||
@@ -23,7 +24,8 @@ U0 DirEntryDel(CDirEntry *tempde)
|
||||
}
|
||||
|
||||
U0 DirEntryDel2(CDirEntry *tempde)
|
||||
{ //Frees user_data
|
||||
{//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);
|
||||
@@ -31,25 +33,27 @@ U0 DirEntryDel2(CDirEntry *tempde)
|
||||
}
|
||||
}
|
||||
|
||||
U0 DirLstDel(CDirEntry *tempde)
|
||||
{ //Doesn't Free user_data
|
||||
U0 DirTreeDel(CDirEntry *tempde)
|
||||
{//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)
|
||||
DirLstDel(tempde->sub);
|
||||
DirTreeDel(tempde->sub);
|
||||
DirEntryDel(tempde);
|
||||
tempde=tempde2;
|
||||
}
|
||||
}
|
||||
|
||||
U0 DirLstDel2(CDirEntry *tempde)
|
||||
{ //Frees user_data
|
||||
U0 DirTreeDel2(CDirEntry *tempde)
|
||||
{//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)
|
||||
DirLstDel2(tempde->sub);
|
||||
DirTreeDel2(tempde->sub);
|
||||
DirEntryDel2(tempde);
|
||||
tempde=tempde2;
|
||||
}
|
||||
@@ -60,9 +64,9 @@ I64 DirEntryCompareName(CDirEntry *e1,CDirEntry *e2)
|
||||
U8 buf1[CDIR_FILENAME_LEN],buf2[CDIR_FILENAME_LEN],
|
||||
buf3[CDIR_FILENAME_LEN],buf4[CDIR_FILENAME_LEN];
|
||||
I64 d1=0,d2=0;
|
||||
if (e1->attr & _ATTR_DIR)
|
||||
if (e1->attr & RS_ATTR_DIR)
|
||||
d1=1;
|
||||
if (e2->attr & _ATTR_DIR)
|
||||
if (e2->attr & RS_ATTR_DIR)
|
||||
d2=1;
|
||||
if (d1!=d2)
|
||||
return d2-d1;
|
||||
@@ -134,13 +138,13 @@ U0 DirFilesSort(CDirEntry **_tempde,I64 key)
|
||||
}
|
||||
|
||||
CDirEntry *DirFilesFlatten(CDirEntry *tempde,CDirEntry **_result,I64 fuf_flags)
|
||||
{ //returns last node
|
||||
{//Returns last node
|
||||
CDirEntry *tempde1;
|
||||
Bool del;
|
||||
if (tempde)
|
||||
while (TRUE) {
|
||||
tempde1=tempde->next;
|
||||
if (!(tempde->attr&_ATTR_DIR)||!(fuf_flags&FUF_JUST_FILES)) {
|
||||
if (!(tempde->attr&RS_ATTR_DIR)||!(fuf_flags&FUF_JUST_FILES)) {
|
||||
_result=*_result=tempde;
|
||||
del=FALSE;
|
||||
} else
|
||||
@@ -190,7 +194,7 @@ CDirEntry *SysFilesFind(U8 *files_find_mask,I64 fuf_flags)
|
||||
}
|
||||
|
||||
U0 PutFileLink(U8 *filename,I64 line=0,Bool plain_text=FALSE)
|
||||
{
|
||||
{//Put $LK,"DolDoc",A="FI:::/Doc/DolDocOverview.TXT.Z"$ file,line link to StdOut, $LK,"DocPut",A="MN:DocPut"$.
|
||||
U8 *buf;
|
||||
if (!filename) return;
|
||||
if (IsRaw) {
|
||||
@@ -199,24 +203,32 @@ U0 PutFileLink(U8 *filename,I64 line=0,Bool plain_text=FALSE)
|
||||
else
|
||||
"%s",filename;
|
||||
} else {
|
||||
buf=FileNameAbs(filename);
|
||||
if (plain_text) {
|
||||
if (line)
|
||||
"$$LK,\"%s,%04d\",A=\"PL:%s,%d\"$$",filename,line,buf,line;
|
||||
//LK_DOC,LK_DOC_ANCHOR,LK_DOC_FIND,LK_DOC_LINE
|
||||
if (filename[0]=='A'&&filename[2]==':') {
|
||||
if (line) //See $LK,"SpriteEdText",A="MN:SpriteEdText"$()
|
||||
"$$LK,\"%s,%04d\",A=\"AL:%s,%d\"$$",filename+3,line,filename+3,line;
|
||||
else
|
||||
"$$LK,\"%s\",A=\"PI:%s\"$$",filename,buf;
|
||||
"$$LK,\"%s\",A=\"AI:%s\"$$",filename+3,filename+3;
|
||||
} else {
|
||||
if (line)
|
||||
"$$LK,\"%s,%04d\",A=\"FL:%s,%d\"$$",filename,line,buf,line;
|
||||
else
|
||||
"$$LK,\"%s\",A=\"FI:%s\"$$",filename,buf;
|
||||
buf=FileNameAbs(filename);
|
||||
if (plain_text) {
|
||||
if (line)
|
||||
"$$LK,\"%s,%04d\",A=\"PL:%s,%d\"$$",filename,line,buf,line;
|
||||
else
|
||||
"$$LK,\"%s\",A=\"PI:%s\"$$",filename,buf;
|
||||
} else {
|
||||
if (line)
|
||||
"$$LK,\"%s,%04d\",A=\"FL:%s,%d\"$$",filename,line,buf,line;
|
||||
else
|
||||
"$$LK,\"%s\",A=\"FI:%s\"$$",filename,buf;
|
||||
}
|
||||
Free(buf);
|
||||
}
|
||||
Free(buf);
|
||||
}
|
||||
}
|
||||
|
||||
U0 PutDirLink(U8 *dirname)
|
||||
{
|
||||
{//Put $LK,"DolDoc",A="FI:::/Doc/DolDocOverview.TXT.Z"$ dir macro to StdOut, $LK,"DocPut",A="MN:DocPut"$.
|
||||
U8 *buf;
|
||||
if (!dirname) return;
|
||||
if (IsRaw)
|
||||
@@ -232,6 +244,7 @@ I64 Dir2(U8 *files_find_mask,I64 fuf_flags,Bool full)
|
||||
{
|
||||
CDirEntry *tempde1=NULL,*tempde2;
|
||||
U8 *st;
|
||||
CDateStruct ds;
|
||||
I64 csize=0xFFFF,c=0xFFFF,result=0;
|
||||
tempde1=SysFilesFind(files_find_mask,fuf_flags);
|
||||
if (!(st=CurDir))
|
||||
@@ -262,16 +275,17 @@ I64 Dir2(U8 *files_find_mask,I64 fuf_flags,Bool full)
|
||||
if (full)
|
||||
"%D %T %0*tX %0*tX ",tempde1->datetime,tempde1->datetime,
|
||||
csize,tempde1->size,c,tempde1->cluster;
|
||||
else
|
||||
"%02d/%02d %02d:%02d %0*tX ",Month(tempde1->datetime),Day(tempde1->datetime),
|
||||
Hour24(tempde1->datetime),Minute(tempde1->datetime),
|
||||
else {
|
||||
Date2Struct(&ds,tempde1->datetime+local_time_offset);
|
||||
"%02d/%02d %02d:%02d %0*tX ",ds.mon,ds.day_of_mon,ds.hour,ds.min,
|
||||
csize,tempde1->size;
|
||||
if (tempde1->attr & _ATTR_DIR)
|
||||
}
|
||||
if (tempde1->attr & RS_ATTR_DIR)
|
||||
PutDirLink(tempde1->name);
|
||||
else
|
||||
PutFileLink(tempde1->name);
|
||||
|
||||
NewLine;
|
||||
'\n';
|
||||
DirEntryDel(tempde1);
|
||||
tempde1=tempde2;
|
||||
}
|
||||
|
||||
+36
-28
@@ -1,5 +1,5 @@
|
||||
U8 *FileExtDot(U8 *src)
|
||||
{
|
||||
{//Find dot char in name.
|
||||
I64 ch;
|
||||
while (ch=*src++)
|
||||
if (ch=='.' && *src!='/' && *src!='.')
|
||||
@@ -8,7 +8,7 @@ U8 *FileExtDot(U8 *src)
|
||||
}
|
||||
|
||||
U8 *FileExtRem(U8 *src,U8 *dst=NULL)
|
||||
{
|
||||
{//Remove filename extension from str.
|
||||
U8 *ptr;
|
||||
if (ptr=FileExtDot(src)) {
|
||||
if (dst)
|
||||
@@ -20,7 +20,7 @@ U8 *FileExtRem(U8 *src,U8 *dst=NULL)
|
||||
}
|
||||
|
||||
Bool IsDotZ(U8 *filename)
|
||||
{
|
||||
{//Does name end in .Z?
|
||||
I64 i=StrLen(filename);
|
||||
if (i>6 && filename[i-1]=='Z' && filename[i-2]=='.' && filename[i-6]=='.')
|
||||
return TRUE;
|
||||
@@ -29,7 +29,7 @@ Bool IsDotZ(U8 *filename)
|
||||
}
|
||||
|
||||
Bool IsDotC(U8 *filename)
|
||||
{
|
||||
{//Does name end in .C?
|
||||
I64 i=StrLen(filename);
|
||||
if (i>6 && filename[i-1]=='C' && filename[i-2]=='.' && filename[i-6]=='.')
|
||||
return TRUE;
|
||||
@@ -38,7 +38,7 @@ Bool IsDotC(U8 *filename)
|
||||
}
|
||||
|
||||
Bool FilesFindMatch(U8 *test_filename,U8 *files_find_mask,I64 fuf_flags=0)
|
||||
{
|
||||
{//Does filename meet $LK,"Files Find",A="FI:::/Doc/FileUtils.TXT"$ mask?
|
||||
U8 *st1=StrNew(files_find_mask),
|
||||
*st2=MAlloc(StrLen(files_find_mask)+1);
|
||||
Bool result=FALSE;
|
||||
@@ -80,13 +80,13 @@ Bool FilesFindMatch(U8 *test_filename,U8 *files_find_mask,I64 fuf_flags=0)
|
||||
}
|
||||
|
||||
U0 PrtChk(CPrt *p)
|
||||
{
|
||||
{//Check for valid partition. Throw exception.
|
||||
if (!p || p->pt_signature!=PRT_SIGNATURE_VAL)
|
||||
throw('Prt');
|
||||
}
|
||||
|
||||
U8 Prt2Drv(CPrt *p=NULL)
|
||||
{
|
||||
{//Prt ptr to Drv letter.
|
||||
if (!p)
|
||||
p=Fs->cur_prt;
|
||||
PrtChk(p);
|
||||
@@ -94,28 +94,31 @@ U8 Prt2Drv(CPrt *p=NULL)
|
||||
}
|
||||
|
||||
CPrt *Drv2Prt(U8 drv_let=0)
|
||||
{
|
||||
{//Drv letter to Prt ptr.
|
||||
CPrt *p;
|
||||
if (!drv_let)
|
||||
p=Fs->cur_prt;
|
||||
else {
|
||||
if (drv_let==':')
|
||||
drv_let=*sys_acct;
|
||||
p=drv_to_prt[ToUpper(drv_let)-'A'];
|
||||
drv_let=ToUpper(drv_let);
|
||||
if (!('A'<=drv_let<='Z'))
|
||||
throw('Prt');
|
||||
p=dsk.drv_to_prt[drv_let-'A'];
|
||||
}
|
||||
PrtChk(p);
|
||||
return p;
|
||||
}
|
||||
|
||||
U0 BlkDevChk(CBlkDev *bdev)
|
||||
{
|
||||
{//Check for valid BlkDev. Throw exception.
|
||||
if (!bdev || bdev->bd_signature!=BD_SIGNATURE_VAL ||
|
||||
!(BDT_NULL<bdev->type<BDT_NUM_TYPES))
|
||||
throw('BlkDev');
|
||||
}
|
||||
|
||||
CBlkDev *Drv2BlkDev(U8 drv_let=0)
|
||||
{
|
||||
{//Drv letter to BlkDev ptr.
|
||||
CPrt *p=Drv2Prt(drv_let);
|
||||
CBlkDev *bdev=p->bdev;
|
||||
BlkDevChk(bdev);
|
||||
@@ -123,7 +126,7 @@ CBlkDev *Drv2BlkDev(U8 drv_let=0)
|
||||
}
|
||||
|
||||
Bool IsDrvWritable(U8 drv_let=0)
|
||||
{
|
||||
{//Is drive writable?
|
||||
CBlkDev *bdev=Drv2BlkDev(drv_let);
|
||||
if (bdev->flags & BDF_READ_ONLY)
|
||||
return FALSE;
|
||||
@@ -132,7 +135,7 @@ Bool IsDrvWritable(U8 drv_let=0)
|
||||
}
|
||||
|
||||
U8 *CurDir(CTask *task=NULL,CTask *mem_task=NULL)
|
||||
{
|
||||
{//MAlloc copy of cur dir with partition letter.
|
||||
U8 *st;
|
||||
if (!task) task=Fs;
|
||||
if (!task->cur_dir)
|
||||
@@ -145,7 +148,7 @@ U8 *CurDir(CTask *task=NULL,CTask *mem_task=NULL)
|
||||
}
|
||||
|
||||
U8 *DirNameAbs(U8 *_dirname)
|
||||
{
|
||||
{//MAlloc absolute dir string with partition letter.
|
||||
I64 maxlen;
|
||||
U8 drv[3],*cur_dir,*buf2,*buf3,*buf,*dirname,*temp_name;
|
||||
if (!Fs->cur_dir || !*Fs->cur_dir)
|
||||
@@ -210,7 +213,7 @@ U8 *DirNameAbs(U8 *_dirname)
|
||||
}
|
||||
|
||||
U8 *FileNameAbs(U8 *_filename,I64 fuf_flags=0)
|
||||
{//$LK,"FUF_Z_OR_NOT_Z",A="MN:FUF_Z_OR_NOT_Z"$, $LK,"FUF_SCAN_PARENTS",A="MN:FUF_SCAN_PARENTS"$
|
||||
{//Absolute filename. Accepts $LK,"FUF_Z_OR_NOT_Z",A="MN:FUF_Z_OR_NOT_Z"$, $LK,"FUF_SCAN_PARENTS",A="MN:FUF_SCAN_PARENTS"$.
|
||||
U8 *buf,*buf2,*buf3,*filename,*temp_name,*temp_buf;
|
||||
CDirEntry de;
|
||||
filename=MStrUtil(_filename,SUF_REM_LEADING|SUF_REM_TRAILING|SUF_REM_CTRL_CHARS);
|
||||
@@ -243,7 +246,7 @@ U8 *FileNameAbs(U8 *_filename,I64 fuf_flags=0)
|
||||
}
|
||||
|
||||
U8 *ChgExt(U8 *filename,U8 *extension)
|
||||
{//Change filename extension
|
||||
{//Change filename extension.
|
||||
U8 *result=MAlloc(StrLen(filename)+1+StrLen(extension)+1);
|
||||
StrCpy(result,filename);
|
||||
if (FileExtDot(filename))
|
||||
@@ -280,16 +283,16 @@ CDirEntry *Cd2DirEntry(CDirEntry *tempde,U8 *abs_name)
|
||||
I64 FileAttr(U8 *name,I64 attr=0)
|
||||
{
|
||||
if (IsDotZ(name))
|
||||
attr|=_ATTR_COMPRESSED;
|
||||
attr|=RS_ATTR_COMPRESSED;
|
||||
else
|
||||
attr&=~_ATTR_COMPRESSED;
|
||||
attr&=~RS_ATTR_COMPRESSED;
|
||||
if (IsDotC(name))
|
||||
attr|=_ATTR_CONTIGUOUS;
|
||||
attr|=RS_ATTR_CONTIGUOUS;
|
||||
return attr;
|
||||
}
|
||||
|
||||
Bool FileNameChk(U8 *filename)
|
||||
{
|
||||
{//Return check for valid filename, not checking existence.
|
||||
U8 *ptr=filename;
|
||||
if (!filename) return FALSE;
|
||||
if (!*ptr) return FALSE;
|
||||
@@ -305,20 +308,20 @@ Bool FileNameChk(U8 *filename)
|
||||
}
|
||||
|
||||
U8 *DirFile(U8 *dirname,U8 *name=NULL,U8 *_extension=NULL)
|
||||
{/*
|
||||
Strips file from dirname, scans for file upward until found or returns default.
|
||||
{/*Strips file from dirname, scans for file upward until found or
|
||||
returns default.
|
||||
|
||||
("/Kernel/Hash1a.CPP.Z",NULL,NULL) returns "D:/Kernel"
|
||||
("/Kernel",NULL,"PRJ.Z") returns "D:/Kernel/Kernel.PRJ.Z"
|
||||
("/Kernel/Dsk",NULL,"PRJ.Z") returns "D:/Kernel/Kernel.PRJ.Z"
|
||||
("/Apps/MusicOrgan","Load","CPP.Z") returns "D:/Apps/MusicOrgan/Load.CPP.Z"
|
||||
("/Apps/Psalmody","Load","CPP.Z") returns "D:/Apps/Psalmody/Load.CPP.Z"
|
||||
*/
|
||||
U8 *st=DirNameAbs(dirname),*st2,*st3,*result,*dft=NULL,*ext;
|
||||
if (_extension && *_extension) {
|
||||
if (*_extension=='.')
|
||||
ext=StrNew(_extension);
|
||||
else
|
||||
ext=MPrint(".%s",_extension);
|
||||
ext=MStrPrint(".%s",_extension);
|
||||
} else
|
||||
ext=StrNew("");
|
||||
while (StrOcc(st,'/')&&!IsDir(st))
|
||||
@@ -329,10 +332,10 @@ Strips file from dirname, scans for file upward until found or returns default.
|
||||
StrLastRem(st2,"/",st3);
|
||||
|
||||
if (name)
|
||||
result=MPrint("%s/%s%s",st,name,ext);
|
||||
result=MStrPrint("%s/%s%s",st,name,ext);
|
||||
else {
|
||||
if (*ext)
|
||||
result=MPrint("%s/%s%s",st,st3,ext);
|
||||
result=MStrPrint("%s/%s%s",st,st3,ext);
|
||||
else
|
||||
result=StrNew(st);
|
||||
}
|
||||
@@ -356,12 +359,17 @@ Strips file from dirname, scans for file upward until found or returns default.
|
||||
}
|
||||
|
||||
U8 *ToggleZorNotZ(U8 *name)
|
||||
{
|
||||
{//MAlloc name with Z if not Z or vice versa.
|
||||
U8 *result;
|
||||
if (IsDotZ(name)) {
|
||||
result=StrNew(name);
|
||||
result[StrLen(name)-2]=0;
|
||||
} else
|
||||
result=MPrint("%s.Z",name);
|
||||
result=MStrPrint("%s.Z",name);
|
||||
return result;
|
||||
}
|
||||
|
||||
U8 *FileNameTempTxt()
|
||||
{//Make pretty-safe temp filename in home dir.
|
||||
return MStrPrint("HOME/SysTemp%X.TXT.Z",GetTSC>>8&0xFFFFFFFF);
|
||||
}
|
||||
+28
-34
@@ -131,7 +131,6 @@ U0 FAT32Fmt(U8 drv_let,Bool quick=TRUE)
|
||||
Free(fis);
|
||||
}
|
||||
|
||||
|
||||
Bool FATNameTo(U8 *dst,U8 *src)
|
||||
{
|
||||
I64 i;
|
||||
@@ -228,7 +227,6 @@ Bool DirLongNameFill(CDirEntry *tempde,CFAT32DirEntryLong *de,I64 *xsum)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
Bool FAT32CDirFill(CDirEntry *tempde,CFAT32DirEntry *de)
|
||||
{
|
||||
Bool result;
|
||||
@@ -244,7 +242,7 @@ Bool FAT32CDirFill(CDirEntry *tempde,CFAT32DirEntry *de)
|
||||
}
|
||||
|
||||
Bool FAT32DirFill(CFAT32DirEntry *de,CDirEntry *tempde,I64 *_de_cnt=NULL)
|
||||
{ //Fill up to 3 entries and store cnt of entries.
|
||||
{//Fill up to 3 entries and store cnt of entries.
|
||||
I64 de_cnt=0,i,l,xsum,ord;
|
||||
U8 *ptr,dname[16];
|
||||
CFAT32DirEntryLong *ld=de;
|
||||
@@ -259,7 +257,7 @@ Bool FAT32DirFill(CFAT32DirEntry *de,CDirEntry *tempde,I64 *_de_cnt=NULL)
|
||||
if ((l=StrLen(tempde->name))>13) {
|
||||
ptr=&ld[de_cnt];
|
||||
MemSet(ptr,0,sizeof(CFAT32DirEntryLong));
|
||||
ld[de_cnt].attr=_ATTR_LONG_NAME;
|
||||
ld[de_cnt].attr=RS_ATTR_LONG_NAME;
|
||||
ld[de_cnt].xsum=xsum;
|
||||
ld[de_cnt].ord=0x42;
|
||||
for (i=13;i<l;i++)
|
||||
@@ -273,7 +271,7 @@ Bool FAT32DirFill(CFAT32DirEntry *de,CDirEntry *tempde,I64 *_de_cnt=NULL)
|
||||
}
|
||||
ptr=&de[de_cnt];
|
||||
MemSet(ptr,0,sizeof(CFAT32DirEntryLong));
|
||||
ld[de_cnt].attr=_ATTR_LONG_NAME;
|
||||
ld[de_cnt].attr=RS_ATTR_LONG_NAME;
|
||||
ld[de_cnt].xsum=xsum;
|
||||
ld[de_cnt].ord=ord;
|
||||
for (i=0;i<l;i++)
|
||||
@@ -287,7 +285,7 @@ Bool FAT32DirFill(CFAT32DirEntry *de,CDirEntry *tempde,I64 *_de_cnt=NULL)
|
||||
}
|
||||
de[de_cnt].cluster_lo=tempde->cluster.u16[0];
|
||||
de[de_cnt].cluster_hi=tempde->cluster.u16[1];
|
||||
if (!(tempde->attr&_ATTR_DIR))
|
||||
if (!(tempde->attr&RS_ATTR_DIR))
|
||||
de[de_cnt].size=tempde->size;
|
||||
de[de_cnt].attr=tempde->attr;
|
||||
if (!tempde->datetime)
|
||||
@@ -298,9 +296,8 @@ Bool FAT32DirFill(CFAT32DirEntry *de,CDirEntry *tempde,I64 *_de_cnt=NULL)
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Bool FAT32FileFind(CPrt *p,I64 cur_dir_cluster,U8 *name,CDirEntry *_result,I64 fuf_flags=0)
|
||||
{ //$LK,"FUF_JUST_DIRS",A="MN:FUF_JUST_DIRS"$, $LK,"FUF_JUST_FILES",A="MN:FUF_JUST_FILES"$
|
||||
{//$LK,"FUF_JUST_DIRS",A="MN:FUF_JUST_DIRS"$, $LK,"FUF_JUST_FILES",A="MN:FUF_JUST_FILES"$
|
||||
Bool result=FALSE,unlock;
|
||||
CFAT32DirEntry *buf;
|
||||
I64 xsum=0,attr,cur_dir_entry,entries_per_cluster;
|
||||
@@ -325,16 +322,16 @@ Bool FAT32FileFind(CPrt *p,I64 cur_dir_cluster,U8 *name,CDirEntry *_result,I64 f
|
||||
while (ch=*buf[cur_dir_entry].name) {
|
||||
attr=buf[cur_dir_entry].attr;
|
||||
if (ch!=0xE5) {
|
||||
if (attr&_ATTR_LONG_NAME_MASK==_ATTR_LONG_NAME)
|
||||
if (attr&RS_ATTR_LONG_NAME_MASK==RS_ATTR_LONG_NAME)
|
||||
DirLongNameFill(&long_name,&buf[cur_dir_entry],&xsum);
|
||||
else {
|
||||
if (!(attr&_ATTR_VOL_ID)) {
|
||||
if (!(attr&RS_ATTR_VOL_ID)) {
|
||||
if (xsum==FATNameXSum(buf[cur_dir_entry].name))
|
||||
MemCpy(_result,&long_name,sizeof(CDirEntry));
|
||||
else
|
||||
MemSet(_result,0,sizeof(CDirEntry));
|
||||
if (!(fuf_flags&FUF_JUST_DIRS && !(attr & _ATTR_DIR)) &&
|
||||
!(fuf_flags&FUF_JUST_FILES && attr & _ATTR_DIR) &&
|
||||
if (!(fuf_flags&FUF_JUST_DIRS && !(attr & RS_ATTR_DIR)) &&
|
||||
!(fuf_flags&FUF_JUST_FILES && attr & RS_ATTR_DIR) &&
|
||||
FAT32CDirFill(_result,&buf[cur_dir_entry]) &&
|
||||
!StrCmp(dname,_result->name)) {
|
||||
result=TRUE;
|
||||
@@ -412,7 +409,6 @@ Bool FAT32Cd(U8 *name,I64 cur_dir_cluster)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
U0 FAT32FreeClusters(CPrt *p,I64 c)
|
||||
{
|
||||
I64 next,saved_c=c;
|
||||
@@ -514,7 +510,6 @@ I64 FAT32AllocClusters(CPrt *p,I64 c,I64 cnt)
|
||||
return first;
|
||||
}
|
||||
|
||||
|
||||
I64 FAT32AllocContiguousClusters(CPrt *p,I64 cnt)
|
||||
{
|
||||
I64 i,first=1;
|
||||
@@ -600,7 +595,7 @@ Bool FAT32DirNew(CPrt *p,U8 *cur_dir,CDirEntry *tempde,Bool free_old_chain)
|
||||
cur_dir_entry=0;
|
||||
while (ch=*buf[cur_dir_entry].name) {
|
||||
attr=buf[cur_dir_entry].attr;
|
||||
if (ch!=0xE5 && attr&_ATTR_LONG_NAME_MASK==_ATTR_LONG_NAME)
|
||||
if (ch!=0xE5 && attr&RS_ATTR_LONG_NAME_MASK==RS_ATTR_LONG_NAME)
|
||||
DirLongNameFill(&long_name,&buf[cur_dir_entry],&xsum);
|
||||
else {
|
||||
avail_cnt=FAT32_ENTRIES_PER_BLK-cur_dir_entry & (FAT32_ENTRIES_PER_BLK-1);
|
||||
@@ -617,7 +612,7 @@ Bool FAT32DirNew(CPrt *p,U8 *cur_dir,CDirEntry *tempde,Bool free_old_chain)
|
||||
+cur_dir_entry>>FAT32_ENTRIES_BITS,1);
|
||||
cur_dir_entry+=de_cnt-1; //gets inc'ed
|
||||
written=TRUE;
|
||||
} else if (ch!=0xE5 && !(attr&_ATTR_VOL_ID)) {
|
||||
} else if (ch!=0xE5 && !(attr&RS_ATTR_VOL_ID)) {
|
||||
if (xsum!=FATNameXSum(buf[cur_dir_entry].name))
|
||||
MemSet(&long_name,0,sizeof(CDirEntry));
|
||||
if (!*long_name.name)
|
||||
@@ -637,7 +632,7 @@ Bool FAT32DirNew(CPrt *p,U8 *cur_dir,CDirEntry *tempde,Bool free_old_chain)
|
||||
*buf[cur_dir_entry].name=0xE5;
|
||||
i=1;
|
||||
while (i<=cur_dir_entry &&
|
||||
buf[cur_dir_entry-i].attr&_ATTR_LONG_NAME_MASK==_ATTR_LONG_NAME)
|
||||
buf[cur_dir_entry-i].attr&RS_ATTR_LONG_NAME_MASK==RS_ATTR_LONG_NAME)
|
||||
*buf[cur_dir_entry-i++].name=0xE5;
|
||||
i--;
|
||||
WBlks(p,&buf[(cur_dir_entry-i)&-FAT32_ENTRIES_PER_BLK],
|
||||
@@ -647,7 +642,7 @@ Bool FAT32DirNew(CPrt *p,U8 *cur_dir,CDirEntry *tempde,Bool free_old_chain)
|
||||
if (i==cur_dir_entry && 0<last_dir_cluster<0x0FFFFFF8) {
|
||||
i=1;
|
||||
while (i<=entries_per_cluster &&
|
||||
last_buf[entries_per_cluster-i].attr&_ATTR_LONG_NAME_MASK==_ATTR_LONG_NAME)
|
||||
last_buf[entries_per_cluster-i].attr&RS_ATTR_LONG_NAME_MASK==RS_ATTR_LONG_NAME)
|
||||
*last_buf[entries_per_cluster-i++].name=0xE5;
|
||||
if (--i>0)
|
||||
WBlks(p,&buf[(entries_per_cluster-i)&-FAT32_ENTRIES_PER_BLK],
|
||||
@@ -746,23 +741,23 @@ I64 FAT32FilesDel(CPrt *p,U8 *cur_dir,U8 *files_find_mask,I64 fuf_flags,
|
||||
while (ch=*buf[cur_dir_entry].name) {
|
||||
attr=buf[cur_dir_entry].attr;
|
||||
if (ch!=0xE5 && ch!='.') {
|
||||
if (attr&_ATTR_LONG_NAME_MASK==_ATTR_LONG_NAME)
|
||||
if (attr&RS_ATTR_LONG_NAME_MASK==RS_ATTR_LONG_NAME)
|
||||
DirLongNameFill(&long_name,&buf[cur_dir_entry],&xsum);
|
||||
else {
|
||||
if (!(attr & _ATTR_VOL_ID) &&
|
||||
(del_dir || !(attr & _ATTR_DIR))) {
|
||||
if (!(attr & RS_ATTR_VOL_ID) &&
|
||||
(del_dir || !(attr & RS_ATTR_DIR))) {
|
||||
if (xsum!=FATNameXSum(buf[cur_dir_entry].name))
|
||||
MemSet(&long_name,0,sizeof(CDirEntry));
|
||||
if (!*long_name.name)
|
||||
FATFromName(long_name.name,buf[cur_dir_entry].name);
|
||||
if (FilesFindMatch(long_name.name,files_find_mask,fuf_flags)) {
|
||||
if (!(attr & _ATTR_DIR)) result++;
|
||||
if (!(attr & RS_ATTR_DIR)) result++;
|
||||
if (print_msg)
|
||||
"Del %s\n",long_name.name;
|
||||
*buf[cur_dir_entry].name=0xE5;
|
||||
i=1;
|
||||
while (i<=cur_dir_entry &&
|
||||
buf[cur_dir_entry-i].attr&_ATTR_LONG_NAME_MASK==_ATTR_LONG_NAME)
|
||||
buf[cur_dir_entry-i].attr&RS_ATTR_LONG_NAME_MASK==RS_ATTR_LONG_NAME)
|
||||
*buf[cur_dir_entry-i++].name=0xE5;
|
||||
i--;
|
||||
WBlks(p,&buf[(cur_dir_entry-i)&-FAT32_ENTRIES_PER_BLK],
|
||||
@@ -772,7 +767,7 @@ I64 FAT32FilesDel(CPrt *p,U8 *cur_dir,U8 *files_find_mask,I64 fuf_flags,
|
||||
if (i==cur_dir_entry && last_dir_cluster!=INVALID_CLUSTER) {
|
||||
i=1;
|
||||
while (i<=entries_per_cluster &&
|
||||
last_buf[entries_per_cluster-i].attr&_ATTR_LONG_NAME_MASK==_ATTR_LONG_NAME)
|
||||
last_buf[entries_per_cluster-i].attr&RS_ATTR_LONG_NAME_MASK==RS_ATTR_LONG_NAME)
|
||||
*last_buf[entries_per_cluster-i++].name=0xE5;
|
||||
if (--i>0)
|
||||
WBlks(p,&buf[(entries_per_cluster-i)&-FAT32_ENTRIES_PER_BLK],
|
||||
@@ -823,7 +818,7 @@ I64 FAT32FileWrite(CPrt *p,U8 *cur_dir,U8 *name,U8 *buf,I64 size,
|
||||
PrintErr("Invalid FileName.\n");
|
||||
else {
|
||||
FAT32FilesDel(p,cur_dir,de.name,0,FALSE,FALSE);
|
||||
if (attr & _ATTR_CONTIGUOUS)
|
||||
if (attr & RS_ATTR_CONTIGUOUS)
|
||||
contiguous=TRUE;
|
||||
else
|
||||
contiguous=FALSE;
|
||||
@@ -864,10 +859,10 @@ CDirEntry *FAT32FilesFind(U8 *files_find_mask,I64 fuf_flags,CDirEntry *parent=NU
|
||||
while (ch=*buf[cur_dir_entry].name) {
|
||||
attr=buf[cur_dir_entry].attr;
|
||||
if (ch!=0xE5) {
|
||||
if (attr&_ATTR_LONG_NAME_MASK==_ATTR_LONG_NAME)
|
||||
if (attr&RS_ATTR_LONG_NAME_MASK==RS_ATTR_LONG_NAME)
|
||||
DirLongNameFill(&long_name,&buf[cur_dir_entry],&xsum);
|
||||
else {
|
||||
if (!(attr&_ATTR_VOL_ID)) {
|
||||
if (!(attr&RS_ATTR_VOL_ID)) {
|
||||
tempde=MAlloc(sizeof(CDirEntry));
|
||||
if (xsum==FATNameXSum(buf[cur_dir_entry].name))
|
||||
MemCpy(tempde,&long_name,sizeof(CDirEntry));
|
||||
@@ -875,7 +870,7 @@ CDirEntry *FAT32FilesFind(U8 *files_find_mask,I64 fuf_flags,CDirEntry *parent=NU
|
||||
MemSet(tempde,0,sizeof(CDirEntry));
|
||||
if (FAT32CDirFill(tempde,&buf[cur_dir_entry])) {
|
||||
tempde->parent=parent;
|
||||
if (Bt(&fuf_flags,FUf_RECURSE) && attr&_ATTR_DIR && *tempde->name!='.') {
|
||||
if (Bt(&fuf_flags,FUf_RECURSE) && attr&RS_ATTR_DIR && *tempde->name!='.') {
|
||||
tempde->next=result;
|
||||
result=tempde;
|
||||
tempde->full_name=DirNameAbs(tempde->name);
|
||||
@@ -886,8 +881,8 @@ CDirEntry *FAT32FilesFind(U8 *files_find_mask,I64 fuf_flags,CDirEntry *parent=NU
|
||||
Cd("..");
|
||||
}
|
||||
PrtLock(p);
|
||||
} else if ((attr&_ATTR_DIR || !Bt(&fuf_flags,FUf_JUST_DIRS)) &&
|
||||
!(Bt(&fuf_flags,FUf_RECURSE) && *tempde->name=='.' && attr&_ATTR_DIR) &&
|
||||
} else if ((attr&RS_ATTR_DIR || !Bt(&fuf_flags,FUf_JUST_DIRS)) &&
|
||||
!(Bt(&fuf_flags,FUf_RECURSE) && *tempde->name=='.' && attr&RS_ATTR_DIR) &&
|
||||
FilesFindMatch(tempde->name,files_find_mask,fuf_flags)) {
|
||||
tempde->next=result;
|
||||
result=tempde;
|
||||
@@ -921,7 +916,6 @@ CDirEntry *FAT32FilesFind(U8 *files_find_mask,I64 fuf_flags,CDirEntry *parent=NU
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Bool FAT32MkDir(CPrt *p,U8 *cur_dir,U8 *name)
|
||||
{
|
||||
I64 size=p->spc<<BLK_SIZE_BITS,c,
|
||||
@@ -933,9 +927,9 @@ Bool FAT32MkDir(CPrt *p,U8 *cur_dir,U8 *name)
|
||||
|
||||
try {
|
||||
unlock_break=BreakLock;
|
||||
c=FileWrite(name,buf,size,0,_ATTR_DIR,FALSE);
|
||||
c=FileWrite(name,buf,size,0,RS_ATTR_DIR,FALSE);
|
||||
MemSet(&d_native,0,sizeof(CDirEntry));
|
||||
d_native.attr=_ATTR_DIR;
|
||||
d_native.attr=RS_ATTR_DIR;
|
||||
*d_native.name='.';
|
||||
d_native.name[1]=0;
|
||||
d_native.cluster=c;
|
||||
@@ -945,7 +939,7 @@ Bool FAT32MkDir(CPrt *p,U8 *cur_dir,U8 *name)
|
||||
dFAT++;
|
||||
|
||||
MemSet(&d_native,0,sizeof(CDirEntry));
|
||||
d_native.attr=_ATTR_DIR;
|
||||
d_native.attr=RS_ATTR_DIR;
|
||||
*d_native.name='.';
|
||||
d_native.name[1]='.';
|
||||
d_native.name[2]=0;
|
||||
|
||||
@@ -121,13 +121,13 @@ Bool ISO1CDirFill(CDirEntry *tempde,CISO1DirEntry *de)
|
||||
tempde->size=de->size.little;
|
||||
tempde->attr=FileAttr(tempde->name);
|
||||
if (de->flags & ISO1_ATTR_DIR)
|
||||
tempde->attr|=_ATTR_DIR;
|
||||
tempde->attr|=RS_ATTR_DIR;
|
||||
tempde->datetime=ISO1DateStruct2CDate(&de->date);
|
||||
return result;
|
||||
}
|
||||
|
||||
Bool ISO1FileFind(CPrt *p,I64 cur_dir_cluster,U8 *name,CDirEntry *_result,I64 fuf_flags=0)
|
||||
{ //$LK,"FUF_JUST_DIRS",A="MN:FUF_JUST_DIRS"$, $LK,"FUF_JUST_FILES",A="MN:FUF_JUST_FILES"$
|
||||
{//$LK,"FUF_JUST_DIRS",A="MN:FUF_JUST_DIRS"$, $LK,"FUF_JUST_FILES",A="MN:FUF_JUST_FILES"$
|
||||
CISO1DirEntry *isoptr,*buf;
|
||||
U8 dname[CDIR_FILENAME_LEN];
|
||||
Bool result=FALSE,unlock;
|
||||
@@ -142,7 +142,7 @@ Bool ISO1FileFind(CPrt *p,I64 cur_dir_cluster,U8 *name,CDirEntry *_result,I64 fu
|
||||
unlock=PrtLock(p);
|
||||
isoptr=MAlloc(p->spc<<BLK_SIZE_BITS);
|
||||
RClusters(Fs->cur_prt,isoptr,cur_dir_cluster,1);
|
||||
if (isoptr->name_len==1 && !isoptr->name) { //curdir
|
||||
if (isoptr->name_len==1 && !isoptr->name) {//curdir
|
||||
i=(isoptr->size.little+p->spc<<BLK_SIZE_BITS-1)/p->spc<<BLK_SIZE_BITS;
|
||||
buf=MAlloc(p->spc<<BLK_SIZE_BITS*i);
|
||||
RClusters(Fs->cur_prt,buf,cur_dir_cluster,i);
|
||||
@@ -163,8 +163,8 @@ Bool ISO1FileFind(CPrt *p,I64 cur_dir_cluster,U8 *name,CDirEntry *_result,I64 fu
|
||||
if (!StrCmp(name,dname)) {
|
||||
result=ISO1CDirFill(_result,isoptr);
|
||||
if (result &&
|
||||
!(fuf_flags&FUF_JUST_DIRS && !(_result->attr & _ATTR_DIR)) &&
|
||||
!(fuf_flags&FUF_JUST_FILES && _result->attr & _ATTR_DIR) )
|
||||
!(fuf_flags&FUF_JUST_DIRS && !(_result->attr & RS_ATTR_DIR)) &&
|
||||
!(fuf_flags&FUF_JUST_FILES && _result->attr & RS_ATTR_DIR) )
|
||||
goto exit_this;
|
||||
else
|
||||
result=FALSE;
|
||||
@@ -237,7 +237,7 @@ CDirEntry *ISO1FilesFind(U8 *files_find_mask,I64 fuf_flags,CDirEntry *parent=NUL
|
||||
throw('FUF');
|
||||
isoptr=MAlloc(p->spc<<BLK_SIZE_BITS);
|
||||
RClusters(Fs->cur_prt,isoptr,cur_dir_cluster,1);
|
||||
if (isoptr->name_len==1 && !isoptr->name) { //curdir
|
||||
if (isoptr->name_len==1 && !isoptr->name) {//curdir
|
||||
i=(isoptr->size.little+p->spc<<BLK_SIZE_BITS-1)/p->spc<<BLK_SIZE_BITS;
|
||||
buf=MAlloc(p->spc<<BLK_SIZE_BITS*i);
|
||||
RClusters(Fs->cur_prt,buf,cur_dir_cluster,i);
|
||||
@@ -256,7 +256,7 @@ CDirEntry *ISO1FilesFind(U8 *files_find_mask,I64 fuf_flags,CDirEntry *parent=NUL
|
||||
tempde=MAlloc(sizeof(CDirEntry));
|
||||
if (ISO1CDirFill(tempde,buf)) {
|
||||
tempde->parent=parent;
|
||||
if (Bt(&fuf_flags,FUf_RECURSE) && tempde->attr&_ATTR_DIR && *tempde->name!='.') {
|
||||
if (Bt(&fuf_flags,FUf_RECURSE) && tempde->attr&RS_ATTR_DIR && *tempde->name!='.') {
|
||||
tempde->next=result;
|
||||
result=tempde;
|
||||
tempde->full_name=DirNameAbs(tempde->name);
|
||||
@@ -264,8 +264,8 @@ CDirEntry *ISO1FilesFind(U8 *files_find_mask,I64 fuf_flags,CDirEntry *parent=NUL
|
||||
tempde->sub=ISO1FilesFind(files_find_mask,fuf_flags,tempde);
|
||||
Cd("..");
|
||||
}
|
||||
} else if ((tempde->attr & _ATTR_DIR || !Bt(&fuf_flags,FUf_JUST_DIRS)) &&
|
||||
!(Bt(&fuf_flags,FUf_RECURSE) && *tempde->name=='.' && tempde->attr&_ATTR_DIR) &&
|
||||
} else if ((tempde->attr & RS_ATTR_DIR || !Bt(&fuf_flags,FUf_JUST_DIRS)) &&
|
||||
!(Bt(&fuf_flags,FUf_RECURSE) && *tempde->name=='.' && tempde->attr&RS_ATTR_DIR) &&
|
||||
FilesFindMatch(tempde->name,files_find_mask,fuf_flags)) {
|
||||
tempde->next=result;
|
||||
result=tempde;
|
||||
|
||||
@@ -130,7 +130,7 @@ U0 RedSeaFSFmt(U8 drv_let,Bool quick=TRUE)
|
||||
|
||||
d_native=root_dir-offset(CDirEntry.start);
|
||||
|
||||
d_native->attr=_ATTR_DIR|_ATTR_CONTIGUOUS;
|
||||
d_native->attr=RS_ATTR_DIR|RS_ATTR_CONTIGUOUS;
|
||||
*d_native->name='.';
|
||||
d_native->cluster=br->root_cluster;
|
||||
d_native->size=BLK_SIZE;
|
||||
@@ -140,7 +140,7 @@ U0 RedSeaFSFmt(U8 drv_let,Bool quick=TRUE)
|
||||
|
||||
*d_native->name='.';
|
||||
d_native->name[1]='.';
|
||||
d_native->attr=_ATTR_DIR|_ATTR_CONTIGUOUS;
|
||||
d_native->attr=RS_ATTR_DIR|RS_ATTR_CONTIGUOUS;
|
||||
d_native->cluster=br->root_cluster;
|
||||
d_native->datetime=Now;
|
||||
|
||||
@@ -154,7 +154,7 @@ U0 RedSeaFSFmt(U8 drv_let,Bool quick=TRUE)
|
||||
}
|
||||
|
||||
Bool RedSeaFSFileFind(CPrt *p,I64 cur_dir_cluster,U8 *name,CDirEntry *_result,I64 fuf_flags=0)
|
||||
{ //$LK,"FUF_JUST_DIRS",A="MN:FUF_JUST_DIRS"$, $LK,"FUF_JUST_FILES",A="MN:FUF_JUST_FILES"$
|
||||
{//$LK,"FUF_JUST_DIRS",A="MN:FUF_JUST_DIRS"$, $LK,"FUF_JUST_FILES",A="MN:FUF_JUST_FILES"$
|
||||
CDirEntry *buf,*buf2,*ptr;
|
||||
U8 dname[CDIR_FILENAME_LEN];
|
||||
I64 ch;
|
||||
@@ -184,9 +184,9 @@ Bool RedSeaFSFileFind(CPrt *p,I64 cur_dir_cluster,U8 *name,CDirEntry *_result,I6
|
||||
while (TRUE) {
|
||||
if (!(ch=*ptr->name))
|
||||
break;
|
||||
else if (!(ptr->attr & _ATTR_DELETED) &&
|
||||
!(fuf_flags&FUF_JUST_DIRS && !(ptr->attr & _ATTR_DIR)) &&
|
||||
!(fuf_flags&FUF_JUST_FILES && ptr->attr & _ATTR_DIR) &&
|
||||
else if (!(ptr->attr & RS_ATTR_DELETED) &&
|
||||
!(fuf_flags&FUF_JUST_DIRS && !(ptr->attr & RS_ATTR_DIR)) &&
|
||||
!(fuf_flags&FUF_JUST_FILES && ptr->attr & RS_ATTR_DIR) &&
|
||||
!StrCmp(dname,ptr->name)) {
|
||||
MemCpy(&_result->attr,&ptr->attr,CDIR_SIZE);
|
||||
result=TRUE;
|
||||
@@ -204,8 +204,6 @@ exit_this:
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
U8 *RedSeaFSFileRead(CPrt *p,U8 *cur_dir,U8 *filename,I64 *_size,I64 *_attr)
|
||||
{
|
||||
U8 *buf=NULL;
|
||||
@@ -351,7 +349,6 @@ I64 RedSeaFSAllocClusters(CPrt *p,I64 cnt)
|
||||
return first;
|
||||
}
|
||||
|
||||
|
||||
Bool RedSeaFSDirNew(CPrt *p,U8 *cur_dir,CDirEntry *de,Bool free_old_chain)
|
||||
{
|
||||
CDirEntry *buf,*buf2,*ptr,de2;
|
||||
@@ -361,7 +358,7 @@ Bool RedSeaFSDirNew(CPrt *p,U8 *cur_dir,CDirEntry *de,Bool free_old_chain)
|
||||
U8 *temp,*parent_dir;
|
||||
try {
|
||||
unlock_break=BreakLock;
|
||||
de->attr|=_ATTR_CONTIGUOUS;
|
||||
de->attr|=RS_ATTR_CONTIGUOUS;
|
||||
unlock=PrtLock(p);
|
||||
cur_dir_cluster=Name2DirCluster(p,cur_dir);
|
||||
buf2=MAlloc(BLK_SIZE);
|
||||
@@ -419,7 +416,7 @@ Bool RedSeaFSDirNew(CPrt *p,U8 *cur_dir,CDirEntry *de,Bool free_old_chain)
|
||||
}
|
||||
}
|
||||
break;
|
||||
} else if (ptr->attr & _ATTR_DELETED) {
|
||||
} else if (ptr->attr & RS_ATTR_DELETED) {
|
||||
if (!written) {
|
||||
MemCpy(&ptr->start,&de->start,CDIR_SIZE);
|
||||
WBlks(p,buf(U8 *)+j<<BLK_SIZE_BITS,p->data+cur_dir_cluster+j,1);
|
||||
@@ -433,7 +430,7 @@ Bool RedSeaFSDirNew(CPrt *p,U8 *cur_dir,CDirEntry *de,Bool free_old_chain)
|
||||
if (!written)
|
||||
MemCpy(&ptr->start,&de->start,CDIR_SIZE);
|
||||
else
|
||||
ptr->attr|=_ATTR_DELETED;
|
||||
ptr->attr|=RS_ATTR_DELETED;
|
||||
WBlks(p,buf(U8 *)+j<<BLK_SIZE_BITS,p->data+cur_dir_cluster+j,1);
|
||||
break;
|
||||
}
|
||||
@@ -482,13 +479,13 @@ I64 RedSeaFSFilesDel(CPrt *p,U8 *cur_dir,U8 *files_find_mask,I64 fuf_flags,
|
||||
while (TRUE) {
|
||||
if (!(ch=*ptr->name))
|
||||
break;
|
||||
else if (!(ptr->attr & _ATTR_DELETED) && ch!='.' && (del_dir ||
|
||||
!(ptr->attr & _ATTR_DIR)) &&
|
||||
else if (!(ptr->attr & RS_ATTR_DELETED) && ch!='.' && (del_dir ||
|
||||
!(ptr->attr & RS_ATTR_DIR)) &&
|
||||
FilesFindMatch(ptr->name,files_find_mask,fuf_flags)) {
|
||||
if (!(ptr->attr & _ATTR_DIR)) result++;
|
||||
if (!(ptr->attr & RS_ATTR_DIR)) result++;
|
||||
if (print_msg)
|
||||
"Del %s\n",ptr->name;
|
||||
ptr->attr|=_ATTR_DELETED;
|
||||
ptr->attr|=RS_ATTR_DELETED;
|
||||
WBlks(p,buf(U8 *)+j<<BLK_SIZE_BITS,p->data+cur_dir_cluster+j,1);
|
||||
RedSeaFSFreeClusters(p,ptr->cluster,(ptr->size+BLK_SIZE-1)>>BLK_SIZE_BITS);
|
||||
}
|
||||
@@ -529,7 +526,7 @@ I64 RedSeaFSFileWrite(CPrt *p,U8 *cur_dir,U8 *name,U8 *buf,I64 size,
|
||||
else
|
||||
c=INVALID_CLUSTER;
|
||||
de.cluster=c;
|
||||
de.attr=attr|_ATTR_CONTIGUOUS;
|
||||
de.attr=attr|RS_ATTR_CONTIGUOUS;
|
||||
de.datetime=cdt;
|
||||
if (blk_cnt)
|
||||
WClustersBlks(p,buf,c,blk_cnt);
|
||||
@@ -565,11 +562,11 @@ CDirEntry *RedSeaFSFilesFind(U8 *files_find_mask,I64 fuf_flags,CDirEntry *parent
|
||||
while (TRUE) {
|
||||
if (!(ch=*ptr->name))
|
||||
break;
|
||||
else if (!(ptr->attr & _ATTR_DELETED)) {
|
||||
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&_ATTR_DIR && *tempde->name!='.') {
|
||||
if (Bt(&fuf_flags,FUf_RECURSE) && tempde->attr&RS_ATTR_DIR && *tempde->name!='.') {
|
||||
tempde->next=result;
|
||||
result=tempde;
|
||||
tempde->full_name=DirNameAbs(tempde->name);
|
||||
@@ -579,8 +576,8 @@ CDirEntry *RedSeaFSFilesFind(U8 *files_find_mask,I64 fuf_flags,CDirEntry *parent
|
||||
Cd("..");
|
||||
}
|
||||
PrtLock(p);
|
||||
} else if ((tempde->attr&_ATTR_DIR || !Bt(&fuf_flags,FUf_JUST_DIRS)) &&
|
||||
!(Bt(&fuf_flags,FUf_RECURSE) && *tempde->name=='.' && tempde->attr&_ATTR_DIR) &&
|
||||
} else if ((tempde->attr&RS_ATTR_DIR || !Bt(&fuf_flags,FUf_JUST_DIRS)) &&
|
||||
!(Bt(&fuf_flags,FUf_RECURSE) && *tempde->name=='.' && tempde->attr&RS_ATTR_DIR) &&
|
||||
FilesFindMatch(tempde->name,files_find_mask,fuf_flags)) {
|
||||
tempde->next=result;
|
||||
result=tempde;
|
||||
@@ -606,15 +603,15 @@ Bool RedSeaFSMkDir(CPrt *p,U8 *cur_dir,U8 *name)
|
||||
|
||||
try {
|
||||
unlock_break=BreakLock;
|
||||
c=FileWrite(name,buf,size,0,_ATTR_DIR,FALSE);
|
||||
d_native->attr=_ATTR_DIR|_ATTR_CONTIGUOUS;
|
||||
c=FileWrite(name,buf,size,0,RS_ATTR_DIR,FALSE);
|
||||
d_native->attr=RS_ATTR_DIR|RS_ATTR_CONTIGUOUS;
|
||||
StrCpy(d_native->name,name);
|
||||
d_native->cluster=c;
|
||||
d_native->size=size;
|
||||
d_native->datetime=Now;
|
||||
d_native(U8 *)+=CDIR_SIZE;
|
||||
|
||||
d_native->attr=_ATTR_DIR|_ATTR_CONTIGUOUS;
|
||||
d_native->attr=RS_ATTR_DIR|RS_ATTR_CONTIGUOUS;
|
||||
*d_native->name='.';
|
||||
d_native->name[1]='.';
|
||||
d_native->name[2]=0;
|
||||
|
||||
Reference in new issue
Block a user