This commit is contained in:
2025-12-15 21:42:14 +05:30
parent 1b24256653
commit 4d5d06c3c0
9 changed files with 90 additions and 31 deletions

View File

@ -37,11 +37,20 @@ target_link_libraries(IACore PRIVATE
target_link_libraries(IACore PUBLIC mimalloc-static)
if(WIN32)
if(MSVC)
target_link_options(IACore PUBLIC "/INCLUDE:mi_version")
else()
target_link_options(IACore PUBLIC "")
endif()
endif()
target_precompile_headers(IACore PUBLIC inc/IACore/PCH.hpp)
target_compile_options(IACore PRIVATE -fno-exceptions)
set(NO_EXCEPT_FLAG "$<IF:$<CXX_COMPILER_ID:MSVC>,/EHs-c-,-fno-exceptions>")
target_compile_options(IACore PRIVATE ${NO_EXCEPT_FLAG})
target_compile_options(IACore INTERFACE
$<$<NOT:$<BOOL:$<TARGET_PROPERTY:USE_EXCEPTIONS>>>:-fno-exceptions>
$<$<NOT:$<BOOL:$<TARGET_PROPERTY:USE_EXCEPTIONS>>>:${NO_EXCEPT_FLAG}>
)
define_property(TARGET PROPERTY USE_EXCEPTIONS

View File

@ -228,11 +228,14 @@ namespace IACore
Expected<SIZE_T, String> FileOps::WriteTextFile(IN CONST FilePath &path, IN CONST String &contents,
IN BOOL overwrite)
{
if (!overwrite && FileSystem::exists(path))
return MakeUnexpected(std::format("File aready exists: {}", path.string().c_str()));
const auto f = fopen(path.string().c_str(), "w");
const char *mode = overwrite ? "w" : "wx";
const auto f = fopen(path.string().c_str(), mode);
if (!f)
{
if (!overwrite && errno == EEXIST)
return MakeUnexpected(std::format("File already exists: {}", path.string().c_str()));
return MakeUnexpected(std::format("Failed to write to file: {}", path.string().c_str()));
}
const auto result = fwrite(contents.data(), 1, contents.size(), f);
fputc(0, f);
fclose(f);
@ -242,12 +245,14 @@ namespace IACore
Expected<SIZE_T, String> FileOps::WriteBinaryFile(IN CONST FilePath &path, IN Span<UINT8> contents,
IN BOOL overwrite)
{
if (!overwrite && FileSystem::exists(path))
return MakeUnexpected(std::format("File aready exists: {}", path.string().c_str()));
const auto f = fopen(path.string().c_str(), "wb");
const char *mode = overwrite ? "w" : "wx";
const auto f = fopen(path.string().c_str(), mode);
if (!f)
{
if (!overwrite && errno == EEXIST)
return MakeUnexpected(std::format("File already exists: {}", path.string().c_str()));
return MakeUnexpected(std::format("Failed to write to file: {}", path.string().c_str()));
}
const auto result = fwrite(contents.data(), 1, contents.size(), f);
fclose(f);
return result;

View File

@ -175,6 +175,8 @@ namespace IACore
VOID IPC_Manager::NodeSession::SendPacket(IN UINT16 packetID, IN Span<CONST UINT8> payload)
{
// Protect the RingBuffer write cursor from concurrent threads
ScopedLock lock(SendMutex);
MONI->Push(packetID, payload);
}

View File

@ -206,19 +206,35 @@ namespace IACore
// Manual Quote-Aware Splitter
std::string currentToken;
bool inQuotes = false;
bool isEscaped = false;
for (char c : args)
{
if (isEscaped)
{
// Previous char was '\', so we treat this char literally.
currentToken += c;
isEscaped = false;
continue;
}
if (c == '\\')
{
// Escape sequence start
isEscaped = true;
continue;
}
if (c == '\"')
{
// Toggle quote state
inQuotes = !inQuotes;
// Determine if you want to keep the quotes or strip them.
// Usually for execvp, you strip them so the shell receives the raw content.
continue;
}
if (c == ' ' && !inQuotes)
{
// Token boundary
if (!currentToken.empty())
{
argStorage.push_back(currentToken);
@ -230,6 +246,7 @@ namespace IACore
currentToken += c;
}
}
if (!currentToken.empty())
{
argStorage.push_back(currentToken);

View File

@ -104,6 +104,8 @@ namespace IACore
SteadyTimePoint CreationTime{};
SharedPtr<ProcessHandle> ProcessHandle;
Mutex SendMutex;
String SharedMemName;
PUINT8 MappedPtr{};