* New version 2.20.11
[alpine.git] / pith / osdep / creatdir.c
blobd489cdee5976ad55751b0a1d6e9df2cb002c6c56
1 #if !defined(lint) && !defined(DOS)
2 static char rcsid[] = "$Id: creatdir.c 769 2007-10-24 00:15:40Z hubert@u.washington.edu $";
3 #endif
5 /*
6 * ========================================================================
7 * Copyright 2006-2007 University of Washington
8 * Copyright 2013-2016 Eduardo Chappa
10 * Licensed under the Apache License, Version 2.0 (the "License");
11 * you may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
14 * http://www.apache.org/licenses/LICENSE-2.0
16 * ========================================================================
19 #include <system.h>
20 #include "../charconv/utf8.h"
21 #include "../charconv/filesys.h"
22 #include "creatdir.h"
25 #ifdef S_IRWXU
26 #define MAILDIR_MODE S_IRWXU
27 #else
28 #define MAILDIR_MODE 0700
29 #endif
33 /*----------------------------------------------------------------------
34 Create the mail subdirectory.
36 Args: dir -- Name of the directory to create
38 Result: Directory is created. Returns 0 on success, else -1 on error
39 and errno is valid.
40 ----*/
41 int
42 create_mail_dir(char *dir)
44 if(our_mkdir(dir, MAILDIR_MODE) < 0)
45 return(-1);
47 #ifndef _WINDOWS
48 our_chmod(dir, MAILDIR_MODE);
50 /* Some systems need this, on others we don't care if it fails */
51 our_chown(dir, getuid(), getgid());
52 #endif /* !_WINDOWS */
54 return(0);