MCPcopy Create free account
hub / github.com/aldostools/webMAN-MOD / parsePath

Function parsePath

include/ftp.h:45–97  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43#define MAX_TRANSFER_WAIT 15000000 // 15 seconds
44
45static u8 parsePath(char *absPath_s, const char *path, const char *cwd, bool scan)
46{
47 if(!absPath_s || !path || !cwd) return 0;
48
49 if(*path == '/')
50 {
51 strcopy(absPath_s, path);
52
53 normalize_path(absPath_s, true);
54
55 if(islike(path, "/dev_blind")) {mount_device("/dev_blind", NULL, NULL); filepath_check(absPath_s); return 1;}
56 if(islike(path, "/dev_hdd1") ) mount_device("/dev_hdd1", NULL, NULL);
57 }
58 else
59 {
60 u16 len = strcopy(absPath_s, cwd);
61
62 normalize_path(absPath_s, true);
63
64 strcat(absPath_s + len, path);
65 }
66
67 #ifdef USE_NTFS
68 if(is_ntfs_path(absPath_s)) check_ntfs_volumes();
69 #endif
70
71 if(scan)
72 if(not_exists(absPath_s))
73 {
74 strcpy(absPath_s, path); check_path_alias(absPath_s); filepath_check(absPath_s);
75 if(file_exists(absPath_s)) return 0;
76
77 normalize_path((char*)cwd, false);
78
79 if(absPath_s[0] != '/'){
80 // Path is relative, need to concat it after cwd
81 if(cwd[strlen(cwd) - 1] != '/'){
82 // cwd doesn't end with a slash
83 snprintf(absPath_s, STD_PATH_LEN, "%s/%s", cwd, path);
84 } else {
85 // cwd ends with a slash
86 snprintf(absPath_s, STD_PATH_LEN, "%s%s", cwd, path);
87 }
88 } else {
89 // Path is absolute
90 strncopy(absPath_s, STD_PATH_LEN, path);
91 }
92 }
93
94 filepath_check(absPath_s);
95
96 return 0;
97}
98
99static u8 findPath(char *absPath_s, const char *path, const char* cwd)
100{

Callers 2

findPathFunction · 0.85
absPathFunction · 0.85

Calls 15

strcopyFunction · 0.85
mount_deviceFunction · 0.85
filepath_checkFunction · 0.85
is_ntfs_pathFunction · 0.85
check_ntfs_volumesFunction · 0.85
check_path_aliasFunction · 0.85
strncopyFunction · 0.85
normalize_pathFunction · 0.50
islikeFunction · 0.50
strcatFunction · 0.50
not_existsFunction · 0.50
strcpyFunction · 0.50

Tested by

no test coverage detected