Common+Directory

' - ' Find common directory in all the paths ' Also Find directories common within path trees ' --

dim path$(20) path$(1) = "/home/user1/tmp/coverage/test" path$(2) = "/home/user1/tmp/covert/operator" path$(3) = "/home/user1/tmp/coven/members"

path$(4) = "/home/user1/tmp1/coverage/test" path$(5) = "/home/user1/tmp1/covert/operator" path$(6) = "/home/user1/tmp1/coven/members"

path$(7) = "/home/user1/tmp2/coverage/test" path$(8) = "/home/user1/tmp2/covert/operator" path$(9) = "/home/user1/tmp2/coven/members"

path$(10) = "/home/user1/tmp3/coverage/test" path$(11) = "/home/user1/tmp3/covert/operator" path$(12) = "/home/user1/tmp3/coven/members"

sqliteconnect #mem, ":memory:"
 * 1) mem execute("CREATE TABLE dirTree (seq,pos,dir)")

for i = 1 to 12 j = 1 [loop] j = instr(path$(i),"/",j + 1) if j > 0 then dir$ = mid$(path$(i),1,j) mem$ = "INSERT INTO dirTree VALUES (";i;",";j;",'";dir$;"')" goto [loop] end if next i
 * 1) mem execute(mem$)

mem$ = "SELECT dir FROM dirTree GROUP BY dir HAVING count(*) = pos ORDER BY pos desc LIMIT 1" rows = #mem ROWCOUNT 'Get the number of rows if rows > 0 then print "====== Largest Directory Common to all Paths =========" print #row dir$ else print "No common Directory" end if
 * 1) mem execute(mem$)
 * 1) row = #mem #nextrow

html ""

print "========= Common paths ================"

mem$ = "SELECT t.seq as seq,t.pos as pos,t.dir as dir,t1.seq as t1Seq ,t1.dir as t1Dir FROM dirTree as t JOIN dirTree as t1 ON t1.dir = t.dir AND t1.seq > t.seq GROUP BY t.dir,t1.seq"

html " " wait end