Skip to content

Commit 6a023d4

Browse files
committed
Replace jerry_port_path_normalize,jerry_port_path_free,jerry_port_path_base with jerry_port_path_style,jerry_port_get_cwd
Partially fixes jerryscript-project#4979 Closes: jerryscript-project#4983 JerryScript-DCO-1.0-Signed-off-by: Yonggang Luo [email protected]
1 parent 6cf9162 commit 6a023d4

File tree

9 files changed

+686
-221
lines changed

9 files changed

+686
-221
lines changed

docs/05.PORT-API.md

+10-36
Original file line numberDiff line numberDiff line change
@@ -173,52 +173,26 @@ void jerry_port_line_free (jerry_char_t *buffer_p);
173173

174174
## Filesystem
175175

176-
```
177-
/**
178-
* Canonicalize a file path.
179-
*
180-
* If possible, the implementation should resolve symbolic links and other directory references found in the input path,
181-
* and create a fully canonicalized file path as the result.
182-
*
183-
* The function may return with NULL in case an error is encountered, in which case the calling operation will not
184-
* proceed.
185-
*
186-
* The implementation should allocate storage for the result path as necessary. Non-NULL return values will be passed
187-
* to `jerry_port_path_free` when the result is no longer needed by the caller, which can be used to finalize
188-
* dynamically allocated buffers.
189-
*
190-
* NOTE: The implementation must not return directly with the input, as the input buffer is released after the call.
191-
*
192-
* @param path_p: zero-terminated string containing the input path
193-
* @param path_size: size of the input path string in bytes, excluding terminating zero
194-
*
195-
* @return buffer with the normalized path if the operation is successful,
196-
* NULL otherwise
197-
*/
198-
jerry_char_t *jerry_port_path_normalize (const jerry_char_t *path_p, jerry_size_t path_size);
199-
```
200-
201176
```c
202177
/**
203-
* Free a path buffer returned by jerry_port_path_normalize.
178+
* Get the path style of the current OS
204179
*
205-
* @param path_p: the path buffer to free
180+
* @return path style
206181
*/
207-
void jerry_port_path_free (jerry_char_t *path_p);
182+
jerry_path_style_t jerry_port_path_style (void);
208183
```
209184
210185
```c
211186
/**
212-
* Get the offset of the basename component in the input path.
213-
*
214-
* The implementation should return the offset of the first character after the last path separator found in the path.
215-
* This is used by the caller to split the path into a directory name and a file name.
216-
*
217-
* @param path_p: input zero-terminated path string
187+
* Get the current working directory, the output string will be zero-terminated
218188
*
219-
* @return offset of the basename component in the input path
189+
* @param path_p When path_p is `NULL`, or the `path_size` is not enough,
190+
* return size of current working directory, otherwise fill the
191+
* path_p with current working directory, '\0` terminator also filled.
192+
* @param path_size the `path_p` buffer size, including '\0` terminator
193+
* @return The size of current working directory, excluding '\0' terminator
220194
*/
221-
jerry_size_t jerry_port_path_base (const jerry_char_t *path_p);
195+
jerry_size_t jerry_port_get_cwd (jerry_char_t *path_p, jerry_size_t path_size);
222196
```
223197

224198
```c

0 commit comments

Comments
 (0)