Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
libcifpp
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
libcifpp
Commits
fd42b7f4
Unverified
Commit
fd42b7f4
authored
Jan 11, 2021
by
Maarten L. Hekkelman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
search data_dir as well as cache_dir, for MacOS
parent
edcea220
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
5 deletions
+38
-5
src/Cif++.cpp
+37
-4
src/CifUtils.cpp
+1
-1
No files found.
src/Cif++.cpp
View file @
fd42b7f4
...
...
@@ -3096,13 +3096,46 @@ void File::loadDictionary(const char* dict)
fs
::
path
dict_name
(
dict
);
auto
data
=
loadResource
(
dict
);
if
(
not
data
and
dict_name
.
extension
().
string
()
!=
".dic"
)
data
=
loadResource
(
dict_name
.
parent_path
()
/
(
dict_name
.
filename
().
string
()
+
".dic"
));
if
(
not
data
)
throw
std
::
runtime_error
(
"Dictionary not found or defined ("
+
dict_name
.
string
()
+
")"
);
loadDictionary
(
*
data
);
if
(
data
)
loadDictionary
(
*
data
);
else
{
// might be a compressed dictionary on disk
fs
::
path
p
=
dict
;
p
=
p
.
parent_path
()
/
(
p
.
filename
().
string
()
+
".gz"
);
if
(
not
fs
::
exists
(
p
))
{
for
(
const
char
*
dir
:
{
CACHE_DIR
,
DATA_DIR
})
{
auto
p2
=
fs
::
path
(
dir
)
/
p
;
if
(
fs
::
exists
(
p2
))
{
swap
(
p
,
p2
);
break
;
}
}
}
if
(
fs
::
exists
(
p
))
{
std
::
ifstream
file
(
p
,
std
::
ios
::
binary
);
if
(
not
file
.
is_open
())
throw
std
::
runtime_error
(
"Could not open dictionary ("
+
p
.
string
()
+
")"
);
io
::
filtering_stream
<
io
::
input
>
in
;
in
.
push
(
io
::
gzip_decompressor
());
in
.
push
(
file
);
loadDictionary
(
in
);
}
else
throw
std
::
runtime_error
(
"Dictionary not found or defined ("
+
dict_name
.
string
()
+
")"
);
}
}
void
File
::
loadDictionary
(
std
::
istream
&
is
)
...
...
src/CifUtils.cpp
View file @
fd42b7f4
...
...
@@ -1187,7 +1187,7 @@ std::unique_ptr<std::istream> loadResource(std::filesystem::path name)
if
(
fs
::
exists
(
p
))
{
std
::
unique_ptr
<
std
::
ifstream
>
file
(
new
std
::
ifstream
(
p
));
std
::
unique_ptr
<
std
::
ifstream
>
file
(
new
std
::
ifstream
(
p
,
std
::
ios
::
binary
));
if
(
file
->
is_open
())
result
.
reset
(
file
.
release
());
}
...
...
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