http://prdownloads.sourceforge.net/lufs/lufs-0.9.6.tar.gz?download
[lufs.git] / filesystems / wavfs / tools.cpp
1 #include <fcntl.h>
2 #include <unistd.h>
3
4 #include <vector>
5 #include <string>
6
7 #include <lufs/proto.h>
8 #include <lufs/fs.h>
9
10 using namespace std;
11
12 #include "tools.h"
13
14 bool endswith( const char* s, const char* end )
15 {
16         int ls = strlen(s);
17         int le = strlen(end);
18         if(le>ls) return false;
19                 
20         return !strcmp(s+ls-le,end);
21 }
22
23 string removeend( const char* s, const char* end) 
24 {
25         int ls = strlen(s);
26         int le = strlen(end);
27         if(le>ls) 
28                 return string();
29                 
30         if(strcmp(s+ls-le,end))
31                 return string();
32         
33         return string(s, ls-le);
34 }
35
36 string mktemp(const char* base)
37 {
38         char buf[2048];
39         sprintf(buf,"/var/tmp/lufs-%s-%d", base, rand());
40         return buf;
41 }