Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
ScalFMM
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
solverstack
ScalFMM
Commits
f2ee844e
Commit
f2ee844e
authored
10 years ago
by
Quentin Khan
Browse files
Options
Downloads
Patches
Plain Diff
FFmaGenericLoader: refactored file opening and added details about open errors
parent
6ecb938d
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
Src/Files/FFmaGenericLoader.hpp
+23
-27
23 additions, 27 deletions
Src/Files/FFmaGenericLoader.hpp
with
23 additions
and
27 deletions
Src/Files/FFmaGenericLoader.hpp
+
23
−
27
View file @
f2ee844e
...
...
@@ -213,6 +213,22 @@ private:
FReal
*
tmpVal
;
///< Temporary array to read data
/// Count of other data pieces to read in a particle record after the 4 first ones.
unsigned
int
otherDataToRead
;
void
open_file
(
const
std
::
string
filename
,
const
bool
binary
)
{
if
(
binary
)
{
this
->
file
=
new
std
::
fstream
(
filename
.
c_str
(),
std
::
ifstream
::
in
|
std
::
ios
::
binary
);
}
else
{
this
->
file
=
new
std
::
fstream
(
filename
.
c_str
(),
std
::
ifstream
::
in
)
;
}
// test if open
if
(
!
this
->
file
->
is_open
()){
std
::
cerr
<<
"File "
<<
filename
<<
" not opened! Error: "
<<
strerror
(
errno
)
<<
std
::
endl
;
std
::
exit
(
EXIT_FAILURE
);
}
std
::
cout
<<
"Opened file "
<<
filename
<<
std
::
endl
;
}
public
:
/**
* This constructor opens a file using the given mode and reads its
...
...
@@ -228,18 +244,7 @@ public:
file
(
nullptr
),
binaryFile
(
binary
),
centerOfBox
(
0.0
,
0.0
,
0.0
),
boxWidth
(
0.0
),
nbParticles
(
0
),
tmpVal
(
nullptr
),
otherDataToRead
(
0
)
{
if
(
binary
)
{
this
->
file
=
new
std
::
fstream
(
filename
.
c_str
(),
std
::
ifstream
::
in
|
std
::
ios
::
binary
);
}
else
{
this
->
file
=
new
std
::
fstream
(
filename
.
c_str
(),
std
::
ifstream
::
in
)
;
}
// test if open
if
(
!
this
->
file
->
is_open
()){
std
::
cerr
<<
"File "
<<
filename
<<
" not opened! "
<<
std
::
endl
;
std
::
exit
(
EXIT_FAILURE
);
}
std
::
cout
<<
"Open file "
<<
filename
<<
std
::
endl
;
this
->
open_file
(
filename
,
binary
);
this
->
readHeader
();
}
...
...
@@ -256,29 +261,20 @@ public:
*/
FFmaGenericLoader
(
const
std
::
string
&
filename
)
:
file
(
nullptr
),
binaryFile
(
false
),
centerOfBox
(
0.0
,
0.0
,
0.0
),
boxWidth
(
0.0
),
nbParticles
(
0
),
tmpVal
(
nullptr
),
otherDataToRead
(
0
)
{
std
::
string
ext
(
".bfma"
);
// open particle file
if
(
filename
.
find
(
ext
)
!=
std
::
string
::
npos
)
{
if
(
filename
.
find
(
".bfma"
)
!=
std
::
string
::
npos
)
{
binaryFile
=
true
;
this
->
file
=
new
std
::
fstream
(
filename
.
c_str
(),
std
::
ifstream
::
in
|
std
::
ios
::
binary
);
}
else
if
(
filename
.
find
(
".fma"
)
!=
std
::
string
::
npos
)
{
this
->
file
=
new
std
::
fstream
(
filename
.
c_str
(),
std
::
ifstream
::
in
)
;
}
else
{
}
else
if
(
filename
.
find
(
".fma"
)
!=
std
::
string
::
npos
)
{
binaryFile
=
false
;
}
else
{
std
::
cout
<<
"FFmaGenericLoader: "
<<
"Only .fma or .bfma input file are allowed. Got "
<<
filename
<<
"."
<<
std
::
endl
;
std
::
exit
(
EXIT_FAILURE
)
;
}
// test if open
if
(
!
this
->
file
->
is_open
()){
std
::
cerr
<<
"File "
<<
filename
<<
" not opened! "
<<
std
::
endl
;
std
::
exit
(
EXIT_FAILURE
);
}
std
::
cout
<<
"Open file "
<<
filename
<<
std
::
endl
;
this
->
open_file
(
filename
,
binaryFile
);
this
->
readHeader
();
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment