ASPL Guide to Operations v 1.00
© 2024 by SetSphere.COM


3. 14
   ggdir primitive to get the group of directories

 

logo

ggdir(dir,pathname)     where pathname is a user specified path to a directory on the UNIX system

ggdir  GADg  1            ous:H_H_H_H

●  Operator ggdir primitive to get the group of directories

Use the primitive function ggdir() to glob directories on the UNIX system. This function is defined the context of the POSIX grouping class.

 

ggdir EXAMPLE1
The script createtestff.pl creates test directories, subdirectories, and files on the UNIX system. In this example, we create a directory structure in /tmp/junk to show how to glob directories and test with ASPL operators. We start ASPL loading the sample workspace TESTGGDIR. We issue the ggdir() function to glob the directories /tmp/junk/dir1 and /tmp/junk/dir2.

 

ggdir OPERATION1

mkdir /tmp/junk
    (create the directory /tmp/junk)

createtestff.pl /tmp/junk
    (run createtestff.pl to create the directory structure)

tree /tmp/junk
    (view the directory structure in /tmp/junk)

tree -d /tmp/junk
    (view the subdirectories in the directory structure)

aspl -wsname TESTGGDIR -groupingclass POSIX
    (start ASPL loading the sample workspace TESTGGDIR)

①  aspl> egCwhoami
    (ping the grouping class)

②  aspl> ggls ggdir()
    (display the ggdir() function)

③  aspl> ggls ggdir
    (list all ggdir related functions)

④  aspl> timeout 90
    (set timeout to 90 seconds in case your system is too slow)

⑤  aspl> sudir1 = ggdir(dir,/tmp/junk/dir1/subdir1.1/subdir1.2)
    (sudir1 set variable is assigned the directory /tmp/junk/dir1/subdir1.1/subdir1.2)

⑥  aspl> sudir2 = ggdir(dir,/tmp/junk/dir2/subdir2.1/subdir2.2)
    (sudir2 set variable is assigned the directory /tmp/junk/dir2/subdir2.1/subdir2.2)

⑦  aspl> sim sudir1 sudir2
    (display the similarity between sudir1 sudir2)

⑧  aspl> f& sudir1 sudir2
    (display the elements (files) intersection between sudir1 and sudir2)

⑨  aspl> g& sudir1 sudir2
    (display the elements (files) intersection between sudir1 and sudir2)

⑩  aspl> d& sudir1 sudir2
    (display the subgroups (subdirectories) intersection between sudir1 and sudir2)

⑪  aspl> dD sudir1 sudir2
    (display the subgroups (subdirectories) symmetric difference between sudir1 and sudir2)

⑫  aspl> d\ sudir1 sudir2
    (display the subgroups (subdirectories) symmetric difference between sudir1 and sudir2)

⑬  aspl> d\ sudir2 sudir1
    (display the subgroups (subdirectories) symmetric difference between sudir2 and sudir1)

⑭  aspl> dU sudir1 sudir2
    (display the subgroups (subdirectories) union between sudir1 and sudir2)

⑮  aspl> dir1 = ggdir(dir,/tmp/junk/dir1)
    (dir1 set variable is assigned the directory /tmp/junk/dir1)

⑯  aspl> dir2 = ggdir(dir,/tmp/junk/dir2)
    (dir2 set variable is assigned the directory /tmp/junk/dir2)

⑰  aspl> f& dir1 dir2
    (display the elements intersection between dir1 and dir2)

⑱  aspl> y*& dir1 dir2
    (fuzzy match the elements and display the comparison)

 

ggdir EXAMPLE2
In this example we start ASPL loading the sample workspace TESTGGDIR. We issue the ggdir() function to glob the directories /tmp/testfinder/fuudir and /tmp/testfinder/locadir.

 

ggdir OPERATION2

aspl -wsname TESTGGDIR -groupingclass POSIX
    (start ASPL loading the sample workspace TESTGGDIR)

①  aspl> egCwhoami
    (ping the grouping class)

②  aspl> fuudir = ggdir(dir,/tmp/testfinder/fuudir)
    (fuudir set variable is assigned the directory /tmp/testfinder/fuudir)

③  aspl> locadir = ggdir(dir,/tmp/testfinder/locadir)
    (locadir set variable is assigned the directory /tmp/testfinder/locadir)

④  aspl> display fuudir
    (display the set variable fuudir)

⑤  aspl> f& fuudir locadir
    (display the intersection between fuudir and locadir)

⑥  aspl> sim fuudir locadir
    (display the similarity between fuudir and locadir)

 

ggdir EXAMPLE3
In this example we compare the naming classes of JNDI Jar files. Three JNDI Jar files are extracted in /tmp/JNDI/jndi1, /tmp/JNDI/jndi2, and /tmp/JNDI/jndi3. We start ASPL loading the sample workspace TESTGGDIR, then we issue the ggdir() to glob the directories into set variables. We issue set operators to compare the extracted Jar files.

 

ggdir OPERATION3

aspl -wsname TESTGGDIR -groupingclass POSIX
    (start ASPL loading the sample workspace TESTGGDIR)

①  aspl> naming1 = ggdir(dir,/tmp/JNDI/jndi1/javax/naming)
    (naming1 set variable is assigned the directory /tmp/JNDI/jndi1/javax/naming)

②  aspl> naming2 = ggdir(dir,/tmp/JNDI/jndi2/javax/naming)
    (naming2 set variable is assigned the directory /tmp/JNDI/jndi2/javax/naming)

③  aspl> naming3 = ggdir(dir,/tmp/JNDI/jndi3/javax/naming)
    (naming3 set variable is assigned the directory /tmp/JNDI/jndi3/javax/naming)

④  aspl> f& naming1 naming2 naming3
    (display the intersection between naming1 naming2 naming3)

⑤  aspl> fU naming1 naming2 naming3
    (display the intersection between naming1 naming2 naming3)

⑥  aspl> sim naming1 naming2 naming3
    (display the similarity between naming1 naming2 naming3)