\r
HANDLE write_to_file(TCHAR *path, unsigned long sharing, SECURITY_ATTRIBUTES *attributes, unsigned long disposition, unsigned long flags) {\r
HANDLE ret = CreateFile(path, FILE_WRITE_DATA, sharing, attributes, disposition, flags, 0);\r
- if (ret) {\r
+ if (ret!= INVALID_HANDLE_VALUE) {\r
if (SetFilePointer(ret, 0, 0, FILE_END) != INVALID_SET_FILE_POINTER) SetEndOfFile(ret);\r
return ret;\r
}\r
\r
/* Try to open the file to check if it exists and to get attributes. */\r
HANDLE file = CreateFile(path, 0, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);\r
- if (file) {\r
+ if (file != INVALID_HANDLE_VALUE) {\r
/* Get file attributes. */\r
if (! GetFileInformationByHandle(file, &info)) {\r
/* Reuse current time for rotation timestamp. */\r
/* stdin */\r
if (service->stdin_path[0]) {\r
si->hStdInput = CreateFile(service->stdin_path, FILE_READ_DATA, service->stdin_sharing, 0, service->stdin_disposition, service->stdin_flags, 0);\r
- if (! si->hStdInput) {\r
+ if (si->hStdInput == INVALID_HANDLE_VALUE) {\r
log_event(EVENTLOG_ERROR_TYPE, NSSM_EVENT_CREATEFILE_FAILED, service->stdin_path, error_string(GetLastError()), 0);\r
return 2;\r
}\r
if (service->stdout_path[0]) {\r
if (service->rotate_files) rotate_file(service->name, service->stdout_path, service->rotate_seconds, service->rotate_bytes_low, service->rotate_bytes_high, service->rotate_delay, service->stdout_copy_and_truncate);\r
HANDLE stdout_handle = write_to_file(service->stdout_path, service->stdout_sharing, 0, service->stdout_disposition, service->stdout_flags);\r
- if (! stdout_handle) return 4;\r
+ if (stdout_handle == INVALID_HANDLE_VALUE) return 4;\r
\r
if (service->rotate_files && service->rotate_stdout_online) {\r
service->stdout_pipe = si->hStdOutput = 0;\r
else {\r
if (service->rotate_files) rotate_file(service->name, service->stderr_path, service->rotate_seconds, service->rotate_bytes_low, service->rotate_bytes_high, service->rotate_delay, service->stderr_copy_and_truncate);\r
HANDLE stderr_handle = write_to_file(service->stderr_path, service->stderr_sharing, 0, service->stderr_disposition, service->stderr_flags);\r
- if (! stderr_handle) return 7;\r
+ if (stderr_handle == INVALID_HANDLE_VALUE) return 7;\r
\r
if (service->rotate_files && service->rotate_stderr_online) {\r
service->stderr_pipe = si->hStdError = 0;\r
\r
/* Reopen. */\r
logger->write_handle = write_to_file(logger->path, logger->sharing, 0, logger->disposition, logger->flags);\r
- if (! logger->write_handle) {\r
+ if (logger->write_handle == INVALID_HANDLE_VALUE) {\r
error = GetLastError();\r
log_event(EVENTLOG_ERROR_TYPE, NSSM_EVENT_CREATEFILE_FAILED, logger->path, error_string(error), 0);\r
/* Oh dear. Now we can't log anything further. */\r