Skip to content

Improve utility code clarity and add CcpTruncateFile#29

Open
MiloPernemarkDEV wants to merge 5 commits into
carbonengine:mainfrom
MiloPernemarkDEV:file-utils/truncate
Open

Improve utility code clarity and add CcpTruncateFile#29
MiloPernemarkDEV wants to merge 5 commits into
carbonengine:mainfrom
MiloPernemarkDEV:file-utils/truncate

Conversation

@MiloPernemarkDEV

@MiloPernemarkDEV MiloPernemarkDEV commented Jul 10, 2026

Copy link
Copy Markdown

Added CcpTruncateFile as an explicit API for clearing file contents. This avoids requiring users to know that CcpCreateFile internally uses _O_TRUNC, making the truncation behavior clearer at the call site.

The current implementation reuses CcpCreateFile to preserve the existing behavior and avoid duplicating file creation logic. If the preferred approach is to handle truncation directly inside CcpTruncateFile, I can adjust it.

Additional cleanup:

  • Replaced hardcoded buffer sizes in the logging implementation with named constexpr values for improved readability and maintainability.
  • Replaced a C-style pointer cast with reinterpret_cast in the time implementation to make the intent of the conversion explicit.

@MiloPernemarkDEV MiloPernemarkDEV changed the title Add truncate function for a clearer api Improve code clarity and add truncate function in file util Jul 10, 2026
@MiloPernemarkDEV MiloPernemarkDEV changed the title Improve code clarity and add truncate function in file util Improve utility code clarity and add CcpTruncateFile Jul 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant