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
973ccb8c
Commit
973ccb8c
authored
3 years ago
by
Lemmer, Jan
Browse files
Options
Downloads
Patches
Plain Diff
clean commit
parent
cb9c58b8
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
+PlotID/createFileCopy.m
+79
-0
79 additions, 0 deletions
+PlotID/createFileCopy.m
with
79 additions
and
0 deletions
+PlotID/createFileCopy.m
0 → 100644
+
79
−
0
View file @
973ccb8c
function
[
storagePaths
]
=
createFileCopy
(
filePaths
,
folderName
,
storPath
,
ID
,
type
)
% Creates a copy of the files (can be used for multiple paths in a cell array)
% folderName is the name of the exporting folder
% returns the storage paths were files were stored
if
~
iscell
(
filePaths
)
%fixes Issue if Filepath is a char and not a cell array
filePaths
=
{
filePaths
};
end
try
storagePaths
=
cell
(
numel
(
filePaths
,
1
));
for
i
=
1
:
numel
(
filePaths
)
FileNameAndLocation
=
filePaths
{
i
};
[
~
,
name
,
ext
]
=
fileparts
(
filePaths
{
i
});
% get the extension
switch
type
case
'data'
newfile
=
sprintf
([
name
,
ext
]);
%keep original name
%old behaviour
%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
]);
case
'userFcn'
%keep original name
newfile
=
sprintf
([
name
,
ext
]);
otherwise
error
([
type
,
' is not a valid type for createFileCopy'
])
end
%switch
RemotePath
=
fullfile
(
storPath
,
folderName
,
newfile
);
% Check if remote file already exists
count
=
0
;
while
isfile
(
RemotePath
)
&&
ismember
(
type
,{
'data'
,
'dataCentral'
})
% Add a Sufix number to new file name
% TODO add more inteligent way then a simple sufix
count
=
count
+
1
;
[
~
,
name
,
ext
]
=
fileparts
(
RemotePath
);
if
count
<
2
RemotePath
=
fullfile
(
storPath
,
folderName
,
...
[
name
,
'_'
,
num2str
(
count
),
ext
]);
else
RemotePath
=
fullfile
(
storPath
,
folderName
,
...
[
name
(
1
:
end
-
length
(
num2str
(
count
))),
num2str
(
count
),
ext
]);
end
[
~
,
name
,
~
]
=
fileparts
(
RemotePath
);
msg
=
[
'Filename '
,
name
,
...
' already exists in the data folder'
newline
,
...
' PlotID will add an suffix if you continue.'
newline
,
...
' This can cause serious confusions.'
];
warning
(
msg
);
m
=
input
(
'Do you want to continue, Y/N [Y]:'
,
's'
);
if
ismember
(
m
,{
'N'
,
'n'
})
errorMSG
=
[
'Filename already exists in data folder.'
newline
,
...
' Rename the File and restart PlotID.'
];
error
();
end
end
copyfile
(
FileNameAndLocation
,
RemotePath
);
storagePaths
{
i
}
=
RemotePath
;
end
disp
([
type
,
' sucessfully published'
]);
catch
warning
([
type
,
' export was not sucessful'
])
if
exist
(
'errorMSG'
)
error
(
errorMSG
);
end
end
%try
end
%function
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