From: Lloyd Zusman Date: 2002-08-10T04:40:31+09:00 Subject: Re: Getting the file name from a File::Stat object? GOTO Kentaro writes: > At Sat, 10 Aug 2002 03:56:48 +0900, > Lloyd Zusman wrote: >> I want to use that name in order to implement a "File::Stat#textfile?" >> method that returns true if the item in question is a file which >> contains non-binary data. In order to implement the "textfile?" method, >> I have to have a filename that I can pass to an "open" method call, >> as follows: > > I see. But why not File#textfile?. For normal files, you can > implement File#textfile? straightforwardly. > > [ ... etc. ... ] Yes, I could indeed do it that way, but the "File::Stat#textfile?" method seems similar to the "File::Stat#file?" method, and to me, it seems more logical for that method to belong within the File::Stat class. After all, it's only a Unix-specific implementation detail that requires us to open the file and read a block of data in order to determine whether we have a text file. There might be other operating systems that supply that information in a different manner. The "File::Stat#textfile?" method would then not need to do an "open" or a "read" under that OS. Therefore, to me, the "textfile?" method seems to just be returning an attribute of a file, just like "size", "blksize", "ino", "dev", and other information that File::Stat returns. But I guess that this is a matter of personal taste. -- Lloyd Zusman ljz@asfast.com