~sircmpwn/hare-users

Notice: Breaking changes to the path:: module

Details
Message ID
<a0718054-d90c-940d-eea8-14d478dbe7e9@posteo.net>
DKIM signature
missing
Download raw message
The path:: module has been heavily rewritten. The new version is now in 
Hare's master branch. There are several breaking changes - below are 
outlined the most significant, and how to migrate, with a focus on 
paradigm shifts and non-obvious breakages. The rest of the details are 
covered in the module's documentation, and you can respond to this email 
with questions.

You should probably refactor your code, not just fix localized errors.

## Buffers

The module now centers far more heavily around the path::buffer type. 
Many functions that used to take strings now just take a pointer to a 
buffer. The recommended way to work with mutable or normalized paths now 
is to create a buffer once, and then pass around a reference to it, 
rather than using strings. this will reduce the number of buffers that 
you create, and copying overhead.

The entire module now does not do any allocation. If you want to extend 
the life of a string, you should use strings::dup().

Trailing slashes are now removed during normalization.

## Errors

The module no longer uses errors::overflow, instead uses a custom error 
type, with a path::strerror() function.

## Path stack

The add() function has been replaced with push(), pop() and peek(). pop 
and peek will return void if the path is "." or root.

You almost certainly do *not* want to use dirname() or basename(). These 
are POSIX-compliant functions which have very lacking specifications 
(e.g. dirname("..") == "."; dirname("////meow/.//..") == "////meow/.").
You probably want peek() and parent() instead.

## File extensions

File extensions now use a stack paradigm as well. File extensions no 
longer contain a leading ".".
Reply to thread Export thread (mbox)