On 06/06/2016 5:07 PM, Pie? wrote:
On Monday, 6 June 2016 at 03:23:02 UTC, rikki cattermole wrote:
On 06/06/2016 3:11 PM, Pie? wrote:
On Monday, 6 June 2016 at 02:34:07 UTC, Adam D. Ruppe wrote:
On Monday, 6 June 2016 at 02:05:09 UTC, Pie? wrote:
I believe the essentially converted the file into a ubyte or
something and then wrote that out to a temp file and read in the temp
file... this seems a bit of a kludge to me.
They might do that for certain special cases, but
import("file.whatever") just drops the file content in memory and you
can then access it as an array.
Because D allows such an embedding feature, maybe the file system
should allow working with this concept?
Why do you need it through the file system? If you're writing the
code, just use the array in memory. If it is external, see if the
library offers something like that.
DLL and exe are a special case, most things don't need to be physical
files.
Because, as I said, if I'm working with pre-exiting modules that work
with file, I have to provide a file or modify the source.
e.g., how could I do this easily with your read in your png module? It
takes a file..
/// Easily reads a png file into a MemoryImage
MemoryImage readPng(string filename) {
import std.file;
return imageFromPng(readPng(cast(ubyte[]) read(filename)));
recognize the code?
Of course, like I said, it can be modified in this case, but that means
nothing in general.
ubyte[] theArray = import("...");
MemoryImage img = imageFromPng(readPng(theArray));
And that's just from the snippet you provided.
Yay overloads!
Yes, I figured it could be done because of the MemoryImage, but that
wasn't the point. You are delving in to code that you might not
normally have access or might not exist.
Adam wrote the MemoryImage that essentially does this but that is not
the general case.
Image if all you access to was readPng(string filename), then what would
you say? That was my point of posting the code, I didn't mean for you to
go look and see if it was possible to achieve what I was saying in
arsd(Formally known as Adam Druppe) git repository ;)
Then I would say go get a new image library as that one isn't a very
good one.
..snip..
Right got rid of all that text.
If you want to make the filesystem appear to have files it doesn't,
you'll need a virtual file system library.
Welcome to the next issue, getting libraries to support it ;)