Select one of the symbols to view example projects that use it.
 
Outline
...
...
...
...
#define FX_SOURCE_CODE
#include "fx_api.h"
#include "fx_utility.h"
...
Files
loading...
SourceVuSTM32 Libraries and Samplesfilexcommon/src/fx_utility_absolute_path_get.c
 
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/**************************************************************************/ /* */ /* Copyright (c) Microsoft Corporation. All rights reserved. */ /* */ /* This software is licensed under the Microsoft Software License */ /* Terms for Microsoft Azure RTOS. Full text of the license can be */ /* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */ /* and in the root directory of this software. */ /* */... /**************************************************************************/ ... /**************************************************************************/ /**************************************************************************/ /** */ /** FileX Component */ /** */ /** Utility */ /** */... /**************************************************************************/ /**************************************************************************/ #define FX_SOURCE_CODE /* Include necessary system files. */ #include "fx_api.h" #include "fx_utility.h" #ifdef FX_ENABLE_EXFAT... /**************************************************************************/ /* */ /* FUNCTION RELEASE */ /* */ /* _fx_utility_absolute_path_get PORTABLE C */ /* 6.1 */ /* AUTHOR */ /* */ /* William E. Lamie, Microsoft Corporation */ /* */ /* DESCRIPTION */ /* */ /* This function converts concatenating of base and new path to */ /* absolute path. */ /* */ /* INPUT */ /* */ /* base_path Base (current) path */ /* new_path New path */ /* absolute_path Absolute Path */ /* */ /* OUTPUT */ /* */ /* absolute_path Resulting absolute path */ /* return status */ /* */ /* CALLS */ /* */ /* _fx_utility_token_length_get Get the next token length */ /* _fx_utility_string_length_get Get string length */ /* */ /* CALLED BY */ /* */ /* _fx_directory_default_set */ /* */ /* RELEASE HISTORY */ /* */ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 William E. Lamie Initial Version 6.0 */ /* 09-30-2020 William E. Lamie Modified comment(s), */ /* resulting in version 6.1 */ /* */... /**************************************************************************/ UINT _fx_utility_absolute_path_get(CHAR *base_path, CHAR *new_path, CHAR *absolute_path) { UINT length; UINT absolute_position; UINT i; /* Check if we got null pointers. */ if (!base_path || !new_path || !absolute_path) { /* Return error. */ return(FX_INVALID_PATH); }if (!base_path || !new_path || !absolute_path) { ... } /* Is the new path starts from root? */ if ((new_path[0] == '\\') || (new_path[0] == '/')) { /* Yes, set the absolute path to root. */ absolute_path[0] = '\\'; absolute_path[1] = 0; new_path++; }if ((new_path[0] == '\\') || (new_path[0] == '/')) { ... } else { /* Initialize the absolute path with the base path. */ i = 0; while ((base_path[i]) && (i < FX_MAXIMUM_PATH)) { /* Copy a character. */ absolute_path[i] = base_path[i]; /* Move to next character. */ i++; }while ((base_path[i]) && (i < FX_MAXIMUM_PATH)) { ... } /* Is the absolute path still NULL? */ if ((absolute_path[0] == 0) || (i == 0)) { /* Yes, set the absolute path to root. */ absolute_path[0] = '\\'; absolute_path[1] = 0; }if ((absolute_path[0] == 0) || (i == 0)) { ... } }else { ... } /* Loop to add new path to the absolute path. */ while ((length = _fx_utility_token_length_get(new_path)) > 0) { /* Check if the path is too long. */ if ((new_path[length] != 0) && (new_path[length] != '\\') && (new_path[length] != '/')) { /* The path is too long, return error. */ return(FX_INVALID_PATH); }if ((new_path[length] != 0) && (new_path[length] != '\\') && (new_path[length] != '/')) { ... } /* Check if we have a current directory mark. */ if ((length == 1) && (new_path[0] == '.')) { /* The same directory, just skip it. */ }if ((length == 1) && (new_path[0] == '.')) { ... } /* Do we have a parent directory mark? */ else if ((length == 2) && (new_path[0] == '.') && (new_path[1] == '.')) { /* Yes, we need to move the absolute path to the parent directory. */ /* Check absolute path length. */ absolute_position = _fx_utility_string_length_get(absolute_path, FX_MAXIMUM_PATH); if ((absolute_position < 2) || (absolute_path[absolute_position] != 0)) { /* No parent directory left in the absolute path, or invalid path length, return error. */ return(FX_INVALID_PATH); }if ((absolute_position < 2) || (absolute_path[absolute_position] != 0)) { ... } /* Move to the last character of the absolute path. */ absolute_position--; /* Check if we have a directory separator. */ if ((absolute_path[absolute_position] == '\\') || (absolute_path[absolute_position] == '/')) { /* Remove the separator. */ absolute_path[absolute_position] = 0; absolute_position--; }if ((absolute_path[absolute_position] == '\\') || (absolute_path[absolute_position] == '/')) { ... } /* Loop to clear the character backward until a seprator or string exhaust. */ while ((absolute_path[absolute_position] != '\\') && (absolute_path[absolute_position] != '/') && (absolute_position > 0)) { /* Remove one character. */ absolute_path[absolute_position] = 0; absolute_position--; }while ((absolute_path[absolute_position] != '\\') && (absolute_path[absolute_position] != '/') && (absolute_position > 0)) { ... } /* Do we have somthing left in the path? */ if (absolute_position > 1) { /* Yes, remove the last separator. */ absolute_path[absolute_position] = 0; }if (absolute_position > 1) { ... } }else if ((length == 2) && (new_path[0] == '.') && (new_path[1] == '.')) { ... } else { /* Normal directory, add it. */ absolute_position = _fx_utility_string_length_get(absolute_path, FX_MAXIMUM_PATH); /* Check if the path is too long. */ if (absolute_path[absolute_position] != 0) { /* The path is too long, return error. */ return(FX_INVALID_PATH); }if (absolute_path[absolute_position] != 0) { ... } /* Check if we have something in the path. */ if (absolute_position) { /* Do we have a separator in the last character? */ if ((absolute_path[absolute_position - 1] != '\\') && (absolute_path[absolute_position - 1] != '/')) { /* No, add a directory separator to the path string. */ absolute_path[absolute_position] = '\\'; absolute_position++; }if ((absolute_path[absolute_position - 1] != '\\') && (absolute_path[absolute_position - 1] != '/')) { ... } }if (absolute_position) { ... } /* Loop to copy the new path to the absolute path. */ i = 0; while ((absolute_position < FX_MAXIMUM_PATH) && (i < length)) { /* Copy one character. */ absolute_path[absolute_position++] = new_path[i++]; }while ((absolute_position < FX_MAXIMUM_PATH) && (i < length)) { ... } /* Check if we have not exceed the maximum length. */ if (absolute_position < FX_MAXIMUM_PATH) { /* Terminate the string. */ absolute_path[absolute_position] = 0; }if (absolute_position < FX_MAXIMUM_PATH) { ... } else { /* The path is too long, return error. */ return(FX_INVALID_PATH); }else { ... } }else { ... } /* Move to the next component. */ new_path += length; /* Is the next component starts with a separator? */ if ((new_path[0] == '\\') || (new_path[0] == '/')) { /* Yes, skip it. */ new_path++; }if ((new_path[0] == '\\') || (new_path[0] == '/')) { ... } }while ((length = _fx_utility_token_length_get(new_path)) > 0) { ... } return(FX_SUCCESS); }_fx_utility_absolute_path_get (CHAR *base_path, CHAR *new_path, CHAR *absolute_path) { ... } /* ... */#endif /* FX_ENABLE_EXFAT */
Details
Show:
from
Types: Columns:
This file uses the notable symbols shown below. Click anywhere in the file to view more details.