Skip to content

Commit 8a31319

Browse files
committed
组织一个页面中的gif,生成html页面
1 parent 20d2827 commit 8a31319

6 files changed

Lines changed: 106 additions & 0 deletions

File tree

Binary file not shown.
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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+
}
33.6 KB
Binary file not shown.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
2+
<CodeBlocks_project_file>
3+
<FileVersion major="1" minor="6" />
4+
<Project>
5+
<Option title="查看gif文件夹,生成html页面" />
6+
<Option pch_mode="2" />
7+
<Option compiler="gcc" />
8+
<Build>
9+
<Target title="Debug">
10+
<Option output="bin\Debug\查看gif文件夹,生成html页面" prefix_auto="1" extension_auto="1" />
11+
<Option object_output="obj\Debug\" />
12+
<Option type="1" />
13+
<Option compiler="gcc" />
14+
<Compiler>
15+
<Add option="-g" />
16+
</Compiler>
17+
</Target>
18+
<Target title="Release">
19+
<Option output="bin\Release\查看gif文件夹,生成html页面" prefix_auto="1" extension_auto="1" />
20+
<Option object_output="obj\Release\" />
21+
<Option type="1" />
22+
<Option compiler="gcc" />
23+
<Compiler>
24+
<Add option="-O2" />
25+
</Compiler>
26+
<Linker>
27+
<Add option="-s" />
28+
</Linker>
29+
</Target>
30+
</Build>
31+
<Compiler>
32+
<Add option="-Wall" />
33+
<Add option="-fexceptions" />
34+
</Compiler>
35+
<Unit filename="main.cpp" />
36+
<Extensions>
37+
<code_completion />
38+
<debugger />
39+
</Extensions>
40+
</Project>
41+
</CodeBlocks_project_file>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# depslib dependency file v1.0
2+
1491195718 source:c:\users\administrator\desktop\�鿴gif�ļ��У�����htmlҳ��\main.cpp
3+
<iostream>
4+
<io.h>
5+
<string.h>
6+
<fstream>
7+
<windows.h>
8+
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
2+
<CodeBlocks_layout_file>
3+
<ActiveTarget name="Debug" />
4+
<File name="main.cpp" open="1" top="1" tabpos="1">
5+
<Cursor position="480" topLine="6" />
6+
</File>
7+
</CodeBlocks_layout_file>

0 commit comments

Comments
 (0)