Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tnl-dev
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor 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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
TNL
tnl-dev
Commits
0b81f7e7
There was an error fetching the commit references. Please try again later.
Commit
0b81f7e7
authored
6 years ago
by
Tomáš Oberhuber
Committed by
Tomáš Oberhuber
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Added FileOpenError exception.
parent
2c8f1be7
No related branches found
No related tags found
1 merge request
!29
Revision
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/TNL/Exceptions/FileOpenError.h
+32
-0
32 additions, 0 deletions
src/TNL/Exceptions/FileOpenError.h
src/TNL/Exceptions/NotTNLFile.h
+1
-1
1 addition, 1 deletion
src/TNL/Exceptions/NotTNLFile.h
src/TNL/File.hpp
+9
-10
9 additions, 10 deletions
src/TNL/File.hpp
with
42 additions
and
11 deletions
src/TNL/Exceptions/FileOpenError.h
0 → 100644
+
32
−
0
View file @
0b81f7e7
/***************************************************************************
FileOpenError.h - description
-------------------
begin : Mar 5, 2019
copyright : (C) 2019 by Tomas Oberhuber et al.
email : tomas.oberhuber@fjfi.cvut.cz
***************************************************************************/
/* See Copyright Notice in tnl/Copyright */
// Implemented by: Tomas Oberhuber
#pragma once
#include
<string>
#include
<stdexcept>
#include
<TNL/String.h>
namespace
TNL
{
namespace
Exceptions
{
class
FileOpenError
:
public
std
::
runtime_error
{
public:
FileOpenError
(
const
String
&
fileName
)
:
std
::
runtime_error
(
"Unable to open file "
+
fileName
+
"."
)
{}
};
}
// namespace Exceptions
}
// namespace TNL
This diff is collapsed.
Click to expand it.
src/TNL/Exceptions/NotTNLFile.h
+
1
−
1
View file @
0b81f7e7
...
...
@@ -23,7 +23,7 @@ class NotTNLFile
{
public:
NotTNLFile
()
:
std
::
runtime_error
(
"Wr
i
ng magic number found in a binary file. It is not TNL compatible file."
)
:
std
::
runtime_error
(
"Wr
o
ng magic number found in a binary file. It is not TNL compatible file."
)
{}
};
...
...
This diff is collapsed.
Click to expand it.
src/TNL/File.hpp
+
9
−
10
View file @
0b81f7e7
...
...
@@ -19,6 +19,7 @@
#include
<TNL/Exceptions/MICSupportMissing.h>
#include
<TNL/Exceptions/FileSerializationError.h>
#include
<TNL/Exceptions/FileDeserializationError.h>
#include
<TNL/Exceptions/FileOpenError.h>
namespace
TNL
{
...
...
@@ -39,18 +40,16 @@ inline bool File::open( const String& fileName, Mode mode )
if
(
mode
&
Mode
::
Append
)
ios_mode
|=
std
::
ios
::
app
;
if
(
mode
&
Mode
::
AtEnd
)
ios_mode
|=
std
::
ios
::
ate
;
if
(
mode
&
Mode
::
Truncate
)
ios_mode
|=
std
::
ios
::
trunc
;
file
.
open
(
fileName
.
getString
(),
ios_mode
);
/*if( mode == Mode::In )
file.open( fileName.getString(), std::ios::binary | std::ios::in );
else
file.open( fileName.getString(), std::ios::binary | std::ios::out );*/
try
{
file
.
open
(
fileName
.
getString
(),
ios_mode
);
}
catch
(...)
{
throw
Exceptions
::
FileOpenError
(
fileName
);
}
this
->
fileName
=
fileName
;
if
(
!
file
.
good
()
)
{
std
::
cerr
<<
"I am not able to open the file "
<<
fileName
<<
". "
;
return
false
;
}
return
true
;
}
...
...
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