TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: Neil Heller
from: Jasen Betts
date: 2003-07-22 19:08:08
subject: Creating a directory

Hi Neil.

20-Jul-03 13:53:00, Neil Heller wrote to All


 NH> I wrote an application that I wish to modify in the following way:

 NH> If a subdirectory of a certain name does not exist, create it.

 NH> I thought: "this is a piece of cake".  I'll use mkdir() and if the
 NH> return value != 0, it already existed prior to the call.

 NH> That's it.  Quite easy, eh?

 NH> Then I looked at the meager documentation I have and found that
 NH> mkdir() is NON-standard (indeed, its provided as _mkdir()).  Then
 NH> I looked in Snippets and found that this venerable tool uses
 NH> mkdir().  I looked at the methods of the CFile class and found no
 NH> help there.

C makes very few assumptions about the operatinf system
as such mkdir isn't an ISO standard... some operting systems don't support
directories....

mkdir() made it into Posix, so it should be availavble on most
platforms that support that sort of behavior.... (eg not available on CP/M)

note also that mkdir will fail if there's already a file with a name like
the directory you want to create, or may fail for other resons too...

 NH> BTW, mkdir() is a standard part of Java, FWIW.

java is differenlty targeted than C.

 NH> Is there a "standard" way of dealing with directory creation? In
 NH> thinking about this, it seems to me that directories are not
 NH> standard so how can there be a standard way of dealing with them?

Bingo! use mkdir().

---
* Origin: Entropy isn't what it used to be. (3:640/1042)
SEEN-BY: 633/267 270
@PATH: 640/1042 531 954 774/605 123/500 106/2000 633/267

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.