|
| 1 | +#include <iostream> |
| 2 | +#include <io.h> |
| 3 | +#include <string.h> |
| 4 | +#include <fstream> |
| 5 | +#include <windows.h> |
| 6 | +using namespace std; |
| 7 | + |
| 8 | + |
| 9 | +string getHtml(const char * path){ |
| 10 | + struct _finddata_t fd; |
| 11 | + const char * mode = "*.gif"; |
| 12 | + char * openstr = new char[strlen(path) + strlen(mode) + 2]; |
| 13 | + memset(openstr,0,strlen(path) + strlen(mode) + 2); |
| 14 | + sprintf(openstr,"%s/%s",path,mode); |
| 15 | + long handle = _findfirst(openstr, &fd); |
| 16 | + if(-1L == handle){ |
| 17 | + return ""; |
| 18 | + } |
| 19 | + string toReturn = ""; |
| 20 | + do{ |
| 21 | + toReturn += "<img src=\'"+string(fd.name)+"\'/><br>"; |
| 22 | + }while(0 == _findnext(handle, &fd)); |
| 23 | + delete openstr; |
| 24 | + openstr = NULL; |
| 25 | + return toReturn; |
| 26 | +} |
| 27 | + |
| 28 | +int main(int argc, char** args) |
| 29 | +{ |
| 30 | + char gifDirectory[MAX_PATH] = {0}; |
| 31 | + if(argc == 1){ |
| 32 | + cout << "input the gif directory:" << endl; |
| 33 | + cin >> gifDirectory; |
| 34 | + }else { |
| 35 | + if(strlen(args[1]) > MAX_PATH){ |
| 36 | + cout << "invalidate gif path" << endl; |
| 37 | + return 0; |
| 38 | + } |
| 39 | + strcpy(gifDirectory,args[1]); |
| 40 | + } |
| 41 | + string html = getHtml(gifDirectory); |
| 42 | + const char * filename = "tmp.html"; |
| 43 | + char * htmlpath = new char[strlen(gifDirectory) + 10]; |
| 44 | + memset(htmlpath, 0, strlen(gifDirectory) + 10); |
| 45 | + sprintf(htmlpath,"%s/%s",gifDirectory,filename); |
| 46 | + fstream f(htmlpath, ios::out | ios::binary); |
| 47 | + f << html; |
| 48 | + delete htmlpath; |
| 49 | + return 0; |
| 50 | +} |
0 commit comments