KiCad PCB EDA Suite
Loading...
Searching...
No Matches
KIPLATFORM::IO Namespace Reference

Classes

class  MAPPED_FILE
 RAII wrapper for memory-mapped file I/O. More...
 

Functions

FILE * SeqFOpen (const wxString &aPath, const wxString &mode)
 Opens the file like fopen but sets flags (if available) for sequential read hinting.
 
bool DuplicatePermissions (const wxString &aSrc, const wxString &aDest)
 Duplicates the file security data from one file to another ensuring that they are the same between both.
 
bool MakeWriteable (const wxString &aFilePath)
 Ensures that a file has write permissions.
 
bool IsFileHidden (const wxString &aFileName)
 Helper function to determine the status of the 'Hidden' file attribute.
 
void LongPathAdjustment (wxFileName &aFilename)
 Adjusts a filename to be a long path compatible.
 
long long TimestampDir (const wxString &aDirPath, const wxString &aFilespec)
 Computes a hash of modification times and sizes for files matching a pattern.
 

Variables

static constexpr size_t CLOUD_SYNC_BUFFER_SIZE = 512 * 1024
 Buffer size for file I/O operations on cloud-synced folders.
 

Function Documentation

◆ DuplicatePermissions()

bool KIPLATFORM::IO::DuplicatePermissions ( const wxString & aSrc,
const wxString & aDest )

Duplicates the file security data from one file to another ensuring that they are the same between both.

This assumes that the user has permission to set #aDest

Returns
true if the process was successful

Definition at line 52 of file unix/io.cpp.

Referenced by PL_EDITOR_FRAME::SaveDrawingSheetFile(), STEP_PCB_MODEL::WriteGLTF(), STEP_PCB_MODEL::WritePDF(), STEP_PCB_MODEL::WritePLY(), STEP_PCB_MODEL::WriteSTEP(), STEP_PCB_MODEL::WriteSTL(), and STEP_PCB_MODEL::WriteU3D().

◆ IsFileHidden()

bool KIPLATFORM::IO::IsFileHidden ( const wxString & aFileName)

Helper function to determine the status of the 'Hidden' file attribute.

Returns
true if the file attribut is set.

Definition at line 90 of file unix/io.cpp.

Referenced by PROJECT_TREE_PANE::addItemToProjectTree().

◆ LongPathAdjustment()

void KIPLATFORM::IO::LongPathAdjustment ( wxFileName & aFilename)

Adjusts a filename to be a long path compatible.

This is a no-op on non-Windows platforms.

Definition at line 98 of file unix/io.cpp.

◆ MakeWriteable()

bool KIPLATFORM::IO::MakeWriteable ( const wxString & aFilePath)

Ensures that a file has write permissions.

This is useful after copying files that may have been read-only.

Parameters
aFilePathpath to the file to make writeable
Returns
true if the process was successful

Definition at line 75 of file unix/io.cpp.

Referenced by PCB_EDIT_FRAME::SavePcbCopy(), PCB_EDIT_FRAME::SavePcbFile(), and SCH_EDIT_FRAME::saveSchematicFile().

◆ SeqFOpen()

FILE * KIPLATFORM::IO::SeqFOpen ( const wxString & aPath,
const wxString & mode )

Opens the file like fopen but sets flags (if available) for sequential read hinting.

Only use this variant of fopen if the file is truely going to be read sequentially only otherwise you may encounter performance penalities.

Windows in particular is a little ulgy to set the sequential scan flag compared to say linux and it's posix_fadvise

Definition at line 36 of file unix/io.cpp.

Referenced by FILE_LINE_READER::FILE_LINE_READER().

◆ TimestampDir()

long long KIPLATFORM::IO::TimestampDir ( const wxString & aDirPath,
const wxString & aFilespec )

Computes a hash of modification times and sizes for files matching a pattern.

Used for cache invalidation by detecting changes to library directories.

Parameters
aDirPathDirectory to search
aFilespecWildcard pattern to match (e.g. "*.kicad_mod")
Returns
Hash value that changes when any matching file is modified

Definition at line 104 of file unix/io.cpp.

Referenced by SCH_IO_LIB_CACHE::GetLibModificationTime(), DESIGN_BLOCK_IO::GetLibraryTimestamp(), FP_CACHE::GetTimestamp(), GPCB_FPL_CACHE::GetTimestamp(), SCH_IO_LIB_CACHE::IsFileChanged(), and SCH_IO_KICAD_LEGACY_LIB_CACHE::Save().

Variable Documentation

◆ CLOUD_SYNC_BUFFER_SIZE

size_t KIPLATFORM::IO::CLOUD_SYNC_BUFFER_SIZE = 512 * 1024
staticconstexpr

Buffer size for file I/O operations on cloud-synced folders.

Cloud sync services like Google Drive, OneDrive, and Dropbox can report stale file sizes during seek operations immediately after writing. Using a 512KB buffer reduces the number of I/O operations and allows the cloud sync driver to flush data more reliably before subsequent reads. This value was determined empirically to eliminate sync issues.

Definition at line 77 of file io.h.

Referenced by PROJECT_ARCHIVER::Archive(), DIALOG_EXPORT_ODBPP::GenerateODBPPFiles(), JOBS_OUTPUT_ARCHIVE::HandleOutputs(), and PCBNEW_JOBS_HANDLER::JobExportIpc2581().