File tree 1 file changed +19
-1
lines changed
1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -874,7 +874,25 @@ bool MainWindow::addScript(const QString& filePath)
874
874
875
875
QFileInfo info (filePath);
876
876
877
- QString destinationPath (stdPaths[0 ] + ' /' + typePath + ' /' + info.fileName ());
877
+ // check if the directory structure exists first
878
+ // and if not, create what we need
879
+ int i = 0 ;
880
+ bool createDir = true ;
881
+ for (i = 0 ; i < stdPaths.size (); ++i) {
882
+ if (QDir (stdPaths[i] + ' /' + typePath).exists ()) {
883
+ createDir = false ;
884
+ break ;
885
+ }
886
+ }
887
+ if (createDir) {
888
+ // find a path we can create (e.g., first path might be admin-only)
889
+ for (i = 0 ; i < stdPaths.size (); ++i) {
890
+ if (QDir ().mkpath (stdPaths[i] + ' /' + typePath))
891
+ break ;
892
+ }
893
+ }
894
+
895
+ QString destinationPath (stdPaths[i] + ' /' + typePath + ' /' + info.fileName ());
878
896
qDebug () << " copying " << filePath << " to " << destinationPath;
879
897
QFile::remove (destinationPath); // silently fail if there's nothing to remove
880
898
QFile::copy (filePath, destinationPath);
You can’t perform that action at this time.
0 commit comments