diff --git a/.gitignore b/.gitignore index b0afd4835bf581456c0cf7f6dc7bcd8139cddf34..7604078ea253ac7ec683c97eab80ef3fe4975906 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/example.m b/example.m index 45c7e397413a2fced53e8923880947073218ffd5..e803c2bd5b99d848f8843a1dfa5a2c7e75a4788d 100644 --- a/example.m +++ b/example.m @@ -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 diff --git a/fcn_core/Publish.m b/fcn_core/Publish.m index c970e7d9b198083e32602d7c6953fe18497f15e1..ebff3ca809b4a5842a6bf77d2b0749b47f3176ad 100644 --- a/fcn_core/Publish.m +++ b/fcn_core/Publish.m @@ -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) diff --git a/fcn_help/FileCompare.m b/fcn_help/FileCompare.m index 325cfe5e409469d39f064e7bf76402bd7a1ce30f..5a4039d83d88b0f28eb394227136cb32a3fcf6c3 100644 --- a/fcn_help/FileCompare.m +++ b/fcn_help/FileCompare.m @@ -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') diff --git a/fcn_help/createLinkedHDF5.m b/fcn_help/createLinkedHDF5.m index f2d257491d83d212c94fe3cbc2c204947a4846aa..6564a7cf9d8ea806b9cc4fd4485e420fe14aedff 100644 --- a/fcn_help/createLinkedHDF5.m +++ b/fcn_help/createLinkedHDF5.m @@ -1,21 +1,20 @@ 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 diff --git a/test_data.mat b/test_data.mat index 773ad46e46d0a3ab0dac6b68c057827c4ecaf9de..1d2004a11e0bf276402abe32cc62b6ed99f7e475 100644 Binary files a/test_data.mat and b/test_data.mat differ diff --git a/testdata_2.h5 b/testdata_2.h5 index 7891e47e55667d2dcbf9db26acca2fd6512ddf8a..79061fbf1d4dd06ed63a1e4d321d212bdb137e76 100644 Binary files a/testdata_2.h5 and b/testdata_2.h5 differ