Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
K
klee_tutorial
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
Niklas Lundberg
klee_tutorial
Commits
a3ef08d6
Commit
a3ef08d6
authored
4 years ago
by
Blinningjr
Browse files
Options
Downloads
Patches
Plain Diff
Implemented better filepath error message
parent
7235ace1
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
srp_analysis/src/file_handler.rs
+7
-4
7 additions, 4 deletions
srp_analysis/src/file_handler.rs
srp_analysis/src/main.rs
+7
-1
7 additions, 1 deletion
srp_analysis/src/main.rs
with
14 additions
and
5 deletions
srp_analysis/src/file_handler.rs
+
7
−
4
View file @
a3ef08d6
...
@@ -16,17 +16,20 @@ pub fn write_to_file(contents: String, file: PathBuf) -> std::io::Result<()> {
...
@@ -16,17 +16,20 @@ pub fn write_to_file(contents: String, file: PathBuf) -> std::io::Result<()> {
/*
/*
* Load the tasks from a json file `file`.
* Load the tasks from a json file `file`.
*/
*/
pub
fn
load_tasks
(
file
:
PathBuf
)
->
Tasks
{
pub
fn
load_tasks
(
file
:
PathBuf
)
->
Result
<
Tasks
,
String
>
{
let
mut
serialized
=
String
::
new
();
let
mut
serialized
=
String
::
new
();
read_from_file
(
&
mut
serialized
,
file
);
match
read_from_file
(
&
mut
serialized
,
&
file
)
{
return
serde_json
::
from_str
(
&
serialized
)
.unwrap
();
Ok
(
_
)
=>
(),
Err
(
_
)
=>
return
Err
(
format!
(
"Error: Invalid filepath {:?}"
,
file
)),
};
return
Ok
(
serde_json
::
from_str
(
&
serialized
)
.unwrap
());
}
}
/*
/*
* Read string from file `file` and store it in `contents`.
* Read string from file `file` and store it in `contents`.
*/
*/
pub
fn
read_from_file
(
contents
:
&
mut
String
,
file
:
PathBuf
)
->
std
::
io
::
Result
<
()
>
{
pub
fn
read_from_file
(
contents
:
&
mut
String
,
file
:
&
PathBuf
)
->
std
::
io
::
Result
<
()
>
{
let
mut
file
=
File
::
open
(
file
)
?
;
let
mut
file
=
File
::
open
(
file
)
?
;
file
.read_to_string
(
contents
)
?
;
file
.read_to_string
(
contents
)
?
;
Ok
(())
Ok
(())
...
...
This diff is collapsed.
Click to expand it.
srp_analysis/src/main.rs
+
7
−
1
View file @
a3ef08d6
...
@@ -38,7 +38,13 @@ fn main() {
...
@@ -38,7 +38,13 @@ fn main() {
//println!("{:?}", opt);
//println!("{:?}", opt);
let
tasks
:
Tasks
=
match
opt
.in_file
{
let
tasks
:
Tasks
=
match
opt
.in_file
{
Some
(
file
)
=>
load_tasks
(
file
),
Some
(
file
)
=>
match
load_tasks
(
file
)
{
Ok
(
ts
)
=>
ts
,
Err
(
err
)
=>
{
println!
(
"{}"
,
err
);
return
;
},
},
None
=>
create_tasks
(),
None
=>
create_tasks
(),
};
};
...
...
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