This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
JustPingo's profile picture

Dynamic IMount

Started by JustPingo, 10 October 2014 - 06:57 PM
JustPingo #1
Posted 10 October 2014 - 08:57 PM
Hi everyone !

I was wondering, is there a way to create an IMount without a "real" folder ? I mean, an IMount generated on the fly with dynamics datas stored in java.util.String objects ie ?
I searched in the doc and tried to find source codes but never managed to find something like this…

Is it at least possible ?

Thanks in advance !
Edited on 10 October 2014 - 07:45 PM
theoriginalbit #2
Posted 11 October 2014 - 02:22 AM
To be honest, I've had a whole lot of trouble getting an IMount to work with files, let alone anything else, so unless you can return a faux InputStream which instead of having a file, has a string, then I'm going to say no, it's not possible.
JustPingo #3
Posted 11 October 2014 - 11:08 AM
Thanks.
I guess it's time to visit the "Suggestions" section.
theoriginalbit #4
Posted 11 October 2014 - 11:18 AM
tbh I'm not completely sure it would be something that'd be implemented.

why do you want this to be possible? what's your use case?

why can't you just write the string to a file and use that?
JustPingo #5
Posted 11 October 2014 - 11:27 AM
tbh I'm not completely sure it would be something that'd be implemented.

why do you want this to be possible? what's your use case?

I have an item that store an UUID in its NBT, and I want the computer to be able to read it. So there would be a file containing it inside the IMount (inside the IMedia).

why can't you just write the string to a file and use that?

Isn't that super heavy in terms of CPU/HDD? And that would be hard to handle a lot of that disks, and if I remember right I can't know when the item is taken off the DIsk Drive, so I wouldn't be able to delete the "real" files then.

I can create a new peripheral reading the UUID, but I would prefer that way.
Edited on 11 October 2014 - 09:29 AM
theoriginalbit #6
Posted 11 October 2014 - 11:30 AM
what would the purpose be of the user getting the UUID?

EDIT: also, if it's a UUID, this means you should be storing this somewhere so it can be used again, why can't you just open that up in your mount?
Edited on 11 October 2014 - 09:34 AM
JustPingo #7
Posted 11 October 2014 - 11:38 AM
The UUID is like a frequency to communicate with other computers by a very precise network with my peripheral.

But anyway, I can make that when you right click my peripheral with that item, the peripheral automatically connect, and then you can run p.getFrequency(). But that would have been nicer with that IMount stuff.

Thanks anyway !
theoriginalbit #8
Posted 11 October 2014 - 12:12 PM
personally I think that a method is nicer than an IMount. If a user wishes to get the data, an IMount they'd need to open the file and read it, a method call they've got it far easier.
JustPingo #9
Posted 11 October 2014 - 12:21 PM
EDIT: also, if it's a UUID, this means you should be storing this somewhere so it can be used again, why can't you just open that up in your mount?

That is stored in the NBTs.
sci4me #10
Posted 11 October 2014 - 06:27 PM
Okay, with a quick look at IMount, I can tell you that yes, it can be done. As long as you can read/write your data with an Input/Output stream, it will work.
By the way, this gives me an interesting idea… :P/> thanks for that! :D/>