Subversion Repositories spk

Rev

Rev 1 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1 Rev 114
Line 1... Line -...
1
//#include "../filedriver/new.cpp"
-
 
2
 
-
 
3
#include <stdarg.h>
1
#include <stdarg.h>
4
#include <math.h>
2
#include <math.h>
5
#include "strutils.h"
3
#include "strutils.h"
6
//---------------------------------------------------------------------------------
4
//---------------------------------------------------------------------------------
7
char ** strexplode(char separator, char *string, size_t *size, size_t limit)
5
char ** strexplode(char separator, char *string, size_t *size, size_t limit)
8
{
6
{
9
	size_t len=strlen(string);
7
	size_t len=strlen(string);
10
	char *pos=string, *old=string, *end = string + len;
8
	char *pos=string, *old=string, *end = string + len;
11
	char **array;
9
	char **array;
Line 24... Line 22...
24
 
22
 
25
	return array;
23
	return array;
26
}
24
}
27
//---------------------------------------------------------------------------------
25
//---------------------------------------------------------------------------------
28
char * ExtractFileName(const char *pszPath, bool bNoExtension)
26
char * ExtractFileName(const char *pszPath, bool bNoExtension)
29
{
27
{
30
	const char *end=pszPath + strlen(pszPath);
28
	const char *end=pszPath + strlen(pszPath);
31
	char *pos=(char *)strrchr(pszPath, '\\');
29
	char *pos = const_cast<char*>(strrchr(pszPath, '\\'));
32
	if(pos==NULL) pos=(char*)pszPath - 1;
30
	if(pos==NULL) pos=(char*)pszPath - 1;
33
	char *str=new char[end-pos + 1];
31
	char *str=new char[end - pos + 1];
34
	memcpy(str, ++pos, end-pos + 1);
32
	memcpy(str, ++pos, end - pos + 1);
35
	if(bNoExtension){
33
	if(bNoExtension){
36
		pos=strrchr(str, '.');
34
		pos=strrchr(str, '.');
37
		if(pos) *pos=0;
35
		if(pos) *pos=0;
38
	}
36
	}
39
	return str;
37
	return str;
40
}
38
}
41
//---------------------------------------------------------------------------------
39
//---------------------------------------------------------------------------------
-
 
40
#ifdef STRUTILS_WIN_WCHAR
-
 
41
wchar_t * ExtractFileNameW(const wchar_t *pszPath, bool bNoExtension)
-
 
42
{
-
 
43
	const wchar_t *end=pszPath + wcslen(pszPath);
-
 
44
	wchar_t *pos=wcsrchr(pszPath, '\\');
-
 
45
	if(pos==NULL) pos=(wchar_t*)pszPath - 1;
-
 
46
	wchar_t *str=new wchar_t[end - pos + 1];
-
 
47
	memcpy(str, ++pos, (end - pos + 1) * sizeof(wchar_t));
-
 
48
	if(bNoExtension){
-
 
49
		pos=wcsrchr(str, '.');
-
 
50
		if(pos) *pos=0;
-
 
51
	}
-
 
52
	return str;
-
 
53
}
-
 
54
//---------------------------------------------------------------------------------
-
 
55
#endif
-
 
56
 
42
char * ExtractFilePath(const char *pszPath)
57
char * ExtractFilePath(const char *pszPath)
43
{
58
{
44
	char *pos=(char *)strrchr(pszPath, '\\');
59
	const char *pos=strrchr(pszPath, '\\');
45
	char *path=NULL;
60
	char *path = NULL;
46
	if(pos){
61
	if(pos){
47
		path=new char[pos - pszPath + 1];
62
		path = new char[pos - pszPath + 1];
48
		memcpy(path, pszPath, pos - pszPath);
63
		memcpy(path, pszPath, pos - pszPath);
49
		path[pos - pszPath]=0;
64
		path[pos - pszPath] = 0;
50
	}
65
	}
51
	return path;
66
	return path;
52
}
67
}
53
//---------------------------------------------------------------------------------
68
//---------------------------------------------------------------------------------
54
char * strcat2(int num, ...)
69
char * strcat2(int num, ...)
Line 172... Line 187...
172
		int v=str[last] | 0x20;
187
		int v=str[last] | 0x20;
173
		if(!((v >= '0' && v <='9') || (v >= 'a' && v <='f')))
188
		if(!((v >= '0' && v <='9') || (v >= 'a' && v <='f')))
174
			break;
189
			break;
175
	}
190
	}
176
	
191
	
177
	for(size_t i=last - 1; (int)i >= 0; i--){
192
	for(size_t i = last - 1; (int)i >= 0; i--){
178
		v=str[i] | 0x20;
193
		v = str[i] | 0x20;
179
		if(v >= 'a')
194
		if(v >= 'a')
180
			v-=87;
195
			v-=87;
181
		else
196
		else
182
			v-=48;
197
			v-=48;
183
			
198
			
184
		val+=v * (int)pow(16.0f, (int)(last - i - 1));
199
		val += v * (int)pow(16.0, (int)(last - i - 1));
185
	}
200
	}
186
	if(neg)	val*=-1;
201
	if(neg)	val*=-1;
187
	return val;
202
	return val;
188
}
203
}
189
//---------------------------------------------------------------------------------
204
//---------------------------------------------------------------------------------