-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document new File functions (Copy, Rename, GetFileTime, Read/WriteRawFloat, Read/WriteBytes) #262
Comments
IIRC File.Copy also should create directories. But the engine only creates subdirs within the standard locations ( |
@ivan-mogilko I am a bit unsure on returning true on success and false on error. If we ever want to return error codes as enum, this gives us many values for success but only one value for error. |
I thought about this, and my guess is that for the majority of users of AGS the specific error code would be meaningless. What would be interesting is whether operation succeeds or not. In which case their habit would be to test it as any other operation that returns a result, like:
If we make these enums where 0 is success, then this will become a source of endless mistakes. I propose to find another way of getting specific error code. |
uhm, ok. I added File.Copy,GetFileTime and Rename in the simplest way as possible. |
and quickly added RawRawFloat and WriteRawFloat Need to think of examples for these and include any error handle in the example. |
Added examples for File.Rename and File.GetFileTime (nothing too inspired though....) |
@ivan-mogilko shouldn't ReadBytes and WriteBytes be ReadRawBytes and WriteRawBytes? I had to look into the code to figure it out they weren't like WriteInt and instead more like WriteRawIntArray of sorts. It is also weird there is WriteRawFloat but not WriteFloat. Also I feel like File should be reordered so it has static functions alphabetically, functions alphabetically and then properties alphabetically. documented them here |
Personally, I do not like current separation between Read "normal" and Read "raw" values, I think that's confusing and prone to mistakes. I wish there were a separate class for reading and writing "safeguarded" values, if anyone would like to have that. If you think that's necessary, then we can add both "raw" and "not raw" variants for dealing with array of bytes. |
I was thinking the same. In my head nowadays people would prefer some format like ini or json and have something that gives a friendly interface to them. The "safeguarded" version feels more "binary", which is usually hard to quickly inspect. But I don't have a good idea for a name for such class to hide these functions.
It's more that their name should have Raw in it, since they aren't safeguarded. |
Opened a PR with these changes: |
https://github.com/adventuregamestudio/ags-manual/wiki/File
File.Copy
File.GetFileTime
File.Rename
File.ReadRawFloat
File.WriteRawFloat
File.ReadBytes
File.WriteBytes
Some of the new File API were added in PR adventuregamestudio/ags#2541
Additional documentation in the source code https://github.com/adventuregamestudio/ags/blob/e7fc02178d50e808134a651f4a9e07d3d7cc65e0/Engine/ac/file.cpp#L87
A few notes
The text was updated successfully, but these errors were encountered: