Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kicad-source-mirror
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Elphel
kicad-source-mirror
Commits
c9a1b239
Commit
c9a1b239
authored
Jan 07, 2015
by
Jose Ingnacio
Committed by
Wayne Stambaugh
Jan 07, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use XDG_CONFIG_DIR for lock file path on Linux.
* With fixes from Adam Wolf.
parent
547c145a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
65 additions
and
17 deletions
+65
-17
common.cpp
common/common.cpp
+45
-5
lockfile.cpp
common/lockfile.cpp
+5
-3
pgm_base.cpp
common/pgm_base.cpp
+4
-4
common.h
include/common.h
+11
-5
No files found.
common/common.cpp
View file @
c9a1b239
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2014 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2008-201
1
Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-201
1
KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2014
-2015
Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2008-201
5
Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-201
5
KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
...
...
@@ -271,9 +271,9 @@ double RoundTo0( double x, double precision )
int
remainder
=
ix
%
10
;
// remainder is in precision mm
if
(
remainder
<=
2
)
if
(
remainder
<=
2
)
ix
-=
remainder
;
// truncate to the near number
else
if
(
remainder
>=
8
)
else
if
(
remainder
>=
8
)
ix
+=
10
-
remainder
;
// round to near number
if
(
x
<
0
)
...
...
@@ -305,6 +305,46 @@ wxConfigBase* GetNewConfig( const wxString& aProgName )
return
cfg
;
}
wxString
GetKicadLockFilePath
()
{
wxFileName
lockpath
;
lockpath
.
AssignDir
(
wxGetHomeDir
()
);
// Default wx behavior
#if defined( __WXMAC__ )
// In OSX use the standard per user cache directory
lockpath
.
AppendDir
(
wxT
(
"Library"
)
);
lockpath
.
AppendDir
(
wxT
(
"Caches"
)
);
lockpath
.
AppendDir
(
wxT
(
"kicad"
)
);
#elif defined( __UNIX__ )
wxString
envstr
;
// Try first the standard XDG_RUNTIME_DIR, falling back to XDG_CACHE_HOME
if
(
wxGetEnv
(
wxT
(
"XDG_RUNTIME_DIR"
),
&
envstr
)
&&
!
envstr
.
IsEmpty
()
)
{
lockpath
.
AssignDir
(
envstr
);
}
else
if
(
wxGetEnv
(
wxT
(
"XDG_CACHE_HOME"
),
&
envstr
)
&&
!
envstr
.
IsEmpty
()
)
{
lockpath
.
AssignDir
(
envstr
);
}
else
{
// If all fails, just use ~/.cache
lockpath
.
AppendDir
(
wxT
(
".cache"
)
);
}
lockpath
.
AppendDir
(
wxT
(
"kicad"
)
);
#endif
#if defined( __WXMAC__ ) || defined( __UNIX__ )
if
(
!
lockpath
.
DirExists
()
)
{
// Lockfiles should be only readable by the user
lockpath
.
Mkdir
(
0700
,
wxPATH_MKDIR_FULL
);
}
#endif
return
lockpath
.
GetPath
();
}
wxString
GetKicadConfigPath
()
{
...
...
common/lockfile.cpp
View file @
c9a1b239
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2014 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2014 KiCad Developers, see CHANGELOG.TXT for contributors.
* Copyright (C) 2014
-2015
SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2014
-2015
KiCad Developers, see CHANGELOG.TXT for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
...
...
@@ -24,6 +24,7 @@
#include <wx/filename.h>
#include <wx/snglinst.h>
#include <common.h>
wxSingleInstanceChecker
*
LockFile
(
const
wxString
&
aFileName
)
...
...
@@ -41,7 +42,8 @@ wxSingleInstanceChecker* LockFile( const wxString& aFileName )
// We can have filenames coming from Windows, so also convert Windows separator
lockFileName
.
Replace
(
wxT
(
"
\\
"
),
wxT
(
"_"
)
);
wxSingleInstanceChecker
*
p
=
new
wxSingleInstanceChecker
(
lockFileName
);
wxSingleInstanceChecker
*
p
=
new
wxSingleInstanceChecker
(
lockFileName
,
GetKicadLockFilePath
()
);
if
(
p
->
IsAnotherRunning
()
)
{
...
...
common/pgm_base.cpp
View file @
c9a1b239
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2008-201
1
Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-201
1
KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2004
-2015
Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2008-201
5
Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-201
5
KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
...
...
@@ -353,7 +353,7 @@ bool PGM_BASE::initPgm()
wxInitAllImageHandlers
();
m_pgm_checker
=
new
wxSingleInstanceChecker
(
pgm_name
.
GetName
().
Lower
()
+
wxT
(
"-"
)
+
wxGetUserId
()
);
m_pgm_checker
=
new
wxSingleInstanceChecker
(
pgm_name
.
GetName
().
Lower
()
+
wxT
(
"-"
)
+
wxGetUserId
()
,
GetKicadLockFilePath
()
);
if
(
m_pgm_checker
->
IsAnotherRunning
()
)
{
...
...
include/common.h
View file @
c9a1b239
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 201
3
Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2007-201
3
SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2008-201
3
Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-201
3
KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 201
4-2015
Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2007-201
5
SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2008-201
5
Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-201
5
KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
...
...
@@ -278,7 +278,7 @@ bool EnsureTextCtrlWidth( wxTextCtrl* aCtrl, const wxString* aString = NULL );
* wxExecute())
*/
int
ProcessExecute
(
const
wxString
&
aCommandLine
,
int
aFlags
=
wxEXEC_ASYNC
,
wxProcess
*
callback
=
NULL
);
wxProcess
*
callback
=
NULL
);
/*******************/
...
...
@@ -433,6 +433,12 @@ const wxString PrePendPath( const wxString& aEnvVar, const wxString& aPriorityPa
*/
wxConfigBase
*
GetNewConfig
(
const
wxString
&
aProgName
);
/**
* Function GetKicadLockFilePath
* @return A wxString containing the path for lockfiles in Kicad
*/
wxString
GetKicadLockFilePath
();
/**
* Function GetKicadConfigPath
* @return A wxString containing the config path for Kicad
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment