/* * Concordance Programming Language * Utility to recursively reindex all databases from all subdirectories. * Copyright (C) 2002 Dataflight Software, Inc. ALL RIGHTS RESERVED. * Dataflight Software and Concordance are registered trademarks of Dataflight Software, Inc. * * Dataflight Software, Inc. * 2337 Roscomare Road, Suite 11 * Los Angeles, CA 90077 * */ /* Add your user name and password if the databases are password protected. */ /* Type in the name and password within the quotes. */ text szUser = ""; text szPassword = ""; /* Add the initial directory to begin the reindexing; if left blank, */ /* the program will prompt the user for the initial directory. */ /* Type in the initial directory within the quotes, including drive */ /* letter, colon, and backslashes, i.e. "C:\path\more path\" */ text szInitialDirectory = "f:\data\"; main() { char string[256]; int db, i, j; text pszPath, pszMask; i = messageBox("This program will reindex databases in a top level directory"+newline()+ "and recursively through all subdirectories." +newline() + newline() + "Would you like to do this now?", "Reindexing Daemon (Recursive)", MB_ICONQUESTION | MB_YESNO); if (i <> IDYES) return; /* Close any top level database */ closedb(0); if (szInitialDirectory == "") getfile("DCB files", "*.DCB", string, OFN_NOVALIDATE); else { string = szInitialDirectory; if (string[len(string) - 1] <> '\') string = string + "\*.DCB"; else string = string + "*.DCB"; } if (string <> "") { /* If the user specified a single file, then reindex it. */ if (exist(string)) { if ((db = opendb(string, szUser, szPassword)) <> EOF) { reindex(db); closedb(db); } } else { /* The file does not exist. Assume that the path has a */ /* wild card in it. Find the wild card and separate */ /* the path from the wild card specification. */ for(i = 0; string[i]; i = i + 1) if (string[i] == '\') j = i; pszPath = substr(string, 1, j + 1); pszMask = substr(string, j + 2); /* Confirm that the user wants to import the files, then call importPDF() to process the files and subdirectories. */ if (messageBox("Reindex all databases from "+pszPath+" and all subdirectories?", program(), MB_YESNO) == IDYES) ReindexDatabases(db, pszPath, pszMask); } } } /* main() */ ReindexDatabases(int db; text pszPath; text pszMask) { char szFile[256]; text szPath; int i, length, db; /* First reindex all DCB files in the current directory. */ chdir(pszPath); for(szFile = findfirst(pszPath+pszMask, 0); szFile[0]; szFile = findnext()) { Message("Reindexing "+pszPath + szFile, FALSE); if ((db = opendb(pszPath + szFile, szUser, szPassword)) <> EOF) { reindex(db); closedb(db); } } /* Now process all subdirectories. */ for(szFile = findfirst(pszPath+"*.*", 16); szFile[0]; szFile = findnext()) { /* Build a list of every path except . and .. */ if ((szFile <> ".") and (szFile <> "..")) szPath = trim(szPath + newline() + szFile); } /* Now call ourselves recursively to process each subdirectory. */ if (len(szPath) > 0) for(i = findline(szPath, 1, length); i <> 0; i = findnline(szPath, i, length)) { ReindexDatabases(db, pszPath+substr(szPath, i, length)+"\", pszMask); } } /* ConvertDatabases() */ RGB(char red, grn, blu) { return(((blu & 255) * 65536) | ((grn & 255) * 256) | (red & 255)); } /**************************************************************** * Name: Message * * Synopsis: Displays error message and waits for key. * ****************************************************************/ Message(text message; int wait) { text screen; int key; cursoroff(); if (wait) screen = save(5,13,8,96); box(5,13,7,96, "3D", RGB(160, 160, 160), RGB(190, 190, 190)); puts(6,14,pad(message,'C',80), RGB(0,0,0), RGB(190, 190, 190)); if (wait) { key = getkey(); restore(5,13,screen); } return(asc(upper(chr(key)))); } /* Message() */