🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #10383

FileExists() is using wildcards

#10383
From: Hans Galema
Date: Mon, 26 Apr 2004 20:17
50 lines
2183 bytes
Had some bad hours searching for unexpected behaviour
on a remote server.

Finally I could track it down on a 'failing' of FileExists().

There was a '?' in a FileName that was generated by code.
The '?' was interpreted as a wildcard.

Before loading the file in a TRichEdit I checked
it precence by using FileExist.

There came no answer from the server as the folowing
LoadFromFile threw an exeption.

Demo:

void __fastcall TForm1::Button2Click(TObject *Sender)
{
   AnsiString FileName = "Unit1.?";

   if ( FileExists ( FileName ) ) // This will find Unit1.cpp or Unit1.h
      {
      ShowMessage ( FileName + "\n\nFileExists" );

      Memo1->Lines->LoadFromFile ( FileName );   // exeption!
      }
   else
      ShowMessage ( FileName + "\n\nno FileExists" );
}

There is nothing in the help for bcb3 that informs of FileExists using
wildcards.

Now I can write my own file_exists() which does what I want:

#include <stdio.h>
bool file_exists ( char *path )
         {
         FILE *stream = fopen ( path, "rb" );

         if ( ! stream ) return false;

         fclose ( stream );

         return true;
         }

But is there a more native solution ?

Hans.
Technical Details
Message-ID: <408d6cad$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.frii.net!newsfeed.frii.net!news.compaq.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,8374fb71f8a662f4,start
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2004-04-26 13:39:29 PST
Date: Mon, 26 Apr 2004 22:17:10 +0200
From: Hans Galema <dontusethis@dontusethis.nl>
User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.6b) Gecko/20031208
X-Accept-Language: en-us, en
MIME-Version: 1.0
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: FileExists() is using wildcards
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 129.125.202.241
Message-ID: <408d6cad$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1083010221 129.125.202.241 (26 Apr 2004 13:10:21 -0700)
Lines: 50
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.frii.net!newsfeed.frii.net!news.compaq.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail