🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: A file is directory

#12703
From: Jonathan Arnold
Date: Fri, 21 Nov 2003 14:30
20 lines
1595 bytes
Sten Larsson wrote:
> How can I figure out if a path is a directory or a file? Preferrably in
> plain c (as opposed to Win32).

The stat function, while not ANSI C, is POSIX C, so it is in
most nearly any reasonable C library. You can test the mode:

struct stat statbuf;
stat( "C:/", &statbuf );
if ( statbuf.st_mode & S_IFDIR )
{ // We have a directory
   ....
}


-- 
Jonathan Arnold         C/C++/CBuilder Keen Advice:
http://www.keen.com/categories/categorylist_expand.asp?sid=5156620
    Comprehensive C++Builder link site:
http://www.buddydog.org/C++Builder/c++builder.html
Technical Details
Message-ID: <3fbe218c@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <3fbb07d7@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,49b53b5f67858186
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-11-21 06:40:40 PST
Date: Fri, 21 Nov 2003 09:30:36 -0500
From: Jonathan Arnold <jdarnold@buddydog.org>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.6a) Gecko/20031030 MultiZilla/1.5.0.3l
X-Accept-Language: en-us, en, ja
MIME-Version: 1.0
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: A file is directory
References: <3fbb07d7@newsgroups.borland.com>
In-Reply-To: <3fbb07d7@newsgroups.borland.com>
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 66.92.76.225
Message-ID: <3fbe218c@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1069425036 66.92.76.225 (21 Nov 2003 06:30:36 -0700)
Lines: 20
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail