]>
cygwin.com Git - cygwin-apps/setup.git/blob - mkdir.cc
2 * Copyright (c) 2000, Red Hat, Inc.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * A copy of the GNU General Public License can be found at
12 * Written by DJ Delorie <dj@cygnus.com>
19 static const char *cvsid
=
23 #if defined(WIN32) && !defined (_CYGWIN_)
32 mkdir_p (int isadir
, const char *in_path
)
34 char saved_char
, *slash
= 0;
36 char path
[strlen (in_path
) + 1];
37 #if defined(WIN32) && !defined (_CYGWIN_)
39 strcpy (path
, in_path
);
41 d
= GetFileAttributes (path
);
42 if (d
!= 0xffffffff && d
& FILE_ATTRIBUTE_DIRECTORY
)
47 if (CreateDirectory (path
, 0))
49 gse
= GetLastError ();
50 if (gse
!= ERROR_PATH_NOT_FOUND
&& gse
!= ERROR_FILE_NOT_FOUND
)
52 if (gse
== ERROR_ALREADY_EXISTS
)
55 "warning: deleting \"%s\" so I can make a directory there\n",
57 if (DeleteFileA (path
))
58 return mkdir_p (isadir
, path
);
64 strcpy (path
, in_path
);
67 /* if file exists and is a dir return */
68 /* if we want a dir at this point
71 if fails due to present file,
72 rmove the file and return 1
73 else if fails due to missing fail/path
77 for (c
= path
; *c
; c
++)
81 if (*c
== '/' || *c
== '\\')
88 // Trying to create a drive... It's time to give up.
89 if (((slash
- path
) == 2) && (path
[1] == ':'))
94 if (mkdir_p (1, path
))
105 return mkdir_p (isadir
, path
);
This page took 0.039166 seconds and 5 git commands to generate.