Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpenBoard
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lifo
Nicolas Ollinger
OpenBoard
Commits
97b8ff49
Commit
97b8ff49
authored
Mar 15, 2016
by
Craig Watson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check if location is writable before exporting to .ubz
parent
53aa4f49
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
6 deletions
+25
-6
UBExportDocument.cpp
src/adaptors/UBExportDocument.cpp
+24
-5
UBExportDocument.h
src/adaptors/UBExportDocument.h
+1
-1
No files found.
src/adaptors/UBExportDocument.cpp
View file @
97b8ff49
...
...
@@ -68,9 +68,9 @@ void UBExportDocument::persist(UBDocumentProxy* pDocumentProxy)
if
(
mIsVerbose
)
UBApplication
::
showMessage
(
tr
(
"Exporting document..."
));
persistsDocument
(
pDocumentProxy
,
filename
);
bool
success
=
persistsDocument
(
pDocumentProxy
,
filename
);
if
(
mIsVerbose
)
if
(
mIsVerbose
&&
success
)
UBApplication
::
showMessage
(
tr
(
"Export successful."
));
QApplication
::
restoreOverrideCursor
();
...
...
@@ -78,14 +78,30 @@ void UBExportDocument::persist(UBDocumentProxy* pDocumentProxy)
}
void
UBExportDocument
::
persistsDocument
(
UBDocumentProxy
*
pDocumentProxy
,
QString
filename
)
bool
UBExportDocument
::
persistsDocument
(
UBDocumentProxy
*
pDocumentProxy
,
QString
filename
)
{
QFileInfo
info
(
filename
);
info
.
setFile
(
info
.
absolutePath
());
if
(
!
info
.
isWritable
())
{
UBApplication
::
showMessage
(
tr
(
"Export failed: location not writable"
));
// The message is a bit discreet: also show a pop-up
QMessageBox
errorBox
;
errorBox
.
setWindowTitle
(
tr
(
"Export failed"
));
errorBox
.
setText
(
tr
(
"Unable to export to the selected location. You do not have the permissions necessary to save the file."
));
errorBox
.
setIcon
(
QMessageBox
::
Critical
);
errorBox
.
exec
();
return
false
;
}
QuaZip
zip
(
filename
);
zip
.
setFileNameCodec
(
"UTF-8"
);
if
(
!
zip
.
open
(
QuaZip
::
mdCreate
))
{
qWarning
(
"Export failed. Cause: zip.open(): %d"
,
zip
.
getZipError
());
return
;
return
false
;
}
QDir
documentDir
=
QDir
(
pDocumentProxy
->
persistencePath
());
...
...
@@ -93,15 +109,18 @@ void UBExportDocument::persistsDocument(UBDocumentProxy* pDocumentProxy, QString
QuaZipFile
outFile
(
&
zip
);
UBFileSystemUtils
::
compressDirInZip
(
documentDir
,
""
,
&
outFile
,
true
,
this
);
zip
.
close
();
if
(
zip
.
getZipError
()
!=
0
)
{
qWarning
(
"Export failed. Cause: zip.close(): %d"
,
zip
.
getZipError
());
return
false
;
}
zip
.
close
();
UBPlatformUtils
::
setFileType
(
filename
,
0x5542647A
/* UBdz */
);
return
true
;
}
...
...
src/adaptors/UBExportDocument.h
View file @
97b8ff49
...
...
@@ -49,7 +49,7 @@ class UBExportDocument : public UBExportAdaptor, public UBProcessingProgressList
virtual
QString
exportExtention
();
virtual
void
persist
(
UBDocumentProxy
*
pDocument
);
virtual
void
persistsDocument
(
UBDocumentProxy
*
pDocument
,
QString
filename
);
virtual
bool
persistsDocument
(
UBDocumentProxy
*
pDocument
,
QString
filename
);
virtual
void
processing
(
const
QString
&
pObjectName
,
int
pCurrent
,
int
pTotal
);
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment