diff --git a/+PlotID/@userDLG/userDLG.m b/+PlotID/@userDLG/userDLG.m index 3ec2b4b9f2af8d2833631b67a52cf9d0f1c1a8a0..0052a88804903b22c9bcf3f7b2267380ce41e818 100644 --- a/+PlotID/@userDLG/userDLG.m +++ b/+PlotID/@userDLG/userDLG.m @@ -43,6 +43,20 @@ classdef userDLG obj.msg = message; end + function [status] = userDialog(obj,dialogMessage, errorMessage) + %userDialog displays Y/N user input + % if the user selects no an Error will be thrown + m = ''; + while ~ismember(m,{'Y','y','n','N'}) + m = input([dialogMessage,', Y/N [Y]? '],'s'); + end + if ismember(m,{'Y','y'}) + status = true; + else + obj.error(errorMessage) + end + end + function [] = userMSG(obj,message) %userMSG user message without priority % MSG will only be displaye if ShowMessages is true diff --git a/+PlotID/Publish.m b/+PlotID/Publish.m index 0c93f0bccea2f732ac8269ad57f0530428b3fcce..dc58a47a74a7e467d5982f60efb5a17aa6df61a1 100644 --- a/+PlotID/Publish.m +++ b/+PlotID/Publish.m @@ -107,12 +107,23 @@ switch options.Location end folderName = ['.',char(ID)]; %hidden folder +folderNameV = char(ID); %visible Folder %% Create data directory +overwriteDir = false; +% if invisible Folder exists, delete it (publish was not succesfull before) if isfolder(fullfile(storPath,folderName)) - dlgObj.error(['Folder ',folderName, ' exists - Plot was already published ']); -elseif mkdir(fullfile(storPath,folderName)) -else + rmdir(fullfile(storPath,folderName),'s') +end +% if folder already published: ask User +if isfolder(fullfile(storPath,folderNameV)) + msg = ['Folder ',folderNameV, ' exists - Plot was already published ']; + disp(msg); + dialogMsg = 'Do you want to overwrite the existing files'; + overwriteDir = dlgObj.userDialog(dialogMsg, msg); +end +% create folder +if ~mkdir(fullfile(storPath,folderName)) dlgObj.error('Directory could not be created - check remote path and permissions'); end disp(['publishing of ', ID, ' started']); @@ -239,9 +250,11 @@ end if dlgObj.success || options.ForcePublish oldPath = fullfile(storPath,folderName); newPath = strrep(oldPath,'.',''); %remov dot + if overwriteDir + rmdir(newPath,'s'); + dlgObj.userMSG(['old export ', folderNameV, ' deleted']); + end status = movefile(oldPath,newPath); %rename directory -else - % error from userDlg class! end if status diff --git a/.gitignore b/.gitignore index 32ea2493881e83b59a61c69dbd6ba01281a72d3b..b734161eeff0147c2d04d12da02691684f8d9570 100644 --- a/.gitignore +++ b/.gitignore @@ -29,7 +29,8 @@ codegen/ # Personal test files test*.m -test123_data.h5 +test*.h5 +cleanUP.m # files that are created in example.m @@ -41,7 +42,6 @@ unused*/* # Octave session info octave-workspace -test_data.mat #logs log.txt