Talk:Check that file exists: Difference between revisions

Content added Content deleted
(Old solution for C)
 
(check, rather than ensure)
Line 41: Line 41:


This used <code>chdir()</code> from [[POSIX]] to test a directory. I got compiler error, because [[OpenBSD]] has no <dir.h>; I must use <unistd.h>. I also got "input.txt does exist" when input.txt was a directory, because BSD can <code>fopen()</code> a directory. The current solution for C uses <code>S_ISREG()</code> and <code>S_ISDIR()</code> from POSIX. --[[User:Kernigh|Kernigh]] 00:59, 18 May 2011 (UTC)
This used <code>chdir()</code> from [[POSIX]] to test a directory. I got compiler error, because [[OpenBSD]] has no <dir.h>; I must use <unistd.h>. I also got "input.txt does exist" when input.txt was a directory, because BSD can <code>fopen()</code> a directory. The current solution for C uses <code>S_ISREG()</code> and <code>S_ISDIR()</code> from POSIX. --[[User:Kernigh|Kernigh]] 00:59, 18 May 2011 (UTC)

==Rename==

I think this should be named "Check if file exists". I think we are checking, rather than ensuring. "Ensure" implies creation if file does not exist. [[User:Markhobley|Markhobley]] 20:13, 18 August 2011 (UTC)