188 lines
3.9 KiB
Plaintext
188 lines
3.9 KiB
Plaintext
BoolU8 NewLTDirEntry(LTPartition *p,I1 *cur_dir,LTDirEntry *tempm,BoolU4 free_old_chain=TRUE)
|
|
{
|
|
if (p->type==PT_LT)
|
|
return NewLTDirEntry2(p,cur_dir,tempm,free_old_chain,TRUE);
|
|
return FALSE;
|
|
}
|
|
|
|
|
|
void DelLTDirEntry(LTDirEntry *tempm)
|
|
{
|
|
if (tempm) {
|
|
Free(tempm->full_name);
|
|
Free(tempm);
|
|
}
|
|
}
|
|
|
|
void DelLTDirList(LTDirEntry *tempm)
|
|
{
|
|
LTDirEntry *tempm2;
|
|
while (tempm) {
|
|
tempm2=tempm->next;
|
|
if (tempm->sub)
|
|
DelLTDirList(tempm->sub);
|
|
DelLTDirEntry(tempm);
|
|
tempm=tempm2;
|
|
}
|
|
}
|
|
|
|
I8 CompareLTDir(LTDirEntry **e1,LTDirEntry **e2)
|
|
{
|
|
I1 buf1[LT_MAX_FILENAME_LEN+1],buf2[LT_MAX_FILENAME_LEN+1];
|
|
I1 buf3[LT_MAX_FILENAME_LEN+1],buf4[LT_MAX_FILENAME_LEN+1];
|
|
I8 d1=0,d2=0;
|
|
if ((*e1)->attr & LT_ATTR_DIR)
|
|
d1=1;
|
|
if ((*e2)->attr & LT_ATTR_DIR)
|
|
d2=1;
|
|
if (d1!=d2)
|
|
return d2-d1;
|
|
else {
|
|
StrCpy(buf1,(*e1)->name);
|
|
StrCpy(buf2,(*e2)->name);
|
|
RemoveLastSeg(buf1,".",buf3);
|
|
RemoveLastSeg(buf2,".",buf4);
|
|
if (d1=StrCmp(buf3,buf4))
|
|
return d1;
|
|
return StrCmp(buf1,buf2);
|
|
}
|
|
}
|
|
|
|
void SortLTDirFiles(LTDirEntry **tempm)
|
|
{
|
|
I8 i,cnt=0;
|
|
LTDirEntry *tempm1=*tempm,*tempm2,**sort_buf;
|
|
if (tempm1) {
|
|
tempm2=tempm1;
|
|
while (tempm2) {
|
|
cnt++;
|
|
tempm2=tempm2->next;
|
|
}
|
|
if (cnt>1) {
|
|
sort_buf=MAlloc(cnt*sizeof(void *));
|
|
i=0;
|
|
tempm2=tempm1;
|
|
while (tempm2) {
|
|
sort_buf[i++]=tempm2;
|
|
tempm2=tempm2->next;
|
|
}
|
|
QSort(sort_buf,cnt,sizeof(void *),&CompareLTDir);
|
|
tempm1=sort_buf[0];
|
|
*tempm=tempm1;
|
|
for (i=0;i<cnt-1;i++) {
|
|
tempm2=sort_buf[i];
|
|
tempm2->next=sort_buf[i+1];
|
|
}
|
|
tempm2=sort_buf[i];
|
|
tempm2->next=NULL;
|
|
Free(sort_buf);
|
|
|
|
tempm2=tempm1;
|
|
while (tempm2) {
|
|
if (tempm2->sub)
|
|
SortLTDirFiles(&tempm2->sub);
|
|
tempm2=tempm2->next;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
LTDirEntry *SysFindFiles(I1 *wild,U8 fuf_flags=0)
|
|
{
|
|
LTPartition *p=Fs->cur_partition;
|
|
LTDirEntry *result=NULL;
|
|
CheckLTPartition(p);
|
|
if (p->type==PT_LT)
|
|
result=FindLTFiles(wild,fuf_flags);
|
|
else if (p->type==PT_ISO9660)
|
|
result=FindISOFiles(wild,fuf_flags);
|
|
else {
|
|
PutSysText("ST_FILE_SYSTEM_NOT_SUPPORTED");
|
|
result=NULL;
|
|
}
|
|
if (result)
|
|
SortLTDirFiles(&result);
|
|
return result;
|
|
}
|
|
|
|
void PutFileLink(I1 *name,I8 line=0,BoolU4 plain_text=FALSE)
|
|
{
|
|
I1 *buf;
|
|
if (!name) return;
|
|
buf=AbsoluteFileName(name);
|
|
if (plain_text) {
|
|
if (line)
|
|
PrintF("$$LK \"%s,%04d\",\"PL:%s,%d\"$$",
|
|
name,line,buf,line);
|
|
else
|
|
PrintF("$$LK \"%s\",\"PI:%s\"$$",
|
|
name,buf);
|
|
} else {
|
|
if (line)
|
|
PrintF("$$LK \"%s,%04d\",\"FL:%s,%d\"$$",
|
|
name,line,buf,line);
|
|
else
|
|
PrintF("$$LK \"%s\",\"FI:%s\"$$",
|
|
name,buf);
|
|
}
|
|
Free(buf);
|
|
}
|
|
|
|
void PutDirLink(I1 *name)
|
|
{
|
|
I1 *buf;
|
|
if (!name) return;
|
|
buf=AbsoluteDirName(name);
|
|
PrintF("$$MA+A,\"%s\",\"Cd(\\\"%s\\\");Dir;\r\"$$",
|
|
name,buf);
|
|
Free(buf);
|
|
}
|
|
|
|
void DirLT(I1 *wild,BoolU4 full)
|
|
{
|
|
LTPartition *p=Fs->cur_partition;
|
|
LTDirEntry *tempm1=NULL,*tempm2;
|
|
I1 *st;
|
|
tempm1=SysFindFiles(wild,0);
|
|
|
|
if (tempm1) {
|
|
cout "$$MA+A,\"Directory \",\"PopUpCd;Dir;\r\"$$";
|
|
st=CurDir;
|
|
if (full)
|
|
coutln "of ",st,
|
|
"\r\n__DATE__ __TIME__ CMPSIZE_ _UNCOMPRESSSIZE_ "
|
|
"_____CLUSTER____";
|
|
else
|
|
coutln "of ",st,
|
|
"\r\nDATE_ TIME_ __SIZE__";
|
|
Free(st);
|
|
while (tempm1) {
|
|
tempm2=tempm1->next;
|
|
if (full) {
|
|
PrintF("%D %T %08X ",
|
|
tempm1->datetime,
|
|
tempm1->datetime,
|
|
tempm1->size);
|
|
cout tempm1->expanded_size,
|
|
" ",tempm1->cluster;
|
|
} else {
|
|
PrintF("%h1D %h1T %08X ",
|
|
tempm1->datetime,
|
|
tempm1->datetime,
|
|
tempm1->size);
|
|
}
|
|
if (tempm1->attr & LT_ATTR_DIR)
|
|
PutDirLink(tempm1->name);
|
|
else
|
|
PutFileLink(tempm1->name);
|
|
|
|
CrLf;
|
|
DelLTDirEntry(tempm1);
|
|
tempm1=tempm2;
|
|
}
|
|
} else {
|
|
PutSysText("ST_NO_MATCHING_ENTRIES");
|
|
return;
|
|
}
|
|
}
|
|
|