-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathargPath.ino
More file actions
42 lines (41 loc) · 1.05 KB
/
Copy pathargPath.ino
File metadata and controls
42 lines (41 loc) · 1.05 KB
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
int argPathFn(const char* szArgLn, char* szPathFn)
{
char sLine[ILINE];
char *psL= &sLine[0];
int iRC;
if (*szArgLn == ' ') {
szArgLn++;
}
if((iRC= strlen(szArgLn)) > 0) {
if (strncmp(szArgLn, "/", 1) == 0){
strcpy(psL, szArgLn);
} else
if ((*szArgLn == '.')&&(*(szArgLn+1) == '.')) {
strcpy(psL, sPath);
*strrchr(psL, '/') = 0x00; // find last '/' and substitude to EoS
if (strlen(psL) <= 1) {
strcpy(psL, "/");
}
} else
if ((*szArgLn == '.')&&(*(szArgLn+1) == '/')) {
strcpy(psL, sPath);
strncat(psL, "/", ILINE);
strncat(psL, szArgLn +2, ILINE);
} else {
strcpy(psL, sPath);
if (*(psL+strlen(psL)-1) != '/' ) {
strncat(psL, "/", ILINE);
}
strncat(psL, szArgLn, ILINE);
}
} else {
strcpy(psL, sPath);
if (*(psL+strlen(psL)-1) != '/' ) {
strncat(psL, "/", ILINE);
}
iRC= 0;
}
// Serial.println(psL);
strcpy(szPathFn, psL);
return(iRC);
} /* end of function */