Damus

Recent Notes

05nelsonm profile picture
Only idea I have had is to use templates for PRs and Issues with a required check box to tick "AI was not utilized in the generation of this PR/Issue".

If it's not checked, auto-close that shit. If they lied, block them.

05nelsonm profile picture
Nothing beats black dark roast coffee and a cigarette for locking in to conquer the day. Nothing.

05nelsonm profile picture
I think today is going to be release day... Tons of new features, lots of bug fixes, several deprecations, and many many performance improvements.

Has been a fruitful couple of months, but now I must #shipcode

05nelsonm profile picture
How would you work around platform limitations on number of file descriptors that can be open at once? Or the incredible amount of overhead that would require? Or the fact that symbolic links are not a thing on Windows?

IMO, a filesystem is not the right tool for the job, a database is.

05nelsonm profile picture
I assume this is to open a file?

Personally, I took the approach of splitting into 3 separate functions; openRead, openWrite, openReadWrite.

This allows for different return types which inherit from a single common one, and makes clear the contract for which that thing (interface) can and cannot do. Eliminates nearly all API confusion and/or misuse.

openRead doesn't need to take parameters as it must always exist.

openWrite and openReadWrite take an exclusivity enum MaybeCreate, MustCreate, MustExist. This also allows a mode to be expressed for applying appropriate permissions immediately on creation when MaybyCreate and MustCreate are expressed.

openWrite also takes an append boolean parameter, constraining appending/truncation behavior to that function only.

I spent a lot of time playing with my API, bumping into and figuring out workarounds for several platform specific limitations (such as pwrite with O_APPEND being broken on Linux/FreeBSD).

https://github.com/05nelsonm/kmp-file/blob/master/library/file/src/commonMain/kotlin/io/matthewnelson/kmp/file/OpenExcl.kt


https://github.com/05nelsonm/kmp-file/blob/master/library/file/src/commonMain/kotlin/io/matthewnelson/kmp/file/FileStream.kt