Redesign of package os
#976
Replies: 26 comments 4 replies
-
Should "files" be represented by a custom data structure or a handle? |
Beta Was this translation helpful? Give feedback.
-
I feel like having the filename, file size and other metadata in a struct might be useful to have on-hand. If the metadata is unnecessary for the function it could just accept the handle on the struct. (some error returns left out for clarity)
|
Beta Was this translation helpful? Give feedback.
-
I'm not sure what the best approach is. If you need the file info, you can ask for it from the handle, but having a semi-opaque struct means you can store extra information in the struct for internal issue. |
Beta Was this translation helpful? Give feedback.
-
So it's an interesting design decision, the reason being is that the OS will be storing a lot of the file information internally already. And things like caching the long name for the file is only useful on Windows as it uses 16-bit wide chars for everything. |
Beta Was this translation helpful? Give feedback.
-
The handle could be an semi-opaque struct and then functions like That way any relevant caching can be done for each OS while still supplying uniform functions and behavior. |
Beta Was this translation helpful? Give feedback.
-
The other question is whether to use short names or long names for things e.g. I prefer the latter but I guess most people are more familiar with |
Beta Was this translation helpful? Give feedback.
-
I think something like this is the best option:
It solves a lot of the TOCTOU issues. |
Beta Was this translation helpful? Give feedback.
-
I prefer the latter as well, the thing is is that you need to be consistent if you decide on either of them. You can't make Personally when I see the former I think of the console command instead of an actual API call but that's just me. |
Beta Was this translation helpful? Give feedback.
-
@Lunatoid Of course. Consistency is key here. |
Beta Was this translation helpful? Give feedback.
-
So in the example you posted, the handles/files are pointers to OS specific structs or is it just a "typedef" of e.g. a Win32 HANDLE? |
Beta Was this translation helpful? Give feedback.
-
In a sense, yes. |
Beta Was this translation helpful? Give feedback.
-
Current branch for work: https://github.com/odin-lang/Odin/tree/dev-pkg-os/core/os_v2 |
Beta Was this translation helpful? Give feedback.
-
Here's a list of things that I'd expect in a platform layer (based on Essence's API):
|
Beta Was this translation helpful? Give feedback.
-
Processes and the filesystem aspects are the main ideas behind |
Beta Was this translation helpful? Give feedback.
-
Would consider these stats/infos also as nice to have in a os independent way:
And for proc names i would use the long names not the console names like |
Beta Was this translation helpful? Give feedback.
-
What about POSIX compliant stuffs i.e. sharing POSIX stuff across compliant OSs? Much of the linux and macOS implementation will be very similar and identical in places |
Beta Was this translation helpful? Give feedback.
-
I am not so interested in POSIX compliance. Especially since Odin's constructs will not map directly to the POSIX C interfaces. |
Beta Was this translation helpful? Give feedback.
-
Some of these are redundant? |
Beta Was this translation helpful? Give feedback.
-
Should we still make the heap and virtualalloc stuff? |
Beta Was this translation helpful? Give feedback.
-
That's a good question. Maybe the normal stuff should be in |
Beta Was this translation helpful? Give feedback.
-
Current Proposed read functions: I was so free and added these: And here was the first proposed design: |
Beta Was this translation helpful? Give feedback.
-
The other thing is what about memory for some of these functions there is more than just temporary memory needed for example the process list. How should we deal with that? |
Beta Was this translation helpful? Give feedback.
-
Also what about errors? |
Beta Was this translation helpful? Give feedback.
-
I did some work on the Linux file API for v2, let me know if this is inline with expectations Branch: https://github.com/rytc/Odin/tree/linux_osv2 |
Beta Was this translation helpful? Give feedback.
-
Has anyone looked at os2? I have found it really ugly that it now requires one todo allocations for opening a file? For me this feels a bit crazy. |
Beta Was this translation helpful? Give feedback.
-
A other thing is if some of the proposed procs for processes should go in there own package? As the first proposal for a function set included these procs. Idea: core:process or core:os/process or exec (maybe a bit too narrow for what you can do) |
Beta Was this translation helpful? Give feedback.
-
Redesign of
package os
.This will need to have a minimal OS interface. e.g. on Windows, it should have its own miniature "core:sys/win32" rather than importing that.
The package's interface needs to be the same across all OSes.
The following code is just an example of the interface that I want, and not the final design.
Beta Was this translation helpful? Give feedback.
All reactions