[Novalug] file whats ?

John Franklin franklin@elfie.org
Fri Sep 12 10:00:07 EDT 2014


File handles vs file pointers?

If you have in a C program:

	FILE *fp = fopen("foo", "wb");

fp is a pointer to a FILE structure.  This is called a "FILE pointer" in the fopen(3) man page.  Because this pointer is generally the only way you interact with the FILE structure, documentation often refers to it as the file pointer.

The FILE structure itself is opaque to the developer and contains system-specific data about what file is open, the read/write state of the connection and the position in the file of the last read or write.  This FILE structure is sometimes called a file handle.  In languages other than C where pointers are less overt, such a Perl, a similar structure is more often called the file handle.

The current file position may also be called a pointer in some documentation.  It's usually clear from context if they're talking about a pointer to the structure or the current position in the file.

If you're a technical editor producing documentation, you're probably more conscious of the use of "pointer" vs "handle."  For the rest of us reading documentation (and blog entries and code examples), pointer vs handle is considered largely interchangeable.  As it should be, following Postel's Law.

jf

On Sep 12, 2014, at 7:11 AM, Walt Smith via Novalug <novalug@firemountain.net> wrote:

> file handle, file pointers, file locking, coherence...
> 
> And while we're here, and having a real technical
> discussion... which actually woke me up  ...
> 
> quote:
> 
> Short answer: Gary is correct.  The file (inode) is deleted (freed) when the reference count reaches zero.  Directory entries and open file handles both count as references.
> 
> Based on a quick skimming, the other answers also look correct, but are more detailed.  (One minor nit of Jason's answer: the version on disk is called an inode.  The version in memory is called a vnode.)
> 
> /quote
> 
> This might be for knoobee programmers:
> There are file handles, and file pointers.
> And perhaps a few other synonyms.
> 
> A very long time ago, I was confused by the 2 names
> in *nix docs.   At one point it seemed file handles were
> a DOS (MS) thingy, while file pointers were another 
> *nix specific thingy.
> 
> So my Q is: what is the difff between them ? and what other
> related terms could be confused ?
> 
> I also need to re-read the editor description....
> I think it's good to know the technique of a text ed, session... 
> whther the whole tamale "line" and/or block being edited is in RAM,
> how and when the line or block is written back out in 
> (what) order  to insure file coherence....     the description given 
> prev is good to know how the multiple accesses don't get
> cornfused ...
> 
> 
> thx,
> Walt....
> 
> ----
> The government is lawless, not the people.
> **********************************************************************
> The Novalug mailing list is hosted by firemountain.net.
> 
> To unsubscribe or change delivery options:
> http://www.firemountain.net/mailman/listinfo/novalug

-- 
John Franklin
franklin@elfie.org






More information about the Novalug mailing list