LTCD_070816.ISO
This commit is contained in:
1 parent
d14bbc24f9
commit
0e9364ff4c
506 files changed
+157705
-41812
No files matched your search
@@ -0,0 +1,69 @@
|
||||
#help_index "Utils"
|
||||
|
||||
//$LK,"StrUtil","MN:StrUtil"$() operations on files
|
||||
|
||||
public void SUFile(I1 *name,U8 su_flags)
|
||||
{//String utility on a single file
|
||||
//See $LK,"SU Flags","MN:SU_SINGLE_SPACE"$
|
||||
I1 *dst;
|
||||
BoolU4 changed=FALSE;
|
||||
I8 reduced=0;
|
||||
Ltf *l=LtfRead(name,LTFF_PLAIN_TEXT_WITH_TABS | LTFF_NO_CURSOR);
|
||||
LtfEntry *cl;
|
||||
cl=l->dummy.next;
|
||||
while (cl!=l) {
|
||||
if (cl->btype==LTFT_TEXT) {
|
||||
dst=MStrUtil(cl->display,su_flags);
|
||||
if (StrCmp(dst,cl->display)) {
|
||||
reduced=reduced+StrLen(cl->display)-StrLen(dst);
|
||||
changed=TRUE;
|
||||
Free(cl->display);
|
||||
cl->display=dst;
|
||||
} else
|
||||
Free(dst);
|
||||
}
|
||||
cl=cl->next;
|
||||
}
|
||||
if (changed) {
|
||||
PrintF("Reduced %s by %d chars\r\n",name,reduced);
|
||||
StrCpy(l->filename.name,name);
|
||||
LtfWrite(l);
|
||||
}
|
||||
LtfDel(l);
|
||||
}
|
||||
|
||||
void SUList(LTDirEntry *tempm1,U8 su_flags)
|
||||
{
|
||||
LTDirEntry *tempm2;
|
||||
while (tempm1) {
|
||||
tempm2=tempm1->next;
|
||||
if (tempm1->attr & LT_ATTR_DIR) {
|
||||
if (tempm1->sub) {
|
||||
coutln SysText("ST_SCANNING_DIRECTORY"),tempm1->full_name;
|
||||
SUList(tempm1->sub,su_flags);
|
||||
}
|
||||
} else
|
||||
SUFile(tempm1->full_name,su_flags);
|
||||
DelLTDirEntry(tempm1);
|
||||
tempm1=tempm2;
|
||||
}
|
||||
}
|
||||
|
||||
//flags +r=recurse
|
||||
public void SU(I1 *wild,U8 su_flags,I1 *flags)
|
||||
{//Apply string utilities to files
|
||||
//You can convert spaces to tabs, for example
|
||||
//or removing trailing spaces on lines.
|
||||
//See $LK,"SU Flags","MN:SU_SINGLE_SPACE"$
|
||||
U8 f=0;
|
||||
GetFFlags(&f,SysText("ST_FILE_UTIL_FLAGS"),flags);
|
||||
SUList(FindFiles(wild,f),su_flags);
|
||||
}
|
||||
|
||||
//flags +r=recurse
|
||||
public void S2T(I1 *wild,I1 *flags)
|
||||
{//Spaces to tabs
|
||||
SU(wild,SU_S2T|SU_REMOVE_TRAILING,flags);
|
||||
}
|
||||
|
||||
#help_index ""
|
||||
Reference in new issue
Block a user