I have to publish drawings to a path that I have no control over. To this end I am writting a routine to find a file using a recursive search of sub-directories, and return it's path (still incomplete). My C++ coding is not advanced (I'm still weak with pointers and classes), but it is improving.
The code below compiles fine and loads into AutoCAD no problem, but when I run it I get a fatal exception.
static void FileLocator_FileLocator() {
TCHAR * SearchRootPath = NULL;// = _T("Hold");
(acedGetString (1, _T("\nEnter Search Directory Path: "), SearchRootPath));
TCHAR * SearchFileName = NULL;
(acedGetString (1, _T("\nEnter Search File Name: "), SearchFileName));
TCHAR * SearchWildCard = NULL;
(acedGetString (1, _T("\nEnter Directory Wildcard Filter<*.*>: "), SearchWildCard));
FileCheck (SearchRootPath, SearchFileName, SearchWildCard);
}// FileLocator
//
//
//
static void FileCheck (CString RootPath, CString FileName, CString DirWildCard){
int Count = 0;
CString CrntSubDir;
CString NewSubDirPath;
CFileFind finder;
if (DirWildCard){
DirWildCard = "*.*";
};
bool Testing = finder.FindFile (RootPath+DirWildCard);
TrueFalseTest (Testing, "Root Path Tested ");
while (Testing)
{
if ((finder.MatchesMask(FILE_ATTRIBUTE_DIRECTORY)) && ((finder.IsDots()) == 0))
{
if (RootPath.Right(1) != _T("\\")){
CrntSubDir = _T("\\")+finder.GetFileName();
};// if
acutPrintf (_T("\nSub-Directory: %s\n"), CrntSubDir);
NewSubDirPath = RootPath + CrntSubDir;
acutPrintf (_T("\nNext Sub-Directory: %s\n"), NewSubDirPath);
}// If MatchesMask
else {
acutPrintf (_T("\nFileName: %s"), (LPCTSTR) finder.GetFileName());
}// else
if (Count < 1000) {
Count++;
}// if Failsafe counter
else if (Count >= 1000){
Testing = FALSE;
}// Failsafe reached
Testing = finder.FindNextFile();
}// while
acutPrintf (_T("\nCount = %d"), Count);
}// Filecheck
My current configuration is as follows:
Window 7 and AutoCAD 2012(64bit)
Visual Studio 2008
3.47GHz dual processor 6 core
24Gig RAM
Invidia Quadro 4000
238Gig SSD
I tested this using VS2008, AutoCAD 2010 on a 32bit XP machine and the same thing happened. I'll would be happy for any help or advise, what have I done wrong.
Thanks again for your help.
Shawndoe