FileDescriptor

B

bob smith

Can someone help me understand the class FileDescriptor?

Seems like it is mainly a wrapper for this:

private int fd;

But there's no obvious way to access or set that value. Am I missing something?
 
D

Daniel Pitts

Can someone help me understand the class FileDescriptor?

Seems like it is mainly a wrapper for this:

private int fd;

But there's no obvious way to access or set that value. Am I missing something?
What would you do with that value? It is generally opaque, and only
useful to pass through to other methods which already take the
FileDescriptor object.
 
A

Arne Vajhøj

Can someone help me understand the class FileDescriptor?

Seems like it is mainly a wrapper for this:

private int fd;

But there's no obvious way to access or set that value. Am I missing something?

To quote the docs:

<docs>
Instances of the file descriptor class serve as an opaque handle to the
underlying machine-specific structure representing an open file, an open
socket, or another source or sink of bytes. The main practical use for a
file descriptor is to create a FileInputStream or FileOutputStream to
contain it.
</docs>

You can get it out from a File*Stream and you can use it to
construct a new File*Stream.

But what it contains is implementation specific and hidden
from you.

Good OOP.

On various *nix and *nix-like OS'es it could be a traditional
int fd.

Arne
 
R

Roedy Green

Can someone help me understand the class FileDescriptor?

It is not a class you would use directly. It provides a way to hold a
platform-specific handle to an open file.

At the assembler level in Windows, when you open a file, Windows gives
you an int handle to use to read/write. You don't specify the full
filename each time or read or write, just the handle.
 
A

Arne Vajhoej

It is not a class you would use directly. It provides a way to hold a
platform-specific handle to an open file.

So far so good.
At the assembler level in Windows,

Nope. C level.
when you open a file, Windows gives
you an int handle to use to read/write. You don't specify the full
filename each time or read or write, just the handle.

That is like almost all languages and all API's.

Arne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top