Re: [Chicken-users] severe bug in file-exists?

2011-09-28 Thread John Cowan
Sven Hartrumpf scripsit:

> (file-exists? filename)
> Filename must be a string. The file-exists? procedure
> returns #t if the named file exists at the time the procedure
> is called, #f otherwise.

Since nothing is said about exceptions, you are free to throw one if
you cannot determine the answer.  I agree that access() is the Right
Thing here.

-- 
Henry S. Thompson said, / "Syntactic, structural,   John Cowan
Value constraints we / Express on the fly." co...@ccil.org
Simon St. Laurent: "Your / Incomprehensible http://www.ccil.org/~cowan
Abracadabralike / schemas must die!"

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] severe bug in file-exists?

2011-09-28 Thread Thomas Chust
2011/9/28 Christian Kellermann :
> [...]
> As I see it, this procedure needs an overhaul anyway. If fstat fails
> it returns #f regardless the reason.
> [...]

Hello,

while it is true that only an ENOENT errno indicates a missing path
component in any file system operation, I also wonder why on earth
anyone would want to use fstat to check for the existence of a file?

To use fstat you first have to open the file, but if it can be opened,
it clearly exists and calling fstat at all is redundant. However, if
it cannot be opened, a large variety of reasons other than
nonexistence of the file can be responsible.

Calling stat instead of fstat and checking for an ENOENT errno would
be an option, but if one is only interested in the existence of the
file it looks like overkill to me to collect all the metainformation
about the file and then throw it away.

I would say that the canonical way to check for file existence is
calling access with the candidate path as first argument and the mode
F_OK as second argument and checking for an ENOENT errno.

Ciao,
Thomas


-- 
When C++ is your hammer, every problem looks like your thumb.

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] severe bug in file-exists?

2011-09-28 Thread Sven Hartrumpf
Wed, 28 Sep 2011 15:40:57 +0200, ckeen wrote:

> As I see it, this procedure needs an overhaul anyway. If fstat fails
> it returns #f regardless the reason. On IRC we have been coming
> to the understanding that we should raise an I/O exception for all
> other cases (if the fstat fails for other reasons than the file not
> being there).
> 
> What does R7RS specify there?

Nothing, just this:

(file-exists? filename)
Filename must be a string. The file-exists? procedure
returns #t if the named file exists at the time the procedure
is called, #f otherwise.

Sven

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] severe bug in file-exists?

2011-09-28 Thread Christian Kellermann
* Sven Hartrumpf  [110928 15:38]:
> Hi Christian.
> 
> Wed, 28 Sep 2011 15:10:46 +0200, ckeen wrote:
> >> I have just lost some files
> 
> > I hope the data is not lost completely.
> 
> No, it can be recovered automatically :-)
> 
> > I have filed bug #706 in the tracker.
> > https://bugs.call-cc.org/ticket/706
> 
> Thanks for filing the bug.
> 
> Looking at the report, I see that file-exists? returns
> the file name if the file exists.
> This violates R7RS and R6RS, does not it?

As I see it, this procedure needs an overhaul anyway. If fstat fails
it returns #f regardless the reason. On IRC we have been comming
to the understanding that we should raise an I/O exception for all
other cases (if the fstat fails for other reasons than the file not
being there).

What does R7RS specify there?

-- 
Who can (make) the muddy water (clear)? Let it be still, and it will
gradually become clear. Who can secure the condition of rest? Let
movement go on, and the condition of rest will gradually arise.
 -- Lao Tse. 

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] severe bug in file-exists?

2011-09-28 Thread Sven Hartrumpf
Hi Christian.

Wed, 28 Sep 2011 15:10:46 +0200, ckeen wrote:
>> I have just lost some files

> I hope the data is not lost completely.

No, it can be recovered automatically :-)

> I have filed bug #706 in the tracker.
> https://bugs.call-cc.org/ticket/706

Thanks for filing the bug.

Looking at the report, I see that file-exists? returns
the file name if the file exists.
This violates R7RS and R6RS, does not it?

Sven

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] severe bug in file-exists?

2011-09-28 Thread Christian Kellermann
* Sven Hartrumpf  [110928 14:57]:
> Hi all.
> 
> I have just lost some files (fortunately, they can be restored somehow)
> because file-exists? returned #f for large files (> 2 GB).

I am sorry to hear that. This seems to be an issue with 32bit chickens.
Thanks for the report, I hope the data is not lost completely.

I have files bug #706 in the tracker.
https://bugs.call-cc.org/ticket/706

Kind regards,

Christian

-- 
Who can (make) the muddy water (clear)? Let it be still, and it will
gradually become clear. Who can secure the condition of rest? Let
movement go on, and the condition of rest will gradually arise.
 -- Lao Tse. 

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] severe bug in file-exists?

2011-09-28 Thread Sven Hartrumpf
Hi all.

I have just lost some files (fortunately, they can be restored somehow)
because file-exists? returned #f for large files (> 2 GB).

Version:
CHICKEN
(c)2008-2011 The Chicken Team
(c)2000-2007 Felix L. Winkelmann
Version 4.7.4 (rev b6eba65)
linux-unix-gnu-x86 [ manyargs dload ]
compiled 2011-09-23 on sem11 (Linux)

This is a 32bit build on a 64bit machine.
(Same for 4.7.0)

Ciao
Sven

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users