Jump to content











Photo
- - - - -

[Release] LIST.G4B: front-end for grub4dos' function 'ls'

grub4dos

  • Please log in to reply
No replies to this topic

#1 deomsh

deomsh

    Frequent Member

  • Advanced user
  • 196 posts
  •  
    Netherlands

Posted 19 May 2023 - 04:13 PM

Lately I was working on a sub-directory to test more advanced wildcards. But things run a bit 'out of hand', so I scripted a full front-end for grub4dos' internal function 'ls': https://github.com/deomsh/LIST.G4B

 

This script can be used as a replacement for 'ls', output should be the same, but with a few modifications:

  • pager is working, I made my own pager (not working on grub4efi)
  • empty directories are greyed out (except on NTFS only, not possible to discriminate between empty directories and  zero-byte files on this file-system. I choose to show zero-byte files as directories - 'ls' can SHOW the difference)
  • sub-directories can be parsed too (with the well known switch '-s')
  • colors can be set on file-names, file-extensions, not-empty directories, empty directories and on sub-directories

I took idea's for switches from the Linux/ Unix BASH command-line, MS-DOS 7.1 and Windows 10 CMD.

 

Starting with LIST.G4B is easiest without any other parameter, small-help will show up. The small-help will also be shown if an error is made about the actual commands (an idea steve6375 gave me when I published TEXTSTAT.G4B). See first print-screen:

 

01 LIST.G4B v0.7 with empty command-line and with bad switch.png

 

There are six basic forms of output. The two 'wide' outputs are self-adjusting to the actual graphics mode: number of column's between 5 and 12 (I am afraid 320x240 or 200? is not fully supported with 'wide'). See next six print-screens.

 

02 LIST v0.7 root.png 03 LIST v0.7 -b root.png 04 LIST v0.7 -l root.png 05 LIST v0.7 -lh root.png 06 LIST v0.7 -w root.png 07 LIST v0.7 -c root.png

 

BTW escaped spaces '\ ' are only visible in the default 'ls'-mode, in al other modes removed.

 

Following wildcards are supported: '?' and multiple '*' in file-names and file-extensions. In directories only ONE '*' at the end of the LAST directory-name in the PATH. Default LIST.G4B is not case-sensitive, but this can be altered with switch '-case'. See next three print-screens:

 

08 LIST v0.7 -b root+several wildcard tests.png 09 LIST v0.7 -root-G+asterisk- wildcard in dir compared with -b switch.png 10 LIST v0.7 test with -case after vol and set lscol=BDE6F on EXT2 (hd6,4).png

 

Also sorting is added. There are three sorting possibilities: name, extension and file-size. Also 'grouping' on directories/ files is available. See next print-screen for an example:

 

12 LIST v0.7 -ogn -c root.png

 

BTW my second programmer-son helped me a lot. First with the algorithm of 'selection sort' - which was quite easy because I (re)invented my own pointers (24 bits for memory address of files and 8 bits for their length).

Later he insisted I had to try 'quick sort' too, which should be faster in theory.

But because I pre-sorted in 35 'buckets', in most cases selection sort is still faster (number of 'swaps' seems to be best with selection sort - I found 'break-even' in case of about 15 pointers in a bucket). This sorting method also has the virtue the sorted file is immediate available for echoing, so output is more fluently.

However with switch '-qs' quick sort is available too.

 

 

With switch '-n' the number of folders and files is counted and echo'd at the end (with -nq exported to a set-variable). See next two print-screens. On the second print-screen can be seen the file names with leading spaces can not be displayed with sorting (they are NOT according to the Microsoft's Long File Name specification anyway).

 

13 LIST v0.7 -n -w -og root (including starting spaces).png 14 LIST v0.7 -n -w -ogn root (NOT including starting spaces).png

 

BTW ment is the folder: '  LFN Starting Spaces in Total Commander'

 

With switch '-e'/ '--e' only empty directories are displayed/ not displayed. With switches '-d'/ '-f' directories/ files only. Colors can be set with switch '-col:NXDES' (for details see the 'Help'). Next two print-screens give examples (empty folders brown, not-empty folders yellow and device+path+sub-directories high-white:

 

15 LIST v0.7 -e -w -on -s -d -col=77F6F root on graphicsmode 1600.png 16 LIST v0.7 --e -w -on -s -d -col=77E6F root on graphicsmode 1600.png

 

BTW it is also possible to set colors with variable 'lscol', active until grub4dos command-line is left.

 

Another possibility is to filter on Short File Names/ Long File Names, but only as far 'ls' is showing them. So no truncated file names here. See next print-screen for some examples:

 

17 LIST v0.7 tests with -sfn and --sfn on (hd0,0)-windows-.png

 

Inspired by the '-e' switch from the BASH command-line I added multiple extensions: switch '-me'. Also multiple directories ('-md') OR multiple subdirectories ('-ms'). Can all be used with and without switch '-s'. See next three print-screens:

 

18 LIST v0.7 -me -w -oe -s (hd0,0)-asterisk.DLL asterisk.TLB asterisk.CPL asterisk.OCX on graphicsmode 1280.png 19 LIST7M -col=BDE6F -oge -md -s (hd0,0)-windows-Asterisk- -sAsterisk- -cAsterisk- -inf- -tAsterisk- -appliAsterisk -allAsterisk-.png 20 LIST v0.7 tests with -ms -s -oge -w -col=BDE6F (hd0,0)-windows- SYSasterisk- IOSUBSYS- COMMAND- notSTSTEM- ALLasterisk-.png

 

For the more advanced users (if any) my implementation of redirecting, piping and adding other commands after 'FILE'. This is more complicated, but there are some instructions in the Help. A few examples can be seen in next print-screen:

 

22 LIST v0.7 tests with redirect, pipe and CMD on (hd0,0)-windwos-.png

 

About the support of grub4efi: although (almost fully supported) quite unstable, even with switch '-mdbase:startsector' to use a free memory area on grub4efi. See last print-screen:

 

24 LIST.G4B v0.7 -mdbase=0x22000 -s -w -oge -col=BDE6F (hd0,0)- on grub4efi graphicsmode 1024 + crashes.png

 

 

 

 

 

 

 

 



#2 steve6375

steve6375

    Platinum Member

  • Developer
  • 7566 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films
  •  
    United Kingdom

Posted 20 May 2023 - 11:57 AM

Looks really useful!  Thanks!

 

column  has only one letter L in it. not two

 

Seems to have problems under grub4efi (malloc errors after several runs) but that is problems with grub4efi not your code!



#3 deomsh

deomsh

    Frequent Member

  • Advanced user
  • 196 posts
  •  
    Netherlands

Posted 20 May 2023 - 07:48 PM

Thanks.

 

During this project I became aware column is without one 'l' (I used it as a variable name too) - but I see in the 'Help' I failed.

Also my Pagestat sub-routine has still variable 'collumn'. :ph34r:

 

BTW under grub4efi I observed earlier these malloc errors after several runs. I hope this will become better in the future.

 

Addendum:

 

In my first post I forgot to mention a few details, and I want to add some clarifications (that post became already quite long).

 

1) about differing behavior with 'pager' compared to 'ls': if pager is 'on' and using 'ls' it is not possible to quit with 'Q' (only a bit of a problem in case of large directories).

 

2) if before using LIST.G4B pager is set 'off', it is still possible to end the script with 'Q' (or pause with 'Escape'). Of course Ctrl+C can be used, is not always working if piping output of 'ls' if a large directory to a call.

BTW a technical detail: I used 'beep 0 1' to 'break' processing of the 'call command-line' (in sub-routine :lastkey).

 

3) with most switches no memory is used.

 

4) total size of counted files is not included with switch '-n'/ '-nq'. Will this be useful to anyone?

 

 



#4 deomsh

deomsh

    Frequent Member

  • Advanced user
  • 196 posts
  •  
    Netherlands

Posted 07 October 2023 - 09:50 PM

Version 0.8: https://github.com/deomsh/LIST.G4B
Bugfix: redirect to '">" nul' ending with cat-error
Bugfix: not everything showed with '-ogn/-oge' combined with '-s'
Bugfix: echoing subdirectories if '-s' combined with CMD (without wildcards)
Bugfix: switches '-og' and '-f/-d' not compatible anymore
Bugfix: switch "-col:NXDES': N and DE must be different
Bugfix: with '-e -d -s' if no empty dirs found
Bugfix: with '-w/-c' initial pager status not returned
Bugfix: Better fill-out with '-c'
New: always number of folders/files/total filesize afterwards
         except with '-w/-c': set variable 'COUNT' exported like '-q'
         switch '-n' removed, switch '-q' instead of '-nq'
New: Name starting with dot supported if no Extension exists (linux)
New 'File not found' if no folders/files found
New switch: '-m[n]:FILEx' to parse image files or block device 'regions' with a File System

 

Some action print-screens of new functionality:

 

LIST v0.8 list imagefile, with partiton mbr too.png LIST v0.8 list iso with color, sorting and -s.png LIST v0.8 list El torito boot-image as blocklist on cd.png

 

BTW I added list an iso with '-s' to show parsing of sub-directories, 'FILEx' after '-m[n]:' is showed in parentheses  with '-s' only. A sub-directory of the File System in an image/blocklist can be directly accessed too.

In the background the mapping to (rd) is read-out, at minimum the root '/' is needed as path - device before this path will be ignored. So after such a list there is direct access to all files too on (rd), or in case of partitioned images with (rd,0) etcetera. I use MBR only, maybe someone can test if an image with GPT can be accessed too - watch available (top-)memory!.

Further ALL functions of LIST.G4B are available (or should be :ph34r: ).







Also tagged with one or more of these keywords: grub4dos

1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users