Skip to content

Commit

Permalink
Replace jerry_port_path_normalize,jerry_port_path_free,jerry_port_pat…
Browse files Browse the repository at this point in the history
…h_base with jerry_port_path_style,jerry_port_get_cwd
  • Loading branch information
lygstate committed Dec 11, 2024
1 parent 99ec1f9 commit f40c749
Show file tree
Hide file tree
Showing 9 changed files with 681 additions and 218 deletions.
46 changes: 10 additions & 36 deletions docs/05.PORT-API.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,52 +166,26 @@ void jerry_port_line_free (jerry_char_t *buffer_p);

## Filesystem

```
/**
* Canonicalize a file path.
*
* If possible, the implementation should resolve symbolic links and other directory references found in the input path,
* and create a fully canonicalized file path as the result.
*
* The function may return with NULL in case an error is encountered, in which case the calling operation will not
* proceed.
*
* The implementation should allocate storage for the result path as necessary. Non-NULL return values will be passed
* to `jerry_port_path_free` when the result is no longer needed by the caller, which can be used to finalize
* dynamically allocated buffers.
*
* NOTE: The implementation must not return directly with the input, as the input buffer is released after the call.
*
* @param path_p: zero-terminated string containing the input path
* @param path_size: size of the input path string in bytes, excluding terminating zero
*
* @return buffer with the normalized path if the operation is successful,
* NULL otherwise
*/
jerry_char_t *jerry_port_path_normalize (const jerry_char_t *path_p, jerry_size_t path_size);
```

```c
/**
* Free a path buffer returned by jerry_port_path_normalize.
* Get the path style of the current OS
*
* @param path_p: the path buffer to free
* @return path style
*/
void jerry_port_path_free (jerry_char_t *path_p);
jerry_path_style_t jerry_port_path_style ();
```

```c
/**
* Get the offset of the basename component in the input path.
*
* The implementation should return the offset of the first character after the last path separator found in the path.
* This is used by the caller to split the path into a directory name and a file name.
*
* @param path_p: input zero-terminated path string
* Get the current working directory, the output string will be zero-terminated
*
* @return offset of the basename component in the input path
* @param path_p When path_p is `NULL`, or the `path_size` is not enough,
* return size of current working directory, otherwise fill the
* path_p with current working directory, '\0` terminator also filled.
* @param path_size the `path_p` buffer size, including '\0` terminator
* @return The size of current working directory, excluding '\0' terminator
*/
jerry_size_t jerry_port_path_base (const jerry_char_t *path_p);
jerry_size_t jerry_port_get_cwd (jerry_char_t *path_p, jerry_size_t path_size);
```
```c
Expand Down
Loading

0 comments on commit f40c749

Please sign in to comment.