Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ca387ba

Browse files
committed
Implement jerry_port_path_normalize in a more reliable way
Replace jerry_port_path_normalize,jerry_port_path_free,jerry_port_path_base with jerry_port_path_style,jerry_port_get_cwd Partially fixes #4979 Closes: #4983 JerryScript-DCO-1.0-Signed-off-by: Yonggang Luo luoyonggang@gmail.com
1 parent d2d30df commit ca387ba

File tree

10 files changed

+824
-165
lines changed

10 files changed

+824
-165
lines changed

‎docs/05.PORT-API.md

Lines changed: 25 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,16 @@ void jerry_port_init (void);
2626
void jerry_port_fatal (jerry_fatal_code_t code);
2727
```
2828

29+
The path style of the OS
30+
31+
```c
32+
typedef enum
33+
{
34+
JERRY_STYLE_WINDOWS,
35+
JERRY_STYLE_UNIX,
36+
} jerry_path_style_t;
37+
```
38+
2939
Error codes
3040

3141
```c
@@ -172,52 +182,33 @@ void jerry_port_line_free (jerry_char_t *buffer_p);
172182

173183
## Filesystem
174184

175-
```
176-
/**
177-
* Canonicalize a file path.
178-
*
179-
* If possible, the implementation should resolve symbolic links and other directory references found in the input path,
180-
* and create a fully canonicalized file path as the result.
181-
*
182-
* The function may return with NULL in case an error is encountered, in which case the calling operation will not
183-
* proceed.
184-
*
185-
* The implementation should allocate storage for the result path as necessary. Non-NULL return values will be passed
186-
* to `jerry_port_path_free` when the result is no longer needed by the caller, which can be used to finalize
187-
* dynamically allocated buffers.
188-
*
189-
* NOTE: The implementation must not return directly with the input, as the input buffer is released after the call.
190-
*
191-
* @param path_p: zero-terminated string containing the input path
192-
* @param path_size: size of the input path string in bytes, excluding terminating zero
193-
*
194-
* @return buffer with the normalized path if the operation is successful,
195-
* NULL otherwise
196-
*/
197-
jerry_char_t *jerry_port_path_normalize (const jerry_char_t *path_p, jerry_size_t path_size);
198-
```
199-
200185
```c
201186
/**
202-
* Free a path buffer returned by jerry_port_path_normalize.
187+
* Get the path style of the current OS
203188
*
204-
* @param path_p: the path buffer to free
189+
* @return path style
205190
*/
206-
voidjerry_port_path_free (jerry_char_t *path_p);
191+
jerry_path_style_tjerry_port_path_style (void);
207192
```
208193
209194
```c
210195
/**
211-
* Get the offset of the basename component in the input path.
196+
* Get the cwd, the output string will be zero-terminated
212197
*
213-
* The implementation should return the offset of the first character after the last path separator found in the path.
214-
* This is used by the caller to split the path into a directory name and a file name.
198+
* @param buffer_p: the buffer to storage the cwd
199+
* @param buffer_size: the `buffer_p` buffer size, including '0円` terminator
215200
*
216-
* @param path_p: input zero-terminated path string
201+
* @note
202+
* - cwd: current working directory
217203
*
218-
* @return offset of the basename component in the input path
204+
* @return The length of cwd, excluding '0円' terminator
205+
* - When buffer_p is `NULL` and get cwd succeed return length of cwd
206+
* - When buffer_p is `NULL` and get cwd failed return 0
207+
* - When buffer_p is not `NULL` and the `buffer_size - 1` just equal to
208+
* length of cwd; and get cwd succeed return `buffer_size - 1`.
209+
* - Otherwise means get cwd failed and return 0
219210
*/
220-
jerry_size_t jerry_port_path_base (const jerry_char_t *path_p);
211+
jerry_size_t jerry_port_get_cwd (jerry_char_t *buffer_p, jerry_size_t buffer_size);
221212
```
222213

223214
```c

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /