oeed / CraftOS-Standards

Community standard file formats, communication systems, etc. for ComputerCraft and CraftOS 2.0
Other
20 stars 14 forks source link

Temporary Directory Standard #38

Closed ghost closed 8 years ago

ghost commented 8 years ago

This is my proposal for a standard path/directory for temporary files. Feel free to take a look and let me know what you think.

I know that it isn't even code, but it's something that should be standardized.

Let me know what you think.

lyqyd commented 8 years ago

If this is going to be a thing, it belongs at /tmp.

oeed commented 8 years ago

I can't really remember ever needing this, but I certainly agree that standardising it is a good idea though.

@viluon If it's not already mentioned in the contributing file, can we make the 'Depreciates' field to only be used when it is depreciating something? @cyanisaac You can remove that row from the table. The same applies for the version, that's really only needed for file formats in which the version is important. The COS number given to this file (which we need to mention in the contributing file too @viluon; they shouldn't add one when they first make a proposal, we will assign one when it has been approved and they can add it) will do the job.

I'd argue that that MIME mightn't be the most appropriate, it should either be based on the directory MIME or just use the directory one.

I feel like it is also worth mentioning that an OS that sandboxes programs should clear out the program's temp folder, rather than the root one.

Also, small nit picks: I don't think the sleep call should be in the example, you're not closing the second file handle, you're not wrapping the file handle calls in if statements and the last code block isn't using Lua.

@lyqyd I'd disagree somewhat, I think at the very least it should be hidden.

viluon commented 8 years ago

agreed with @demhydraz. Also, could you please comment that over at #13 @oeed? Otherwise I'll probably forget about it :confused:

ghost commented 8 years ago

/tmp is a better place. Also ok I'll remove the unnecessary stuff from the spec - I didn't know what to have and what I didn't need, and I didn't want to submit a terrible request.

Oh, and the sleep(0) is there as an example - when a sleep is called it yields the coroutine, meaning stuff can happen to files during that time. I probably should have explained that in the example, although that's probably not really necessary.

EDIT: And I wrote that example at 11:20PM with myself falling half asleep on the keyboard, hence the other various mistakes.

EDIT 2: Wait, shouldn't it be at /.tmp? I feel like the user shouldn't need to see the temp directory really.

oeed commented 8 years ago

And I think you should provide an API to generate a pseudorandom name (with prefixes, maybe like appname-XXYYZZ where X, Y and Z are all distinct random characters) to avoid name clashes.

That's super complicated for something that doesn't need to be, a sandbox does that job for you.

It seems to be that the only reason you guys want tmp is because it's what Linux uses which was probably fairly arbitrary. Complicating it with changing the API seems stupid when you could just prefix a full stop.

Regarding the sleep @cyanisaac I completely understand where you're coming from, but I can just see it confusing some people.

oeed commented 8 years ago

i.e. Some stoned guy in the seventies randomly thought it up.

I get what you're saying, but to simply follow tradition when it doesn't serve our purpose well is just backwards.

oeed commented 8 years ago

A full stop added doesn't really make it any less concise.

lyqyd commented 8 years ago

There's no good reason for it to be hidden. Just because the user "doesn't need" to see it isn't enough to justify hiding it.

oeed commented 8 years ago

@lyqyd I get what you mean. I guess most of it is just differing philosophies, so I won't argue over that.

However, we really need examples of what sort of uses this has. If modifying the files stored here will cause crashes or problems, which I'd imagine might be quite likely, then I'd say that's certainly a good reason to hide it.

ghost commented 8 years ago

However, we really need examples of what sort of uses this has. If modifying the files stored here will cause crashes or problems, which I'd imagine might be quite likely, then I'd say that's certainly a good reason to hide it.

Actually the point is that the files here are junk. They don't really need to be referred back to, and it should be treated as if the files could change or disappear at any time.

But maybe that's a bad idea, and maybe we should do something different to prevent things from changing when they need to be referred back to (although I would argue that it misses the point of the directory)

oeed commented 8 years ago

That's a good point @cyanisaac. Ultimately hiding it is a matter of how much control you as the developer believe the user should have. Clearly, some people want it to be visible and others not.

As such I'd suggest we make /tmp standard but mention that it is permissible for the developer to treat it as a hidden folder if they wish (although the requirements for it to be hidden are that it is in the root folder, not just any folder called 'tmp').

ghost commented 8 years ago

That's a good point @cyanisaac. Ultimately hiding it is a matter of how much control you as the developer believe the user should have. Clearly, some people want it to be visible and others not. As such I'd suggest we make /tmp standard but mention that it is permissible for the developer to treat it as a hidden folder if they wish (although the requirements for it to be hidden are that it is in the root folder, not just any folder called 'tmp').

Good thinking, I will do something like that with my standard tomorrow (super late at the moment).

oeed commented 8 years ago

Any update on this @cyanisaac? Once those changes have been made you can post it on the forums and soon after we can merge it :smile:

ghost commented 8 years ago

I will get to work on this now. I've been busy this week that's why there's been a lack of updates :P

ghost commented 8 years ago

More changes have been made. Let me know if I've missed anything.

oeed commented 8 years ago

Looks good to me, anyone else have any issues?

viluon commented 8 years ago

@cyanisaac while you are saying that the temporary directory is located at /tmp, in the OS-side example you are using /.tmp. Either change that or list /.tmp in the "Location" field of your quick info table Since you've removed the dot entries in https://github.com/cyanisaac/CraftOS-Standards/commit/c18adcdebb9f0dda209e18a8dbf49c8c6ddaba62, I think you just forgot about the OS example :wink:

Other than that, I think this proposal is ready to be accepted!

Luca0208 commented 8 years ago

:+1: from me

ghost commented 8 years ago

Gah I totally missed that. Fixed in OS-sided example.

viluon commented 8 years ago

Thanks for the fix @cyanisaac :smiley:

lyqyd commented 8 years ago

Looks good to me. The standard appears to allow for /tmp to exist only in RAM, which is good!

oeed commented 8 years ago

Okay, @cyanisaac this looks good to go. Can you post a topic in General with a link to the most up to date preview of the file (i.e. this) and another link to this page with a brief description of what the format is?

Once there are no objects or changes we'll then be able to merge!

ghost commented 8 years ago

I edited my original thread, forgot to tell you guys. The links now link to these pull requests and some other stuff. Can it be merged?

Sorry for taking forever. I'm bad at remembering things.

oeed commented 8 years ago

Oh of course, sorry @cyanisaac! You posted that ages ago!

Looks all good.