-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMU_path.h
More file actions
41 lines (33 loc) · 744 Bytes
/
Copy pathMU_path.h
File metadata and controls
41 lines (33 loc) · 744 Bytes
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
#pragma once
#include<string.h>
#include<stdio.h>
#include "MU_declaration.h"
static char PATH[256];
inline void musnake::initPath(char* path) {
char* p = PATH;
strcpy(PATH, path);
while (*p)p++;
while (*p != '\\' && *p != '/')p--;
*(++p) = 0;
}
inline void musnake::catPath(char* dest, char* relative) {
strcpy(dest, PATH);
strcat(dest, relative);
char* cp = dest;
while (*cp) {
#if defined(_WIN32) || defined(_WIN64)
if (*cp == '/') *cp = '\\';
#elif defined(_linux) || defined(_linux_) || defined(_unix) || defined(_unix_)
if (*cp == '\\') *cp = '/';
#endif
cp++;
}
}
inline void int2str(char* dest, int num) {
sprintf(dest, "%d", num);
}
inline int str2int(char* src) {
int i;
sscanf(src, "%d", &i);
return i;
}