Sujet : Re: saving fileXXX.bmp
De : fir (at) *nospam* grunge.pl (fir)
Groupes : comp.lang.cDate : 26. Mar 2024, 11:59:28
Autres entêtes
Organisation : i2pn2 (i2pn.org)
Message-ID : <utu9q9$33qfv$1@i2pn2.org>
References : 1 2 3 4 5 6 7 8
User-Agent : Mozilla/5.0 (Windows NT 5.1; rv:27.0) Gecko/20100101 Firefox/27.0 SeaMonkey/2.24
fir wrote:
see the code for list (by design i invented working on sickle.c -
those name convention for this list is not yet quite clear as i
generally variables and arrays wrote lettercase but here this
list im not so sure so i used pascals
>
>
void StrCopyMaxNBytes(char* dest, char* src, int n)
{
for(int i=0; i<n; i++) { dest[i]=src[i]; if(!src[i]) break; }
}
>
>
//list
>
const int FileNameListEntry_name_max = 500;
struct FileNameListEntry { char name[FileNameListEntry_name_max]; };
>
FileNameListEntry* FileNameList = NULL;
int FileNameList_Size = 0;
>
void FileNameList_AddOne(char* name)
{
FileNameList_Size++;
FileNameList = (FileNameListEntry*) realloc(FileNameList,
FileNameList_Size * sizeof(FileNameListEntry) );
StrCopyMaxNBytes((char*)&FileNameList[FileNameList_Size-1].name,
name, FileNameListEntry_name_max);
return ;
}
>
ok so to the addtion of container code above this work
WIN32_FIND_DATA ffd;
void ReadDIrectoryFileNamesToList(char* dir)
{
HANDLE h = FindFirstFile(dir, &ffd);
if(!h) ERROR_EXIT("error reading directory");
do {
if (!(ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
FileNameList_AddOne(ffd.cFileName);
}
while (FindNextFile(h, &ffd));
}
int main(void)
{
// ReadDIrectoryFileNamesToList("C:\*");
ReadDIrectoryFileNamesToList("*");
for(int i=0; i< FileNameList_Size; i++)
printf("\n %d %s", i, FileNameList[i].name );
return 'ok';
}
so i got all teh names in list ..eventually i could sort it hovever i got bad experiences with my sorting routine
back then i wanted to revrite quicksort to be as simpel as possible and cookd a form that had an error but lost the ability to say which of the form is correct so i had a sort of quicksort trauma now