Skip to content

Commit

Permalink
skip path checking when h5_opt is set to 'skip'. close #3
Browse files Browse the repository at this point in the history
  • Loading branch information
mikejiang committed Mar 15, 2019
1 parent f7c6716 commit d241c64
Showing 1 changed file with 23 additions and 16 deletions.
39 changes: 23 additions & 16 deletions inst/include/cytolib/H5CytoFrame.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,24 +409,31 @@ class H5CytoFrame:public CytoFrame{
void convertToPb(pb::CytoFrame & fr_pb, const string & h5_filename, H5Option h5_opt) const
{
fr_pb.set_is_h5(true);
if(!fs::equivalent(fs::path(filename_).parent_path(), fs::path(h5_filename).parent_path()))
if(h5_opt != H5Option::skip)
{
switch(h5_opt)
auto dest = fs::path(h5_filename).parent_path();
if(!fs::exists(dest))
throw(logic_error(dest.string() + "doesn't exist!"));

if(!fs::equivalent(fs::path(filename_).parent_path(), dest))
{
case H5Option::copy:
fs::copy(filename_, h5_filename);
break;
case H5Option::move:
fs::rename(filename_, h5_filename);
break;
case H5Option::link:
fs::create_hard_link(filename_, h5_filename);
break;
case H5Option::symlink:
fs::create_symlink(filename_, h5_filename);
break;
case H5Option::skip:
break;
switch(h5_opt)
{
case H5Option::copy:
fs::copy(filename_, h5_filename);
break;
case H5Option::move:
fs::rename(filename_, h5_filename);
break;
case H5Option::link:
fs::create_hard_link(filename_, h5_filename);
break;
case H5Option::symlink:
fs::create_symlink(filename_, h5_filename);
break;
default:
throw(logic_error("invalid h5_opt!"));
}
}
}
}
Expand Down

0 comments on commit d241c64

Please sign in to comment.