Mercurial > hg > nnchat
changeset 557:02244c553741
Fix Win32 side of log directory creation.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 13 Nov 2012 01:06:26 +0200 |
parents | 9b72d0060b85 |
children | e32881ece842 |
files | main.c |
diffstat | 1 files changed, 15 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/main.c Mon Nov 12 20:08:07 2012 +0200 +++ b/main.c Tue Nov 13 01:06:26 2012 +0200 @@ -1661,8 +1661,8 @@ #ifdef __WIN32 DWORD attr = GetFileAttributes(path); - *isDirectory = (attr & FILE_ATTRIBUTE_DIRECTORY); - *isWritable = (attr & FILE_ATTRIBUTE_READONLY) == 0 && *isDirectory == FALSE; + *isDirectory = (attr & FILE_ATTRIBUTE_DIRECTORY) != 0; + *isWritable = (attr & FILE_ATTRIBUTE_READONLY) == 0; *isReadable = TRUE; #else uid_t id = geteuid(); @@ -1674,6 +1674,9 @@ *isWritable = (id == sb.st_uid && (sb.st_mode & S_IWUSR)); *isReadable = (id == sb.st_uid && (sb.st_mode & S_IRUSR)); #endif + + THERR("'%s': dir=%d, wr=%d, rd=%d\n", + path, *isDirectory, *isWritable, *isReadable); return TRUE; } @@ -1684,6 +1687,7 @@ size_t start = 0, end; BOOL res = FALSE, exists, isDir, isWritable, isReadable; + THMSG(0, "Creating directory %s\n", cpath); do { for (save = 0, end = start; path[end] != 0; end++) @@ -1873,9 +1877,18 @@ else if (!isWritable) { +#ifdef __WIN32 + if (!nn_mkdir_rec(optLogPath)) + { + THERR("Could not create log file directory '%s'.\n", + optLogPath); + goto err_exit; + } +#else THERR("The log file path '%s' is not writable.\n", optLogPath); goto err_exit; +#endif } } else