File tree 1 file changed +47
-0
lines changed
1 file changed +47
-0
lines changed Original file line number Diff line number Diff line change
1
+ #include < iostream>
2
+ #include < vector>
3
+ #include < string>
4
+ #include < sstream>
5
+
6
+ using namespace std ;
7
+
8
+ // Function to split a string by specified delimeter.
9
+ vector<string> split (string str, char delimiter) {
10
+ vector<string> internal;
11
+ stringstream ss (str); // Turn the string into a stream.
12
+ string tok;
13
+
14
+ while (getline (ss, tok, delimiter)) {
15
+ internal.push_back (tok);
16
+ }
17
+
18
+ return internal;
19
+ }
20
+
21
+ // Function to reverse a string.
22
+ void reverseStr (string& str)
23
+ {
24
+ int n = str.length ();
25
+
26
+ // Swap character starting from two
27
+ // corners
28
+ for (int i = 0 ; i < n / 2 ; i++)
29
+ swap (str[i], str[n - i - 1 ]);
30
+ }
31
+
32
+ void path_check (std::string &path){ // FIXME check if path exists
33
+
34
+ std::string last = path.substr (path.size (),1 );
35
+ if (last != " /" ){
36
+ path = path + " /" ;
37
+ }
38
+
39
+ }
40
+
41
+ void delete_file (std::string file_name){
42
+
43
+ if (remove (file_name.c_str ()) != 0 ){
44
+ perror (" Error deleting a file\n " );
45
+ }
46
+
47
+ }
You can’t perform that action at this time.
0 commit comments