Better fstream?

Does anyone know any portable file classes that expose more control over files than what <fstream> provides? For example, specifying a creation disposition when opening, locking read/write access through new open() calls, truncating/enlarging the file to a given size, etc.
I do not, but this is an OS-specific issue anyway... It is really, really easy to wrap a custom iostream around whatever OS-specific file I/O you want -- heck, you can even make it really generic with a couple callback/functors.
Sure, it's easy, but I don't really want to deal with it. I don't like wondering whether I've passed the right flags for my needs or whether I've read the documentation wrong.
I assume you want more than <filesystem> offers as well?
that gives you resize file (truncates or fills), but that is only 1 of your 3 examples.
I know you can lock any number of ways, but I don't know one that works with fstream. I think FILE* has a way, but is that universal or an OS extender, I forget?
Creation, not sure what you want to do there beyond text or binary, trunc or append sorts of things. What is missing?
I assume you want more than <filesystem> offers as well?
I want file operations on a file I currently have open.

I think FILE* has a way, but is that universal or an OS extender, I forget?
I would guess most OSs implement file sharing logic, but I'm okay if it's only a best effort implementation, or if it throws if the system doesn't support the particular semantics.

Creation, not sure what you want to do there beyond text or binary, trunc or append sorts of things. What is missing?
For example, looking at .NET:
1
2
3
4
5
6
7
8
9
public enum FileMode
{
    CreateNew = 1,
    Create,
    Open,
    OpenOrCreate,
    Truncate,
    Append,
}
https://docs.microsoft.com/en-us/dotnet/api/system.io.filemode?view=net-6.0
Er, you can do all those FileMode things with standard iostreams as-is.
Topic archived. No new replies allowed.