KiCad PCB EDA Suite
common.cpp File Reference
#include <fctsys.h>
#include <eda_base_frame.h>
#include <common.h>
#include <macros.h>
#include <reporter.h>
#include <mutex>
#include <settings/settings_manager.h>
#include <wx/process.h>
#include <wx/config.h>
#include <wx/utils.h>
#include <wx/stdpaths.h>
#include <wx/url.h>
#include <boost/uuid/uuid_generators.hpp>
#include <boost/uuid/uuid_io.hpp>
#include <boost/functional/hash.hpp>

Go to the source code of this file.

Macros

#define USE_WXLOCALE   1 /* 0 to call setlocale, 1 to call wxLocale */
 Global variables definitions. More...
 

Enumerations

enum  Bracket { Bracket_None, Bracket_Normal = ')', Bracket_Curly = '}', Bracket_Max }
 

Functions

wxSize GetTextSize (const wxString &aSingleLine, wxWindow *aWindow)
 Return the size of aSingleLine of text when it is rendered in aWindow using whatever font is currently set in that window. More...
 
bool EnsureTextCtrlWidth (wxTextCtrl *aCtrl, const wxString *aString)
 Set the minimum pixel width on a text control in order to make a text string be fully visible within it. More...
 
void SelectReferenceNumber (wxTextEntry *aTextEntry)
 Select the number (or "?") in a reference for ease of editing. More...
 
void wxStringSplit (const wxString &aText, wxArrayString &aStrings, wxChar aSplitter)
 Split aString to a string list separated at aSplitter. More...
 
int ProcessExecute (const wxString &aCommandLine, int aFlags, wxProcess *callback)
 Run a command in a child process. More...
 
timestamp_t GetNewTimeStamp ()
 
wxString KIwxExpandEnvVars (const wxString &str)
 
const wxString ExpandEnvVarSubstitutions (const wxString &aString)
 Replace any environment variable references with their values. More...
 
const wxString ResolveUriByEnvVars (const wxString &aUri)
 Replace any environment variables in file-path uris (leaving network-path URIs alone). More...
 
bool EnsureFileDirectoryExists (wxFileName *aTargetFullFileName, const wxString &aBaseFilename, REPORTER *aReporter)
 Make aTargetFullFileName absolute and create the path of this file if it doesn't yet exist. More...
 
std::ostream & operator<< (std::ostream &out, const wxSize &size)
 Helper function to print the given wxSize to a stream. More...
 
std::ostream & operator<< (std::ostream &out, const wxPoint &pt)
 Helper function to print the given wxPoint to a stream. More...
 
bool matchWild (const char *pat, const char *text, bool dot_special)
 A copy of wxMatchWild(), which wxWidgets attributes to Douglas A. More...
 
long long TimestampDir (const wxString &aDirPath, const wxString &aFilespec)
 A copy of ConvertFileTimeToWx() because wxWidgets left it as a static function private to src/common/filename.cpp. More...
 

Variables

static boost::uuids::random_generator randomGenerator
 
static boost::uuids::string_generator stringGenerator
 
static boost::uuids::nil_generator nilGenerator
 
KIID niluuid (0)
 

Macro Definition Documentation

◆ USE_WXLOCALE

#define USE_WXLOCALE   1 /* 0 to call setlocale, 1 to call wxLocale */

Global variables definitions.

TODO: All of these variables should be moved into the class were they are defined and used. Most of them probably belong in the application class.

Definition at line 201 of file common.cpp.

Enumeration Type Documentation

◆ Bracket

enum Bracket
Enumerator
Bracket_None 
Bracket_Normal 
Bracket_Curly 
Bracket_Max 

Definition at line 381 of file common.cpp.

382 {
383  Bracket_None,
384  Bracket_Normal = ')',
385  Bracket_Curly = '}',
386 #ifdef __WINDOWS__
387  Bracket_Windows = '%', // yeah, Windows people are a bit strange ;-)
388 #endif
390 };

Function Documentation

◆ EnsureFileDirectoryExists()

bool EnsureFileDirectoryExists ( wxFileName *  aTargetFullFileName,
const wxString &  aBaseFilename,
REPORTER aReporter = NULL 
)

Make aTargetFullFileName absolute and create the path of this file if it doesn't yet exist.

Parameters
aTargetFullFileNamethe wxFileName containing the full path and file name to modify. The path may be absolute or relative to aBaseFilename .
aBaseFilenamea full filename. Only its path is used to set the aTargetFullFileName path.
aReportera point to a REPORTER object use to show messages (can be NULL)
Returns
true if aOutputDir already exists or was successfully created.

Definition at line 552 of file common.cpp.

555 {
556  wxString msg;
557  wxString baseFilePath = wxFileName( aBaseFilename ).GetPath();
558 
559  // make aTargetFullFileName path, which is relative to aBaseFilename path (if it is not
560  // already an absolute path) absolute:
561  if( !aTargetFullFileName->MakeAbsolute( baseFilePath ) )
562  {
563  if( aReporter )
564  {
565  msg.Printf( _( "Cannot make path \"%s\" absolute with respect to \"%s\"." ),
566  aTargetFullFileName->GetPath(),
567  baseFilePath );
568  aReporter->Report( msg, RPT_SEVERITY_ERROR );
569  }
570 
571  return false;
572  }
573 
574  // Ensure the path of aTargetFullFileName exists, and create it if needed:
575  wxString outputPath( aTargetFullFileName->GetPath() );
576 
577  if( !wxFileName::DirExists( outputPath ) )
578  {
579  if( wxMkdir( outputPath ) )
580  {
581  if( aReporter )
582  {
583  msg.Printf( _( "Output directory \"%s\" created.\n" ), outputPath );
584  aReporter->Report( msg, RPT_SEVERITY_INFO );
585  return true;
586  }
587  }
588  else
589  {
590  if( aReporter )
591  {
592  msg.Printf( _( "Cannot create output directory \"%s\".\n" ), outputPath );
593  aReporter->Report( msg, RPT_SEVERITY_ERROR );
594  }
595 
596  return false;
597  }
598  }
599 
600  return true;
601 }
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Function Report is a pure virtual function to override in the derived object.
#define _(s)
Definition: 3d_actions.cpp:33

References _, REPORTER::Report(), RPT_SEVERITY_ERROR, and RPT_SEVERITY_INFO.

Referenced by DIALOG_GEN_FOOTPRINT_POSITION::CreateAsciiFiles(), DIALOG_GEN_FOOTPRINT_POSITION::CreateGerberFiles(), DIALOG_PLOT_SCHEMATIC::createPlotFileName(), DIALOG_EXPORT_SVG::ExportSVGFile(), DIALOG_GENDRILL::GenDrillAndMapFiles(), PLOT_CONTROLLER::OpenPlotfile(), and DIALOG_PLOT::Plot().

◆ EnsureTextCtrlWidth()

bool EnsureTextCtrlWidth ( wxTextCtrl *  aCtrl,
const wxString *  aString = NULL 
)

Set the minimum pixel width on a text control in order to make a text string be fully visible within it.

The current font within the text control is considered. The text can come either from the control or be given as an argument. If the text control is larger than needed, then nothing is done.

Parameters
aCtrlthe text control to potentially make wider.
aStringthe text that is used in sizing the control's pixel width. If NULL, then the text already within the control is used.
Returns
bool - true if the aCtrl had its size changed, else false.

Definition at line 278 of file common.cpp.

279 {
280  wxWindow* window = aCtrl->GetParent();
281 
282  if( !window )
283  window = aCtrl;
284 
285  wxString ctrlText;
286 
287  if( !aString )
288  {
289  ctrlText = aCtrl->GetValue();
290  aString = &ctrlText;
291  }
292 
293  wxSize textz = GetTextSize( *aString, window );
294  wxSize ctrlz = aCtrl->GetSize();
295 
296  if( ctrlz.GetWidth() < textz.GetWidth() + 10 )
297  {
298  ctrlz.SetWidth( textz.GetWidth() + 10 );
299  aCtrl->SetSizeHints( ctrlz );
300  return true;
301  }
302 
303  return false;
304 }
wxSize GetTextSize(const wxString &aSingleLine, wxWindow *aWindow)
Return the size of aSingleLine of text when it is rendered in aWindow using whatever font is currentl...
Definition: common.cpp:263

References GetTextSize().

Referenced by GERBVIEW_FRAME::UpdateTitleAndInfo().

◆ ExpandEnvVarSubstitutions()

const wxString ExpandEnvVarSubstitutions ( const wxString &  aString)

Replace any environment variable references with their values.

Parameters
aString= a string containing (perhaps) references to env var
Returns
a string where env var are replaced by their value

Definition at line 525 of file common.cpp.

526 {
527  // wxGetenv( wchar_t* ) is not re-entrant on linux.
528  // Put a lock on multithreaded use of wxGetenv( wchar_t* ), called from wxEpandEnvVars(),
529  static std::mutex getenv_mutex;
530 
531  std::lock_guard<std::mutex> lock( getenv_mutex );
532 
533  // We reserve the right to do this another way, by providing our own member function.
534  return KIwxExpandEnvVars( aString );
535 }
wxString KIwxExpandEnvVars(const wxString &str)
Definition: common.cpp:396

References KIwxExpandEnvVars().

Referenced by FILENAME_RESOLVER::addPath(), FILENAME_RESOLVER::checkEnvVarPath(), S3D_PLUGIN_MANAGER::checkPluginName(), S3D_PLUGIN_MANAGER::checkPluginPath(), FILENAME_RESOLVER::createPathList(), LIB_TABLE::ExpandSubstitutions(), S3D_CACHE::Get3DConfigDir(), WS_DATA_MODEL::MakeFullFileName(), TEXT_BUTTON_FILE_BROWSER::OnButtonClick(), FILENAME_RESOLVER::ResolvePath(), ResolveUriByEnvVars(), FILENAME_RESOLVER::Set3DConfigDir(), S3D_CACHE::Set3DConfigDir(), FILENAME_RESOLVER::SetProjectDir(), and FILENAME_RESOLVER::ShortenPath().

◆ GetNewTimeStamp()

timestamp_t GetNewTimeStamp ( )

Definition at line 365 of file common.cpp.

366 {
367  static timestamp_t oldTimeStamp;
368  timestamp_t newTimeStamp;
369 
370  newTimeStamp = time( NULL );
371 
372  if( newTimeStamp <= oldTimeStamp )
373  newTimeStamp = oldTimeStamp + 1;
374 
375  oldTimeStamp = newTimeStamp;
376 
377  return newTimeStamp;
378 }
#define NULL
uint32_t timestamp_t
timestamp_t is our type to represent unique IDs for all kinds of elements; historically simply the ti...
Definition: common.h:53

References NULL.

◆ GetTextSize()

wxSize GetTextSize ( const wxString &  aSingleLine,
wxWindow *  aWindow 
)

Return the size of aSingleLine of text when it is rendered in aWindow using whatever font is currently set in that window.

Definition at line 263 of file common.cpp.

264 {
265  wxCoord width;
266  wxCoord height;
267 
268  {
269  wxClientDC dc( aWindow );
270  dc.SetFont( aWindow->GetFont() );
271  dc.GetTextExtent( aSingleLine, &width, &height );
272  }
273 
274  return wxSize( width, height );
275 }

Referenced by DIALOG_EDIT_COMPONENTS_LIBID::AdjustGridColumns(), LIB_TREE_MODEL_ADAPTER::AttachTo(), DIALOG_FIELDS_EDITOR_GLOBAL::DIALOG_FIELDS_EDITOR_GLOBAL(), EDA_DRAW_FRAME::EDA_DRAW_FRAME(), EnsureTextCtrlWidth(), FIELDS_EDITOR_GRID_DATA_MODEL::GetDataWidth(), DIALOG_FP_CONFLICT_ASSIGNMENT_SELECTOR::recalculateColumns(), ZONE_SETTINGS::SetupLayersList(), and NET_SELECTOR_COMBOPOPUP::updateSize().

◆ KIwxExpandEnvVars()

wxString KIwxExpandEnvVars ( const wxString &  str)

Definition at line 396 of file common.cpp.

397 {
398  size_t strlen = str.length();
399 
400  wxString strResult;
401  strResult.Alloc( strlen );
402 
403  for( size_t n = 0; n < strlen; n++ )
404  {
405  wxUniChar str_n = str[n];
406 
407  switch( str_n.GetValue() )
408  {
409 #ifdef __WINDOWS__
410  case wxT( '%' ):
411 #endif // __WINDOWS__
412  case wxT( '$' ):
413  {
414  Bracket bracket;
415 #ifdef __WINDOWS__
416  if( str_n == wxT( '%' ) )
417  bracket = Bracket_Windows;
418  else
419 #endif // __WINDOWS__
420  if( n == strlen - 1 )
421  {
422  bracket = Bracket_None;
423  }
424  else
425  {
426  switch( str[n + 1].GetValue() )
427  {
428  case wxT( '(' ):
429  bracket = Bracket_Normal;
430  str_n = str[++n]; // skip the bracket
431  break;
432 
433  case wxT( '{' ):
434  bracket = Bracket_Curly;
435  str_n = str[++n]; // skip the bracket
436  break;
437 
438  default:
439  bracket = Bracket_None;
440  }
441  }
442 
443  size_t m = n + 1;
444  wxUniChar str_m = str[m];
445 
446  while( m < strlen && ( wxIsalnum( str_m ) || str_m == wxT( '_' ) ) )
447  str_m = str[++m];
448 
449  wxString strVarName( str.c_str() + n + 1, m - n - 1 );
450 
451  // NB: use wxGetEnv instead of wxGetenv as otherwise variables
452  // set through wxSetEnv may not be read correctly!
453  bool expanded = false;
454  wxString tmp;
455 
456  if( wxGetEnv( strVarName, &tmp ) )
457  {
458  strResult += tmp;
459  expanded = true;
460  }
461  else
462  {
463  // variable doesn't exist => don't change anything
464 #ifdef __WINDOWS__
465  if ( bracket != Bracket_Windows )
466 #endif
467  if ( bracket != Bracket_None )
468  strResult << str[n - 1];
469 
470  strResult << str_n << strVarName;
471  }
472 
473  // check the closing bracket
474  if( bracket != Bracket_None )
475  {
476  if( m == strlen || str_m != (wxChar)bracket )
477  {
478  // under MSW it's common to have '%' characters in the registry
479  // and it's annoying to have warnings about them each time, so
480  // ignore them silently if they are not used for env vars
481  //
482  // under Unix, OTOH, this warning could be useful for the user to
483  // understand why isn't the variable expanded as intended
484 #ifndef __WINDOWS__
485  wxLogWarning( _( "Environment variables expansion failed: missing '%c' "
486  "at position %u in '%s'." ),
487  (char)bracket, (unsigned int) (m + 1), str.c_str() );
488 #endif // __WINDOWS__
489  }
490  else
491  {
492  // skip closing bracket unless the variables wasn't expanded
493  if( !expanded )
494  strResult << (wxChar)bracket;
495 
496  m++;
497  }
498  }
499 
500  n = m - 1; // skip variable name
501  str_n = str[n];
502  }
503  break;
504 
505  case wxT( '\\' ):
506  // backslash can be used to suppress special meaning of % and $
507  if( n != strlen - 1 && (str[n + 1] == wxT( '%' ) || str[n + 1] == wxT( '$' )) )
508  {
509  str_n = str[++n];
510  strResult += str_n;
511 
512  break;
513  }
514  // else fall through
515 
516  default:
517  strResult += str_n;
518  }
519  }
520 
521  return strResult;
522 }
Bracket
Definition: common.cpp:381
#define _(s)
Definition: 3d_actions.cpp:33

References _, Bracket_Curly, Bracket_None, and Bracket_Normal.

Referenced by ExpandEnvVarSubstitutions().

◆ matchWild()

bool matchWild ( const char *  pat,
const char *  text,
bool  dot_special 
)

A copy of wxMatchWild(), which wxWidgets attributes to Douglas A.

Lewis dalew.nosp@m.is@c.nosp@m.s.Buf.nosp@m.falo.nosp@m..EDU and ircII's reg.c.

This version is modified to skip any encoding conversions (for performance).

Definition at line 774 of file common.cpp.

775 {
776  if( !*text )
777  {
778  /* Match if both are empty. */
779  return !*pat;
780  }
781 
782  const char *m = pat,
783  *n = text,
784  *ma = NULL,
785  *na = NULL;
786  int just = 0,
787  acount = 0,
788  count = 0;
789 
790  if( dot_special && (*n == '.') )
791  {
792  /* Never match so that hidden Unix files
793  * are never found. */
794  return false;
795  }
796 
797  for(;;)
798  {
799  if( *m == '*' )
800  {
801  ma = ++m;
802  na = n;
803  just = 1;
804  acount = count;
805  }
806  else if( *m == '?' )
807  {
808  m++;
809 
810  if( !*n++ )
811  return false;
812  }
813  else
814  {
815  if( *m == '\\' )
816  {
817  m++;
818 
819  /* Quoting "nothing" is a bad thing */
820  if( !*m )
821  return false;
822  }
823  if( !*m )
824  {
825  /*
826  * If we are out of both strings or we just
827  * saw a wildcard, then we can say we have a
828  * match
829  */
830  if( !*n )
831  return true;
832 
833  if( just )
834  return true;
835 
836  just = 0;
837  goto not_matched;
838  }
839 
840  /*
841  * We could check for *n == NULL at this point, but
842  * since it's more common to have a character there,
843  * check to see if they match first (m and n) and
844  * then if they don't match, THEN we can check for
845  * the NULL of n
846  */
847  just = 0;
848 
849  if( *m == *n )
850  {
851  m++;
852  count++;
853  n++;
854  }
855  else
856  {
857  not_matched:
858 
859  /*
860  * If there are no more characters in the
861  * string, but we still need to find another
862  * character (*m != NULL), then it will be
863  * impossible to match it
864  */
865  if( !*n )
866  return false;
867 
868  if( ma )
869  {
870  m = ma;
871  n = ++na;
872  count = acount;
873  }
874  else
875  return false;
876  }
877  }
878  }
879 }
#define NULL

References NULL.

Referenced by TimestampDir().

◆ operator<<() [1/2]

std::ostream& operator<< ( std::ostream &  out,
const wxSize &  size 
)

Helper function to print the given wxSize to a stream.

Used for debugging functions like EDA_ITEM::Show and also in unit testing fixtures.

Definition at line 681 of file common.cpp.

682 {
683  out << " width=\"" << size.GetWidth() << "\" height=\"" << size.GetHeight() << "\"";
684  return out;
685 }

◆ operator<<() [2/2]

std::ostream& operator<< ( std::ostream &  out,
const wxPoint pt 
)

Helper function to print the given wxPoint to a stream.

Used for debugging functions like EDA_ITEM::Show and also in unit testing fixtures.

Definition at line 688 of file common.cpp.

689 {
690  out << " x=\"" << pt.x << "\" y=\"" << pt.y << "\"";
691  return out;
692 }

References wxPoint::x, and wxPoint::y.

◆ ProcessExecute()

int ProcessExecute ( const wxString &  aCommandLine,
int  aFlags = wxEXEC_ASYNC,
wxProcess *  callback = NULL 
)

Run a command in a child process.

Parameters
aCommandLineThe process and any arguments to it all in a single string.
aFlagsThe same args as allowed for wxExecute()
callbackwxProcess implementing OnTerminate to be run when the child process finishes
Returns
int - pid of process, 0 in case of error (like return values of wxExecute())

Definition at line 359 of file common.cpp.

360 {
361  return wxExecute( aCommandLine, aFlags, callback );
362 }

Referenced by doPrintFile(), ExecuteFile(), GetAssociatedDocument(), OpenFile(), OpenPDF(), and SCH_EDIT_FRAME::WriteNetListFile().

◆ ResolveUriByEnvVars()

const wxString ResolveUriByEnvVars ( const wxString &  aUri)

Replace any environment variables in file-path uris (leaving network-path URIs alone).

Definition at line 538 of file common.cpp.

539 {
540  // URL-like URI: return as is.
541  wxURL url( aUri );
542 
543  if( url.GetError() == wxURL_NOERR )
544  return aUri;
545 
546  // Otherwise, the path points to a local file. Resolve environment
547  // variables if any.
548  return ExpandEnvVarSubstitutions( aUri );
549 }
const wxString ExpandEnvVarSubstitutions(const wxString &aString)
Replace any environment variable references with their values.
Definition: common.cpp:525

References ExpandEnvVarSubstitutions().

Referenced by GetAssociatedDocument().

◆ SelectReferenceNumber()

void SelectReferenceNumber ( wxTextEntry *  aTextEntry)

Select the number (or "?") in a reference for ease of editing.

Definition at line 307 of file common.cpp.

308 {
309  wxString ref = aTextEntry->GetValue();
310 
311  if( ref.find_first_of( '?' ) != ref.npos )
312  {
313  aTextEntry->SetSelection( ref.find_first_of( '?' ), ref.find_last_of( '?' ) + 1 );
314  }
315  else
316  {
317  wxString num = ref;
318 
319  while( !num.IsEmpty() && ( !isdigit( num.Last() ) || !isdigit( num.GetChar( 0 ) ) ) )
320  {
321  if( !isdigit( num.Last() ) )
322  num.RemoveLast();
323 
324  if( !isdigit( num.GetChar ( 0 ) ) )
325  num = num.Right( num.Length() - 1);
326  }
327 
328  aTextEntry->SetSelection( ref.Find( num ), ref.Find( num ) + num.Length() );
329 
330  if( num.IsEmpty() )
331  aTextEntry->SetSelection( -1, -1 );
332  }
333 }

Referenced by DIALOG_EDIT_ONE_FIELD::OnSetFocusText(), DIALOG_FOOTPRINT_BOARD_EDITOR::OnUpdateUI(), and DIALOG_TEXT_PROPERTIES::TransferDataToWindow().

◆ TimestampDir()

long long TimestampDir ( const wxString &  aDirPath,
const wxString &  aFilespec 
)

A copy of ConvertFileTimeToWx() because wxWidgets left it as a static function private to src/common/filename.cpp.

TimestampDir

This routine offers SIGNIFICANT performance benefits over using wxWidgets to gather timestamps from matching files in a directory.

Parameters
aDirPaththe directory to search
aFilespeca (wildcarded) file spec to match against
Returns
a hash of the last-mod-dates of all matching files in the directory

Definition at line 916 of file common.cpp.

917 {
918  long long timestamp = 0;
919 
920 #if defined( __WIN32__ )
921  // Win32 version.
922  // Save time by not searching for each path twice: once in wxDir.GetNext() and once in
923  // wxFileName.GetModificationTime(). Also cuts out wxWidgets' string-matching and case
924  // conversion by staying on the MSW side of things.
925  std::wstring filespec( aDirPath.t_str() );
926  filespec += '\\';
927  filespec += aFilespec.t_str();
928 
929  WIN32_FIND_DATA findData;
930  wxDateTime lastModDate;
931 
932  HANDLE fileHandle = ::FindFirstFile( filespec.data(), &findData );
933 
934  if( fileHandle != INVALID_HANDLE_VALUE )
935  {
936  do
937  {
938  ConvertFileTimeToWx( &lastModDate, findData.ftLastWriteTime );
939  timestamp += lastModDate.GetValue().GetValue();
940  }
941  while ( FindNextFile( fileHandle, &findData ) != 0 );
942  }
943 
944  FindClose( fileHandle );
945 #else
946  // POSIX version.
947  // Save time by not converting between encodings -- do everything on the file-system side.
948  std::string filespec( aFilespec.fn_str() );
949  std::string dir_path( aDirPath.fn_str() );
950 
951  DIR* dir = opendir( dir_path.c_str() );
952 
953  if( dir )
954  {
955  for( dirent* dir_entry = readdir( dir ); dir_entry; dir_entry = readdir( dir ) )
956  {
957  if( !matchWild( filespec.c_str(), dir_entry->d_name, true ) )
958  continue;
959 
960  std::string entry_path = dir_path + '/' + dir_entry->d_name;
961  struct stat entry_stat;
962 
963  if( wxCRT_Lstat( entry_path.c_str(), &entry_stat ) == 0 )
964  {
965  // Timestamp the source file, not the symlink
966  if( S_ISLNK( entry_stat.st_mode ) ) // wxFILE_EXISTS_SYMLINK
967  {
968  char buffer[ PATH_MAX + 1 ];
969  ssize_t pathLen = readlink( entry_path.c_str(), buffer, PATH_MAX );
970 
971  if( pathLen > 0 )
972  {
973  struct stat linked_stat;
974  buffer[ pathLen ] = '\0';
975  entry_path = dir_path + buffer;
976 
977  if( wxCRT_Lstat( entry_path.c_str(), &linked_stat ) == 0 )
978  {
979  entry_stat = linked_stat;
980  }
981  else
982  {
983  // if we couldn't lstat the linked file we'll have to just use
984  // the symbolic link info
985  }
986  }
987  }
988 
989  if( S_ISREG( entry_stat.st_mode ) ) // wxFileExists()
990  timestamp += entry_stat.st_mtime * 1000;
991  }
992  else
993  {
994  // if we couldn't lstat the file itself all we can do is use the name
995  timestamp += (signed) std::hash<std::string>{}( std::string( dir_entry->d_name ) );
996  }
997  }
998 
999  closedir( dir );
1000  }
1001 #endif
1002 
1003  return timestamp;
1004 }
bool matchWild(const char *pat, const char *text, bool dot_special)
A copy of wxMatchWild(), which wxWidgets attributes to Douglas A.
Definition: common.cpp:774

References matchWild().

Referenced by FP_CACHE::GetTimestamp(), and GPCB_FPL_CACHE::GetTimestamp().

◆ wxStringSplit()

void wxStringSplit ( const wxString &  aText,
wxArrayString &  aStrings,
wxChar  aSplitter 
)

Split aString to a string list separated at aSplitter.

Parameters
aTextis the text to split
aStringswill contain the splitted lines
aSplitteris the 'split' character

Definition at line 336 of file common.cpp.

337 {
338  wxString tmp;
339 
340  for( unsigned ii = 0; ii < aText.Length(); ii++ )
341  {
342  if( aText[ii] == aSplitter )
343  {
344  aStrings.Add( tmp );
345  tmp.Clear();
346  }
347 
348  else
349  tmp << aText[ii];
350  }
351 
352  if( !tmp.IsEmpty() )
353  {
354  aStrings.Add( tmp );
355  }
356 }

Referenced by CINFO3D_VISU::AddShapeWithClearanceToContainer(), export_vrml_pcbtext(), EDA_TEXT::GetTextBox(), HTML_MESSAGE_BOX::ListSet(), DIALOG_FOOTPRINT_WIZARD_LIST::onShowTrace(), SCH_TEXT::Plot(), BRDITEMS_PLOTTER::PlotTextePcb(), EDA_TEXT::Print(), TEXTE_PCB::TransformShapeWithClearanceToPolygonSet(), and EDA_TEXT::TransformTextShapeToSegmentList().

Variable Documentation

◆ nilGenerator

boost::uuids::nil_generator nilGenerator
static

Definition at line 51 of file common.cpp.

◆ niluuid

◆ randomGenerator

boost::uuids::random_generator randomGenerator
static

Definition at line 47 of file common.cpp.

Referenced by KIID::KIID().

◆ stringGenerator

boost::uuids::string_generator stringGenerator
static

Definition at line 50 of file common.cpp.

Referenced by KIID::KIID().