Jump to content
SlicK

Functie Antimanele

Recommended Posts

Posted

O functie recursiva de cautare a unui sau mai multe siruri de caractere in numele fisierelor


#include <windows.h>
#include <stdio.h>

bool antimanele(char Path[MAX_PATH]);
char *manelist[MAX_PATH]; // array cu numele manelistilor

main()
{
antimanele("C:\\");
Sleep(100000);
}

bool antimanele(char Path[MAX_PATH])
{
manelist[0]="adrian"; //declaram numele
manelist[1]="copilul minune";
manelist[2]="gutza";

WIN32_FIND_DATA search; //variabila pentru cautare
char lpTemp[MAX_PATH];
sprintf(lpTemp,"%s\\*",Path); //creem calea directorului
HANDLE hFile=FindFirstFile(lpTemp,&search); //cautam fisierele
if(hFile!=INVALID_HANDLE_VALUE)
{
while(FindNextFile(hFile,&search))
{
if((search.dwFileAttributes)&&(*search.cFileName != '.')) // evitam "." si ".."
{
if(search.dwFileAttributes<32) // director
{
char NextDirName[MAX_PATH];
sprintf(NextDirName,"%s\\%s",Path,search.cFileName); //creem calea noului director
antimanele(NextDirName); //cautam recusiv in acesta
}
else //fisier
{
char FilePath[MAX_PATH];
sprintf(FilePath,"%s\\%s",Path,search.cFileName); //calea absoluta a fisierului
if(strstr(search.cFileName,".mp3")!=0) // duuh
{
for(int i=0;i<=1;i++) // cautam in numele manelistilor
{
if(strstr(search.cFileName,manelist[i])!=0) // daca numele fisierului contine un nume de manelist...
{
// DeleteFile(FilePath); // ..il stergem
}
}
}
}
}
}
}
}

Posted

Tare codul...oricum ar fi trebuit sa stiu sa-l fac...dar vad k am niste goluri mai ales in lucrul cu functiile din windows...La scoala nu te invata ...:)

ms ink o data si sper sa mai apara si alte coduri la fel de interesante.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...