Re: Directories are not files
From: Barry Margolin (barry.margolin_at_level3.com)
Date: 08/28/03
- Next message: Chuck Dillon: "Re: sql from within c program"
- Previous message: William Ahern: "Re: Directories are not files"
- In reply to: William Ahern: "Re: Directories are not files"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 28 Aug 2003 17:50:00 GMT
In article <0ao121-nqi.ln1@wilbur.25thandClement.com>,
William Ahern <william@wilbur.25thandClement.com> wrote:
>>From what I gather, back in the more formative days of Unix you could easily
>just open() and read() a directory and by standard convention read a list
>of the files in that directory (fgets() maybe?).
I don't think you could ever do it with fgets(). But the original
directory format was fixed-length structures (which is why filenames were
limited to 14 characters), which you could read easily with fread().
>But then as time went on the format of the directory "file" started to get
>more complex and differentiated across implementations. So then readdir()
>and freinds emerged as the only portable way to read the directory data.
>
>Directories are still files, but their format is platform/filesystem
>dependent. Ever wonder why there's that wierd d_reclen (record length)
>member of struct dirent?
Note, however, that network file servers often don't make them accessible
as ordinary files. Many operating systems don't allow users to read
directories directly, and network protocols try to abstract away the
differences when possible.
So if you try to "cat dir-on-nfs-server", you'll usually get an error like:
cat: input error on dir-on-nfs-server: Is a directory
-- Barry Margolin, barry.margolin@level3.com Level(3), Woburn, MA *** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups. Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.
- Next message: Chuck Dillon: "Re: sql from within c program"
- Previous message: William Ahern: "Re: Directories are not files"
- In reply to: William Ahern: "Re: Directories are not files"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|