-
Notifications
You must be signed in to change notification settings - Fork 0
/
filelib.cpp
47 lines (38 loc) · 837 Bytes
/
filelib.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
//
// Created by conor on 2/25/2018.
//
#include <fstream>
#include "filelib.h"
#include "atr2func.h"
filelib::filelib() {
}
bool filelib::exist(std::string thisfile) {
std::ifstream testopen(thisfile);
return testopen.good();
}
std::string filelib::base_name(std::string name) {
int k;
std::string s1, s2;
s1.clear();
s2.clear();
k = 0;
while ((k < name.length()) && (name[k] != '.')) {
s1 = s1 + name[k];
k++;
}
return s1;
}
std::string filelib::no_path(std::string fn) {
int i, k;
k = 0;
for (i = fn.length() - 1; i >= 0; i--) {
if(((fn[i] == '\\') || (fn[i] == ':') || (fn[i] == '/')) && (k < i)) {
k = i;
}
}
if (k != 0) {
return atr2func::rstr(fn, fn.length() - k - 1);
} else {
return fn;
}
}