Re: Imaginary File Path
Re: Imaginary File Path
- Subject: Re: Imaginary File Path
- From: John Goodman <email@hidden>
- Date: Fri, 7 Dec 2007 12:02:52 -0500
To use a pipe your C++ would have to read the data from stdin,
I'm not the author of the C++ tool; I'm just compiling code I get
from someone else's project. The tool unfortunately doesn't use
stdin, or any stream, for the input data.
for a socket your first process would create a UNIX domain socket
using bind (the socket will appear in the filesystem as a socket
file), then pass the path of the socket to the tool.
This sounds promising. My exposure to UNIX is limited to what I've
seen funneled through Mac OS X, so there's a lot I don't know. But
the description of sockets and bind that I'm seeing makes me think I
can learn enough to make this work. ("A socket is created with no
name. A remote process has no way to refer to a socket until an
address is bound to the socket... The bind() call enables a process
to specify the local address of the socket.")
If the tool needs to randomly access the data in the file, things
will get considerably more complicated.
I don't believe this is the case, but you're making it clear to me
that I'd better check. If the tool *does* need random access, then
I'm going to punt on my stream idea.
Thank you for the suggestions and for pointing me down a new (non-
imaginary) path to explore.
On Dec 7, 2007, at 11:19 AM, James Bucanek wrote:
John Goodman <mailto:email@hidden> wrote (Friday, December
7, 2007 7:35 AM -0500):
What I'd like to do instead, is to find a way to present my data
as if
it were a file, without actually saving the data to disk. If I have
the data in memory, I'd like to be able to persuade the command line
tool that the file is "really" on the disk, by giving it an
"imaginary" file path.
You'll have to involve the file system. By definition, a "path" is
a name in a filesystem. To access the data associated with that
path you'll have to create an entity in the filesystem or the
filesystem simply won't know what your C++ tool is talking about.
Ideally, I could even stream the data to the tool, as long as the
tool
thought it was working with a file.
The only simple choices that I can think of are a pipe or a socket,
both of which would require that the C++ tool read the data in the
file sequentially. To use a pipe your C++ would have to read the
data from stdin, for a socket your first process would create a
UNIX domain socket using bind (the socket will appear in the
filesystem as a socket file), then pass the path of the socket to
the tool.
If the tool needs to randomly access the data in the file, things
will get considerably more complicated. You might experiment with
mmap(), although I doubt this will help much because ultimately the
data will still end up on the disk.
The only other solution that leaps to mind is something like FUSE
where you could create a virtual filesystem that presented your
data as a file. But that's like renting a crane to take out the
garbage.
Or, just find yourself a RAM disk driver and write the data to a
file on the RAM disk.
--
James Bucanek
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden