|
hey all,
i need to know how many sub-directories are under a certain direcotry (could be a hard disk)...
at the moment im using the following code and just wlaking the directory tree but its pretty slow.. can some1 help me out and speed it up (or better yet, tell me the win32 api call i dont know abnout which does this all for me )
<br />
int GetFileFolderCount(char* folder, int recurse, char *ignoreFolders, int *folders)<br />
{<br />
WIN32_FIND_DATA FindFileData;<br />
HANDLE hFind;<br />
int fileFound = 1;<br />
int len = strlen(folder)+5;<br />
char *searchPath = (char*)malloc(len);<br />
if (!searchPath) return 0;<br />
if (folder[strlen(folder)-1]=='\\')<br />
folder[strlen(folder)-1] = '\0';<br />
_snprintf(searchPath,len ,"%s\\*.*",folder);<br />
hFind = FindFirstFile(searchPath, &FindFileData);<br />
if (hFind == INVALID_HANDLE_VALUE) return 0;<br />
<br />
while (fileFound && continueSearch)<br />
{<br />
if (recurse && FindFileData.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY)<br />
{<br />
char *newSearch;<br />
if (!strcmp(FindFileData.cFileName,".") || !strcmp(FindFileData.cFileName,".."))<br />
{<br />
fileFound = FindNextFile(hFind,&FindFileData);<br />
continue;<br />
}<br />
len = strlen(folder)+strlen(FindFileData.cFileName)+5;<br />
newSearch = (char*)malloc(len);<br />
if (!newSearch) return 0;<br />
_snprintf(newSearch,len,"%s\\%s\0",folder,FindFileData.cFileName);<br />
if (!ignorefolder(newSearch,ignoreFolders))<br />
{<br />
(*folders)++;<br />
GetFileFolderCount(newSearch,recurse,ignoreFolders ,folders);<br />
}<br />
free(newSearch);<br />
}<br />
else if (!recurse && FindFileData.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY)<br />
{<br />
fileFound = FindNextFile(hFind,&FindFileData);<br />
continue; <br />
}<br />
fileFound = FindNextFile(hFind,&FindFileData);<br />
}<br />
FindClose(hFind);<br />
free(searchPath);<br />
return 1;<br />
}<br />
thanx
|
|
|
|
|
that is exactly how I would do it, I don't see anything you can do to speed it up. There is no win32 api to do directly what you want.
-- Rocky Dean Pulley
|
|
|
|
|
hello everybody,
i know, it's been few times i've asked this already, but as i didn't took notes and apply the answers, i cannot find them anymore ...
the only thing i remember is that Mr Alok did answer usefully my request (that was a function like FilePathExists() , but i can't find it. was it really that ?).
so, the question is :
i'd like to check (when i get a File path and name throw GetSaveFileName() - MFC) to check whether the file really exist or not.
As precision, i am working both on VC++ + and .NET 2003, and still MFC.
thanks in advance.
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Shell function is PathFileExists
MFC function is CFile::GetStatus
Pssst. You see that little light on your monitor? That's actually a government installed spy camera. Smile and wave to big brother!
|
|
|
|
|
Jack Squirrel wrote:
Shell function is PathFileExists
argglll, here is why i could find it
very thank you jack
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
What About Runtime Function
_access
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
:s i'm not really enjoying programming that way... but that's only my feeling
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
toxcct wrote:
that's only my feeling
You still remember that
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
And if you want to avoid the shell altogether, then you can use the Win32 API GetFileAttributes and look for (DWORD)-1 as return code.
|
|
|
|
|
Please could you help me develop a game for my project.
It has to be in for the end of the week (Friday), all that needs to be produced is a one level game with possibly two moving characters, some sound and collision detection.
Any help would be greatly appreciated.
Cheers.
|
|
|
|
|
You can try this:
Egg Catcher Game[^]
It is written in Turbo C++, offcourse By me
needinghelpp wrote:
two moving characters
It Has.
needinghelpp wrote:
some sound and collision detection.
Yes, Both
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
Thank you for your reply.
The program i need to create unfortunately has got to be made using <windows.h> and use direct x 9. (as this is what we're being taught on the course).
Thanks for your help.
|
|
|
|
|
|
|
hi
i want to place tabs at bottom of my property sheet (CPropertySheet derived class), by default they appear at top.
can any one plz help me in this regard
Azam
|
|
|
|
|
hi,
I have declared a macro as #define x 100.
i am having a text file.within the text file i have 'x'.
How can i read it as symbol constant x instaed of string "x".
otherwise is possible to convert the string "x" into symbol constant x
Thanks and regards,
chezhian
|
|
|
|
|
you concatenate the string with x, so, it is not directly written into a string. this way, it will be evaluated by the preprocessor...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
i didn't concatenate anything with x. while reading by default it is considered as a string.
|
|
|
|
|
|
That's very tough to do. You must understand that the preprocessor only acts on your source file. So you essentially have to convert your text file to a compilable C++ (or C) file and then run the preprocessor over it to make it treat x as a symbol.
Instead, I'd suggest that you create a table where you store strings versus values and then use that table to figure out the value, given a string like "x".
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Hi everybody,
I have a program running in tray , but when the user clicks in the caption bar the 'x' button i want that my program did'nt exit.it should simply continue working in tray .
My problem is not to Hide the dialog so that it worked in tray, but to catch that user clicked 'x' button
How can i do it?
Regards
m0n0
|
|
|
|
|
Giorgi Moniava wrote:
when the user clicks in the caption bar the 'x' button i want that my program did'nt exit
Handle OnCancel() Virtual Function
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
I had a default Cancel button with code :
void CRemindMEDlg::OnBnClickedCancel()
{
Shell_NotifyIcon(NIM_DELETE, &tnid);
OnCancel();
}
if i changed OnCancel(); simply with ShowWindow(SW_HIDE)
then 'x' button would work correctly , but Cancel button No.
So thanks to your Advice and Ravi Bhavnani -s , i ve done next
void CRemindMEDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if(nID==SC_CLOSE) bClose=false;
CDialog::OnSysCommand(nID, lParam);
}
and OnBnClickedCancel()changed to :
void CRemindMEDlg::OnBnClickedCancel()
{
if(bClose) { OnCancel();Shell_NotifyIcon(NIM_DELETE,&tnid);}
else {CDialog::ShowWindow(SW_HIDE);bClose=true;}
}
Now it works ,
Thanks to both of you for attention.
m0n0
|
|
|
|
|
Handle WM_SYSCOMMAND and check for the case SC_CLOSE .
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
thanks
m0n0
|
|
|
|