diff options
Diffstat (limited to '3rdparty/bx/src/process.cpp')
-rw-r--r-- | 3rdparty/bx/src/process.cpp | 39 |
1 files changed, 19 insertions, 20 deletions
diff --git a/3rdparty/bx/src/process.cpp b/3rdparty/bx/src/process.cpp index 90d663b3f5a..8afa1feb230 100644 --- a/3rdparty/bx/src/process.cpp +++ b/3rdparty/bx/src/process.cpp @@ -1,9 +1,8 @@ /* - * Copyright 2010-2018 Branimir Karadzic. All rights reserved. - * License: https://github.com/bkaradzic/bx#license-bsd-2-clause + * Copyright 2010-2022 Branimir Karadzic. All rights reserved. + * License: https://github.com/bkaradzic/bx/blob/master/LICENSE */ -#include "bx_p.h" #include <bx/process.h> #include <stdio.h> @@ -34,28 +33,28 @@ namespace bx ProcessReader::~ProcessReader() { - BX_CHECK(NULL == m_file, "Process not closed!"); + BX_ASSERT(NULL == m_file, "Process not closed!"); } bool ProcessReader::open(const FilePath& _filePath, const StringView& _args, Error* _err) { - BX_CHECK(NULL != _err, "Reader/Writer interface calling functions must handle errors."); + BX_ASSERT(NULL != _err, "Reader/Writer interface calling functions must handle errors."); if (NULL != m_file) { - BX_ERROR_SET(_err, BX_ERROR_READERWRITER_ALREADY_OPEN, "ProcessReader: File is already open."); + BX_ERROR_SET(_err, kErrorReaderWriterAlreadyOpen, "ProcessReader: File is already open."); return false; } char tmp[kMaxFilePath*2] = "\""; - strCat(tmp, BX_COUNTOF(tmp), _filePath.get() ); + strCat(tmp, BX_COUNTOF(tmp), _filePath); strCat(tmp, BX_COUNTOF(tmp), "\" "); strCat(tmp, BX_COUNTOF(tmp), _args); m_file = popen(tmp, "r"); if (NULL == m_file) { - BX_ERROR_SET(_err, BX_ERROR_READERWRITER_OPEN, "ProcessReader: Failed to open process."); + BX_ERROR_SET(_err, kErrorReaderWriterOpen, "ProcessReader: Failed to open process."); return false; } @@ -64,7 +63,7 @@ namespace bx void ProcessReader::close() { - BX_CHECK(NULL != m_file, "Process not open!"); + BX_ASSERT(NULL != m_file, "Process not open!"); FILE* file = (FILE*)m_file; m_exitCode = pclose(file); m_file = NULL; @@ -72,7 +71,7 @@ namespace bx int32_t ProcessReader::read(void* _data, int32_t _size, Error* _err) { - BX_CHECK(NULL != _err, "Reader/Writer interface calling functions must handle errors."); BX_UNUSED(_err); + BX_ASSERT(NULL != _err, "Reader/Writer interface calling functions must handle errors."); BX_UNUSED(_err); FILE* file = (FILE*)m_file; int32_t size = (int32_t)fread(_data, 1, _size, file); @@ -80,11 +79,11 @@ namespace bx { if (0 != feof(file) ) { - BX_ERROR_SET(_err, BX_ERROR_READERWRITER_EOF, "ProcessReader: EOF."); + BX_ERROR_SET(_err, kErrorReaderWriterEof, "ProcessReader: EOF."); } else if (0 != ferror(file) ) { - BX_ERROR_SET(_err, BX_ERROR_READERWRITER_READ, "ProcessReader: read error."); + BX_ERROR_SET(_err, kErrorReaderWriterRead, "ProcessReader: read error."); } return size >= 0 ? size : 0; @@ -105,28 +104,28 @@ namespace bx ProcessWriter::~ProcessWriter() { - BX_CHECK(NULL == m_file, "Process not closed!"); + BX_ASSERT(NULL == m_file, "Process not closed!"); } bool ProcessWriter::open(const FilePath& _filePath, const StringView& _args, Error* _err) { - BX_CHECK(NULL != _err, "Reader/Writer interface calling functions must handle errors."); + BX_ASSERT(NULL != _err, "Reader/Writer interface calling functions must handle errors."); if (NULL != m_file) { - BX_ERROR_SET(_err, BX_ERROR_READERWRITER_ALREADY_OPEN, "ProcessWriter: File is already open."); + BX_ERROR_SET(_err, kErrorReaderWriterAlreadyOpen, "ProcessWriter: File is already open."); return false; } char tmp[kMaxFilePath*2] = "\""; - strCat(tmp, BX_COUNTOF(tmp), _filePath.get() ); + strCat(tmp, BX_COUNTOF(tmp), _filePath); strCat(tmp, BX_COUNTOF(tmp), "\" "); strCat(tmp, BX_COUNTOF(tmp), _args); m_file = popen(tmp, "w"); if (NULL == m_file) { - BX_ERROR_SET(_err, BX_ERROR_READERWRITER_OPEN, "ProcessWriter: Failed to open process."); + BX_ERROR_SET(_err, kErrorReaderWriterOpen, "ProcessWriter: Failed to open process."); return false; } @@ -135,7 +134,7 @@ namespace bx void ProcessWriter::close() { - BX_CHECK(NULL != m_file, "Process not open!"); + BX_ASSERT(NULL != m_file, "Process not open!"); FILE* file = (FILE*)m_file; m_exitCode = pclose(file); m_file = NULL; @@ -143,7 +142,7 @@ namespace bx int32_t ProcessWriter::write(const void* _data, int32_t _size, Error* _err) { - BX_CHECK(NULL != _err, "Reader/Writer interface calling functions must handle errors."); BX_UNUSED(_err); + BX_ASSERT(NULL != _err, "Reader/Writer interface calling functions must handle errors."); BX_UNUSED(_err); FILE* file = (FILE*)m_file; int32_t size = (int32_t)fwrite(_data, 1, _size, file); @@ -151,7 +150,7 @@ namespace bx { if (0 != ferror(file) ) { - BX_ERROR_SET(_err, BX_ERROR_READERWRITER_WRITE, "ProcessWriter: write error."); + BX_ERROR_SET(_err, kErrorReaderWriterWrite, "ProcessWriter: write error."); } return size >= 0 ? size : 0; |