-
Notifications
You must be signed in to change notification settings - Fork 0
/
LJFS_Utils.cpp
52 lines (43 loc) · 931 Bytes
/
LJFS_Utils.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
// Luke Schlather
// Thursday, September 10 2009
// Licensed under the LGPL
#include<iostream>
#include<cstdlib>
using namespace std;
void checkContinue(string message) {
string input;
cout << "Warning: " << message << endl;
cout << "Continue: (y/n)" << endl;
cin >> input;
if ((input!="y")&&(input!="Y")) {
exit(1);
}
}
string filenameSansExtension(string filename) {
int i=0;
for (i=filename.size()-1;i>=0;--i) {
if(filename[i]=='.') {
break;
}
}
return filename.substr(0,i);
}
string filenameExtension(string filename) {
int i=0;
for (i=filename.size()-1;i>=0;--i) {
if(filename[i]=='.') {
break;
}
}
return filename.substr(i+1,filename.size());
}
string printCurrentTime() {
char buffer[100];
time_t t=time(0);
struct tm *tmp;
tmp = localtime(&t);
strftime(buffer,40,"%F_%H.%M.%S",tmp);
string now(buffer);
cout << now << endl;
return now;
}