Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
plotID_matlab
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
plotID
plotID_matlab
Commits
e364a277
Commit
e364a277
authored
3 years ago
by
Lemmer, Jan
Browse files
Options
Downloads
Patches
Plain Diff
Add LinkReplace Feature
parent
85820716
No related branches found
No related tags found
2 merge requests
!13
PreRelease_V0.1
,
!12
PreRelease_V0.1
Pipeline
#564375
canceled
3 years ago
Stage: Run
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
+PlotID/replaceLinkedHDF5.m
+61
-0
61 additions, 0 deletions
+PlotID/replaceLinkedHDF5.m
with
61 additions
and
0 deletions
+PlotID/replaceLinkedHDF5.m
0 → 100644
+
61
−
0
View file @
e364a277
function
replaceLinkedHDF5
(
linkedFilepath
)
% replaceLinkedHDF5 replaces the HDF5, that contains only a link to another
% HDF5 File with a file containing the actual Data, thus turning it into an
% independent data file. It essentially turns the plotID option
% 'centralized' into 'individual'.
% Filepath is the location of the File that contains the link. The
% filepath to the linked data has to be present in the file itself.
%% Check whether the only Objects present are links
h5inf
=
h5info
(
linkedFilepath
);
% default behaviour dont overwrite
overwrite
=
false
;
if
isempty
([
h5inf
.
Groups
,
h5inf
.
Datasets
,
h5inf
.
Datatypes
,
h5inf
.
Attributes
])
&&
...
all
(
size
(
h5inf
.
Links
)
==
[
1
1
])
% There are no other known objects present and
% there is only one linked file
overwrite
=
true
;
end
%% Create Copies of files
for
i
=
1
:
size
(
h5inf
.
Links
,
2
)
% This is the file with full data
linkTargetPath
=
h5inf
.
Links
(
i
)
.
Value
{
1
,
1
};
% This is the empty file
% TODO filename decision
linkSourcePath
=
strcat
(
linkedFilepath
,
'_'
,
num2str
(
i
));
% Create an absolute path from the relative linking path
absoluteTP
=
regexp
(
linkSourcePath
,
filesep
,
'split'
);
TargetPathSplit
=
regexp
(
linkTargetPath
,
filesep
,
'split'
);
% How many levels do we need to go up in the relative path
% This is merely counting the occurances of '..' within the path, but
% should not cause issues if the realtive path was created by the
% linking process
levelsUp
=
sum
(
contains
(
TargetPathSplit
,
'..'
));
absoluteTP
=
absoluteTP
(
1
:(
end
-
(
1
+
levelsUp
))
);
%Remove filename + levels
linkTargetPath
=
strjoin
([
absoluteTP
,
TargetPathSplit
(
~
contains
(
TargetPathSplit
,
'..'
))],
filesep
);
if
~
isfile
(
linkTargetPath
)
warning
(
strcat
(
"Link destination
""
"
,
linkTargetPath
,
"
""
does not exist or relative path does not fit, no copy created"
))
end
if
overwrite
% can only be for i=1, and size = 1
linkSourcePath
=
linkedFilepath
;
end
disp
(
'Copying file from '
,
linkSourcePath
,
' to '
,
linkTargetPath
)
copyfile
(
linkTargetPath
,
linkSourcePath
);
end
end
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