Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
biboumi
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
98
Issues
98
List
Boards
Labels
Service Desk
Milestones
Merge Requests
12
Merge Requests
12
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
louiz’
biboumi
Commits
33fa1dcd
Commit
33fa1dcd
authored
Sep 18, 2015
by
louiz’
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Also a xdg_data_path
parent
ea0b2f2b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
5 deletions
+22
-5
louloulibs/utils/xdg.cpp
louloulibs/utils/xdg.cpp
+13
-4
louloulibs/utils/xdg.hpp
louloulibs/utils/xdg.hpp
+1
-0
src/main.cpp
src/main.cpp
+1
-1
src/test.cpp
src/test.cpp
+7
-0
No files found.
louloulibs/utils/xdg.cpp
View file @
33fa1dcd
...
...
@@ -3,11 +3,11 @@
#include "louloulibs.h"
std
::
string
xdg_
config_path
(
const
std
::
string
&
filename
)
std
::
string
xdg_
path
(
const
std
::
string
&
filename
,
const
char
*
env_var
)
{
const
char
*
xdg_
config_home
=
::
getenv
(
"XDG_CONFIG_HOME"
);
if
(
xdg_
config_home
&&
xdg_confi
g_home
[
0
]
==
'/'
)
return
std
::
string
{
xdg_
config_
home
}
+
"/"
PROJECT_NAME
"/"
+
filename
;
const
char
*
xdg_
home
=
::
getenv
(
env_var
);
if
(
xdg_
home
&&
xd
g_home
[
0
]
==
'/'
)
return
std
::
string
{
xdg_home
}
+
"/"
PROJECT_NAME
"/"
+
filename
;
else
{
const
char
*
home
=
::
getenv
(
"HOME"
);
...
...
@@ -18,3 +18,12 @@ std::string xdg_config_path(const std::string& filename)
}
}
std
::
string
xdg_config_path
(
const
std
::
string
&
filename
)
{
return
xdg_path
(
filename
,
"XDG_CONFIG_HOME"
);
}
std
::
string
xdg_data_path
(
const
std
::
string
&
filename
)
{
return
xdg_path
(
filename
,
"XDG_DATA_HOME"
);
}
louloulibs/utils/xdg.hpp
View file @
33fa1dcd
...
...
@@ -9,5 +9,6 @@
* http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
*/
std
::
string
xdg_config_path
(
const
std
::
string
&
filename
);
std
::
string
xdg_data_path
(
const
std
::
string
&
filename
);
#endif
/* XDG_HPP_INCLUDED */
src/main.cpp
View file @
33fa1dcd
...
...
@@ -69,7 +69,7 @@ int main(int ac, char** av)
if
(
ac
>
1
)
Config
::
filename
=
av
[
1
];
else
Config
::
filename
=
xdg_path
(
"biboumi.cfg"
);
Config
::
filename
=
xdg_
config_
path
(
"biboumi.cfg"
);
Config
::
file_must_exist
=
true
;
std
::
cerr
<<
"Using configuration file: "
<<
Config
::
filename
<<
std
::
endl
;
...
...
src/test.cpp
View file @
33fa1dcd
...
...
@@ -13,6 +13,7 @@
#include <utils/revstr.hpp>
#include <irc/irc_user.hpp>
#include <utils/split.hpp>
#include <utils/xdg.hpp>
#include <xmpp/jid.hpp>
#include <irc/iid.hpp>
#include <string.h>
...
...
@@ -423,6 +424,12 @@ int main()
res
=
xdg_config_path
(
"coucou.txt"
);
std
::
cout
<<
res
<<
std
::
endl
;
assert
(
res
==
"/some_weird_dir/biboumi/coucou.txt"
);
::
setenv
(
"XDG_DATA_HOME"
,
"/datadir"
,
1
);
res
=
xdg_data_path
(
"bonjour.txt"
);
std
::
cout
<<
res
<<
std
::
endl
;
assert
(
res
==
"/datadir/biboumi/bonjour.txt"
);
}
return
0
;
...
...
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