All pastes #436135 Raw Edit

Stuff

public cpp v1 · immutable
·published 2007-04-12 11:24 UTC
rendered paste body
#include <cstdlib>#include <iostream>#include <windows.h>#include <vector>#include <fstream>using namespace std;int main(int argc, char *argv[]){          int filescount = 0,count = 0,anzahl = 0,size;   string endung,ausgabe,klein;  string html = "<html>\n <Head><Title>Bilder</Title></head>\n <Body><Table border = \"1\"><tr>";    ofstream log;    HANDLE fHandle;  WIN32_FIND_DATA wfd;    char *pfad = "*";  //Anzahl der Dateien Rausfinden:**********************************************  fHandle=FindFirstFile(pfad,&wfd);  while (FindNextFile(fHandle,&wfd))       if (!(wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) filescount++;  FindClose(fHandle);    //****************************************************************************    int index = 0;   char *array[filescount-1];  //String Array Anlegen    // Das ganze noch einmal und dabei die Pfäde in das Array eintragen  fHandle=FindFirstFile(pfad,&wfd);  while (FindNextFile(fHandle,&wfd))       if (!(wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))     {       array[index] = (char*)malloc(MAX_PATH);         //Speicher für den String reservieren      memcpy(array[index], wfd.cFileName, MAX_PATH);  //Pfad in das Array Kopieren      index++;                                        //Nächstes Element    }  FindClose(fHandle);      //Resultate Ausgeben  printf("Anzahl der Dateien:%d\n\n",filescount);  for (index=0; index<filescount; index++){             count = strlen(array[index]);                    endung = "";          endung.push_back(array[index][count -4]);          endung.push_back(array[index][count -3]);          endung.push_back(array[index][count -2]);          endung.push_back(array[index][count -1]);                    count = endung.size();          klein.clear();               for(int i = 0;i < count;i++) {                     klein.push_back(tolower(endung[i]));                     }                                            if((klein == ".gif") || (klein == "jpeg")  || (klein == ".jpg") || (klein == ".bmp")) {                                  html = html += "<td><img width =";                                  html = html += "\"500\"";                                  html = html += " src=\"";                                  html = html += array[index];                                  html = html += "\"></td></tr>\n";                                                                  }                                else {                                       anzahl++;                                      }                                                                }                   if(anzahl == filescount) {                     log.open("logfile.txt");                     log<<"Gefundene Dateien:\n";                            for(int i = 0;i < filescount;i++) {                                 log<<array[i]<<"\n";                              }                              log<<"KEINE BILDDATEI GEFUNDEN";                              log.close();                    }                     else {         html += "</table>\n<body>\n</html>";           ofstream file;           file.open("Bilder.htm");           file<<html;           file.close();                          log.open("logfile.txt");                     log<<"Gefundene Dateien:\n";                            for(int i = 0;i < filescount;i++) {                                 log<<array[i]<<"\n";                              }                              log<<"Bilddatei(en) gefunden, html-datei erstellt.";                              log.close();                             } return 0;}