Skip to content

Commit d241c64

Browse files
author
mikejiang
committed
skip path checking when h5_opt is set to 'skip'. close #3
1 parent f7c6716 commit d241c64

File tree

1 file changed

+23
-16
lines changed

1 file changed

+23
-16
lines changed

inst/include/cytolib/H5CytoFrame.hpp

+23-16
Original file line numberDiff line numberDiff line change
@@ -409,24 +409,31 @@ class H5CytoFrame:public CytoFrame{
409409
void convertToPb(pb::CytoFrame & fr_pb, const string & h5_filename, H5Option h5_opt) const
410410
{
411411
fr_pb.set_is_h5(true);
412-
if(!fs::equivalent(fs::path(filename_).parent_path(), fs::path(h5_filename).parent_path()))
412+
if(h5_opt != H5Option::skip)
413413
{
414-
switch(h5_opt)
414+
auto dest = fs::path(h5_filename).parent_path();
415+
if(!fs::exists(dest))
416+
throw(logic_error(dest.string() + "doesn't exist!"));
417+
418+
if(!fs::equivalent(fs::path(filename_).parent_path(), dest))
415419
{
416-
case H5Option::copy:
417-
fs::copy(filename_, h5_filename);
418-
break;
419-
case H5Option::move:
420-
fs::rename(filename_, h5_filename);
421-
break;
422-
case H5Option::link:
423-
fs::create_hard_link(filename_, h5_filename);
424-
break;
425-
case H5Option::symlink:
426-
fs::create_symlink(filename_, h5_filename);
427-
break;
428-
case H5Option::skip:
429-
break;
420+
switch(h5_opt)
421+
{
422+
case H5Option::copy:
423+
fs::copy(filename_, h5_filename);
424+
break;
425+
case H5Option::move:
426+
fs::rename(filename_, h5_filename);
427+
break;
428+
case H5Option::link:
429+
fs::create_hard_link(filename_, h5_filename);
430+
break;
431+
case H5Option::symlink:
432+
fs::create_symlink(filename_, h5_filename);
433+
break;
434+
default:
435+
throw(logic_error("invalid h5_opt!"));
436+
}
430437
}
431438
}
432439
}

0 commit comments

Comments
 (0)