Skip to content
Snippets Groups Projects
Commit 87d9c58a authored by Lemmer, Jan's avatar Lemmer, Jan
Browse files

Centralized is working

parent cd152a09
No related branches found
No related tags found
3 merge requests!13PreRelease_V0.1,!12PreRelease_V0.1,!1Add Link-replacement feature
......@@ -28,5 +28,9 @@ codegen/
test*.m
export/*
# files that are crfeated in example.m
testdata_2.h5
test_data.mat
# Octave session info
octave-workspace
......@@ -58,5 +58,13 @@ path.script = mfilename('fullpath'); % filename of the m.script
path.rdata = {dataset1,dataset2} ; % don't forget the extension
Publish(path, ID, figs, 'Location', 'local','Method','individual','CopyUserFCN',true)
Publish(path, ID, figs, 'Location', 'local','Method','centraliced','CopyUserFCN',true)
% Second Plot to test centralized method
fig(2) =figure;
plot(x,y,'-k');
hold on
plot(x1,y1,'-r');
Publish(path, ID, figs, 'Location', 'local','Method','centraliced','CopyUserFCN',true)
\ No newline at end of file
......@@ -58,11 +58,14 @@ switch options.Method
end
% Check if the new plot is based on the original data-set
% copy the data(once)
for i=1:numel(DataPaths.rdata)
if fileCompare(DataPaths.rdata{i},{fList.name}) % identical file exists
createLinkedHDF5(DataPaths.rdata{i},storPath,ID)
for i=1:numel(DataPaths.rdata)
% check if identical file exists (status = 1)
[status, id] = fileCompare(DataPaths.rdata{i},fList);
if status
sourcePath = fullfile(fList(id).folder, fList(id).name);
createLinkedHDF5(sourcePath,storPath,ID);
else % no identical file exists
createFileCopy(DataPaths.rdata{i},'data',storPath,ID,'data');
createFileCopy(DataPaths.rdata,'data',storPath,ID,'dataCentral');
end
end
case 'individual'
......@@ -93,7 +96,7 @@ function [] = createFileCopy(filePaths,folderName,storPath,ID,type)
% folderName is the name of the exporting folder
disp(['Start to copy ', type]);
try
% try
for i = 1:numel(filePaths)
FileNameAndLocation = filePaths{i};
[~,name,ext] = fileparts(filePaths{i}); % get the extension
......@@ -102,6 +105,9 @@ function [] = createFileCopy(filePaths,folderName,storPath,ID,type)
case 'data'
sufix = '_data';
newfile = sprintf([ID, sufix, '_' , num2str(i) ,ext]);
case 'dataCentral'
%keep original name
newfile = sprintf([name,ext]);
case 'script'
sufix = '_script';
newfile = sprintf([ID, sufix ,ext]);
......@@ -117,9 +123,9 @@ function [] = createFileCopy(filePaths,folderName,storPath,ID,type)
copyfile(FileNameAndLocation,RemotePath);
end
disp([type, ' sucessfully published']);
catch
warning([type,' export was not sucessful'])
end %try
% catch
% warning([type,' export was not sucessful'])
% end %try
end
function tf = mustBeFigure(h)
......
......@@ -4,27 +4,33 @@ function [status, id] = fileCompare(filename,fileList)
% the functions uses the windows system function fc or the unix function
% diff
%% Not working!!!
if isempty(fileList)
% no comparison necessary
status =false;
return
end
[~,~,ext1] = fileparts(filename);
id = zeros(numel(fileList),1);
for i=1:numel(fileList)
[~,~,ext2] = fileparts(fileList{i});
[~,~,ext2] = fileparts(fileList(i).name);
if ~isequal(ext1,ext2)
%warning('File extension are not identical');
status = false;
return
continue
end
filepath = fullfile(fileList(i).folder,fileList(i).name);
if ispc
[status,~] = system(['fc ' filename ' ' fileList{i}]);
[status,~] = system(['fc ' filename ' ' filepath]);
% 0 -> identical, 1 -> not identical
id(i) = ~status; % false (not identical), true(identical)
status = ~status; % false (not identical), true(identical)
id(i) = status;
elseif isunix %untested!
[status,~] = system(['diff ' filename ' ' fileList{i}]);
[status,~] = system(['diff ' filename ' ' filepath]);
id(i) = ~status; % ???
else
warning('Platform not supported')
......
function [status] = createLinkedHDF5(SourceFile,TargetPath,ID)
%UNTITLED4 Summary of this function goes here
% Detailed explanation goes here
%createLinkedHDF5 creates a HDF file that references the Sourcefile
% TargetPath is the STorage Location, ID the Foldername
% Status returns true if the function was sucessfull
plist_id = 'H5P_DEFAULT';
% Work in Progress... Problem mit dem Pfad...
%try
fid = H5F.create(fullfile(TargetPath,[ID,'_data.h5']));
try
fid = H5F.create(fullfile(TargetPath,ID,[ID,'_data.h5']));
%create External Link to Sourcefile in the Group linkToExternal
H5L.create_external(SourceFile,'/',fid, SourceFile ,plist_id,plist_id);
H5L.create_external(['..\data\',SourceFile],'/',fid, SourceFile ,plist_id,plist_id);
H5F.close(fid);
status = 1;
% catch
% warning('No linked HDF file was created');
% status = 0;
% end
catch
warning('No linked HDF file was created');
status = 0;
end
end
No preview for this file type
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment