-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFileCompress.cpp
More file actions
36 lines (33 loc) · 948 Bytes
/
FileCompress.cpp
File metadata and controls
36 lines (33 loc) · 948 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include "FileCompress.h"
FileCompress :: FileCompress(char *_buf, miniFileInfo *_fileInfo, int _fileNum)
{
strcpy(bufDir, _buf);
fileInfo = _fileInfo;
fileNum = _fileNum;
SECURITY_ATTRIBUTES attribute;
attribute.nLength = sizeof(attribute);
attribute.lpSecurityDescriptor = NULL;
attribute.bInheritHandle = FALSE;
CreateDirectory(bufDir, &attribute);
for (int i = 0; i < fileNum; i++)
{
printf("~%s\n", fileInfo[i].fileName);
compressMono(fileInfo[i].fileName, i);
}
}
bool FileCompress :: compressMono(char *fileName, int n)
{
FILE *fin, *fout;
char bufName[MAXLEN], ss[MAXLEN];
strcpy(bufName, bufDir);
sprintf(ss, "%d", n);
strcat(bufName, ss);
fin = fopen(fileName, "rb");
fout = fopen(bufName, "wb");
char t;
while (fread(&t, sizeof(char), 1, fin))
fwrite(&t, sizeof(char), 1, fout);
fclose(fin);
fclose(fout);
return true;
}