]>
git.saurik.com Git - wxWidgets.git/blob - utils/Install/packace/uac_crt.c
1 /* ------------------------------------------------------------------------ */
3 /* Creates/Replaces files or directories. */
5 /* ------------------------------------------------------------------------ */
10 #include <fcntl.h> // AMIGA: open()
11 #include <stdio.h> // pipeit() remove()
12 #include <string.h> // strncpy()
13 #include <sys/types.h>
14 #include <sys/stat.h> // struct stat
18 #if defined(DOS) || defined(WINNT) || defined(WIN16)
19 #include <io.h> // access()
32 /* gets file name from header
34 CHAR
*ace_fname(CHAR
* s
, thead
* head
, INT nopath
)
39 strncpy(s
, (CHAR
*)(*(tfhead
*) head
).FNAME
, i
= (*(tfhead
*) head
).FNAME_SIZE
);
46 memmove(s
, cp
+1, strlen(cp
));
52 void check_ext_dir(CHAR
* f
) // checks/creates path of file
62 if ((cp
= (CHAR
*) strchr(&f
[strlen(d
) + 1], DIRSEP
))!=NULL
)
72 #if (defined(__OS2__) && !defined(__EMX__)) || (defined(WINNT) && !defined(__CYGWIN__))
79 pipeit("\n Error while creating directory.\n");
84 INT
ovr_delete(CHAR
* n
) // deletes directory or file
86 if (remove(n
) && rmdir(n
))
88 pipeit("\n Could not delete file or directory. Access denied.\n");
94 INT
create_dest_file(CHAR
* file
, INT a
) // creates file or directory
98 ex
= fileexists(file
);
105 { // create dir or file?
108 #if (defined(__OS2__) && !defined(__EMX__)) || (!defined(__CYGWIN__) && defined(WINNT))
109 if ((!ex
&& mkdir(file
)) || (ex
&& (st
.st_mode
& S_IFDIR
)))
111 if ((!ex
&& mkdir(file
, 0)) || (ex
&& (st
.st_mode
& S_IFDIR
)))
114 pipeit("\n Could not create directory.\n");
118 _dos_setfileattr(file
, a
); // set directory attributes
125 { // does the file already exist
128 i
= wrask("Overwrite existing file?"); // prompt for overwrite
133 if ((i
&& !f_ovrall
) || ovr_delete(file
))
134 return (-1); // delete?
136 #if defined(__OS2_) || defined(__EMX__) || defined(WIN32)
137 if ((han
= open(file
, O_WRONLY
| O_TRUNC
| O_CREAT
| O_BINARY
,
138 S_IREAD
| S_IWRITE
| S_IEXEC
| S_IDELETE
|
139 S_IRGRP
| S_IWGRP
| S_IROTH
| S_IWOTH
)) < 0)
141 if ((han
= open(file
, O_WRONLY
| O_TRUNC
| O_CREAT
,
142 S_IREAD
| S_IWRITE
| S_IEXEC
| S_IDELETE
|
143 S_IRGRP
| S_IWGRP
| S_IROTH
| S_IWOTH
)) < 0)
145 pipeit("\n Could not create destination file.\n");